Skip to content

Commit

Permalink
Merge pull request #375 from KomodoPlatform/update/kdf/sign_raw_trans…
Browse files Browse the repository at this point in the history
…action
  • Loading branch information
gcharang authored Nov 17, 2024
2 parents c860054 + 1a09a0b commit 9867dbc
Show file tree
Hide file tree
Showing 13 changed files with 467 additions and 28 deletions.
34 changes: 33 additions & 1 deletion filepathSlugs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,8 @@
"src/pages/komodo-defi-framework/api/common_structures/wallet/index.mdx": [
"wallet-operations-structures",
"raw-tx-info",
"input-txns"
"input-txns",
"pay-for-gas"
],
"src/pages/komodo-defi-framework/api/index.mdx": [
"komodo-de-fi-framework-rpc-methods"
Expand Down Expand Up @@ -2825,6 +2826,36 @@
"token-protocol-parse-error-error",
"unexpected-token-protocol-error"
],
"src/pages/komodo-defi-framework/api/v20/fee_management/get_eth_estimated_fee_per_gas/index.mdx": [
"get-eth-estimated-fee-per-gas",
"request",
"response"
],
"src/pages/komodo-defi-framework/api/v20/fee_management/get_swap_transaction_fee_policy/index.mdx": [
"get-swap-transaction-fee-policy",
"request",
"response"
],
"src/pages/komodo-defi-framework/api/v20/fee_management/index.mdx": [
"evm-network-fee-management",
"fee-management-methods",
"fee-management-configuration",
"in-the-coins-file",
"in-the-mm-2-json-file"
],
"src/pages/komodo-defi-framework/api/v20/fee_management/set_swap_transaction_fee_policy/index.mdx": [
"set-swap-transaction-fee-policy",
"request",
"response"
],
"src/pages/komodo-defi-framework/api/v20/fee_management/start_eth_fee_estimator/index.mdx": [
"start-eth-fee-estimator",
"response"
],
"src/pages/komodo-defi-framework/api/v20/fee_management/stop_eth_fee_estimator/index.mdx": [
"stop-eth-fee-estimator",
"response"
],
"src/pages/komodo-defi-framework/api/v20/get_current_mtp/index.mdx": [
"get-current-mtp",
"arguments",
Expand Down Expand Up @@ -3667,6 +3698,7 @@
"configuration-parameters",
"example-allowing-weak-password",
"example-not-allowing-weak-password",
"example-using-gas-api",
"example-wss-with-certificates",
"example-for-hd-wallets",
"coins-file-configuration",
Expand Down
29 changes: 29 additions & 0 deletions src/data/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,35 @@
}
]
},
{
"title": "Fee Management",
"links": [
{
"title": "Overview",
"href": "/komodo-defi-framework/api/v20/fee_management/"
},
{
"title": "get_eth_estimated_fee_per_gas",
"href": "/komodo-defi-framework/api/v20/fee_management/get_eth_estimated_fee_per_gas/"
},
{
"title": "get_swap_transaction_fee_policy",
"href": "/komodo-defi-framework/api/v20/fee_management/get_swap_transaction_fee_policy/"
},
{
"title": "set_swap_transaction_fee_policy",
"href": "/komodo-defi-framework/api/v20/fee_management/set_swap_transaction_fee_policy/"
},
{
"title": "start_eth_fee_estimator",
"href": "/komodo-defi-framework/api/v20/fee_management/start_eth_fee_estimator/"
},
{
"title": "stop_eth_fee_estimator",
"href": "/komodo-defi-framework/api/v20/fee_management/stop_eth_fee_estimator/"
}
]
},
{
"title": "Market Maker Bot",
"links": [
Expand Down
36 changes: 22 additions & 14 deletions src/pages/komodo-defi-framework/api/common_structures/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -438,23 +438,31 @@ The `WithdrawFee` object varies depending on the coin or token type. Refer to th

### FilterCriteria

The `FilterCriteria` object includes different criteria to filter from the different recent swaps:
The 'FilterCriteria' object allows you to filter the results based on specific parameters.

| Parameter | Type | Description |
| --------------- | ------ | ---------------------------------------------- |
| status | string | Status of the transactions (e.g., "completed") |
| date\_from | string | \`Start date in ISO 8601 format |
| date\_to | string | End date in ISO 8601 format |
| my\_coin | string | Coin being used by you for the swap/trade. |
| other\_coin | string | Coin you are trading against |
| from\_timestamp | number | Start timestamp in UNIX format |
| to\_timestamp | number | End timestamp in UNIX format |

| Parameter | Type | Description |
| ---------- | ------------------------ | ---------------------------------------------------------------------- |
| status | object | Return only swaps that match the specified status (e.g., "completed"). |
| date\_from | string (ISO 8601 format) | Return only swaps that started on or after this date. |
| date\_to | string (ISO 8601 format) | Return only swaps that started before this date. |

<CollapsibleSection expandedText="Hide Examples" collapsedText="Show Examples">
<CollapsibleSection expandedText="Hide Example" collapsedText="Show Example">
#### Example

```json
{
"filter": {
"status": "completed",
"date_from": "2024-01-01T00:00:00Z",
"date_to": "2024-07-01T00:00:00Z"
"status": "completed",
"date_from": "2024-01-01T00:00:00Z",
"date_to": "2024-07-01T00:00:00Z",
"my_coin": "BTC",
"other_coin": "ETH",
"from_timestamp": 1672531200,
"to_timestamp": 1704067200
}
}
```
Expand All @@ -476,9 +484,9 @@ The `PagingOptions` object includes options of page selection to consult when lo
```json
{
"paging_options": {
"from_uuid": null,
"limit": 10,
"page_number": 1
"from_uuid": null,
"limit": 10,
"page_number": 1
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ export const description = "Starting with version beta-2.1.3434, the Komodo DeFi

The `RawTxInfo` object includes the following items:

| Parameter | Type | Description |
| ---------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tx\_hex | string | UTXO only. The raw unsigned hex of a proposed transaction. |
| prev\_txns | list | UTXO only. A list of standard [InputTxns objects](/komodo-defi-framework/api/common_structures/wallet/#input-txns). |
| to | string | ETH/EVM only. A destination address to send the funds to. |
| value | string | ETH/EVM only. The amount of funds to be sent as a string with a `0x` prefix, in [wei](https://ethereum.stackexchange.com/questions/253/the-ether-denominations-are-called-finney-szabo-and-wei-what-who-are-these-na) units. |
| gas\_limit | string | ETH/EVM only. The maximum gas to be used for sending the transaction, in [gwei](https://eth-converter.com/) units. |
| Parameter | Type | Description |
| ------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tx\_hex | string | UTXO only. The raw unsigned hex of a proposed transaction. |
| prev\_txns | list | UTXO only. A list of standard [InputTxns objects](/komodo-defi-framework/api/common_structures/wallet/#input-txns). |
| to | string | ETH/EVM only. A destination address to send the funds to. |
| value | string | ETH/EVM only. The amount of funds to be sent as a string with a `0x` prefix, in [wei](https://ethereum.stackexchange.com/questions/253/the-ether-denominations-are-called-finney-szabo-and-wei-what-who-are-these-na) units. |
| gas\_limit | string | ETH/EVM only. The maximum gas to be used for sending the transaction, in [gwei](https://eth-converter.com/) units. |
| pay\_for\_gas | object | Optional, ETH/EVM only. Used for EIP-1559 fee policy config. A standard [PayForGas](/komodo-defi-framework/api/common_structures/wallet/#pay-for-gas) object. |

<DevComment>
TODO: Confirm units used in ETH/EVM transactions.
Expand All @@ -35,7 +36,12 @@ The `RawTxInfo` object includes the following items:
{
"to": "0x927DaFDDa16F1742BeFcBEAE6798090354B294A9",
"value": "0.85",
"gas_limit": "21000"
"gas_limit": "21000",
"pay_for_gas": {
"tx_type": "Eip1559",
"max_fee_per_gas": "1234.567",
"max_priority_fee_per_gas": "1.2"
}
}
```
</CollapsibleSection>
Expand All @@ -49,8 +55,7 @@ The `InputTxns` object includes the following items:
| tx\_hash | string | The transaction id of an unspent transaction from the same wallet output. |
| index | integer | The \[output index([https://bitcoin.stackexchange.com/questions/100765/what-does-the-index-of-an-utxo-stand-for](https://bitcoin.stackexchange.com/questions/100765/what-does-the-index-of-an-utxo-stand-for))] of this unspent transaction output. |
| script\_pub\_key | string | The [scriptpubkey](https://learnmeabitcoin.com/technical/scriptPubKey) of this unspent transaction output. |
| amount | float | The value of this unspent transaction output. |
| amount | | |
| amount | decimal | The value of this unspent transaction output. |

<CollapsibleSection expandedText="Hide Example" collapsedText="Show Example">
```json
Expand All @@ -62,3 +67,47 @@ The `InputTxns` object includes the following items:
}
```
</CollapsibleSection>

### PayForGas

The `PayForGas` object includes the following items:

| Parameter | Type | Description |
| ---------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tx\_type | string | ETH/EVM coins and tokens only. Options are `Legacy` or `Eip1559`. The type of transaction values being configured. |
| gas\_price | decimal | Only used if tx\_type is `Legacy`. Values are in Gwei. The maximium price per gas unit the user is willing to pay for the transaction. |
| max\_fee\_per\_gas | decimal | Only used if tx\_type is `Eip1559`. Values are in Gwei. The maximum amount to pay per unit of gas to get your transaction included in a block. |
| max\_priority\_fee\_per\_gas | decimal | Only used if tx\_type is `Eip1559`. Values are in Gwei. This is paid directly to the miner, and can be set by the user to attract minimal delay in transaction confirmation. |
| min\_wait\_time | integer | Optional, only used if tx\_type is `Eip1559`. Estimated minimum transaction wait time in mempool (in ms) for this priority level. |
| max\_wait\_time | integer | Optional, only used if tx\_type is `Eip1559`. Estimated maximum transaction wait time in mempool (in ms) for this priority level. |

<Note>
[Eip1559](https://www.coinbase.com/en-au/blog/the-technical-benefits-of-eip-1559) allows users to save on gas fees. To use this feature for a coin/token, its entry in your `coins` file must include fields for `chain_id` and `max_eth_tx_type`. To allow eip-1559 transactions, `max_eth_tx_type` should be set to `2`. To find the `chain_id` for an \[EVM network([https://blog.thirdweb.com/evm-compatible-blockchains-and-ethereum-virtual-machine/](https://blog.thirdweb.com/evm-compatible-blockchains-and-ethereum-virtual-machine/))], refer to [chainlist.org](https://chainlist.org). There is also a new `gas_fee_estimator` parameter in the coins file, which can be set to `provider` or `simple`.

By default, `simple` gas fee estimation suggests a fee based on fee history. If set `gas_fee_estimator` is set to `provider`, users must set the `gas_api` setting in their [MM2.json file](/komodo-defi-framework/setup/configure-mm2-json/) to source recommended fee values from third party providers [Infura](https://www.infura.io/) or [Blocknative](https://www.blocknative.com/).

Use the [start\_eth\_fee\_estimator](/komodo-defi-framework/api/v20/fee_management/start_eth_fee_estimator/) method to begin tracking the fee market for a coin (and its tokens). You can stop tracking the fee market with [stop\_eth\_fee\_estimator](/komodo-defi-framework/api/v20/fee_management/stop_eth_fee_estimator/).

To set or view the current swap transaction fee policy, use the [get\_swap\_transaction\_fee\_policy](/komodo-defi-framework/api/v20/fee_management/get_swap_transaction_fee_policy/) and [set\_swap\_transaction\_fee\_policy](/komodo-defi-framework/api/v20/fee_management/set_swap_transaction_fee_policy/) methods.

For more information about EIP1559, refer to [https://www.blocknative.com/blog/eip-1559-fees](https://www.blocknative.com/blog/eip-1559-fees)
</Note>

<CollapsibleSection expandedText="Hide Legacy Example" collapsedText="Show Legacy Example">
```json
{
"tx_type": "Legacy",
"gas_price": "1234.567"
}
```
</CollapsibleSection>

<CollapsibleSection expandedText="Hide EIP1559 Example" collapsedText="Show EIP1559 Example">
```json
{
"tx_type": "Eip1559",
"max_fee_per_gas": "1234.567",
"max_priority_fee_per_gas": "1.2"
}
```
</CollapsibleSection>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
export const title = "Komodo DeFi Framework Method: Get ETH Estimated Fee per Gas";
export const description =
"The get_eth_estimated_fee_per_gas method allows you to get the gas priority fees from the estimator (started with the 'start_eth_fee_estimator') for an active coin of your choice.";

# get\_eth\_estimated\_fee\_per\_gas

The `get_eth_estimated_fee_per_gas` method allows you to get the estimated gas priority fee for an active coin of your choice. Before using this method, you first need to use the [start\_eth\_fee\_estimator](/komodo-defi-framework/api/v20/fee_management/start_eth_fee_estimator/) method.

| parameter | Type | Description |
| --------- | ------ | ---------------------------------------------------------------------------- |
| coin | string | Ticker of the coin/asset for which we want to start the grass fee estimator. |

## Request

<CodeGroup title="" tag="POST" label="get_eth_estimated_fee_per_gas" mm2MethodDecorate="true">
```json
{
"userpass": "RPC_UserP@SSW0RD",
"method": "get_eth_estimated_fee_per_gas",
"mmrpc": "2.0",
"params": {
"coin": "ETH"
}
}
```
</CodeGroup>

## Response

```json
{
"mmrpc": "2.0",
"result": {
"base_fee": "10.890879158",
"low": {
"max_priority_fee_per_gas": "0.1101",
"max_fee_per_gas": "11.949818698",
"min_wait_time": null,
"max_wait_time": null
},
"medium": {
"max_priority_fee_per_gas": "1.258084291",
"max_fee_per_gas": "13.905056537",
"min_wait_time": null,
"max_wait_time": null
},
"high": {
"max_priority_fee_per_gas": "2.495532249",
"max_fee_per_gas": "15.949758042",
"min_wait_time": null,
"max_wait_time": null
},
"source": "simple",
"base_fee_trend": "",
"priority_fee_trend": "",
"units": "Gwei"
},
"id": null
}

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const title = "Komodo DeFi Framework Method: Get Swap Transaction Fee Policy";
export const description =
"The get_swap_transaction_fee_policy method allows you to get the current gas fees policy used when estimating swap transaction fees for supported for ETH/EVM coins/tokens..";

# get\_swap\_transaction\_fee\_policy

The `get_swap_transaction_fee_policy` method allows you to get the current gas fees policy used when estimating swap transaction fees for supported for ETH/EVM coins/tokens.

| parameter | Type | Description |
| --------- | ------ | ---------------------------------------------------------------------------------------- |
| coin | string | Ticker of the supported ETH/EVM coin/asset for which we want to view the fee policy for. |

## Request

<CodeGroup title="" tag="POST" label="get_swap_transaction_fee_policy" mm2MethodDecorate="true">
```json
{
"userpass": "RPC_UserP@SSW0RD",
"method": "get_swap_transaction_fee_policy",
"mmrpc": "2.0",
"params": {
"coin": "ETH"
}
}
```
</CodeGroup>

## Response

```json
{
"mmrpc": "2.0",
"result": "High",
"id": null
}

```
Loading

0 comments on commit 9867dbc

Please sign in to comment.