Skip to content

Commit c0a01af

Browse files
authored
Merge pull request #392 from dimxy/1inch-update
add 1inch rpc docs
2 parents 0e8f601 + 2919d7c commit c0a01af

File tree

7 files changed

+645
-0
lines changed

7 files changed

+645
-0
lines changed

src/pages/komodo-defi-framework/api/index.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,9 @@ Below is a table of the currently available legacy, v2.0 and v2.0 (Dev) methods:
145145
| [withdraw](/komodo-defi-framework/api/legacy/withdraw/#withdraw) | [withdraw](/komodo-defi-framework/api/v20/withdraw/#withdraw) | |
146146
| | | [withdraw\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/withdraw_nft/#withdraw-nfts) |
147147
| | | [z\_coin\_tx\_history](/komodo-defi-framework/api/v20-dev/zhtlc_coins/transaction_history/#zhtlc-coin-transaction-history) |
148+
| | | [one\_inch\_v6\_0\_classic\_swap\_quote](/komodo-defi-framework/api/v20-dev/one_inch_v6_0_classic_swap_quote/#1inch_v6_0_classic_swap_quote) |
149+
| | | [one\_inch\_v6\_0\_classic\_swap\_create](/komodo-defi-framework/api/v20-dev/one_inch_v6_0_classic_swap_create/#1inch_v6_0_classic_swap_create) |
150+
| | | [one\_inch\_v6\_0\_classic\_swap\_liquidity\_sources](/komodo-defi-framework/api/v20-dev/one_inch_v6_0_classic_liquidity_sources/#1inch_v6_0_classic_swap_liquidity_sources) |
151+
| | | [one\_inch\_v6\_0\_classic\_swap\_tokens](/komodo-defi-framework/api/v20-dev/one_inch_v6_0_classic_swap_tokens/#1inch_v6_0_classic_swap_tokens) |
152+
| | | [get\_token\_allowance](/komodo-defi-framework/api/v20-dev/get_token_allowance/#get_token_allowance) |
153+
| | | [approve\_token](/komodo-defi-framework/api/v20-dev/approve_token/#approve_token) |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
export const title = "Komodo DeFi Framework Method: Approve Token (v2)";
2+
export const description =
3+
"The approve_token method approves token spending for address";
4+
5+
# approve\_token
6+
7+
The `approve_token` method approves token spending for address.
8+
9+
## Arguments
10+
11+
| Structure | Type | Description |
12+
| --------------- | ---- | ---------------------------------------------------------------------------- |
13+
| coin | string | Token ticker |
14+
| spender | string | Address to approve |
15+
| amount | float | Amount to approve in coins units |
16+
17+
## Response
18+
19+
| Structure | Type | Description |
20+
| --------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
21+
| result | string | Approval transaction id |
22+
23+
#### 📌 Examples
24+
25+
#### Command
26+
27+
<CodeGroup title="" tag="POST" label="approve_token" mm2MethodDecorate="true">
28+
```json
29+
{
30+
"mmrpc": "2.0",
31+
"userpass": "RPC_UserP@SSW0RD",
32+
"method": "approve_token",
33+
"params": {
34+
"coin": "USDT-ERC20",
35+
"spender": "0x1234567890123456789",
36+
"amount": 1.23
37+
}
38+
}
39+
```
40+
</CodeGroup>
41+
42+
<CollapsibleSection expandedText="Hide Response" collapsedText="Show Response">
43+
#### Response
44+
45+
```json
46+
{
47+
"mmrpc": "2.0",
48+
"result": "0x1234567890abcdef01234567890abcdef0",
49+
"id": "null"
50+
}
51+
```
52+
</CollapsibleSection>
53+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
export const title = "Komodo DeFi Framework Method: Get Token Allowance (v2)";
2+
export const description =
3+
"The get_token_allowance method returns token allowance for address";
4+
5+
# get\_token\_allowance
6+
7+
The `get_token_allowance` method returns token allowance for address.
8+
9+
## Arguments
10+
11+
| Structure | Type | Description |
12+
| --------------- | ---- | ---------------------------------------------------------------------------- |
13+
| coin | string | Token ticker |
14+
| address | string | Address to query allowance for |
15+
16+
## Response
17+
18+
| Structure | Type | Description |
19+
| --------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
20+
| result | float | Allowance, in coins units. |
21+
22+
#### 📌 Examples
23+
24+
#### Command
25+
26+
<CodeGroup title="" tag="POST" label="get_token_allowance" mm2MethodDecorate="true">
27+
```json
28+
{
29+
"mmrpc": "2.0",
30+
"userpass": "RPC_UserP@SSW0RD",
31+
"method": "get_token_allowance",
32+
"params": {
33+
"coin": "USDT-ERC20",
34+
"address": "0x1234567890123456789"
35+
}
36+
}
37+
```
38+
</CodeGroup>
39+
40+
<CollapsibleSection expandedText="Hide Response" collapsedText="Show Response">
41+
#### Response
42+
43+
```json
44+
{
45+
"mmrpc": "2.0",
46+
"result": "0",
47+
"id": null
48+
}
49+
```
50+
</CollapsibleSection>
51+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
export const title = "Komodo DeFi Framework Method: 1inch v6.0 Classic Swap Create (v2)";
2+
export const description =
3+
"The 1inch_v6_0_classic_swap_create method returns transaction data for classic swap from 1inch API version 6.0.";
4+
5+
# 1inch\_v6\_0\_classic\_swap\_create
6+
7+
The `1inch_v6_0_classic_swap_create` method returns transaction data for classic swap from 1inch API version 6.0.
8+
9+
## Arguments
10+
11+
| Structure | Type | Description |
12+
| --------------- | ---- | ---------------------------------------------------------------------------- |
13+
| base | string | Base coin name |
14+
| rel | string | Rel coin name (must be from the same EVM chain as the base coin) |
15+
| amount | numeric string or rational | Swap amount (in coins units) |
16+
| slippage | float | Allowed slippage, min: 0; max: 50 |
17+
| fee | float | Optional. Partner fee, percentage of src token amount will be sent to referrer address, min: 0; max: 3. Should be the same for quote and swap rpc. Default is 0 |
18+
| protocols | string | Optional. Specify liquidity sources e.g.: &protocols=WETH,CURVE,BALANCER,...,ZRX (by default - all used) |
19+
| gas_price | numeric string | Optional. Network price per gas, in Gwei. 1inch takes in account gas expenses to determine exchange route. Should be the same for a quote and swap |
20+
| complexity_level | numeric | Optional. Maximum number of token-connectors to be used in a transaction, min: 0; max: 3; default: 2 |
21+
| parts | numeric | Optional. Limit maximum number of parts each main route parts can be split into. Should be the same for a quote and swap. Default: 20; max: 100 |
22+
| main_route_parts | numeric | Optional. Limit maximum number of main route parts. Should be the same for a quote and swap. Default: 20; max: 50 |
23+
| gas_limit | numeric | Optional. Maximum amount of gas for a swap. Should be the same for a quote and swap. Default: 11500000; max: 11500000 |
24+
| include_tokens_info | boolean | Optional. Return fromToken and toToken info in response (default is true) |
25+
| include_protocols | boolean | Optional. Return used swap protocols in response (default is true) |
26+
| include_gas | boolean | Optional. Include estimated gas in return value (default is true) |
27+
| connector_tokens | string | Optional. Token-connectors can be specified via this parameter. If not set, default token-connectors will be used |
28+
| excluded_protocols | string | Optional. Excluded supported liquidity sources. Should be the same for a quote and swap, max: 5 |
29+
| permit | string | Optional. Used according https://eips.ethereum.org/EIPS/eip-2612 |
30+
| compatibility | bool | Optional. Exclude the Unoswap method |
31+
| receiver | bool | Optional. This address will receive funds after the swap. By default same address as 'my address' |
32+
| referrer | bool | Optional. Address to receive the partner fee. Must be set explicitly if fee is also set |
33+
| disable_estimate | bool | Optional. if true, disable most of the checks, default: false |
34+
| allow_partial_fill | bool | Optional. if true, the algorithm can cancel part of the route, if the rate has become less attractive. Unswapped tokens will return to 'my address'. Default: true |
35+
| use_permit2 | bool | Optional. Enable this flag for auto approval by Permit2 contract if you did an approval to Uniswap Permit2 smart contract for this token. Default is false |
36+
37+
## Response
38+
39+
| Structure | Type | Description |
40+
| --------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
41+
| dst_amount | rational number | Destination token amount, in coins units. |
42+
| src_token | [TokenInfo](/komodo-defi-framework/api/v20/one_inch_v6_0_classic_swap_create/#TokenInfo) | Source (base) token info. |
43+
| dst_token | [TokenInfo](/komodo-defi-framework/api/v20/one_inch_v6_0_classic_swap_create/#TokenInfo) | Destination (rel) token info. |
44+
| protocols | list of [ProtocolInfo](/komodo-defi-framework/api/v20/one_inch_v6_0_classic_swap_create/#ProtocolInfo) | Optional. Used liquidity sources to route trade. |
45+
| tx | [TxFields](/komodo-defi-framework/api/v20/one_inch_v6_0_classic_swap_create/#TxFields) | Swap tx fields (returned only for create swap rpc) |
46+
47+
### TokenInfo
48+
| Structure | Type | Description |
49+
| --------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
50+
| address | string | Token contract address. |
51+
| symbol | string | Token symbol. |
52+
| name | string | Token name. |
53+
| decimals | numeric | Number of digits after decimal point for the token amount. |
54+
| eip2612 | boolean | Is Eip-2612 supported. |
55+
| is_fot | boolean | Is FoT token. |
56+
| logo_uri | string | Token logo uri. |
57+
| tags | list of string | Token tags. |
58+
59+
### ProtocolInfo
60+
| Structure | Type | Description |
61+
| --------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
62+
| name | string | Liquidity source name. |
63+
| part | numeric | Protocol part. |
64+
| from_token_address | string | From-token contract address. |
65+
| to_token_address | numeric | To-token contract address. |
66+
67+
### TxFields
68+
| Structure | Type | Description |
69+
| --------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
70+
| from | string | From address |
71+
| to | string | To address |
72+
| data | string | Transaction data |
73+
| value | numeric | Transaction value |
74+
| gas_price | float | Gas price |
75+
| gas | numeric | Gas |
76+
77+
#### 📌 Examples
78+
79+
#### Command
80+
81+
<CodeGroup title="" tag="POST" label="1inch_v6_0_classic_swap_quote" mm2MethodDecorate="true">
82+
```json
83+
{
84+
"mmrpc": "2.0",
85+
"userpass": "RPC_UserP@SSW0RD",
86+
"method": "1inch_v6_0_classic_swap_quote",
87+
"params": {
88+
"base": "ETH",
89+
"rel": "USDC-ERC20",
90+
"amount": 0.1,
91+
"include_tokens_info": true,
92+
"include_protocols": true,
93+
"include_gas": true,
94+
"fee": 0.0,
95+
"complexity_level": 3,
96+
"gas_limit": 11500000,
97+
"main_route_parts": 50,
98+
"parts": 100,
99+
"protocols": ""
100+
}
101+
}
102+
```
103+
</CodeGroup>
104+
105+
<CollapsibleSection expandedText="Hide Response" collapsedText="Show Response">
106+
#### Response
107+
108+
```json
109+
{
110+
"mmrpc": "2.0",
111+
"result": {
112+
"dst_amount": {
113+
"amount": "0.000000000035136197",
114+
"amount_fraction": {
115+
"numer": "35136197",
116+
"denom": "1000000000000000000"
117+
},
118+
"amount_rat": [
119+
[
120+
1,
121+
[
122+
35136197
123+
]
124+
],
125+
[
126+
1,
127+
[
128+
2808348672,
129+
232830643
130+
]
131+
]
132+
]
133+
},
134+
"src_token": {
135+
"address": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
136+
"symbol": "ETH",
137+
"name": "Ether",
138+
"decimals": 18,
139+
"eip2612": false,
140+
"isFoT": false,
141+
"logoURI": "https://tokens.1inch.io/0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.png",
142+
"tags": [
143+
"crosschain",
144+
"GROUP:ETH",
145+
"native",
146+
"PEG:ETH"
147+
]
148+
},
149+
"dst_token": {
150+
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
151+
"symbol": "USDT",
152+
"name": "Tether USD",
153+
"decimals": 6,
154+
"eip2612": false,
155+
"isFoT": false,
156+
"logoURI": "https://tokens-data.1inch.io/images/1/0xdac17f958d2ee523a2206206994597c13d831ec7.webp",
157+
"tags": [
158+
"crosschain",
159+
"GROUP:USDT",
160+
"PEG:USD",
161+
"tokens"
162+
]
163+
},
164+
"protocols": [
165+
[
166+
[
167+
{
168+
"name": "PMM15",
169+
"part": 100,
170+
"fromTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
171+
"toTokenAddress": "0xdac17f958d2ee523a2206206994597c13d831ec7"
172+
}
173+
]
174+
]
175+
],
176+
"tx": {
177+
"from": "0x590559f6fb7720f24ff3e2fccf6015b466e9c92c",
178+
"to": "0x111111125421ca6dc452d289314280a0f8842a65",
179+
"data": "07ed2379000000000000000000000000f313b370d28760b98a2e935e56be92feb2c4ec04000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000f313b370d28760b98a2e935e56be92feb2c4ec04000000000000000000000000590559f6fb7720f24ff3e2fccf6015b466e9c92c000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000212c64300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000033c64b2acd3506aded3c1dafdb6fcac91b7a3b6b42a3fe374c25fdd3df2e1f837ca466cb20f8da0c6fa46d937b90bf8a3fc3c68614b3a94c667999d026a40e1de9d0000000000000000000000000000000000000002de00006e00005400004e802026678dcd0000000000000000000000000000000000000000590559f6fb7720f24ff3e2fccf6015b466e9c92c000000000000000000000000000000000000000000000000000000e8d4a5100000206b4be0b94041c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2d0e30db05120111111125421ca6dc452d289314280a0f8842a65c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2012456a75868e8eb936a05227576bce26784ccdc8d75e0db817d687734fcf4c1c3d1d15ee296000000000000000000000000807cf9a772d5a3f9cefbc1192e939d62f0d9bd380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000002182199000000000000000000000000000000000000000000000000002386099b1bf000000000000000000000000000000001915c00674734b400000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000002800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000419709bee012bcde5380cd388d52134750a9dd29efd835b9ad7a8792b0da1149e00d9aa573ae0f4b7b6365536e846bc792f8ec1452de4fb7b53a39abfc0e2c901c1b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014111111125421ca6dc452d289314280a0f8842a6500000000000000000000000000000000c095c0a2",
180+
"value": "0.01",
181+
"gas_price": "22.078218982",
182+
"gas": 228890
183+
},
184+
"gas": null
185+
},
186+
"id": null
187+
}
188+
```
189+
</CollapsibleSection>
190+

0 commit comments

Comments
 (0)