@curvefi/api 2.46.7 → 2.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -955,6 +955,9 @@ import curve from "@curvefi/api";
955
955
  (async () => {
956
956
  await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
957
957
 
958
+ curve.hasDepositAndStake()
959
+ // true
960
+
958
961
  const pool = curve.getPool('compound');
959
962
  const amounts = [1000, 1000];
960
963
 
@@ -1039,6 +1042,9 @@ import curve from "@curvefi/api";
1039
1042
  await curve.cryptoFactory.fetchPools();
1040
1043
  await curve.tricryptoFactory.fetchPools();
1041
1044
 
1045
+ curve.hasRouter();
1046
+ // true
1047
+
1042
1048
  await curve.getBalances(['DAI', 'CRV']);
1043
1049
  // [ '9900.0', '100049.744832225238317557' ]
1044
1050
 
@@ -1046,44 +1052,114 @@ import curve from "@curvefi/api";
1046
1052
  // OR await curve.router.getBestRouteAndOutput('0x6B175474E89094C44Da98b954EedeAC495271d0F', '0xD533a949740bb3306d119CC777fa900bA034cd52', '1000');
1047
1053
  const expected = await curve.router.expected('DAI', 'CRV', '1000');
1048
1054
  // OR await curve.router.expected('0x6B175474E89094C44Da98b954EedeAC495271d0F', '0xD533a949740bb3306d119CC777fa900bA034cd52', '1000');
1055
+ const required = await curve.router.required(route, output);
1049
1056
  const priceImpact = await curve.router.priceImpact('DAI', 'CRV', '1000');
1050
1057
  // OR await curve.router.priceImpact('0x6B175474E89094C44Da98b954EedeAC495271d0F', '0xD533a949740bb3306d119CC777fa900bA034cd52', '1000');
1058
+ const args = curve.router.getArgs(route);
1051
1059
 
1052
- console.log(route, output, expected, priceImpact);
1060
+ console.log(route, output, expected, required, priceImpact, args);
1053
1061
  // route = [
1054
1062
  // {
1055
- // poolId: '3pool',
1056
- // poolAddress: '0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7',
1057
- // outputCoinAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
1058
- // i: 0,
1059
- // j: 2,
1060
- // swapType: 1,
1061
- // swapAddress: '0x0000000000000000000000000000000000000000'
1063
+ // poolId: 'mim',
1064
+ // swapAddress: '0x5a6a4d54456819380173272a5e8e9b9904bdf41b',
1065
+ // inputCoinAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
1066
+ // outputCoinAddress: '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3',
1067
+ // swapParams: [ 1, 0, 2, 1, 4 ],
1068
+ // poolAddress: '0x5a6a4d54456819380173272a5e8e9b9904bdf41b',
1069
+ // basePool: '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7',
1070
+ // baseToken: '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490',
1071
+ // secondBasePool: '0x0000000000000000000000000000000000000000',
1072
+ // secondBaseToken: '0x0000000000000000000000000000000000000000'
1062
1073
  // },
1063
1074
  // {
1064
- // poolId: 'tricrypto2',
1065
- // poolAddress: '0xD51a44d3FaE010294C616388b506AcdA1bfAAE46',
1066
- // outputCoinAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1067
- // i: 0,
1068
- // j: 2,
1069
- // swapType: 3,
1070
- // swapAddress: '0x0000000000000000000000000000000000000000'
1075
+ // poolId: 'factory-crvusd-6',
1076
+ // swapAddress: '0xbe426b0f37c112dd20d5866769c8034171567b31',
1077
+ // inputCoinAddress: '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3',
1078
+ // outputCoinAddress: '0xf939e0a03fb07f59a73314e73794be0e57ac1b4e',
1079
+ // swapParams: [ 0, 1, 1, 1, 2 ],
1080
+ // poolAddress: '0xbe426b0f37c112dd20d5866769c8034171567b31',
1081
+ // basePool: '0x0000000000000000000000000000000000000000',
1082
+ // baseToken: '0x0000000000000000000000000000000000000000',
1083
+ // secondBasePool: '0x0000000000000000000000000000000000000000',
1084
+ // secondBaseToken: '0x0000000000000000000000000000000000000000'
1071
1085
  // },
1072
1086
  // {
1073
- // poolId: 'crveth',
1074
- // poolAddress: '0x8301AE4fc9c624d1D396cbDAa1ed877821D7C511',
1087
+ // poolId: 'factory-tricrypto-4',
1088
+ // swapAddress: '0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14',
1089
+ // inputCoinAddress: '0xf939e0a03fb07f59a73314e73794be0e57ac1b4e',
1075
1090
  // outputCoinAddress: '0xd533a949740bb3306d119cc777fa900ba034cd52',
1076
- // i: 0,
1077
- // j: 1,
1078
- // swapType: 3,
1079
- // swapAddress: '0x0000000000000000000000000000000000000000'
1091
+ // swapParams: [ 0, 2, 1, 3, 3 ],
1092
+ // poolAddress: '0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14',
1093
+ // basePool: '0x0000000000000000000000000000000000000000',
1094
+ // baseToken: '0x0000000000000000000000000000000000000000',
1095
+ // secondBasePool: '0x0000000000000000000000000000000000000000',
1096
+ // secondBaseToken: '0x0000000000000000000000000000000000000000'
1080
1097
  // }
1081
1098
  // ]
1082
1099
  //
1083
- // output = expected = 378.881631202862354937
1084
- //
1100
+ // output = expected = 2359.161199223806107003
1101
+ // required = 999.898950158673335108
1085
1102
  // priceImpact = 0.158012 %
1086
-
1103
+ //
1104
+ // args = {
1105
+ // _route: [
1106
+ // '0x6b175474e89094c44da98b954eedeac495271d0f',
1107
+ // '0x5a6a4d54456819380173272a5e8e9b9904bdf41b',
1108
+ // '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3',
1109
+ // '0xbe426b0f37c112dd20d5866769c8034171567b31',
1110
+ // '0xf939e0a03fb07f59a73314e73794be0e57ac1b4e',
1111
+ // '0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14',
1112
+ // '0xd533a949740bb3306d119cc777fa900ba034cd52',
1113
+ // '0x0000000000000000000000000000000000000000',
1114
+ // '0x0000000000000000000000000000000000000000',
1115
+ // '0x0000000000000000000000000000000000000000',
1116
+ // '0x0000000000000000000000000000000000000000'
1117
+ // ],
1118
+ // _swapParams: [
1119
+ // [ 1, 0, 2, 1, 4 ],
1120
+ // [ 0, 1, 1, 1, 2 ],
1121
+ // [ 0, 2, 1, 3, 3 ],
1122
+ // [ 0, 0, 0, 0, 0 ],
1123
+ // [ 0, 0, 0, 0, 0 ]
1124
+ // ],
1125
+ // _pools: [
1126
+ // '0x5a6a4d54456819380173272a5e8e9b9904bdf41b',
1127
+ // '0xbe426b0f37c112dd20d5866769c8034171567b31',
1128
+ // '0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14',
1129
+ // '0x0000000000000000000000000000000000000000',
1130
+ // '0x0000000000000000000000000000000000000000'
1131
+ // ],
1132
+ // _basePools: [
1133
+ // '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7',
1134
+ // '0x0000000000000000000000000000000000000000',
1135
+ // '0x0000000000000000000000000000000000000000',
1136
+ // '0x0000000000000000000000000000000000000000',
1137
+ // '0x0000000000000000000000000000000000000000'
1138
+ // ],
1139
+ // _baseTokens: [
1140
+ // '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490',
1141
+ // '0x0000000000000000000000000000000000000000',
1142
+ // '0x0000000000000000000000000000000000000000',
1143
+ // '0x0000000000000000000000000000000000000000',
1144
+ // '0x0000000000000000000000000000000000000000'
1145
+ // ],
1146
+ // _secondBasePools: [
1147
+ // '0x0000000000000000000000000000000000000000',
1148
+ // '0x0000000000000000000000000000000000000000',
1149
+ // '0x0000000000000000000000000000000000000000',
1150
+ // '0x0000000000000000000000000000000000000000',
1151
+ // '0x0000000000000000000000000000000000000000'
1152
+ // ],
1153
+ // _secondBaseTokens: [
1154
+ // '0x0000000000000000000000000000000000000000',
1155
+ // '0x0000000000000000000000000000000000000000',
1156
+ // '0x0000000000000000000000000000000000000000',
1157
+ // '0x0000000000000000000000000000000000000000',
1158
+ // '0x0000000000000000000000000000000000000000'
1159
+ // ]
1160
+ // }
1161
+
1162
+
1087
1163
  await curve.router.isApproved('DAI', 1000);
1088
1164
  // false
1089
1165
  await curve.router.approve('DAI', 1000);
@@ -1,265 +1,287 @@
1
1
  [
2
2
  {
3
- "name": "CommitOwnership",
4
- "inputs": [
5
- {
6
- "name": "admin",
7
- "type": "address",
8
- "indexed": false
9
- }
10
- ],
11
3
  "anonymous": false,
12
- "type": "event"
13
- },
14
- {
15
- "name": "ApplyOwnership",
16
4
  "inputs": [
17
5
  {
18
- "name": "admin",
19
- "type": "address",
20
- "indexed": false
21
- }
22
- ],
23
- "anonymous": false,
24
- "type": "event"
25
- },
26
- {
27
- "name": "TrustedForwardershipTransferred",
28
- "inputs": [
6
+ "indexed": true,
7
+ "name": "sender",
8
+ "type": "address"
9
+ },
29
10
  {
30
- "name": "previous_forwarder",
31
- "type": "address",
32
- "indexed": false
11
+ "indexed": true,
12
+ "name": "receiver",
13
+ "type": "address"
33
14
  },
34
15
  {
35
- "name": "new_forwarder",
36
- "type": "address",
37
- "indexed": false
38
- }
39
- ],
40
- "anonymous": false,
41
- "type": "event"
42
- },
43
- {
44
- "stateMutability": "nonpayable",
45
- "type": "constructor",
46
- "inputs": [
16
+ "indexed": false,
17
+ "name": "route",
18
+ "type": "address[11]"
19
+ },
47
20
  {
48
- "name": "_swap",
49
- "type": "address"
21
+ "indexed": false,
22
+ "name": "swap_params",
23
+ "type": "uint256[5][5]"
24
+ },
25
+ {
26
+ "indexed": false,
27
+ "name": "pools",
28
+ "type": "address[5]"
29
+ },
30
+ {
31
+ "indexed": false,
32
+ "name": "in_amount",
33
+ "type": "uint256"
34
+ },
35
+ {
36
+ "indexed": false,
37
+ "name": "out_amount",
38
+ "type": "uint256"
50
39
  }
51
40
  ],
52
- "outputs": []
41
+ "name": "Exchange",
42
+ "type": "event"
53
43
  },
54
44
  {
55
45
  "stateMutability": "payable",
56
46
  "type": "fallback"
57
47
  },
58
48
  {
59
- "stateMutability": "payable",
60
- "type": "function",
61
- "name": "exchange",
62
49
  "inputs": [
63
50
  {
64
- "name": "_amount",
65
- "type": "uint256"
51
+ "name": "_weth",
52
+ "type": "address"
66
53
  },
67
54
  {
68
- "name": "_route",
69
- "type": "address[6]"
55
+ "name": "_stable_calc",
56
+ "type": "address"
70
57
  },
71
58
  {
72
- "name": "_indices",
73
- "type": "uint256[8]"
59
+ "name": "_crypto_calc",
60
+ "type": "address"
74
61
  },
75
62
  {
76
- "name": "_min_received",
77
- "type": "uint256"
63
+ "name": "_snx_coins",
64
+ "type": "address[4]"
78
65
  }
79
66
  ],
80
- "outputs": []
67
+ "name": "constructor",
68
+ "outputs": [],
69
+ "stateMutability": "nonpayable",
70
+ "type": "constructor"
81
71
  },
82
72
  {
83
- "stateMutability": "view",
84
- "type": "function",
85
- "name": "get_exchange_routing",
86
73
  "inputs": [
87
74
  {
88
- "name": "_initial",
89
- "type": "address"
75
+ "name": "_route",
76
+ "type": "address[11]"
90
77
  },
91
78
  {
92
- "name": "_target",
93
- "type": "address"
79
+ "name": "_swap_params",
80
+ "type": "uint256[5][5]"
94
81
  },
95
82
  {
96
83
  "name": "_amount",
97
84
  "type": "uint256"
85
+ },
86
+ {
87
+ "name": "_expected",
88
+ "type": "uint256"
98
89
  }
99
90
  ],
91
+ "name": "exchange",
100
92
  "outputs": [
101
- {
102
- "name": "",
103
- "type": "address[6]"
104
- },
105
- {
106
- "name": "",
107
- "type": "uint256[8]"
108
- },
109
93
  {
110
94
  "name": "",
111
95
  "type": "uint256"
112
96
  }
113
97
  ],
114
- "gas": "58134"
98
+ "stateMutability": "payable",
99
+ "type": "function"
115
100
  },
116
101
  {
117
- "stateMutability": "view",
118
- "type": "function",
119
- "name": "can_route",
120
102
  "inputs": [
121
103
  {
122
- "name": "_initial",
123
- "type": "address"
104
+ "name": "_route",
105
+ "type": "address[11]"
124
106
  },
125
107
  {
126
- "name": "_target",
127
- "type": "address"
108
+ "name": "_swap_params",
109
+ "type": "uint256[5][5]"
110
+ },
111
+ {
112
+ "name": "_amount",
113
+ "type": "uint256"
114
+ },
115
+ {
116
+ "name": "_expected",
117
+ "type": "uint256"
118
+ },
119
+ {
120
+ "name": "_pools",
121
+ "type": "address[5]"
128
122
  }
129
123
  ],
124
+ "name": "exchange",
130
125
  "outputs": [
131
126
  {
132
127
  "name": "",
133
- "type": "bool"
128
+ "type": "uint256"
134
129
  }
135
130
  ],
136
- "gas": "26895"
131
+ "stateMutability": "payable",
132
+ "type": "function"
137
133
  },
138
134
  {
139
- "stateMutability": "nonpayable",
140
- "type": "function",
141
- "name": "commit_transfer_ownership",
142
135
  "inputs": [
143
136
  {
144
- "name": "addr",
145
- "type": "address"
146
- }
147
- ],
148
- "outputs": [],
149
- "gas": "39075"
150
- },
151
- {
152
- "stateMutability": "nonpayable",
153
- "type": "function",
154
- "name": "accept_transfer_ownership",
155
- "inputs": [],
156
- "outputs": [],
157
- "gas": "39020"
158
- },
159
- {
160
- "stateMutability": "view",
161
- "type": "function",
162
- "name": "isTrustedForwarder",
163
- "inputs": [
137
+ "name": "_route",
138
+ "type": "address[11]"
139
+ },
164
140
  {
165
- "name": "_forwarder",
166
- "type": "address"
141
+ "name": "_swap_params",
142
+ "type": "uint256[5][5]"
143
+ },
144
+ {
145
+ "name": "_amount",
146
+ "type": "uint256"
167
147
  }
168
148
  ],
149
+ "name": "get_dy",
169
150
  "outputs": [
170
151
  {
171
152
  "name": "",
172
- "type": "bool"
153
+ "type": "uint256"
173
154
  }
174
155
  ],
175
- "gas": "2737"
156
+ "stateMutability": "view",
157
+ "type": "function"
176
158
  },
