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 gas limit options #287

Merged
merged 5 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
1 change: 1 addition & 0 deletions filepathSlugs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3791,6 +3791,7 @@
"utxo-coin-example",
"antara-smartchain-example",
"1c-evm-like-tokens-eth-erc-20-matic-plg-20-bnb-bep-20",
"gas-limit-options",
"erc-20-token-example",
"bep-20-token-example",
"1d-qrc-20-tokens",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,28 @@ The token's contract **must** have `approve` and `transferFrom` methods. Additio
* Protocol `"type"` field: `"ETH"` or `"ERC20"`
* Protocol `"protocol_data"` field (ERC20 only): `"platform"` - `"ETH"`, `"ETC"` or other Ethereum forks. `"contract_address"` - ERC20 token [checksummed](https://coincodex.com/article/2078/ethereum-address-checksum-explained/) smart contract address.

| Parameter | Type | Description |
| ----------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| chain\_id | integer | To find the EVM chain ID, see [Chainlist](https://chainlist.org/) |
| protocol.type | string | Platform / protocol - e.g `ETH` for Ethereum, `ERC20` for ERC20 tokens on the Ethereum network |
| protocol.protocol\_data | object | Required for tokens only. |
| protocol.protocol\_data.platform | string | The parent coin of the token's platform - e.g `MATIC` for PLG20 tokens |
| protocol.protocol\_data.contract\_address | string | **Must be mixed case** The indentifying hex string for the token's contract. Can be found on sites like [EthScan](https://etherscan.io/), [BscScan](https://bscscan.com/) & [PolygonScan](https://polygonscan.com/) |
| Parameter | Type | Description |
| ----------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| chain\_id | integer | To find the EVM chain ID, see [Chainlist](https://chainlist.org/) |
| gas\_limit | object | Optional, required for tokens only. Defines more precise gas prices for swap or transaction operations, useful for tokens called ovcer proxy contracts which often require more than the default gas. See the `Gas Limit Options` table below for more information. |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useful for tokens called ovcer proxy contracts which often require more than the default gas.

It's used for the reverse of this actually, we use default limits that allow tokens that use proxy contracts but we can use these parameters to lower limits for other tokens if needed. @dimxy please confirm this and also give this docs PR a review.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes all gas_limit params are optional and internally set to default values (which maybe too high for certain tokens, so could be tuned for new or existing evm tokens)

| protocol.type | string | Platform / protocol - e.g `ETH` for Ethereum, `ERC20` for ERC20 tokens on the Ethereum network |
| protocol.protocol\_data | object | Required for tokens only. |
| protocol.protocol\_data.platform | string | The parent coin of the token's platform - e.g `MATIC` for PLG20 tokens |
| protocol.protocol\_data.contract\_address | string | **Must be mixed case** The identifying hex string for the token's contract. Can be found on sites like [EthScan](https://etherscan.io/), [BscScan](https://bscscan.com/) & [PolygonScan](https://polygonscan.com/) |

### Gas Limit Options

| Parameter | Type | Description |
| ---------------------- | ------- | ------------------------------------------------------- |
| eth\_send\_coins | integer | Gas limit for sending coins. |
| eth\_send\_erc20 | integer | Gas limit for sending ERC20 tokens. |
| eth\_payment | integer | Gas limit for swap payment tx with coins. |
| erc20\_payment | integer | Gas limit for swap payment tx with ERC20 tokens. |
| eth\_receiver\_spend | integer | Gas limit for swap receiver spend tx with coins. |
| erc20\_receiver\_spend | integer | Gas limit for swap receiver spend tx with ERC20 tokens. |
| eth\_sender\_refund | integer | Gas limit for swap refund tx with coins. |
| erc20\_sender\_refund | integer | Gas limit for swap refund tx with with ERC20 tokens. |
| eth\_max\_trade\_gas | integer | Gas limit for other operations. |

### ERC20 token example

Expand All @@ -152,6 +167,17 @@ The token's contract **must** have `approve` and `transferFrom` methods. Additio
"platform": "ETH",
"contract_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
}
},
"gas_limit": {
"eth_send_coins": 21000,
"eth_send_erc20": 65000,
"eth_payment": 75000,
"erc20_payment": 120000,
"eth_receiver_spend": 55000,
"erc20_receiver_spend": 130000,
"eth_sender_refund": 110000,
"erc20_sender_refund": 110000,
"eth_max_trade_gas": 150000
}
}
```
Expand Down
Loading