@curvefi/api 1.10.0 → 1.14.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 +38 -0
- package/lib/constants/abis/abis-ethereum.d.ts +1 -1
- package/lib/constants/abis/abis-ethereum.js +68 -2
- package/lib/constants/abis/abis-polygon.d.ts +4 -0
- package/lib/constants/abis/abis-polygon.js +154 -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/busd/deposit.json +5 -10
- package/lib/constants/abis/json/busd/swap.json +18 -36
- package/lib/constants/abis/json/compound/deposit.json +5 -10
- package/lib/constants/abis/json/compound/migration.json +1 -2
- package/lib/constants/abis/json/compound/oldSwap.json +16 -32
- package/lib/constants/abis/json/compound/swap.json +18 -36
- package/lib/constants/abis/json/iearn/deposit.json +5 -10
- package/lib/constants/abis/json/iearn/swap.json +18 -36
- package/lib/constants/abis/json/paave/rewards.json +657 -0
- package/lib/constants/abis/json/pax/deposit.json +5 -10
- package/lib/constants/abis/json/pax/swap.json +19 -38
- package/lib/constants/abis/json/ren/swap.json +19 -38
- package/lib/constants/abis/json/ren-polygon/swap.json +1112 -0
- package/lib/constants/abis/json/sbtc/swap.json +19 -38
- package/lib/constants/abis/json/streamer.json +257 -0
- package/lib/constants/abis/json/susdv2/deposit.json +5 -10
- package/lib/constants/abis/json/susdv2/swap.json +16 -32
- package/lib/constants/abis/json/usdt/deposit.json +5 -10
- package/lib/constants/abis/json/usdt/swap.json +19 -37
- 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} +48 -14
- package/lib/constants/coins-polygon.d.ts +31 -0
- package/lib/constants/coins-polygon.js +74 -0
- package/lib/curve.d.ts +23 -7
- package/lib/curve.js +133 -91
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -0
- package/lib/interfaces.d.ts +3 -0
- package/lib/pools.d.ts +25 -4
- package/lib/pools.js +323 -101
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +49 -41
- package/package.json +6 -5
- package/lib/constants/coins.d.ts +0 -25
package/lib/curve.js
CHANGED
|
@@ -59,9 +59,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
59
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
60
|
};
|
|
61
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
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;
|
|
63
63
|
var ethers_1 = require("ethers");
|
|
64
|
-
var
|
|
64
|
+
var ethcall_1 = require("ethcall");
|
|
65
65
|
var ERC20_json_1 = __importDefault(require("./constants/abis/json/ERC20.json"));
|
|
66
66
|
var cERC20_json_1 = __importDefault(require("./constants/abis/json/cERC20.json"));
|
|
67
67
|
var yERC20_json_1 = __importDefault(require("./constants/abis/json/yERC20.json"));
|
|
@@ -71,48 +71,20 @@ var address_provider_json_1 = __importDefault(require("./constants/abis/json/add
|
|
|
71
71
|
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/json/gaugecontroller.json"));
|
|
72
72
|
var router_json_1 = __importDefault(require("./constants/abis/json/router.json"));
|
|
73
73
|
var registry_exchange_json_1 = __importDefault(require("./constants/abis/json/registry_exchange.json"));
|
|
74
|
+
var streamer_json_1 = __importDefault(require("./constants/abis/json/streamer.json"));
|
|
74
75
|
var abis_ethereum_1 = require("./constants/abis/abis-ethereum");
|
|
76
|
+
var abis_polygon_1 = require("./constants/abis/abis-polygon");
|
|
77
|
+
var coins_ethereum_1 = require("./constants/coins-ethereum");
|
|
78
|
+
var coins_polygon_1 = require("./constants/coins-polygon");
|
|
79
|
+
var aliases_1 = require("./constants/aliases");
|
|
75
80
|
exports.ALIASES = {
|
|
76
81
|
"crv": "0xD533a949740bb3306d119CC777fa900bA034cd52",
|
|
77
|
-
"pool_proxy": "0xeCb456EA5365865EbAb8a2661B0c503410e9B347",
|
|
78
|
-
"gauge_proxy": "0x519AFB566c05E00cfB9af73496D00217A630e4D5",
|
|
79
82
|
"voting_escrow": "0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2",
|
|
80
83
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
81
|
-
"minter": "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0",
|
|
82
|
-
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
83
84
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
84
85
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
85
86
|
"registry_exchange": "",
|
|
86
87
|
};
|
|
87
|
-
var cTokens = [
|
|
88
|
-
'0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643',
|
|
89
|
-
'0x39AA39c021dfbaE8faC545936693aC917d5E7563',
|
|
90
|
-
"0x8e595470ed749b85c6f7669de83eae304c2ec68f",
|
|
91
|
-
"0x48759f220ed983db51fa7a8c0d2aab8f3ce4166a",
|
|
92
|
-
"0x76eb2fe28b36b3ee97f3adae0c69606eedb2a37c", // cyUSDC
|
|
93
|
-
];
|
|
94
|
-
var yTokens = [
|
|
95
|
-
"0xC2cB1040220768554cf699b0d863A3cd4324ce32",
|
|
96
|
-
"0x26EA744E5B887E5205727f55dFBE8685e3b21951",
|
|
97
|
-
"0xE6354ed5bC4b393a5Aad09f21c46E101e692d447",
|
|
98
|
-
"0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01",
|
|
99
|
-
"0xd6aD7a6750A7593E092a9B218d66C0A814a3436e",
|
|
100
|
-
"0x83f798e925BcD4017Eb265844FDDAbb448f1707D",
|
|
101
|
-
"0x04bC0Ab673d88aE9dbC9DA2380cB6B79C4BCa9aE",
|
|
102
|
-
"0x73a052500105205d34Daf004eAb301916DA8190f", // yTUSD
|
|
103
|
-
];
|
|
104
|
-
var ycTokens = [
|
|
105
|
-
"0x99d1Fa417f94dcD62BfE781a1213c092a47041Bc",
|
|
106
|
-
"0x9777d7E2b60bB01759D0E2f8be2095df444cb07E",
|
|
107
|
-
"0x1bE5d71F2dA660BFdee8012dDc58D024448A0A59", // ycUSDT
|
|
108
|
-
];
|
|
109
|
-
var aTokens = [
|
|
110
|
-
"0x028171bCA77440897B824Ca71D1c56caC55b68A3",
|
|
111
|
-
"0xBcca60bB61934080951369a648Fb03DF4F96263C",
|
|
112
|
-
"0x3Ed3B47Dd13EC9a98b44e6204A523E766B225811",
|
|
113
|
-
"0x6c5024cd4f8a59110119c56f8933403a539555eb", // sSUSD
|
|
114
|
-
];
|
|
115
|
-
var customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
|
|
116
88
|
var Curve = /** @class */ (function () {
|
|
117
89
|
function Curve() {
|
|
118
90
|
// @ts-ignore
|
|
@@ -120,6 +92,7 @@ var Curve = /** @class */ (function () {
|
|
|
120
92
|
// @ts-ignore
|
|
121
93
|
this.signer = null;
|
|
122
94
|
this.signerAddress = '';
|
|
95
|
+
this.chainId = 0;
|
|
123
96
|
// @ts-ignore
|
|
124
97
|
this.multicallProvider = null;
|
|
125
98
|
this.contracts = {};
|
|
@@ -131,9 +104,9 @@ var Curve = /** @class */ (function () {
|
|
|
131
104
|
) {
|
|
132
105
|
if (options === void 0) { options = {}; }
|
|
133
106
|
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
-
var _a,
|
|
135
|
-
return __generator(this, function (
|
|
136
|
-
switch (
|
|
107
|
+
var cTokens, yTokens, ycTokens, aTokens, network, _a, customAbiTokens, _b, _i, _c, pool, _d, _e, coinAddr, _f, _g, coinAddr, _h, _j, coinAddr, addressProviderContract, _k;
|
|
108
|
+
return __generator(this, function (_l) {
|
|
109
|
+
switch (_l.label) {
|
|
137
110
|
case 0:
|
|
138
111
|
// JsonRpc provider
|
|
139
112
|
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
@@ -162,180 +135,249 @@ var Curve = /** @class */ (function () {
|
|
|
162
135
|
providerSettings = providerSettings;
|
|
163
136
|
this.provider = new ethers_1.ethers.providers.InfuraProvider(providerSettings.network, providerSettings.apiKey);
|
|
164
137
|
}
|
|
138
|
+
else if (providerType.toLowerCase() === 'Alchemy'.toLowerCase()) {
|
|
139
|
+
providerSettings = providerSettings;
|
|
140
|
+
this.provider = new ethers_1.ethers.providers.AlchemyProvider(providerSettings.network, providerSettings.apiKey);
|
|
141
|
+
}
|
|
165
142
|
else {
|
|
166
143
|
throw Error('Wrong providerType');
|
|
167
144
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return [
|
|
145
|
+
_a = this.provider.network;
|
|
146
|
+
if (_a) return [3 /*break*/, 2];
|
|
147
|
+
return [4 /*yield*/, this.provider._networkPromise];
|
|
171
148
|
case 1:
|
|
172
|
-
|
|
173
|
-
|
|
149
|
+
_a = (_l.sent());
|
|
150
|
+
_l.label = 2;
|
|
174
151
|
case 2:
|
|
175
|
-
|
|
176
|
-
|
|
152
|
+
network = _a;
|
|
153
|
+
console.log("CURVE-JS IS CONNECTED TO NETWORK:", network);
|
|
154
|
+
this.chainId = network.chainId;
|
|
155
|
+
if (network.chainId === 1 || network.chainId === 1337) {
|
|
156
|
+
cTokens = coins_ethereum_1.cTokensEthereum;
|
|
157
|
+
yTokens = coins_ethereum_1.yTokensEthereum;
|
|
158
|
+
ycTokens = coins_ethereum_1.ycTokensEthereum;
|
|
159
|
+
aTokens = coins_ethereum_1.aTokensEthereum;
|
|
160
|
+
exports.ALIASES = aliases_1.ALIASES_ETHEREUM;
|
|
161
|
+
exports.POOLS_DATA = abis_ethereum_1.POOLS_DATA_ETHEREUM;
|
|
162
|
+
exports.BTC_COINS = coins_ethereum_1.BTC_COINS_ETHEREUM;
|
|
163
|
+
exports.BTC_COINS_LOWER_CASE = coins_ethereum_1.BTC_COINS_LOWER_CASE_ETHEREUM;
|
|
164
|
+
exports.ETH_COINS = coins_ethereum_1.ETH_COINS_ETHEREUM;
|
|
165
|
+
exports.ETH_COINS_LOWER_CASE = coins_ethereum_1.ETH_COINS_LOWER_CASE_ETHEREUM;
|
|
166
|
+
exports.LINK_COINS = coins_ethereum_1.LINK_COINS_ETHEREUM;
|
|
167
|
+
exports.LINK_COINS_LOWER_CASE = coins_ethereum_1.LINK_COINS_LOWER_CASE_ETHEREUM;
|
|
168
|
+
exports.EUR_COINS = coins_ethereum_1.EUR_COINS_ETHEREUM;
|
|
169
|
+
exports.EUR_COINS_LOWER_CASE = coins_ethereum_1.EUR_COINS_LOWER_CASE_ETHEREUM;
|
|
170
|
+
exports.USD_COINS = coins_ethereum_1.USD_COINS_ETHEREUM;
|
|
171
|
+
exports.USD_COINS_LOWER_CASE = coins_ethereum_1.USD_COINS_LOWER_CASE_ETHEREUM;
|
|
172
|
+
exports.COINS = coins_ethereum_1.COINS_ETHEREUM;
|
|
173
|
+
exports.DECIMALS = coins_ethereum_1.DECIMALS_ETHEREUM;
|
|
174
|
+
exports.DECIMALS_LOWER_CASE = coins_ethereum_1.DECIMALS_LOWER_CASE_ETHEREUM;
|
|
175
|
+
}
|
|
176
|
+
else if (network.chainId === 137) {
|
|
177
|
+
cTokens = coins_polygon_1.cTokensPolygon;
|
|
178
|
+
yTokens = coins_polygon_1.yTokensPolygon;
|
|
179
|
+
ycTokens = coins_polygon_1.ycTokensPolygon;
|
|
180
|
+
aTokens = coins_polygon_1.aTokensPolygon;
|
|
181
|
+
exports.ALIASES = aliases_1.ALIASES_POLYGON;
|
|
182
|
+
exports.POOLS_DATA = abis_polygon_1.POOLS_DATA_POLYGON;
|
|
183
|
+
exports.BTC_COINS = coins_polygon_1.BTC_COINS_POLYGON;
|
|
184
|
+
exports.BTC_COINS_LOWER_CASE = coins_polygon_1.BTC_COINS_LOWER_CASE_POLYGON;
|
|
185
|
+
exports.ETH_COINS = coins_polygon_1.ETH_COINS_POLYGON;
|
|
186
|
+
exports.ETH_COINS_LOWER_CASE = coins_polygon_1.ETH_COINS_LOWER_CASE_POLYGON;
|
|
187
|
+
exports.LINK_COINS = coins_polygon_1.LINK_COINS_POLYGON;
|
|
188
|
+
exports.LINK_COINS_LOWER_CASE = coins_polygon_1.LINK_COINS_LOWER_CASE_POLYGON;
|
|
189
|
+
exports.EUR_COINS = coins_polygon_1.EUR_COINS_POLYGON;
|
|
190
|
+
exports.EUR_COINS_LOWER_CASE = coins_polygon_1.EUR_COINS_LOWER_CASE_POLYGON;
|
|
191
|
+
exports.USD_COINS = coins_polygon_1.USD_COINS_POLYGON;
|
|
192
|
+
exports.USD_COINS_LOWER_CASE = coins_polygon_1.USD_COINS_LOWER_CASE_POLYGON;
|
|
193
|
+
exports.COINS = coins_polygon_1.COINS_POLYGON;
|
|
194
|
+
exports.DECIMALS = coins_polygon_1.DECIMALS_POLYGON;
|
|
195
|
+
exports.DECIMALS_LOWER_CASE = coins_polygon_1.DECIMALS_LOWER_CASE_POLYGON;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
throw Error("Network with chainId ".concat(this.provider.network.chainId, " is not supported"));
|
|
199
|
+
}
|
|
200
|
+
exports.LP_TOKENS = Object.values(exports.POOLS_DATA).map(function (data) { return data.token_address.toLowerCase(); });
|
|
201
|
+
exports.GAUGES = Object.values(exports.POOLS_DATA).map(function (data) { return data.gauge_address.toLowerCase(); });
|
|
202
|
+
customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
|
|
203
|
+
this.multicallProvider = new ethcall_1.Provider();
|
|
204
|
+
return [4 /*yield*/, this.multicallProvider.init(this.provider)];
|
|
177
205
|
case 3:
|
|
206
|
+
_l.sent();
|
|
178
207
|
if (!this.signer) return [3 /*break*/, 5];
|
|
179
|
-
|
|
208
|
+
_b = this;
|
|
180
209
|
return [4 /*yield*/, this.signer.getAddress()];
|
|
181
210
|
case 4:
|
|
182
|
-
|
|
183
|
-
|
|
211
|
+
_b.signerAddress = _l.sent();
|
|
212
|
+
return [3 /*break*/, 6];
|
|
184
213
|
case 5:
|
|
214
|
+
this.signerAddress = '';
|
|
215
|
+
_l.label = 6;
|
|
216
|
+
case 6:
|
|
185
217
|
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
186
218
|
return [4 /*yield*/, this.updateFeeData()];
|
|
187
|
-
case
|
|
188
|
-
|
|
219
|
+
case 7:
|
|
220
|
+
_l.sent();
|
|
189
221
|
// TODO delete toLowerCase()
|
|
190
|
-
for (_i = 0,
|
|
191
|
-
pool =
|
|
222
|
+
for (_i = 0, _c = Object.values(exports.POOLS_DATA); _i < _c.length; _i++) {
|
|
223
|
+
pool = _c[_i];
|
|
192
224
|
this.contracts[pool.swap_address] = {
|
|
193
225
|
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
194
|
-
multicallContract: new
|
|
226
|
+
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
195
227
|
};
|
|
196
228
|
this.contracts[pool.swap_address.toLowerCase()] = {
|
|
197
229
|
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
198
|
-
multicallContract: new
|
|
230
|
+
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
199
231
|
};
|
|
200
232
|
if (pool.token_address !== pool.swap_address) {
|
|
201
233
|
this.contracts[pool.token_address] = {
|
|
202
234
|
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
203
|
-
multicallContract: new
|
|
235
|
+
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
204
236
|
};
|
|
205
237
|
this.contracts[pool.token_address.toLowerCase()] = {
|
|
206
238
|
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
207
|
-
multicallContract: new
|
|
239
|
+
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
208
240
|
};
|
|
209
241
|
}
|
|
210
242
|
this.contracts[pool.gauge_address] = {
|
|
211
243
|
contract: new ethers_1.Contract(pool.gauge_address, gauge_json_1.default, this.signer || this.provider),
|
|
212
|
-
multicallContract: new
|
|
244
|
+
multicallContract: new ethcall_1.Contract(pool.gauge_address, gauge_json_1.default),
|
|
213
245
|
};
|
|
214
246
|
this.contracts[pool.gauge_address.toLowerCase()] = {
|
|
215
247
|
contract: new ethers_1.Contract(pool.gauge_address, gauge_json_1.default, this.signer || this.provider),
|
|
216
|
-
multicallContract: new
|
|
248
|
+
multicallContract: new ethcall_1.Contract(pool.gauge_address, gauge_json_1.default),
|
|
217
249
|
};
|
|
218
250
|
if (pool.deposit_address && this.contracts[pool.deposit_address] === undefined) {
|
|
219
251
|
this.contracts[pool.deposit_address] = {
|
|
220
252
|
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
221
|
-
multicallContract: new
|
|
253
|
+
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
222
254
|
};
|
|
223
255
|
this.contracts[pool.deposit_address.toLowerCase()] = {
|
|
224
256
|
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
225
|
-
multicallContract: new
|
|
257
|
+
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
226
258
|
};
|
|
227
259
|
}
|
|
228
|
-
for (
|
|
229
|
-
coinAddr = _d
|
|
260
|
+
for (_d = 0, _e = pool.underlying_coin_addresses; _d < _e.length; _d++) {
|
|
261
|
+
coinAddr = _e[_d];
|
|
230
262
|
this.contracts[coinAddr] = {
|
|
231
263
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
232
|
-
multicallContract: new
|
|
264
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
233
265
|
};
|
|
234
266
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
235
267
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
236
|
-
multicallContract: new
|
|
268
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
237
269
|
};
|
|
238
270
|
}
|
|
239
|
-
for (
|
|
240
|
-
coinAddr = _f
|
|
271
|
+
for (_f = 0, _g = pool.coin_addresses; _f < _g.length; _f++) {
|
|
272
|
+
coinAddr = _g[_f];
|
|
241
273
|
if (customAbiTokens.includes(coinAddr))
|
|
242
274
|
continue;
|
|
243
275
|
this.contracts[coinAddr] = {
|
|
244
276
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
245
|
-
multicallContract: new
|
|
277
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
246
278
|
};
|
|
247
279
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
248
280
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
249
|
-
multicallContract: new
|
|
281
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
250
282
|
};
|
|
251
283
|
}
|
|
252
284
|
// TODO add all coins
|
|
253
|
-
for (
|
|
254
|
-
coinAddr = _h
|
|
285
|
+
for (_h = 0, _j = pool.coin_addresses; _h < _j.length; _h++) {
|
|
286
|
+
coinAddr = _j[_h];
|
|
255
287
|
if (cTokens.includes(coinAddr)) {
|
|
256
288
|
this.contracts[coinAddr] = {
|
|
257
289
|
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
258
|
-
multicallContract: new
|
|
290
|
+
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
259
291
|
};
|
|
260
292
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
261
293
|
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
262
|
-
multicallContract: new
|
|
294
|
+
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
263
295
|
};
|
|
264
296
|
}
|
|
265
297
|
if (aTokens.includes(coinAddr)) {
|
|
266
298
|
this.contracts[coinAddr] = {
|
|
267
299
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
268
|
-
multicallContract: new
|
|
300
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
269
301
|
};
|
|
270
302
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
271
303
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
272
|
-
multicallContract: new
|
|
304
|
+
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
273
305
|
};
|
|
274
306
|
}
|
|
275
307
|
if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
|
|
276
308
|
this.contracts[coinAddr] = {
|
|
277
309
|
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
278
|
-
multicallContract: new
|
|
310
|
+
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
279
311
|
};
|
|
280
312
|
this.contracts[coinAddr.toLowerCase()] = {
|
|
281
313
|
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
282
|
-
multicallContract: new
|
|
314
|
+
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
283
315
|
};
|
|
284
316
|
}
|
|
285
317
|
}
|
|
318
|
+
if (pool.crv_reward_contract) {
|
|
319
|
+
this.contracts[pool.crv_reward_contract] = {
|
|
320
|
+
contract: new ethers_1.Contract(pool.crv_reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
321
|
+
multicallContract: new ethcall_1.Contract(pool.crv_reward_contract, streamer_json_1.default),
|
|
322
|
+
};
|
|
323
|
+
this.contracts[pool.crv_reward_contract.toLowerCase()] = {
|
|
324
|
+
contract: new ethers_1.Contract(pool.crv_reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
325
|
+
multicallContract: new ethcall_1.Contract(pool.crv_reward_contract, streamer_json_1.default),
|
|
326
|
+
};
|
|
327
|
+
}
|
|
286
328
|
}
|
|
287
329
|
this.contracts[exports.ALIASES.crv] = {
|
|
288
330
|
contract: new ethers_1.Contract(exports.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
289
|
-
multicallContract: new
|
|
331
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.crv, ERC20_json_1.default),
|
|
290
332
|
};
|
|
291
333
|
this.contracts[exports.ALIASES.crv.toLowerCase()] = {
|
|
292
334
|
contract: new ethers_1.Contract(exports.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
293
|
-
multicallContract: new
|
|
335
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.crv, ERC20_json_1.default),
|
|
294
336
|
};
|
|
295
337
|
this.contracts[exports.ALIASES.voting_escrow] = {
|
|
296
338
|
contract: new ethers_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
297
|
-
multicallContract: new
|
|
339
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
298
340
|
};
|
|
299
341
|
this.contracts[exports.ALIASES.voting_escrow.toLowerCase()] = {
|
|
300
342
|
contract: new ethers_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
301
|
-
multicallContract: new
|
|
343
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
302
344
|
};
|
|
303
345
|
this.contracts[exports.ALIASES.address_provider] = {
|
|
304
346
|
contract: new ethers_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
305
|
-
multicallContract: new
|
|
347
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
|
|
306
348
|
};
|
|
307
349
|
this.contracts[exports.ALIASES.address_provider.toLowerCase()] = {
|
|
308
350
|
contract: new ethers_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
309
|
-
multicallContract: new
|
|
351
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.address_provider, address_provider_json_1.default),
|
|
310
352
|
};
|
|
311
353
|
addressProviderContract = this.contracts[exports.ALIASES.address_provider].contract;
|
|
312
|
-
|
|
354
|
+
_k = exports.ALIASES;
|
|
313
355
|
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
314
|
-
case
|
|
315
|
-
|
|
356
|
+
case 8:
|
|
357
|
+
_k.registry_exchange = _l.sent();
|
|
316
358
|
this.contracts[exports.ALIASES.registry_exchange] = {
|
|
317
359
|
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
318
|
-
multicallContract: new
|
|
360
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
319
361
|
};
|
|
320
362
|
this.contracts[exports.ALIASES.registry_exchange.toLowerCase()] = {
|
|
321
363
|
contract: new ethers_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
322
|
-
multicallContract: new
|
|
364
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
323
365
|
};
|
|
324
366
|
this.contracts[exports.ALIASES.gauge_controller] = {
|
|
325
367
|
contract: new ethers_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
326
|
-
multicallContract: new
|
|
368
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
327
369
|
};
|
|
328
370
|
this.contracts[exports.ALIASES.gauge_controller.toLowerCase()] = {
|
|
329
371
|
contract: new ethers_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
330
|
-
multicallContract: new
|
|
372
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
331
373
|
};
|
|
332
374
|
this.contracts[exports.ALIASES.router] = {
|
|
333
375
|
contract: new ethers_1.Contract(exports.ALIASES.router, router_json_1.default, this.signer || this.provider),
|
|
334
|
-
multicallContract: new
|
|
376
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.router, router_json_1.default),
|
|
335
377
|
};
|
|
336
378
|
this.contracts[exports.ALIASES.router.toLowerCase()] = {
|
|
337
379
|
contract: new ethers_1.Contract(exports.ALIASES.router, router_json_1.default, this.signer || this.provider),
|
|
338
|
-
multicallContract: new
|
|
380
|
+
multicallContract: new ethcall_1.Contract(exports.ALIASES.router, router_json_1.default),
|
|
339
381
|
};
|
|
340
382
|
return [2 /*return*/];
|
|
341
383
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import { Networkish } from "@ethersproject/networks";
|
|
3
3
|
import { Pool } from "./pools";
|
|
4
|
-
declare function init(providerType: 'JsonRpc' | 'Web3' | 'Infura', providerSettings: {
|
|
4
|
+
declare function init(providerType: 'JsonRpc' | 'Web3' | 'Infura' | 'Alchemy', providerSettings: {
|
|
5
5
|
url?: string;
|
|
6
6
|
privateKey?: string;
|
|
7
7
|
} | {
|
|
@@ -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
|
@@ -2,6 +2,7 @@ export interface DictInterface<T> {
|
|
|
2
2
|
[index: string]: T;
|
|
3
3
|
}
|
|
4
4
|
export interface PoolDataInterface {
|
|
5
|
+
reference_asset: 'USD' | 'EUR' | 'BTC' | 'ETH' | 'LINK' | 'CRYPTO';
|
|
5
6
|
N_COINS: number;
|
|
6
7
|
underlying_decimals: number[];
|
|
7
8
|
decimals: number[];
|
|
@@ -26,6 +27,7 @@ export interface PoolDataInterface {
|
|
|
26
27
|
deposit_abi?: any;
|
|
27
28
|
old_swap_abi?: any;
|
|
28
29
|
is_meta?: boolean;
|
|
30
|
+
is_fake?: boolean;
|
|
29
31
|
is_crypto?: boolean;
|
|
30
32
|
meta_N?: number;
|
|
31
33
|
meta_decimals?: number[];
|
|
@@ -47,4 +49,5 @@ export interface PoolDataInterface {
|
|
|
47
49
|
reward_token?: string;
|
|
48
50
|
reward_tokens?: string[];
|
|
49
51
|
pool_type?: string;
|
|
52
|
+
crv_reward_contract?: string;
|
|
50
53
|
}
|
package/lib/pools.d.ts
CHANGED
|
@@ -3,10 +3,12 @@ import BigNumber from 'bignumber.js';
|
|
|
3
3
|
import { DictInterface } from './interfaces';
|
|
4
4
|
export declare class Pool {
|
|
5
5
|
name: string;
|
|
6
|
+
referenceAsset: string;
|
|
6
7
|
swap: string;
|
|
7
8
|
zap: string | null;
|
|
8
9
|
lpToken: string;
|
|
9
10
|
gauge: string;
|
|
11
|
+
crvRewardContract: string | null;
|
|
10
12
|
underlyingCoins: string[];
|
|
11
13
|
coins: string[];
|
|
12
14
|
underlyingCoinAddresses: string[];
|
|
@@ -15,6 +17,7 @@ export declare class Pool {
|
|
|
15
17
|
decimals: number[];
|
|
16
18
|
useLending: boolean[];
|
|
17
19
|
isMeta: boolean;
|
|
20
|
+
isFake: boolean;
|
|
18
21
|
isCrypto: boolean;
|
|
19
22
|
basePool: string;
|
|
20
23
|
isFactory: boolean;
|
|
@@ -40,12 +43,31 @@ export declare class Pool {
|
|
|
40
43
|
exchangeWrappedApprove: (inputCoin: string | number, amount: string) => Promise<number>;
|
|
41
44
|
exchangeWrapped: (inputCoin: string | number, outputCoin: string | number, amount: string, maxSlippage: number) => Promise<number>;
|
|
42
45
|
};
|
|
46
|
+
stats: {
|
|
47
|
+
getParameters: () => Promise<{
|
|
48
|
+
virtualPrice: string;
|
|
49
|
+
fee: string;
|
|
50
|
+
adminFee: string;
|
|
51
|
+
A: string;
|
|
52
|
+
gamma?: string;
|
|
53
|
+
}>;
|
|
54
|
+
getPoolBalances: () => Promise<string[]>;
|
|
55
|
+
getPoolWrappedBalances: () => Promise<string[]>;
|
|
56
|
+
getTotalLiquidity: () => Promise<string>;
|
|
57
|
+
getVolume: () => Promise<string>;
|
|
58
|
+
getBaseApy: () => Promise<[daily: string, weekly: string, monthly: string, total: string]>;
|
|
59
|
+
getTokenApy: () => Promise<[baseApy: string, boostedApy: string]>;
|
|
60
|
+
};
|
|
43
61
|
constructor(name: string);
|
|
44
62
|
calcLpTokenAmount: (amounts: string[], isDeposit?: boolean) => Promise<string>;
|
|
45
63
|
calcLpTokenAmountWrapped: (amounts: string[], isDeposit?: boolean) => Promise<string>;
|
|
46
|
-
|
|
47
|
-
getPoolBalances
|
|
48
|
-
getPoolWrappedBalances
|
|
64
|
+
private getParameters;
|
|
65
|
+
private getPoolBalances;
|
|
66
|
+
private getPoolWrappedBalances;
|
|
67
|
+
private getTotalLiquidity;
|
|
68
|
+
private getVolume;
|
|
69
|
+
private getBaseApy;
|
|
70
|
+
private getTokenApy;
|
|
49
71
|
addLiquidityExpected: (amounts: string[]) => Promise<string>;
|
|
50
72
|
addLiquiditySlippage: (amounts: string[]) => Promise<string>;
|
|
51
73
|
addLiquidityIsApproved: (amounts: string[]) => Promise<boolean>;
|
|
@@ -120,7 +142,6 @@ export declare class Pool {
|
|
|
120
142
|
gaugeMaxBoostedDeposit: (...addresses: string[]) => Promise<DictInterface<string>>;
|
|
121
143
|
gaugeOptimalDeposits: (...accounts: string[]) => Promise<DictInterface<string>>;
|
|
122
144
|
boost: (address: string) => Promise<string>;
|
|
123
|
-
getApy: () => Promise<string[]>;
|
|
124
145
|
private _getCoinIdx;
|
|
125
146
|
private _getRates;
|
|
126
147
|
private _balances;
|