177
159
  {
178
- "stateMutability": "nonpayable",
179
- "type": "function",
180
- "name": "set_trusted_forwarder",
181
160
  "inputs": [
182
161
  {
183
- "name": "_forwarder",
184
- "type": "address"
185
- }
186
- ],
187
- "outputs": [
162
+ "name": "_route",
163
+ "type": "address[11]"
164
+ },
188
165
  {
189
- "name": "",
190
- "type": "bool"
166
+ "name": "_swap_params",
167
+ "type": "uint256[5][5]"
168
+ },
169
+ {
170
+ "name": "_amount",
171
+ "type": "uint256"
172
+ },
173
+ {
174
+ "name": "_pools",
175
+ "type": "address[5]"
191
176
  }
192
177
  ],
193
- "gas": "41913"
194
- },
195
- {
196
- "stateMutability": "view",
197
- "type": "function",
198
- "name": "swap",
199
- "inputs": [],
178
+ "name": "get_dy",
200
179
  "outputs": [
201
180
  {
202
181
  "name": "",
203
- "type": "address"
182
+ "type": "uint256"
204
183
  }
205
184
  ],
206
- "gas": "2688"
185
+ "stateMutability": "view",
186
+ "type": "function"
207
187
  },
208
188
  {
209
- "stateMutability": "view",
210
- "type": "function",
211
- "name": "crypto_coins",
212
189
  "inputs": [
213
190
  {
214
- "name": "arg0",
191
+ "name": "_route",
192
+ "type": "address[11]"
193
+ },
194
+ {
195
+ "name": "_swap_params",
196
+ "type": "uint256[5][5]"
197
+ },
198
+ {
199
+ "name": "_out_amount",
215
200
  "type": "uint256"
201
+ },
202
+ {
203
+ "name": "_pools",
204
+ "type": "address[5]"
216
205
  }
217
206
  ],
207
+ "name": "get_dx",
218
208
  "outputs": [
219
209
  {
220
210
  "name": "",
221
- "type": "address"
211
+ "type": "uint256"
222
212
  }
223
213
  ],
224
- "gas": "2827"
214
+ "stateMutability": "view",
215
+ "type": "function"
225
216
  },
