@curvefi/api 2.46.7 → 2.47.1

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,115 @@ 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('DAI', 'CRV', expected);
1056
+ // OR await curve.router.required('0x6B175474E89094C44Da98b954EedeAC495271d0F', '0xD533a949740bb3306d119CC777fa900bA034cd52', expected);
1049
1057
  const priceImpact = await curve.router.priceImpact('DAI', 'CRV', '1000');
1050
1058
  // OR await curve.router.priceImpact('0x6B175474E89094C44Da98b954EedeAC495271d0F', '0xD533a949740bb3306d119CC777fa900bA034cd52', '1000');
1059
+ const args = curve.router.getArgs(route);
1051
1060
 
1052
- console.log(route, output, expected, priceImpact);
1061
+ console.log(route, output, expected, required, priceImpact, args);
1053
1062
  // route = [
1054
1063
  // {
1055
- // poolId: '3pool',
1056
- // poolAddress: '0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7',
1057
- // outputCoinAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
1058
- // i: 0,
1059
- // j: 2,
1060
- // swapType: 1,
1061
- // swapAddress: '0x0000000000000000000000000000000000000000'
1064
+ // poolId: 'mim',
1065
+ // swapAddress: '0x5a6a4d54456819380173272a5e8e9b9904bdf41b',
1066
+ // inputCoinAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
1067
+ // outputCoinAddress: '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3',
1068
+ // swapParams: [ 1, 0, 2, 1, 4 ],
1069
+ // poolAddress: '0x5a6a4d54456819380173272a5e8e9b9904bdf41b',
1070
+ // basePool: '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7',
1071
+ // baseToken: '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490',
1072
+ // secondBasePool: '0x0000000000000000000000000000000000000000',
1073
+ // secondBaseToken: '0x0000000000000000000000000000000000000000'
1062
1074
  // },
1063
1075
  // {
1064
- // poolId: 'tricrypto2',
1065
- // poolAddress: '0xD51a44d3FaE010294C616388b506AcdA1bfAAE46',
1066
- // outputCoinAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
1067
- // i: 0,
1068
- // j: 2,
1069
- // swapType: 3,
1070
- // swapAddress: '0x0000000000000000000000000000000000000000'
1076
+ // poolId: 'factory-crvusd-6',
1077
+ // swapAddress: '0xbe426b0f37c112dd20d5866769c8034171567b31',
1078
+ // inputCoinAddress: '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3',
1079
+ // outputCoinAddress: '0xf939e0a03fb07f59a73314e73794be0e57ac1b4e',
1080
+ // swapParams: [ 0, 1, 1, 1, 2 ],
1081
+ // poolAddress: '0xbe426b0f37c112dd20d5866769c8034171567b31',
1082
+ // basePool: '0x0000000000000000000000000000000000000000',
1083
+ // baseToken: '0x0000000000000000000000000000000000000000',
1084
+ // secondBasePool: '0x0000000000000000000000000000000000000000',
1085
+ // secondBaseToken: '0x0000000000000000000000000000000000000000'
1071
1086
  // },
1072
1087
  // {
1073
- // poolId: 'crveth',
1074
- // poolAddress: '0x8301AE4fc9c624d1D396cbDAa1ed877821D7C511',
1088
+ // poolId: 'factory-tricrypto-4',
1089
+ // swapAddress: '0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14',
1090
+ // inputCoinAddress: '0xf939e0a03fb07f59a73314e73794be0e57ac1b4e',
1075
1091
  // outputCoinAddress: '0xd533a949740bb3306d119cc777fa900ba034cd52',
1076
- // i: 0,
1077
- // j: 1,
1078
- // swapType: 3,
1079
- // swapAddress: '0x0000000000000000000000000000000000000000'
1092
+ // swapParams: [ 0, 2, 1, 3, 3 ],
1093
+ // poolAddress: '0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14',
1094
+ // basePool: '0x0000000000000000000000000000000000000000',
1095
+ // baseToken: '0x0000000000000000000000000000000000000000',
1096
+ // secondBasePool: '0x0000000000000000000000000000000000000000',
1097
+ // secondBaseToken: '0x0000000000000000000000000000000000000000'
1080
1098
  // }
