Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EIP1559 Fee management methods and configs #375

Open
wants to merge 32 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9e4b446
Added documentation for Gas Fee Estimator RPC methods
harsenyan3 Jul 18, 2024
07c3a09
.
harsenyan3 Jul 22, 2024
9e51768
example subheading set
harsenyan3 Jul 22, 2024
c6d055a
fixed common structures
harsenyan3 Jul 22, 2024
af9242a
fixed trailing comma in json request
harsenyan3 Jul 22, 2024
9bec386
link to star_gas_fee_estimator fixed
harsenyan3 Jul 22, 2024
3424c3a
fixed url x2
harsenyan3 Jul 22, 2024
9b8c59a
Merge branch 'dev' into add/gas-fee-estimator-docs
smk762 Sep 9, 2024
ee5304d
linting
smk762 Sep 9, 2024
5db1c3b
linting
smk762 Sep 9, 2024
1004ff2
fix commas in jsons
gcharang Sep 9, 2024
6694a88
gas estimate methods renamed
smk762 Sep 13, 2024
1b397d4
Merge branch 'dev' into add/gas-fee-estimator-docs
smk762 Oct 16, 2024
f38819e
rename methods, fix lint errors
smk762 Oct 16, 2024
bf75b99
Add notes from KDF PR 2051
smk762 Nov 4, 2024
a117530
Merge branch 'add/gas-fee-estimator-docs' into update/kdf/sign_raw_tr…
smk762 Nov 4, 2024
fc38f95
add pay_for_gas object
smk762 Nov 4, 2024
fd529a4
move fee methods into new folder
smk762 Nov 4, 2024
87a11d9
rm old folder files
smk762 Nov 4, 2024
bce576a
adds `gas_api` param to MM2.json config doc
smk762 Nov 4, 2024
ec34e41
add gas_fee_estimator field to listing guide
smk762 Nov 4, 2024
7ae819d
add min_wait_time and max_wait_time for gas fee estimation
smk762 Nov 4, 2024
544ae2e
add start/stop eth fee estimator
smk762 Nov 4, 2024
ef079fb
add get/set fee policy methods
smk762 Nov 4, 2024
006e39c
Add overview page for fee management
smk762 Nov 4, 2024
aab8d8b
linting
smk762 Nov 4, 2024
182d82b
update sign_raw_tx examples
smk762 Nov 4, 2024
04bc4e8
add sign_raw_transaction examples to postman
smk762 Nov 4, 2024
75b8417
update PayForGas object descriptions
smk762 Nov 9, 2024
bccaa38
update description to indicate only supported coins
smk762 Nov 9, 2024
3a603c4
update description of supported eth/evm
smk762 Nov 9, 2024
e76a84b
linting
smk762 Nov 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion filepathSlugs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,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 @@ -2814,6 +2815,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 @@ -3648,6 +3679,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
2,185 changes: 1,902 additions & 283 deletions postman/collections/komodo_defi.postman_collection.json

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions src/data/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,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>
Loading
Loading