226
217
  {
227
- "stateMutability": "view",
228
- "type": "function",
229
- "name": "owner",
230
- "inputs": [],
231
- "outputs": [
218
+ "inputs": [
232
219
  {
233
- "name": "",
234
- "type": "address"
220
+ "name": "_route",
221
+ "type": "address[11]"
222
+ },
223
+ {
224
+ "name": "_swap_params",
225
+ "type": "uint256[5][5]"
226
+ },
227
+ {
228
+ "name": "_out_amount",
229
+ "type": "uint256"
230
+ },
231
+ {
232
+ "name": "_pools",
233
+ "type": "address[5]"
234
+ },
235
+ {
236
+ "name": "_base_pools",
237
+ "type": "address[5]"
235
238
  }
236
239
  ],
237
- "gas": "2748"
238
- },
239
- {
240
- "stateMutability": "view",
241
- "type": "function",
242
- "name": "trusted_forwarder",
243
- "inputs": [],
240
+ "name": "get_dx",
244
241
  "outputs": [
245
242
  {
246
243
  "name": "",
247
- "type": "address"
244
+ "type": "uint256"
248
245
  }
249
246
  ],
250
- "gas": "2778"
247
+ "stateMutability": "view",
248
+ "type": "function"
251
249
  },
252
250
  {
253
- "stateMutability": "view",
254
- "type": "function",
255
- "name": "future_owner",
256
- "inputs": [],
251
+ "inputs": [
252
+ {
253
+ "name": "_route",
254
+ "type": "address[11]"
255
+ },
256
+ {
257
+ "name": "_swap_params",
258
+ "type": "uint256[5][5]"
259
+ },
260
+ {
261
+ "name": "_out_amount",
262
+ "type": "uint256"
263
+ },
264
+ {
265
+ "name": "_pools",
266
+ "type": "address[5]"
267
+ },
268
+ {
269
+ "name": "_base_pools",
270
+ "type": "address[5]"
271
+ },
272
+ {
273
+ "name": "_base_tokens",
274
+ "type": "address[5]"
275
+ }
276
+ ],
277
+ "name": "get_dx",
257
278
  "outputs": [
258
279
  {
259
280
  "name": "",
260
- "type": "address"
281
+ "type": "uint256"
261
282
  }
262
283
  ],
263
- "gas": "2808"
284
+ "stateMutability": "view",
285
+ "type": "function"
264
286
  }
265
287
  ]