1081
1099
  // ]
1082
1100
  //
1083
- // output = expected = 378.881631202862354937
1084
- //
1101
+ // output = expected = 2359.161199223806107003
1102
+ // required = 999.898950158673335108
1085
1103
  // priceImpact = 0.158012 %
1086
-
1104
+ //
1105
+ // args = {
1106
+ // _route: [
1107
+ // '0x6b175474e89094c44da98b954eedeac495271d0f',
1108
+ // '0x5a6a4d54456819380173272a5e8e9b9904bdf41b',
1109
+ // '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3',
1110
+ // '0xbe426b0f37c112dd20d5866769c8034171567b31',
1111
+ // '0xf939e0a03fb07f59a73314e73794be0e57ac1b4e',
1112
+ // '0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14',
1113
+ // '0xd533a949740bb3306d119cc777fa900ba034cd52',
1114
+ // '0x0000000000000000000000000000000000000000',
1115
+ // '0x0000000000000000000000000000000000000000',
1116
+ // '0x0000000000000000000000000000000000000000',
1117
+ // '0x0000000000000000000000000000000000000000'
1118
+ // ],
1119
+ // _swapParams: [
1120
+ // [ 1, 0, 2, 1, 4 ],
1121
+ // [ 0, 1, 1, 1, 2 ],
1122
+ // [ 0, 2, 1, 3, 3 ],
1123
+ // [ 0, 0, 0, 0, 0 ],
1124
+ // [ 0, 0, 0, 0, 0 ]
1125
+ // ],
1126
+ // _pools: [
1127
+ // '0x5a6a4d54456819380173272a5e8e9b9904bdf41b',
1128
+ // '0xbe426b0f37c112dd20d5866769c8034171567b31',
1129
+ // '0x4ebdf703948ddcea3b11f675b4d1fba9d2414a14',
1130
+ // '0x0000000000000000000000000000000000000000',
1131
+ // '0x0000000000000000000000000000000000000000'
1132
+ // ],
1133
+ // _basePools: [
1134
+ // '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7',
1135
+ // '0x0000000000000000000000000000000000000000',
1136
+ // '0x0000000000000000000000000000000000000000',
1137
+ // '0x0000000000000000000000000000000000000000',
1138
+ // '0x0000000000000000000000000000000000000000'
1139
+ // ],
1140
+ // _baseTokens: [
1141
+ // '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490',
1142
+ // '0x0000000000000000000000000000000000000000',
1143
+ // '0x0000000000000000000000000000000000000000',
1144
+ // '0x0000000000000000000000000000000000000000',
1145
+ // '0x0000000000000000000000000000000000000000'
1146
+ // ],
1147
+ // _secondBasePools: [
1148
+ // '0x0000000000000000000000000000000000000000',
1149
+ // '0x0000000000000000000000000000000000000000',
1150
+ // '0x0000000000000000000000000000000000000000',
1151
+ // '0x0000000000000000000000000000000000000000',
1152
+ // '0x0000000000000000000000000000000000000000'
1153
+ // ],
1154
+ // _secondBaseTokens: [
1155
+ // '0x0000000000000000000000000000000000000000',
1156
+ // '0x0000000000000000000000000000000000000000',
1157
+ // '0x0000000000000000000000000000000000000000',
1158
+ // '0x0000000000000000000000000000000000000000',
1159
+ // '0x0000000000000000000000000000000000000000'
1160
+ // ]
1161
+ // }
1162
+
1163
+
1087
1164
  await curve.router.isApproved('DAI', 1000);
1088
1165
  // false
1089
1166
  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
  ]