@curvefi/api 1.8.3 → 1.11.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 +0 -6
- package/lib/boosting.js +2 -2
- package/lib/constants/abis/abis-ethereum.d.ts +1 -1
- package/lib/constants/abis/abis-ethereum.js +97 -5
- package/lib/constants/abis/abis-polygon.d.ts +4 -0
- package/lib/constants/abis/abis-polygon.js +146 -0
- package/lib/constants/abis/json/atricrypto3/swap.json +1269 -0
- package/lib/constants/abis/json/atricrypto3/zap.json +239 -0
- package/lib/constants/abis/json/crveth/swap.json +1258 -0
- package/lib/constants/abis/json/{registry.json → eurt/swap.json} +402 -497
- package/lib/constants/abis/json/eurtusd/deposit.json +257 -0
- package/lib/constants/abis/json/eurtusd/swap.json +1199 -0
- package/lib/constants/abis/json/paave/rewards.json +657 -0
- package/lib/constants/abis/json/registry_exchange.json +0 -37
- package/lib/constants/abis/json/ren-polygon/swap.json +1112 -0
- package/lib/constants/abis/json/tricrypto2/deposit.json +0 -79
- package/lib/constants/aliases.d.ts +16 -0
- package/lib/constants/aliases.js +19 -0
- package/lib/constants/coins-ethereum.d.ts +31 -0
- package/lib/constants/{coins.js → coins-ethereum.js} +47 -13
- package/lib/constants/coins-polygon.d.ts +31 -0
- package/lib/constants/coins-polygon.js +74 -0
- package/lib/curve.d.ts +23 -6
- package/lib/curve.js +137 -80
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/interfaces.d.ts +2 -0
- package/lib/pools.d.ts +2 -11
- package/lib/pools.js +584 -440
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +34 -15
- package/package.json +6 -5
- package/lib/constants/coins.d.ts +0 -25
package/lib/curve.js
CHANGED
|
@@ -46,13 +46,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
60
|
};
|
|
52
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.curve = exports.ALIASES = void 0;
|
|
62
|
+
exports.curve = exports.ALIASES = exports.DECIMALS_LOWER_CASE = exports.DECIMALS = exports.COINS = exports.USD_COINS_LOWER_CASE = exports.USD_COINS = exports.EUR_COINS_LOWER_CASE = exports.EUR_COINS = exports.LINK_COINS_LOWER_CASE = exports.LINK_COINS = exports.ETH_COINS_LOWER_CASE = exports.ETH_COINS = exports.BTC_COINS_LOWER_CASE = exports.BTC_COINS = exports.GAUGES = exports.LP_TOKENS = exports.POOLS_DATA = void 0;
|
|
54
63
|
var ethers_1 = require("ethers");
|
|
55
|
-
var
|
|
64
|
+
var ethcall_1 = require("ethcall");
|
|
56
65
|
var ERC20_json_1 = __importDefault(require("./constants/abis/json/ERC20.json"));
|
|
57
66
|
var cERC20_json_1 = __importDefault(require("./constants/abis/json/cERC20.json"));
|
|
58
67
|
var yERC20_json_1 = __importDefault(require("./constants/abis/json/yERC20.json"));
|
|
@@ -61,46 +70,20 @@ var votingescrow_json_1 = __importDefault(require("./constants/abis/json/votinge
|
|
|
61
70
|
var address_provider_json_1 = __importDefault(require("./constants/abis/json/address_provider.json"));
|
|
62
71
|
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/json/gaugecontroller.json"));
|
|
63
72
|
var router_json_1 = __importDefault(require("./constants/abis/json/router.json"));
|
|
73
|
+
var registry_exchange_json_1 = __importDefault(require("./constants/abis/json/registry_exchange.json"));
|
|
64
74
|
var abis_ethereum_1 = require("./constants/abis/abis-ethereum");
|
|
75
|
+
var abis_polygon_1 = require("./constants/abis/abis-polygon");
|
|
76
|
+
var coins_ethereum_1 = require("./constants/coins-ethereum");
|
|
77
|
+
var coins_polygon_1 = require("./constants/coins-polygon");
|
|
78
|
+
var aliases_1 = require("./constants/aliases");
|
|
65
79
|
exports.ALIASES = {
|
|
66
80
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
67
|
-
"pool_proxy": "0xeCb456EA5365865EbAb8a2661B0c503410e9B347",
|
|
68
|
-
"gauge_proxy": "0x519AFB566c05E00cfB9af73496D00217A630e4D5",
|
|
69
81
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
70
82
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
71
|
-
"minter": "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0",
|
|
72
|
-
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
73
83
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
74
84
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
85
|
+
"registry_exchange": "",
|
|
75
86
|
};
|
|
76
|
-
var cTokens = [
|
|
77
|
-
'0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643',
|
|
78
|
-
'0x39AA39c021dfbaE8faC545936693aC917d5E7563',
|
|
79
|
-
"0x8e595470ed749b85c6f7669de83eae304c2ec68f",
|
|
80
|
-
"0x48759f220ed983db51fa7a8c0d2aab8f3ce4166a",
|
|
81
|
-
"0x76eb2fe28b36b3ee97f3adae0c69606eedb2a37c", // cyUSDC
|
|
82
|
-
];
|
|
83
|
-
var yTokens = [
|
|
84
|
-
"0xC2cB1040220768554cf699b0d863A3cd4324ce32",
|
|
85
|
-
"0x26EA744E5B887E5205727f55dFBE8685e3b21951",
|
|
86
|
-
"0xE6354ed5bC4b393a5Aad09f21c46E101e692d447",
|
|
87
|
-
"0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01",
|
|
88
|
-
"0xd6aD7a6750A7593E092a9B218d66C0A814a3436e",
|
|
89
|
-
"0x83f798e925BcD4017Eb265844FDDAbb448f1707D",
|
|
90
|
-
"0x04bC0Ab673d88aE9dbC9DA2380cB6B79C4BCa9aE",
|
|
91
|
-
"0x73a052500105205d34Daf004eAb301916DA8190f", // yTUSD
|
|
92
|
-
];
|
|
93
|
-
var ycTokens = [
|
|
94
|
-
"0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc",
|
|
95
|
-
"0x9777d7E2b60bB01759D0E2f8be2095df444cb07E",
|
|
96
|
-
"0x1bE5d71F2dA660BFdee8012dDc58D024448A0A59", // ycUSDT
|
|
97
|
-
];
|
|
98
|
-
var aTokens = [
|
|
99
|
-
"0x028171bCA77440897B824Ca71D1c56caC55b68A3",
|
|
100
|
-
"0xBcca60bB61934080951369a648Fb03DF4F96263C",
|
|
101
|
-
"0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811",
|
|
102
|
-
"0x6c5024cd4f8a59110119c56f8933403a539555eb", // sSUSD
|
|
103
|
-
];
|
|
104
87
|
var Curve = /** @class */ (function () {
|
|
105
88
|
function Curve() {
|
|
106
89
|
// @ts-ignore
|
|
@@ -108,6 +91,7 @@ var Curve = /** @class */ (function () {
|
|
|
108
91
|
// @ts-ignore
|
|
109
92
|
this.signer = null;
|
|
110
93
|
this.signerAddress = '';
|
|
94
|
+
this.chainId = 0;
|
|
111
95
|
// @ts-ignore
|
|
112
96
|
this.multicallProvider = null;
|
|
113
97
|
this.contracts = {};
|
|
@@ -119,9 +103,9 @@ var Curve = /** @class */ (function () {
|
|
|
119
103
|
) {
|
|
120
104
|
if (options === void 0) { options = {}; }
|
|
121
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
-
var _a, _i, _b, pool, _c, _d, coinAddr, _e, _f, coinAddr;
|
|
123
|
-
return __generator(this, function (
|
|
124
|
-
switch (
|
|
106
|
+
var cTokens, yTokens, ycTokens, aTokens, network, customAbiTokens, _a, _i, _b, pool, _c, _d, coinAddr, _e, _f, coinAddr, _g, _h, coinAddr, addressProviderContract, _j;
|
|
107
|
+
return __generator(this, function (_k) {
|
|
108
|
+
switch (_k.label) {
|
|
125
109
|
case 0:
|
|
126
110
|
// JsonRpc provider
|
|
127
111
|
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
@@ -153,151 +137,224 @@ var Curve = /** @class */ (function () {
|
|
|
153
137
|
else {
|
|
154
138
|
throw Error('Wrong providerType');
|
|
155
139
|
}
|
|
156
|
-
|
|
157
|
-
this.multicallProvider = new ethers_multicall_1.Provider(this.provider, options.chainId);
|
|
158
|
-
return [3 /*break*/, 3];
|
|
140
|
+
return [4 /*yield*/, this.provider._networkPromise];
|
|
159
141
|
case 1:
|
|
160
|
-
|
|
161
|
-
|
|
142
|
+
network = _k.sent();
|
|
143
|
+
console.log("CURVE-JS IS CONNECTED TO NETWORK:", network);
|
|
144
|
+
this.chainId = network.chainId;
|
|
145
|
+
if (network.chainId === 1) {
|
|
146
|
+
cTokens = coins_ethereum_1.cTokensEthereum;
|
|
147
|
+
yTokens = coins_ethereum_1.yTokensEthereum;
|
|
148
|
+
ycTokens = coins_ethereum_1.ycTokensEthereum;
|
|
149
|
+
aTokens = coins_ethereum_1.aTokensEthereum;
|
|
150
|
+
exports.ALIASES = aliases_1.ALIASES_ETHEREUM;
|
|
151
|
+
exports.POOLS_DATA = abis_ethereum_1.POOLS_DATA_ETHEREUM;
|
|
152
|
+
exports.BTC_COINS = coins_ethereum_1.BTC_COINS_ETHEREUM;
|
|
153
|
+
exports.BTC_COINS_LOWER_CASE = coins_ethereum_1.BTC_COINS_LOWER_CASE_ETHEREUM;
|
|
154
|
+
exports.ETH_COINS = coins_ethereum_1.ETH_COINS_ETHEREUM;
|
|
155
|
+
exports.ETH_COINS_LOWER_CASE = coins_ethereum_1.ETH_COINS_LOWER_CASE_ETHEREUM;
|
|
156
|
+
exports.LINK_COINS = coins_ethereum_1.LINK_COINS_ETHEREUM;
|
|
157
|
+
exports.LINK_COINS_LOWER_CASE = coins_ethereum_1.LINK_COINS_LOWER_CASE_ETHEREUM;
|
|
158
|
+
exports.EUR_COINS = coins_ethereum_1.EUR_COINS_ETHEREUM;
|
|
159
|
+
exports.EUR_COINS_LOWER_CASE = coins_ethereum_1.EUR_COINS_LOWER_CASE_ETHEREUM;
|
|
160
|
+
exports.USD_COINS = coins_ethereum_1.USD_COINS_ETHEREUM;
|
|
161
|
+
exports.USD_COINS_LOWER_CASE = coins_ethereum_1.USD_COINS_LOWER_CASE_ETHEREUM;
|
|
162
|
+
exports.COINS = coins_ethereum_1.COINS_ETHEREUM;
|
|
163
|
+
exports.DECIMALS = coins_ethereum_1.DECIMALS_ETHEREUM;
|
|
164
|
+
exports.DECIMALS_LOWER_CASE = coins_ethereum_1.DECIMALS_LOWER_CASE_ETHEREUM;
|
|
165
|
+
}
|
|
166
|
+
else if (network.chainId === 137) {
|
|
167
|
+
cTokens = coins_polygon_1.cTokensPolygon;
|
|
168
|
+
yTokens = coins_polygon_1.yTokensPolygon;
|
|
169
|
+
ycTokens = coins_polygon_1.ycTokensPolygon;
|
|
170
|
+
aTokens = coins_polygon_1.aTokensPolygon;
|
|
171
|
+
exports.ALIASES = aliases_1.ALIASES_POLYGON;
|
|
172
|
+
exports.POOLS_DATA = abis_polygon_1.POOLS_DATA_POLYGON;
|
|
173
|
+
exports.BTC_COINS = coins_polygon_1.BTC_COINS_POLYGON;
|
|
174
|
+
exports.BTC_COINS_LOWER_CASE = coins_polygon_1.BTC_COINS_LOWER_CASE_POLYGON;
|
|
175
|
+
exports.ETH_COINS = coins_polygon_1.ETH_COINS_POLYGON;
|
|
176
|
+
exports.ETH_COINS_LOWER_CASE = coins_polygon_1.ETH_COINS_LOWER_CASE_POLYGON;
|
|
177
|
+
exports.LINK_COINS = coins_polygon_1.LINK_COINS_POLYGON;
|
|
178
|
+
exports.LINK_COINS_LOWER_CASE = coins_polygon_1.LINK_COINS_LOWER_CASE_POLYGON;
|
|
179
|
+
exports.EUR_COINS = coins_polygon_1.EUR_COINS_POLYGON;
|
|
180
|
+
exports.EUR_COINS_LOWER_CASE = coins_polygon_1.EUR_COINS_LOWER_CASE_POLYGON;
|
|
181
|
+
exports.USD_COINS = coins_polygon_1.USD_COINS_POLYGON;
|
|
182
|
+
exports.USD_COINS_LOWER_CASE = coins_polygon_1.USD_COINS_LOWER_CASE_POLYGON;
|
|
183
|
+
exports.COINS = coins_polygon_1.COINS_POLYGON;
|
|
184
|
+
exports.DECIMALS = coins_polygon_1.DECIMALS_POLYGON;
|
|
185
|
+
exports.DECIMALS_LOWER_CASE = coins_polygon_1.DECIMALS_LOWER_CASE_POLYGON;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
throw Error("Network with chainId ".concat(this.provider.network.chainId, " is not supported"));
|
|
189
|
+
}
|
|
190
|
+
exports.LP_TOKENS = Object.values(exports.POOLS_DATA).map(function (data) { return data.token_address.toLowerCase(); });
|
|
191
|
+
exports.GAUGES = Object.values(exports.POOLS_DATA).map(function (data) { return data.gauge_address.toLowerCase(); });
|
|
192
|
+
customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
|
|
193
|
+
this.multicallProvider = new ethcall_1.Provider();
|
|
194
|
+
return [4 /*yield*/, this.multicallProvider.init(this.provider)];
|
|
162
195
|
case 2:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
case 3:
|
|
166
|
-
if (!this.signer) return [3 /*break*/, 5];
|
|
196
|
+
_k.sent();
|
|
197
|
+
if (!this.signer) return [3 /*break*/, 4];
|
|
167
198
|
_a = this;
|
|
168
199
|
return [4 /*yield*/, this.signer.getAddress()];
|
|
200
|
+
case 3:
|
|
201
|
+
_a.signerAddress = _k.sent();
|
|
202
|
+
_k.label = 4;
|
|
169
203
|
case 4:
|
|
170
|
-
_a.signerAddress = _g.sent();
|
|
171
|
-
_g.label = 5;
|
|
172
|
-
case 5:
|
|
173
204
|
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
174
205
|
return [4 /*yield*/, this.updateFeeData()];
|
|
175
|
-
case
|
|
176
|
-
|
|
206
|
+
case 5:
|
|
207
|
+
_k.sent();
|
|
177
208
|
// TODO delete toLowerCase()
|
|
178
|
-
for (_i = 0, _b = Object.values(
|
|
209
|
+
for (_i = 0, _b = Object.values(exports.POOLS_DATA); _i < _b.length; _i++) {
|
|
179
210
|
pool = _b[_i];
|
|
180
211
|
this.contracts[pool.swap_address] = {
|
|
181
212
|
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
182
|
-
multicallContract: new
|
|
213
|
+
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
183
214
|
};
|
|
184
215
|
this.contracts[pool.swap_address.toLowerCase()] = {
|
|
185
216
|
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
186
|
-
multicallContract: new
|
|
217
|
+
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
187
218
|
};
|
|
188
219
|
if (pool.token_address !== pool.swap_address) {
|
|
189
220
|
this.contracts[pool.token_address] = {
|
|
190
221
|
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
191
|
-
multicallContract: new
|
|
222
|
+
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
192
223
|
};
|
|
193
224
|
this.contracts[pool.token_address.toLowerCase()] = {
|
|
194
225
|
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
195
|
-
multicallContract: new
|
|
226
|
+
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
196
227
|
};
|
|
197
228
|
}
|
|
198
229
|
this.contracts[pool.gauge_address] = {
|
|
199
230
|
contract: new ethers_1.Contract(pool.gauge_address, gauge_json_1.default, this.signer || this.provider),
|
|
200
|
-
multicallContract: new
|
|
231
|
+
multicallContract: new ethcall_1.Contract(pool.gauge_address, gauge_json_1.default),
|
|
201
232
|
};
|
|
202
233
|
this.contracts[pool.gauge_address.toLowerCase()] = {
|
|
203
234
|
contract: new ethers_1.Contract(pool.gauge_address, gauge_json_1.default, this.signer || this.provider),
|
|
204
|
-
multicallContract: new
|
|
235
|
+
multicallContract: new ethcall_1.Contract(pool.gauge_address, gauge_json_1.default),
|
|
205
236
|
};
|
|
206
237
|
if (pool.deposit_address && this.contracts[pool.deposit_address] === undefined) {
|
|
207
238
|
this.contracts[pool.deposit_address] = {
|
|
208
239
|
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
209
|
-
multicallContract: new
|
|
240
|
+
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
210
241
|
};
|
|
211
242
|
this.contracts[pool.deposit_address.toLowerCase()] = {
|
|
212
243
|
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
213
|
-
multicallContract: new
|
|
244
|
+
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
214
245
|
};
|
|
215
246
|
}
|
|
216
247
|
for (_c = 0, _d = pool.underlying_coin_addresses; _c < _d.length; _c++) {
|
|
217
248
|
coinAddr = _d[_c];
|
|
218
249
|
this.contracts[coinAddr] = {
|
|
219
250
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
220
|
-
multicallContract: new
|
|
251
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
221
252
|
};
|
|
222
253
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
223
254
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
224
|
-
multicallContract: new
|
|
255
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
225
256
|
};
|
|
226
257
|
}
|
|
227
|
-
// TODO add all coins
|
|
228
258
|
for (_e = 0, _f = pool.coin_addresses; _e < _f.length; _e++) {
|
|
229
259
|
coinAddr = _f[_e];
|
|
260
|
+
if (customAbiTokens.includes(coinAddr))
|
|
261
|
+
continue;
|
|
262
|
+
this.contracts[coinAddr] = {
|
|
263
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
264
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
265
|
+
};
|
|
266
|
+
this.contracts[coinAddr.toLowerCase()] = {
|
|
267
|
+
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
268
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
// TODO add all coins
|
|
272
|
+
for (_g = 0, _h = pool.coin_addresses; _g < _h.length; _g++) {
|
|
273
|
+
coinAddr = _h[_g];
|
|
230
274
|
if (cTokens.includes(coinAddr)) {
|
|
231
275
|
this.contracts[coinAddr] = {
|
|
232
276
|
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
233
|
-
multicallContract: new
|
|
277
|
+
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
234
278
|
};
|
|
235
279
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
236
280
|
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
237
|
-
multicallContract: new
|
|
281
|
+
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
238
282
|
};
|
|
239
283
|
}
|
|
240
284
|
if (aTokens.includes(coinAddr)) {
|
|
241
285
|
this.contracts[coinAddr] = {
|
|
242
286
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
243
|
-
multicallContract: new
|
|
287
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
244
288
|
};
|
|
245
289
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
246
290
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
247
|
-
multicallContract: new
|
|
291
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
248
292
|
};
|
|
249
293
|
}
|
|
250
294
|
if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
|
|
251
295
|
this.contracts[coinAddr] = {
|
|
252
296
|
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
253
|
-
multicallContract: new
|
|
297
|
+
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
254
298
|
};
|
|
255
299
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
256
300
|
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
257
|
-
multicallContract: new
|
|
301
|
+
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
258
302
|
};
|
|
259
303
|
}
|
|
260
304
|
}
|
|
261
305
|
}
|
|
262
306
|
this.contracts[exports.ALIASES.crv] = {
|
|
263
307
|
contract: new ethers_1.Contract(exports.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
264
|
-
multicallContract: new
|
|
308
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.crv, ERC20_json_1.default),
|
|
265
309
|
};
|
|
266
310
|
this.contracts[exports.ALIASES.crv.toLowerCase()] = {
|
|
267
311
|
contract: new ethers_1.Contract(exports.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
268
|
-
multicallContract: new
|
|
312
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.crv, ERC20_json_1.default),
|
|
269
313
|
};
|
|
270
314
|
this.contracts[exports.ALIASES.voting_escrow] = {
|
|
271
315
|
contract: new ethers_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
272
|
-
multicallContract: new
|
|
316
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
273
317
|
};
|
|
274
318
|
this.contracts[exports.ALIASES.voting_escrow.toLowerCase()] = {
|
|
275
319
|
contract: new ethers_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
276
|
-
multicallContract: new
|
|
320
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
277
321
|
};
|
|
278
322
|
this.contracts[exports.ALIASES.address_provider] = {
|
|
279
323
|
contract: new ethers_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
280
|
-
multicallContract: new
|
|
324
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
|
|
281
325
|
};
|
|
282
326
|
this.contracts[exports.ALIASES.address_provider.toLowerCase()] = {
|
|
283
327
|
contract: new ethers_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
284
|
-
multicallContract: new
|
|
328
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
|
|
329
|
+
};
|
|
330
|
+
addressProviderContract = this.contracts[exports.ALIASES.address_provider].contract;
|
|
331
|
+
_j = exports.ALIASES;
|
|
332
|
+
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
333
|
+
case 6:
|
|
334
|
+
_j.registry_exchange = _k.sent();
|
|
335
|
+
this.contracts[exports.ALIASES.registry_exchange] = {
|
|
336
|
+
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
337
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
338
|
+
};
|
|
339
|
+
this.contracts[exports.ALIASES.registry_exchange.toLowerCase()] = {
|
|
340
|
+
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
341
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
285
342
|
};
|
|
286
343
|
this.contracts[exports.ALIASES.gauge_controller] = {
|
|
287
344
|
contract: new ethers_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
288
|
-
multicallContract: new
|
|
345
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
289
346
|
};
|
|
290
347
|
this.contracts[exports.ALIASES.gauge_controller.toLowerCase()] = {
|
|
291
348
|
contract: new ethers_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
292
|
-
multicallContract: new
|
|
349
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
293
350
|
};
|
|
294
351
|
this.contracts[exports.ALIASES.router] = {
|
|
295
352
|
contract: new ethers_1.Contract(exports.ALIASES.router, router_json_1.default, this.signer || this.provider),
|
|
296
|
-
multicallContract: new
|
|
353
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.router, router_json_1.default),
|
|
297
354
|
};
|
|
298
355
|
this.contracts[exports.ALIASES.router.toLowerCase()] = {
|
|
299
356
|
contract: new ethers_1.Contract(exports.ALIASES.router, router_json_1.default, this.signer || this.provider),
|
|
300
|
-
multicallContract: new
|
|
357
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.router, router_json_1.default),
|
|
301
358
|
};
|
|
302
359
|
return [2 /*return*/];
|
|
303
360
|
}
|
|
@@ -342,7 +399,7 @@ var Curve = /** @class */ (function () {
|
|
|
342
399
|
feeData.maxFeePerGas;
|
|
343
400
|
this.options.maxPriorityFeePerGas = this.feeData.maxPriorityFeePerGas !== undefined ?
|
|
344
401
|
ethers_1.ethers.utils.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
|
|
345
|
-
feeData.
|
|
402
|
+
feeData.maxPriorityFeePerGas;
|
|
346
403
|
_d.label = 7;
|
|
347
404
|
case 7: return [2 /*return*/];
|
|
348
405
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare const curve: {
|
|
|
24
24
|
init: typeof init;
|
|
25
25
|
setCustomFeeData: typeof setCustomFeeData;
|
|
26
26
|
signerAddress: string;
|
|
27
|
+
chainId: number;
|
|
27
28
|
Pool: typeof Pool;
|
|
28
29
|
getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<string[] | import("./interfaces").DictInterface<string[]>>;
|
|
29
30
|
getAllowance: (coins: string[], address: string, spender: string) => Promise<string[]>;
|
package/lib/index.js
CHANGED
|
@@ -50,6 +50,8 @@ function init(providerType, providerSettings, options) {
|
|
|
50
50
|
_a.sent();
|
|
51
51
|
// @ts-ignore
|
|
52
52
|
this.signerAddress = curve_1.curve.signerAddress;
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
this.chainId = curve_1.curve.chainId;
|
|
53
55
|
return [2 /*return*/];
|
|
54
56
|
}
|
|
55
57
|
});
|
|
@@ -62,6 +64,7 @@ var curve = {
|
|
|
62
64
|
init: init,
|
|
63
65
|
setCustomFeeData: setCustomFeeData,
|
|
64
66
|
signerAddress: '',
|
|
67
|
+
chainId: 0,
|
|
65
68
|
Pool: pools_1.Pool,
|
|
66
69
|
getBalances: utils_1.getBalances,
|
|
67
70
|
getAllowance: utils_1.getAllowance,
|
package/lib/interfaces.d.ts
CHANGED
package/lib/pools.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export declare class Pool {
|
|
|
15
15
|
decimals: number[];
|
|
16
16
|
useLending: boolean[];
|
|
17
17
|
isMeta: boolean;
|
|
18
|
+
isFake: boolean;
|
|
19
|
+
isCrypto: boolean;
|
|
18
20
|
basePool: string;
|
|
19
21
|
isFactory: boolean;
|
|
20
22
|
estimateGas: {
|
|
@@ -36,8 +38,6 @@ export declare class Pool {
|
|
|
36
38
|
removeLiquidityOneCoinWrapped: (lpTokenAmount: string, coin: string | number) => Promise<number>;
|
|
37
39
|
exchangeApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
38
40
|
exchange: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
|
|
39
|
-
exchangeTricryptoApprove: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<number>;
|
|
40
|
-
exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number, useEth?: boolean) => Promise<number>;
|
|
41
41
|
exchangeWrappedApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
42
42
|
exchangeWrapped: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
|
|
43
43
|
};
|
|
@@ -112,11 +112,6 @@ export declare class Pool {
|
|
|
112
112
|
exchangeApprove: (inputCoin: string | number, amount: string) => Promise<string[]>;
|
|
113
113
|
private exchangeEstimateGas;
|
|
114
114
|
exchange: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number) => Promise<string>;
|
|
115
|
-
exchangeTricryptoIsApproved: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<boolean>;
|
|
116
|
-
private exchangeTricryptoApproveEstimateGas;
|
|
117
|
-
exchangeTricryptoApprove: (inputCoin: string | number, amount: string, useEth?: boolean) => Promise<string[]>;
|
|
118
|
-
private exchangeTricryptoEstimateGas;
|
|
119
|
-
exchangeTricrypto: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage?: number, useEth?: boolean) => Promise<string>;
|
|
120
115
|
exchangeWrappedExpected: (inputCoin: string | number, outputCoin: string | number, amount: string) => Promise<string>;
|
|
121
116
|
exchangeWrappedIsApproved: (inputCoin: string | number, amount: string) => Promise<boolean>;
|
|
122
117
|
private exchangeWrappedApproveEstimateGas;
|
|
@@ -163,10 +158,6 @@ export declare class Pool {
|
|
|
163
158
|
private _getExchangeOutput;
|
|
164
159
|
private _getExchangeOutputWrapped;
|
|
165
160
|
}
|
|
166
|
-
export declare const _getBestPoolAndOutput: (inputCoinAddress: string, outputCoinAddress: string, amount: string) => Promise<{
|
|
167
|
-
poolAddress: string;
|
|
168
|
-
output: string;
|
|
169
|
-
}>;
|
|
170
161
|
export declare const getBestPoolAndOutput: (inputCoin: string, outputCoin: string, amount: string) => Promise<{
|
|
171
162
|
poolAddress: string;
|
|
172
163
|
output: string;
|