@curvefi/api 1.25.2 → 2.2.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 +797 -590
- package/docs/v1/README.md +916 -0
- package/lib/boosting.d.ts +12 -12
- package/lib/boosting.js +23 -23
- package/lib/constants/abis/{json/2pool → 2pool}/swap.json +0 -0
- package/lib/constants/abis/{json/3pool → 3pool}/swap.json +0 -0
- package/lib/constants/abis/{json/4pool → 4pool}/swap.json +0 -0
- package/lib/constants/abis/{json/ERC20.json → ERC20.json} +0 -0
- package/lib/constants/abis/{json/aave → aave}/rewards.json +0 -0
- package/lib/constants/abis/{json/aave → aave}/swap.json +0 -0
- package/lib/constants/abis/{json/address_provider.json → address_provider.json} +0 -0
- package/lib/constants/abis/{json/ankreth → ankreth}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/ankreth → ankreth}/swap.json +0 -0
- package/lib/constants/abis/{json/atricrypto3 → atricrypto3}/swap.json +0 -0
- package/lib/constants/abis/{json/atricrypto3 → atricrypto3}/zap.json +0 -0
- package/lib/constants/abis/{json/bbtc → bbtc}/deposit.json +0 -0
- package/lib/constants/abis/{json/bbtc → bbtc}/swap.json +0 -0
- package/lib/constants/abis/{json/busd → busd}/deposit.json +0 -0
- package/lib/constants/abis/{json/busd → busd}/swap.json +0 -0
- package/lib/constants/abis/{json/cERC20.json → cERC20.json} +0 -0
- package/lib/constants/abis/{json/compound → compound}/deposit.json +0 -0
- package/lib/constants/abis/{json/compound → compound}/swap.json +0 -0
- package/lib/constants/abis/{json/crveth → crveth}/swap.json +0 -0
- package/lib/constants/abis/{json/deposit_and_stake.json → deposit_and_stake.json} +0 -0
- package/lib/constants/abis/{json/dusd → dusd}/deposit.json +0 -0
- package/lib/constants/abis/{json/dusd → dusd}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/dusd → dusd}/swap.json +0 -0
- package/lib/constants/abis/{json/eurs → eurs}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/eurs → eurs}/swap.json +0 -0
- package/lib/constants/abis/{json/eursusd → eursusd}/swap.json +0 -0
- package/lib/constants/abis/{json/eurt → eurt}/swap.json +0 -0
- package/lib/constants/abis/{json/eurtusd → eurtusd}/deposit.json +0 -0
- package/lib/constants/abis/{json/eurtusd → eurtusd}/swap.json +0 -0
- package/lib/constants/abis/{json/factory-crypto → factory-crypto}/factory-crypto-pool-2.json +0 -0
- package/lib/constants/abis/{json/factory-crypto.json → factory-crypto.json} +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/DepositZapMetaBtcPolygon.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/DepositZapMetaUsdPolygon.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/MetaBTC.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/MetaBTCBalances.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/MetaBTCBalancesRen.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/MetaBTCRen.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/MetaUSD.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/MetaUSDBalances.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain2Balances.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain2Basic.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain2ETH.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain2Optimized.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain3Balances.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain3Basic.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain3ETH.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain3Optimized.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain4Balances.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain4Basic.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain4ETH.json +0 -0
- package/lib/constants/abis/{json/factory-v2 → factory-v2}/Plain4Optimized.json +0 -0
- package/lib/constants/abis/{json/factory.json → factory.json} +0 -0
- package/lib/constants/abis/{json/factoryPools → factoryPools}/deposit.json +0 -0
- package/lib/constants/abis/{json/factoryPools → factoryPools}/rewards.json +0 -0
- package/lib/constants/abis/{json/factoryPools → factoryPools}/swap.json +0 -0
- package/lib/constants/abis/{json/gauge.json → gauge.json} +0 -0
- package/lib/constants/abis/{json/gauge_factory.json → gauge_factory.json} +0 -0
- package/lib/constants/abis/{json/gauge_rewards_only.json → gauge_rewards_only.json} +0 -0
- package/lib/constants/abis/{json/gauge_synthetix.json → gauge_synthetix.json} +0 -0
- package/lib/constants/abis/{json/gauge_v2.json → gauge_v2.json} +0 -0
- package/lib/constants/abis/{json/gauge_v3.json → gauge_v3.json} +0 -0
- package/lib/constants/abis/{json/gauge_v4.json → gauge_v4.json} +0 -0
- package/lib/constants/abis/{json/gauge_v5.json → gauge_v5.json} +0 -0
- package/lib/constants/abis/{json/gaugecontroller.json → gaugecontroller.json} +0 -0
- package/lib/constants/abis/{json/gusd → gusd}/deposit.json +0 -0
- package/lib/constants/abis/{json/gusd → gusd}/swap.json +0 -0
- package/lib/constants/abis/{json/hbtc → hbtc}/swap.json +0 -0
- package/lib/constants/abis/{json/husd → husd}/deposit.json +0 -0
- package/lib/constants/abis/{json/husd → husd}/swap.json +0 -0
- package/lib/constants/abis/{json/ib → ib}/swap.json +0 -0
- package/lib/constants/abis/{json/iearn → iearn}/deposit.json +0 -0
- package/lib/constants/abis/{json/iearn → iearn}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/iearn → iearn}/swap.json +0 -0
- package/lib/constants/abis/{json/link → link}/swap.json +0 -0
- package/lib/constants/abis/{json/minter.json → minter.json} +0 -0
- package/lib/constants/abis/{json/musd → musd}/deposit.json +0 -0
- package/lib/constants/abis/{json/musd → musd}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/musd → musd}/swap.json +0 -0
- package/lib/constants/abis/{json/obtc → obtc}/deposit.json +0 -0
- package/lib/constants/abis/{json/obtc → obtc}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/obtc → obtc}/swap.json +0 -0
- package/lib/constants/abis/{json/paave → paave}/rewards.json +0 -0
- package/lib/constants/abis/{json/pax → pax}/deposit.json +0 -0
- package/lib/constants/abis/{json/pax → pax}/swap.json +0 -0
- package/lib/constants/abis/{json/pbtc → pbtc}/deposit.json +0 -0
- package/lib/constants/abis/{json/pbtc → pbtc}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/pbtc → pbtc}/swap.json +0 -0
- package/lib/constants/abis/{json/rai → rai}/deposit.json +0 -0
- package/lib/constants/abis/{json/rai → rai}/swap.json +0 -0
- package/lib/constants/abis/{json/registry_exchange.json → registry_exchange.json} +0 -0
- package/lib/constants/abis/{json/ren → ren}/swap.json +0 -0
- package/lib/constants/abis/{json/ren-polygon → ren-polygon}/swap.json +0 -0
- package/lib/constants/abis/{json/reth → reth}/swap.json +0 -0
- package/lib/constants/abis/{json/router.json → router.json} +0 -0
- package/lib/constants/abis/{json/rsv → rsv}/deposit.json +0 -0
- package/lib/constants/abis/{json/rsv → rsv}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/rsv → rsv}/swap.json +0 -0
- package/lib/constants/abis/{json/saave → saave}/swap.json +0 -0
- package/lib/constants/abis/{json/sbtc → sbtc}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/sbtc → sbtc}/swap.json +0 -0
- package/lib/constants/abis/{json/seth → seth}/swap.json +0 -0
- package/lib/constants/abis/{json/steth → steth}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/steth → steth}/swap.json +0 -0
- package/lib/constants/abis/{json/streamer.json → streamer.json} +0 -0
- package/lib/constants/abis/{json/susdv2 → susdv2}/deposit.json +0 -0
- package/lib/constants/abis/{json/susdv2 → susdv2}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/susdv2 → susdv2}/swap.json +0 -0
- package/lib/constants/abis/{json/tbtc → tbtc}/deposit.json +0 -0
- package/lib/constants/abis/{json/tbtc → tbtc}/sCurveRewards.json +0 -0
- package/lib/constants/abis/{json/tbtc → tbtc}/swap.json +0 -0
- package/lib/constants/abis/{json/tricrypto2 → tricrypto2}/deposit.json +0 -0
- package/lib/constants/abis/{json/tricrypto2 → tricrypto2}/swap.json +0 -0
- package/lib/constants/abis/{json/usdk → usdk}/deposit.json +0 -0
- package/lib/constants/abis/{json/usdk → usdk}/swap.json +0 -0
- package/lib/constants/abis/{json/usdn → usdn}/deposit.json +0 -0
- package/lib/constants/abis/{json/usdn → usdn}/swap.json +0 -0
- package/lib/constants/abis/{json/usdp → usdp}/deposit.json +0 -0
- package/lib/constants/abis/{json/usdp → usdp}/swap.json +0 -0
- package/lib/constants/abis/{json/usdt → usdt}/deposit.json +0 -0
- package/lib/constants/abis/{json/usdt → usdt}/swap.json +0 -0
- package/lib/constants/abis/{json/ust → ust}/deposit.json +0 -0
- package/lib/constants/abis/{json/ust → ust}/swap.json +0 -0
- package/lib/constants/abis/{json/votingescrow.json → votingescrow.json} +0 -0
- package/lib/constants/abis/{json/yERC20.json → yERC20.json} +0 -0
- package/lib/constants/aliases.d.ts +3 -24
- package/lib/constants/aliases.js +18 -5
- package/lib/constants/coins/avalanche.d.ts +7 -0
- package/lib/constants/coins/avalanche.js +32 -0
- package/lib/constants/{coins-ethereum.d.ts → coins/ethereum.d.ts} +0 -9
- package/lib/constants/{coins-ethereum.js → coins/ethereum.js} +12 -23
- package/lib/constants/{coins-polygon.d.ts → coins/polygon.d.ts} +0 -12
- package/lib/constants/{coins-polygon.js → coins/polygon.js} +8 -20
- package/lib/constants/pools/avalanche.d.ts +4 -0
- package/lib/constants/pools/avalanche.js +113 -0
- package/lib/constants/pools/ethereum.d.ts +2 -0
- package/lib/constants/{abis/abis-ethereum.js → pools/ethereum.js} +517 -1012
- package/lib/constants/pools/index.d.ts +4 -0
- package/lib/constants/pools/index.js +9 -0
- package/lib/constants/pools/polygon.d.ts +4 -0
- package/lib/constants/{abis/abis-polygon.js → pools/polygon.js} +52 -80
- package/lib/constants/utils.d.ts +5 -0
- package/lib/constants/utils.js +69 -0
- package/lib/curve.d.ts +13 -31
- package/lib/curve.js +204 -232
- package/lib/external-api.d.ts +4 -3
- package/lib/external-api.js +18 -1
- package/lib/factory/common.d.ts +2 -0
- package/lib/factory/common.js +45 -0
- package/lib/factory/constants.d.ts +16 -16
- package/lib/factory/constants.js +79 -77
- package/lib/factory/factory-api.d.ts +2 -2
- package/lib/factory/factory-api.js +51 -85
- package/lib/factory/factory-crypto.d.ts +2 -2
- package/lib/factory/factory-crypto.js +30 -35
- package/lib/factory/factory.d.ts +2 -2
- package/lib/factory/factory.js +60 -205
- package/lib/index.d.ts +37 -53
- package/lib/index.js +28 -35
- package/lib/interfaces.d.ts +51 -83
- package/lib/pools/PoolTemplate.d.ts +212 -0
- package/lib/pools/PoolTemplate.js +2371 -0
- package/lib/pools/index.d.ts +3 -0
- package/lib/pools/index.js +7 -0
- package/lib/pools/mixins/common.d.ts +3 -0
- package/lib/pools/mixins/common.js +77 -0
- package/lib/pools/mixins/depositBalancedAmountsMixins.d.ts +5 -0
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +145 -0
- package/lib/pools/mixins/depositBonusMixins.d.ts +5 -0
- package/lib/pools/mixins/depositBonusMixins.js +164 -0
- package/lib/pools/mixins/depositMixins.d.ts +5 -0
- package/lib/pools/mixins/depositMixins.js +373 -0
- package/lib/pools/mixins/depositWrappedMixins.d.ts +3 -0
- package/lib/pools/mixins/depositWrappedMixins.js +243 -0
- package/lib/pools/mixins/poolBalancesMixin.d.ts +4 -0
- package/lib/pools/mixins/poolBalancesMixin.js +129 -0
- package/lib/pools/mixins/swapMixins.d.ts +4 -0
- package/lib/pools/mixins/swapMixins.js +313 -0
- package/lib/pools/mixins/swapWrappedMixins.d.ts +4 -0
- package/lib/pools/mixins/swapWrappedMixins.js +297 -0
- package/lib/pools/mixins/withdrawExpectedMixins.d.ts +6 -0
- package/lib/pools/mixins/withdrawExpectedMixins.js +164 -0
- package/lib/pools/mixins/withdrawImbalanceMixins.d.ts +5 -0
- package/lib/pools/mixins/withdrawImbalanceMixins.js +348 -0
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.d.ts +3 -0
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +207 -0
- package/lib/pools/mixins/withdrawMixins.d.ts +5 -0
- package/lib/pools/mixins/withdrawMixins.js +347 -0
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.d.ts +5 -0
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +104 -0
- package/lib/pools/mixins/withdrawOneCoinMixins.d.ts +5 -0
- package/lib/pools/mixins/withdrawOneCoinMixins.js +347 -0
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.d.ts +3 -0
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +72 -0
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.d.ts +3 -0
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +205 -0
- package/lib/pools/mixins/withdrawWrappedMixins.d.ts +3 -0
- package/lib/pools/mixins/withdrawWrappedMixins.js +206 -0
- package/lib/pools/poolConstructor.d.ts +2 -0
- package/lib/pools/poolConstructor.js +228 -0
- package/lib/pools/utils.d.ts +4 -0
- package/lib/pools/utils.js +85 -0
- package/lib/router.d.ts +13 -0
- package/lib/router.js +651 -0
- package/lib/utils.d.ts +12 -16
- package/lib/utils.js +59 -138
- package/package.json +1 -1
- package/lib/constants/abis/abis-ethereum.d.ts +0 -4
- package/lib/constants/abis/abis-polygon.d.ts +0 -4
- package/lib/constants/abis/json/aRewards.json +0 -1
- package/lib/constants/abis/json/compound/migration.json +0 -57
- package/lib/constants/abis/json/compound/oldSwap.json +0 -688
- package/lib/constants/abis/json/ren/adapter.json +0 -1
- package/lib/constants/abis/json/sbtc/adapter.json +0 -1
- package/lib/pools.d.ts +0 -267
- package/lib/pools.js +0 -4752
|
@@ -42,10 +42,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.getCryptoFactoryPoolData = void 0;
|
|
43
43
|
var ethers_1 = require("ethers");
|
|
44
44
|
var ethcall_1 = require("ethcall");
|
|
45
|
-
var ERC20_json_1 = __importDefault(require("../constants/abis/
|
|
46
|
-
var factory_crypto_pool_2_json_1 = __importDefault(require("../constants/abis/
|
|
47
|
-
var gauge_factory_json_1 = __importDefault(require("../constants/abis/
|
|
48
|
-
var
|
|
45
|
+
var ERC20_json_1 = __importDefault(require("../constants/abis/ERC20.json"));
|
|
46
|
+
var factory_crypto_pool_2_json_1 = __importDefault(require("../constants/abis/factory-crypto/factory-crypto-pool-2.json"));
|
|
47
|
+
var gauge_factory_json_1 = __importDefault(require("../constants/abis/gauge_factory.json"));
|
|
48
|
+
var constants_1 = require("./constants");
|
|
49
49
|
var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
|
|
50
50
|
function getCryptoFactoryIdsAndSwapAddresses() {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -198,16 +198,16 @@ function setCryptoFactoryCoinsContracts(coinAddresses) {
|
|
|
198
198
|
function getCryptoFactoryUnderlyingCoinAddresses(coinAddresses) {
|
|
199
199
|
return __awaiter(this, void 0, void 0, function () {
|
|
200
200
|
return __generator(this, function (_a) {
|
|
201
|
-
return [2 /*return*/, coinAddresses.map(function (coins) { return coins.map(function (c) { return c === WETH_ADDRESS ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : c; }); })];
|
|
201
|
+
return [2 /*return*/, coinAddresses.map(function (coins) { return coins.map(function (c) { return c === constants_1.WETH_ADDRESS ? "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" : c; }); })];
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
function getExistingCoinAddressNameDict() {
|
|
206
206
|
var dict = {};
|
|
207
207
|
var _loop_1 = function (poolData) {
|
|
208
|
-
poolData.
|
|
208
|
+
poolData.wrapped_coin_addresses.forEach(function (addr, i) {
|
|
209
209
|
if (!(addr.toLowerCase() in dict)) {
|
|
210
|
-
dict[addr.toLowerCase()] = poolData.
|
|
210
|
+
dict[addr.toLowerCase()] = poolData.wrapped_coins[i];
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
poolData.underlying_coin_addresses.forEach(function (addr, i) {
|
|
@@ -220,8 +220,12 @@ function getExistingCoinAddressNameDict() {
|
|
|
220
220
|
var poolData = _a[_i];
|
|
221
221
|
_loop_1(poolData);
|
|
222
222
|
}
|
|
223
|
+
if (this.chainId === 1)
|
|
224
|
+
dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "ETH";
|
|
223
225
|
if (this.chainId === 137)
|
|
224
226
|
dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "MATIC";
|
|
227
|
+
if (this.chainId === 43114)
|
|
228
|
+
dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "AVAX";
|
|
225
229
|
return dict;
|
|
226
230
|
}
|
|
227
231
|
function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
|
|
@@ -287,8 +291,8 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
|
|
|
287
291
|
decimals = (_a.sent()).map(function (_d) { return Number(ethers_1.ethers.utils.formatUnits(_d, 0)); });
|
|
288
292
|
newCoinAddresses.forEach(function (addr, i) {
|
|
289
293
|
coinAddrNamesDict[addr] = decimals[i];
|
|
290
|
-
existingCoinAddressDecimalsDict[addr] = decimals[i]; // Add to DECIMALS_LOWER_CASE TODO move to another place
|
|
291
294
|
});
|
|
295
|
+
coinAddrNamesDict['0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'] = 18;
|
|
292
296
|
return [2 /*return*/, coinAddrNamesDict];
|
|
293
297
|
}
|
|
294
298
|
});
|
|
@@ -297,42 +301,37 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
|
|
|
297
301
|
function getCryptoFactoryPoolData() {
|
|
298
302
|
return __awaiter(this, void 0, void 0, function () {
|
|
299
303
|
var _a, poolIds, swapAddresses, tokenAddresses, gaugeAddresses, _b, poolSymbols, poolNames, coinAddresses, underlyingCoinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, CRYPTO_FACTORY_POOLS_DATA, i;
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
switch (_f.label) {
|
|
304
|
+
return __generator(this, function (_c) {
|
|
305
|
+
switch (_c.label) {
|
|
303
306
|
case 0: return [4 /*yield*/, getCryptoFactoryIdsAndSwapAddresses.call(this)];
|
|
304
307
|
case 1:
|
|
305
|
-
_a =
|
|
308
|
+
_a = _c.sent(), poolIds = _a[0], swapAddresses = _a[1];
|
|
306
309
|
setCryptoFactorySwapContracts.call(this, swapAddresses);
|
|
307
310
|
return [4 /*yield*/, getCryptoFactoryTokenAddresses.call(this, swapAddresses)];
|
|
308
311
|
case 2:
|
|
309
|
-
tokenAddresses =
|
|
312
|
+
tokenAddresses = _c.sent();
|
|
310
313
|
setCryptoFactoryTokenContracts.call(this, tokenAddresses);
|
|
311
|
-
(_c = this.constants.LP_TOKENS).push.apply(_c, tokenAddresses); // TODO move to another place
|
|
312
314
|
return [4 /*yield*/, getCryptoFactoryGaugeAddresses.call(this, swapAddresses)];
|
|
313
315
|
case 3:
|
|
314
|
-
gaugeAddresses =
|
|
316
|
+
gaugeAddresses = _c.sent();
|
|
315
317
|
setCryptoFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
316
|
-
(_e = this.constants.GAUGES).push.apply(_e, gaugeAddresses.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })); // TODO move to another place
|
|
317
318
|
return [4 /*yield*/, getCryptoFactorySymbolsAndNames.call(this, tokenAddresses)];
|
|
318
319
|
case 4:
|
|
319
|
-
_b =
|
|
320
|
+
_b = _c.sent(), poolSymbols = _b[0], poolNames = _b[1];
|
|
320
321
|
return [4 /*yield*/, getCryptoFactoryCoinAddresses.call(this, swapAddresses)];
|
|
321
322
|
case 5:
|
|
322
|
-
coinAddresses =
|
|
323
|
+
coinAddresses = _c.sent();
|
|
323
324
|
setCryptoFactoryCoinsContracts.call(this, coinAddresses);
|
|
324
325
|
return [4 /*yield*/, getCryptoFactoryUnderlyingCoinAddresses.call(this, coinAddresses)];
|
|
325
326
|
case 6:
|
|
326
|
-
underlyingCoinAddresses =
|
|
327
|
+
underlyingCoinAddresses = _c.sent();
|
|
327
328
|
existingCoinAddressNameDict = getExistingCoinAddressNameDict.call(this);
|
|
328
329
|
return [4 /*yield*/, getCoinAddressNameDict.call(this, coinAddresses, existingCoinAddressNameDict)];
|
|
329
330
|
case 7:
|
|
330
|
-
coinAddressNameDict =
|
|
331
|
-
|
|
332
|
-
return [4 /*yield*/, getCoinAddressDecimalsDict.call(this, coinAddresses, this.constants.DECIMALS_LOWER_CASE)];
|
|
331
|
+
coinAddressNameDict = _c.sent();
|
|
332
|
+
return [4 /*yield*/, getCoinAddressDecimalsDict.call(this, coinAddresses, this.constants.DECIMALS)];
|
|
333
333
|
case 8:
|
|
334
|
-
coinAddressDecimalsDict =
|
|
335
|
-
coinAddressDecimalsDict['0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'] = 18;
|
|
334
|
+
coinAddressDecimalsDict = _c.sent();
|
|
336
335
|
CRYPTO_FACTORY_POOLS_DATA = {};
|
|
337
336
|
for (i = 0; i < poolIds.length; i++) {
|
|
338
337
|
CRYPTO_FACTORY_POOLS_DATA[poolIds[i]] = {
|
|
@@ -340,23 +339,19 @@ function getCryptoFactoryPoolData() {
|
|
|
340
339
|
full_name: poolNames[i],
|
|
341
340
|
symbol: poolSymbols[i],
|
|
342
341
|
reference_asset: "CRYPTO",
|
|
343
|
-
N_COINS: coinAddresses[i].length,
|
|
344
|
-
is_crypto: true,
|
|
345
|
-
underlying_decimals: underlyingCoinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
346
|
-
decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
347
|
-
use_lending: coinAddresses[i].map(function () { return false; }),
|
|
348
|
-
is_plain: coinAddresses[i].map(function () { return true; }),
|
|
349
|
-
underlying_coins: underlyingCoinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
|
|
350
|
-
coins: coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
|
|
351
342
|
swap_address: swapAddresses[i],
|
|
352
343
|
token_address: tokenAddresses[i],
|
|
353
344
|
gauge_address: gaugeAddresses[i],
|
|
345
|
+
is_crypto: true,
|
|
346
|
+
is_factory: true,
|
|
347
|
+
underlying_coins: underlyingCoinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
|
|
348
|
+
wrapped_coins: coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
|
|
354
349
|
underlying_coin_addresses: underlyingCoinAddresses[i],
|
|
355
|
-
|
|
350
|
+
wrapped_coin_addresses: coinAddresses[i],
|
|
351
|
+
underlying_decimals: underlyingCoinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
352
|
+
wrapped_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
356
353
|
swap_abi: factory_crypto_pool_2_json_1.default,
|
|
357
354
|
gauge_abi: gauge_factory_json_1.default,
|
|
358
|
-
is_factory: true,
|
|
359
|
-
is_crypto_factory: true,
|
|
360
355
|
};
|
|
361
356
|
}
|
|
362
357
|
return [2 /*return*/, CRYPTO_FACTORY_POOLS_DATA];
|
package/lib/factory/factory.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function getFactoryPoolData(this: ICurve): Promise<
|
|
1
|
+
import { IDict, IPoolData, ICurve } from "../interfaces";
|
|
2
|
+
export declare function getFactoryPoolData(this: ICurve): Promise<IDict<IPoolData>>;
|
package/lib/factory/factory.js
CHANGED
|
@@ -51,138 +51,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
51
51
|
exports.getFactoryPoolData = void 0;
|
|
52
52
|
var ethers_1 = require("ethers");
|
|
53
53
|
var ethcall_1 = require("ethcall");
|
|
54
|
-
var ERC20_json_1 = __importDefault(require("../constants/abis/
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var Plain2Balances_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain2Balances.json"));
|
|
68
|
-
var Plain2ETH_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain2ETH.json"));
|
|
69
|
-
var Plain2Optimized_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain2Optimized.json"));
|
|
70
|
-
var Plain3Basic_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain3Basic.json"));
|
|
71
|
-
var Plain3Balances_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain3Balances.json"));
|
|
72
|
-
var Plain3ETH_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain3ETH.json"));
|
|
73
|
-
var Plain3Optimized_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain3Optimized.json"));
|
|
74
|
-
var Plain4Basic_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain4Basic.json"));
|
|
75
|
-
var Plain4Balances_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain4Balances.json"));
|
|
76
|
-
var Plain4ETH_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain4ETH.json"));
|
|
77
|
-
var Plain4Optimized_json_1 = __importDefault(require("../constants/abis/json/factory-v2/Plain4Optimized.json"));
|
|
78
|
-
var implementationABIDictEthereum = {
|
|
79
|
-
"0x5F890841f657d90E081bAbdB532A05996Af79Fe6": swap_json_1.default,
|
|
80
|
-
"0x213be373FDff327658139C7df330817DAD2d5bBE": MetaUSD_json_1.default,
|
|
81
|
-
"0x55Aa9BF126bCABF0bDC17Fa9E39Ec9239e1ce7A9": MetaUSDBalances_json_1.default,
|
|
82
|
-
"0xC6A8466d128Fbfd34AdA64a9FFFce325D57C9a52": MetaBTC_json_1.default,
|
|
83
|
-
"0xc4C78b08fA0c3d0a312605634461A88184Ecd630": MetaBTCBalances_json_1.default,
|
|
84
|
-
"0xECAaecd9d2193900b424774133B1f51ae0F29d9E": MetaBTCRen_json_1.default,
|
|
85
|
-
"0x40fD58D44cFE63E8517c9Bb3ac98676838Ea56A8": MetaBTCBalancesRen_json_1.default,
|
|
86
|
-
"0x6523Ac15EC152Cb70a334230F6c5d62C5Bd963f1": Plain2Basic_json_1.default,
|
|
87
|
-
"0x24D937143d3F5cF04c72bA112735151A8CAE2262": Plain2Balances_json_1.default,
|
|
88
|
-
"0x6326DEbBAa15bCFE603d831e7D75f4fc10d9B43E": Plain2ETH_json_1.default,
|
|
89
|
-
"0x4A4d7868390EF5CaC51cDA262888f34bD3025C3F": Plain2Optimized_json_1.default,
|
|
90
|
-
"0x9B52F13DF69D79Ec5aAB6D1aCe3157d29B409cC3": Plain3Basic_json_1.default,
|
|
91
|
-
"0x50b085f2e5958C4A87baf93A8AB79F6bec068494": Plain3Balances_json_1.default,
|
|
92
|
-
"0x8c1aB78601c259E1B43F19816923609dC7d7de9B": Plain3ETH_json_1.default,
|
|
93
|
-
"0xE5F4b89E0A16578B3e0e7581327BDb4C712E44De": Plain3Optimized_json_1.default,
|
|
94
|
-
"0x5Bd47eA4494e0F8DE6e3Ca10F1c05F55b72466B8": Plain4Basic_json_1.default,
|
|
95
|
-
"0xd35B58386705CE75CE6d09842E38E9BE9CDe5bF6": Plain4Balances_json_1.default,
|
|
96
|
-
"0x88855cdF2b0A8413D470B86952E726684de915be": Plain4ETH_json_1.default,
|
|
97
|
-
"0xaD4753D045D3Aed5C1a6606dFb6a7D7AD67C1Ad7": Plain4Optimized_json_1.default,
|
|
54
|
+
var ERC20_json_1 = __importDefault(require("../constants/abis/ERC20.json"));
|
|
55
|
+
var deposit_json_1 = __importDefault(require("../constants/abis/factoryPools/deposit.json"));
|
|
56
|
+
var gauge_factory_json_1 = __importDefault(require("../constants/abis/gauge_factory.json"));
|
|
57
|
+
var common_1 = require("./common");
|
|
58
|
+
var constants_1 = require("./constants");
|
|
59
|
+
var BLACK_LIST = {
|
|
60
|
+
1: [],
|
|
61
|
+
137: [
|
|
62
|
+
"0x666dc3b4babfd063faf965bd020024af0dc51b64",
|
|
63
|
+
"0xe4199bc5c5c1f63dba47b56b6db7144c51cf0bf8",
|
|
64
|
+
"0x88c4d6534165510b2e2caf0a130d4f70aa4b6d71",
|
|
65
|
+
],
|
|
66
|
+
43114: [],
|
|
98
67
|
};
|
|
99
|
-
var implementationABIDictPolygon = {
|
|
100
|
-
"0x4fb93D7d320E8A263F22f62C2059dFC2A8bCbC4c": MetaUSD_json_1.default,
|
|
101
|
-
"0x39fE1824f98CD828050D7c51dA443E84121c7cf1": MetaUSDBalances_json_1.default,
|
|
102
|
-
"0xC05EB760A135d3D0c839f1141423002681157a17": MetaBTCRen_json_1.default,
|
|
103
|
-
"0xD8336532f6ED7b94282fAF724fe41d6145E07Cfc": MetaBTCBalancesRen_json_1.default,
|
|
104
|
-
"0x571FF5b7b346F706aa48d696a9a4a288e9Bb4091": Plain2Basic_json_1.default,
|
|
105
|
-
"0x8925D9d9B4569D737a48499DeF3f67BaA5a144b9": Plain2Balances_json_1.default,
|
|
106
|
-
"0xAe00f57663F4C85FC948B13963cd4627dAF01061": Plain2ETH_json_1.default,
|
|
107
|
-
"0x8101E6760130be2C8Ace79643AB73500571b7162": Plain2Optimized_json_1.default,
|
|
108
|
-
"0x493084cA44C779Af27a416ac1F71e3823BF21b53": Plain3Basic_json_1.default,
|
|
109
|
-
"0x9B4Ed6F8904E976146b3dC0233CD48Cf81835240": Plain3Balances_json_1.default,
|
|
110
|
-
"0xA9134FaE98F92217f457918505375Ae91fdc5e3c": Plain3ETH_json_1.default,
|
|
111
|
-
"0xCC9fd96C26c450Dd4580893afF75efd5cb6C12Fc": Plain3Optimized_json_1.default,
|
|
112
|
-
"0x991b05d5316fa3A2C053F84658b84987cd5c9970": Plain4Basic_json_1.default,
|
|
113
|
-
"0xC7c46488566b9ef9B981b87E328939CaA5ca152f": Plain4Balances_json_1.default,
|
|
114
|
-
"0xf31bcdf0B9a5eCD7AB463eB905551fBc32e51856": Plain4ETH_json_1.default,
|
|
115
|
-
"0xAc273d5b4FC06625d8b1abA3BE8De15bDFb8E39f": Plain4Optimized_json_1.default,
|
|
116
|
-
};
|
|
117
|
-
var basePoolAddressNameDictEthereum = {
|
|
118
|
-
"0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7": "3pool",
|
|
119
|
-
"0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714": "sbtc",
|
|
120
|
-
"0x93054188d876f558f4a66B2EF1d97d16eDf0895B": "ren",
|
|
121
|
-
};
|
|
122
|
-
var basePoolAddressNameDictPolygon = {
|
|
123
|
-
"0x445FE580eF8d70FF569aB36e80c647af338db351": "aave",
|
|
124
|
-
"0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67": "ren",
|
|
125
|
-
};
|
|
126
|
-
var basePoolAddressCoinsDictEthereum = {
|
|
127
|
-
"0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7": ['DAI', 'USDC', 'USDT'],
|
|
128
|
-
"0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714": ['renBTC', 'WBTC', 'sBTC'],
|
|
129
|
-
"0x93054188d876f558f4a66B2EF1d97d16eDf0895B": ['renBTC', 'WBTC'], // ren
|
|
130
|
-
};
|
|
131
|
-
var basePoolAddressCoinsDictPolygon = {
|
|
132
|
-
"0x445FE580eF8d70FF569aB36e80c647af338db351": ['DAI', 'USDC', 'USDT'],
|
|
133
|
-
"0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67": ['WBTC', 'renBTC'], // ren
|
|
134
|
-
};
|
|
135
|
-
var basePoolAddressCoinAddressesDictEthereum = {
|
|
136
|
-
"0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7": [
|
|
137
|
-
'0x6B175474E89094C44Da98b954EedeAC495271d0F',
|
|
138
|
-
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
139
|
-
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
140
|
-
].map(function (addr) { return addr.toLowerCase(); }),
|
|
141
|
-
"0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714": [
|
|
142
|
-
'0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D',
|
|
143
|
-
'0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
|
|
144
|
-
'0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6',
|
|
145
|
-
].map(function (addr) { return addr.toLowerCase(); }),
|
|
146
|
-
"0x93054188d876f558f4a66B2EF1d97d16eDf0895B": [
|
|
147
|
-
'0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D',
|
|
148
|
-
'0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
|
|
149
|
-
].map(function (addr) { return addr.toLowerCase(); }),
|
|
150
|
-
};
|
|
151
|
-
var basePoolAddressCoinAddressesDictPolygon = {
|
|
152
|
-
"0x445FE580eF8d70FF569aB36e80c647af338db351": [
|
|
153
|
-
'0x8f3cf7ad23cd3cadbd9735aff958023239c6a063',
|
|
154
|
-
'0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
|
|
155
|
-
'0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
|
|
156
|
-
].map(function (addr) { return addr.toLowerCase(); }),
|
|
157
|
-
"0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67": [
|
|
158
|
-
'0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6',
|
|
159
|
-
'0xDBf31dF14B66535aF65AaC99C32e9eA844e14501',
|
|
160
|
-
].map(function (addr) { return addr.toLowerCase(); }),
|
|
161
|
-
};
|
|
162
|
-
var basePoolAddressDecimalsDictEthereum = {
|
|
163
|
-
"0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7": [18, 6, 6],
|
|
164
|
-
"0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714": [8, 8, 18],
|
|
165
|
-
"0x93054188d876f558f4a66B2EF1d97d16eDf0895B": [8, 8], // ren
|
|
166
|
-
};
|
|
167
|
-
var basePoolAddressDecimalsDictPolygon = {
|
|
168
|
-
"0x445FE580eF8d70FF569aB36e80c647af338db351": [18, 6, 6],
|
|
169
|
-
"0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67": [8, 8], // ren
|
|
170
|
-
};
|
|
171
|
-
var basePoolAddressZapDictEthereum = {
|
|
172
|
-
"0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7": "0xA79828DF1850E8a3A3064576f380D90aECDD3359".toLowerCase(),
|
|
173
|
-
"0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714": "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(),
|
|
174
|
-
"0x93054188d876f558f4a66B2EF1d97d16eDf0895B": "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase(), // ren TODO CHECK!!!
|
|
175
|
-
};
|
|
176
|
-
var basePoolAddressZapDictPolygon = {
|
|
177
|
-
"0x445FE580eF8d70FF569aB36e80c647af338db351": "0x5ab5C56B9db92Ba45a0B46a207286cD83C15C939".toLowerCase(),
|
|
178
|
-
"0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67": "0xE2e6DC1708337A6e59f227921db08F21e3394723".toLowerCase(), // ren
|
|
179
|
-
};
|
|
180
|
-
var blackListPolygon = [
|
|
181
|
-
"0x666dc3b4babfd063faf965bd020024af0dc51b64",
|
|
182
|
-
"0xe4199bc5c5c1f63dba47b56b6db7144c51cf0bf8",
|
|
183
|
-
"0x88c4d6534165510b2e2caf0a130d4f70aa4b6d71",
|
|
184
|
-
];
|
|
185
|
-
var blackListEthereum = [];
|
|
186
68
|
var deepFlatten = function (arr) { return [].concat.apply([], arr.map(function (v) { return (Array.isArray(v) ? deepFlatten(v) : v); })); };
|
|
187
69
|
function getFactoryIdsAndSwapAddresses() {
|
|
188
70
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -205,7 +87,7 @@ function getFactoryIdsAndSwapAddresses() {
|
|
|
205
87
|
case 2:
|
|
206
88
|
factories = (_e.sent()).map(function (addr, i) { return ({ id: "factory-v2-".concat(i), address: addr.toLowerCase() }); });
|
|
207
89
|
swapAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address.toLowerCase(); });
|
|
208
|
-
blacklist = this.chainId
|
|
90
|
+
blacklist = BLACK_LIST[this.chainId];
|
|
209
91
|
factories = factories.filter(function (f) { return !swapAddresses.includes(f.address) && !blacklist.includes(f.address); });
|
|
210
92
|
return [2 /*return*/, [factories.map(function (f) { return f.id; }), factories.map(function (f) { return f.address; })]];
|
|
211
93
|
}
|
|
@@ -218,7 +100,7 @@ function getFactorySwapABIs(factorySwapAddresses) {
|
|
|
218
100
|
return __generator(this, function (_a) {
|
|
219
101
|
switch (_a.label) {
|
|
220
102
|
case 0:
|
|
221
|
-
implementationABIDict = this.chainId
|
|
103
|
+
implementationABIDict = constants_1.FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
222
104
|
return [4 /*yield*/, this.contracts[this.constants.ALIASES.factory].multicallContract];
|
|
223
105
|
case 1:
|
|
224
106
|
factoryMulticallContract = _a.sent();
|
|
@@ -358,9 +240,9 @@ function setFactoryCoinsContracts(coinAddresses) {
|
|
|
358
240
|
function getExistingCoinAddressNameDict() {
|
|
359
241
|
var dict = {};
|
|
360
242
|
var _loop_1 = function (poolData) {
|
|
361
|
-
poolData.
|
|
243
|
+
poolData.wrapped_coin_addresses.forEach(function (addr, i) {
|
|
362
244
|
if (!(addr.toLowerCase() in dict)) {
|
|
363
|
-
dict[addr.toLowerCase()] = poolData.
|
|
245
|
+
dict[addr.toLowerCase()] = poolData.wrapped_coins[i];
|
|
364
246
|
}
|
|
365
247
|
});
|
|
366
248
|
poolData.underlying_coin_addresses.forEach(function (addr, i) {
|
|
@@ -373,8 +255,12 @@ function getExistingCoinAddressNameDict() {
|
|
|
373
255
|
var poolData = _a[_i];
|
|
374
256
|
_loop_1(poolData);
|
|
375
257
|
}
|
|
258
|
+
if (this.chainId === 1)
|
|
259
|
+
dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "ETH";
|
|
376
260
|
if (this.chainId === 137)
|
|
377
261
|
dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "MATIC";
|
|
262
|
+
if (this.chainId === 43114)
|
|
263
|
+
dict["0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"] = "AVAX";
|
|
378
264
|
return dict;
|
|
379
265
|
}
|
|
380
266
|
function getCoinAddressNameDict(coinAddresses, existingCoinAddrNameDict) {
|
|
@@ -437,8 +323,8 @@ function getCoinAddressDecimalsDict(coinAddresses, existingCoinAddressDecimalsDi
|
|
|
437
323
|
decimals = (_a.sent()).map(function (_d) { return Number(ethers_1.ethers.utils.formatUnits(_d, 0)); });
|
|
438
324
|
newCoinAddresses.forEach(function (addr, i) {
|
|
439
325
|
coinAddrNamesDict[addr] = decimals[i];
|
|
440
|
-
existingCoinAddressDecimalsDict[addr] = decimals[i]; // Add to DECIMALS_LOWER_CASE TODO move to another place
|
|
441
326
|
});
|
|
327
|
+
coinAddrNamesDict['0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'] = 18;
|
|
442
328
|
return [2 /*return*/, coinAddrNamesDict];
|
|
443
329
|
}
|
|
444
330
|
});
|
|
@@ -482,75 +368,53 @@ function getFactoryBasePoolAddresses(factorySwapAddresses) {
|
|
|
482
368
|
});
|
|
483
369
|
});
|
|
484
370
|
}
|
|
485
|
-
function setFactoryZapContracts() {
|
|
486
|
-
if (this.chainId === 137) {
|
|
487
|
-
var metaUsdZapAddress = "0x5ab5C56B9db92Ba45a0B46a207286cD83C15C939".toLowerCase();
|
|
488
|
-
this.contracts[metaUsdZapAddress] = {
|
|
489
|
-
contract: new ethers_1.Contract(metaUsdZapAddress, DepositZapMetaUsdPolygon_json_1.default, this.signer || this.provider),
|
|
490
|
-
multicallContract: new ethcall_1.Contract(metaUsdZapAddress, DepositZapMetaUsdPolygon_json_1.default),
|
|
491
|
-
};
|
|
492
|
-
var metaBtcZapAddress = "0xE2e6DC1708337A6e59f227921db08F21e3394723".toLowerCase();
|
|
493
|
-
this.contracts[metaBtcZapAddress] = {
|
|
494
|
-
contract: new ethers_1.Contract(metaBtcZapAddress, DepositZapMetaBtcPolygon_json_1.default, this.signer || this.provider),
|
|
495
|
-
multicallContract: new ethcall_1.Contract(metaBtcZapAddress, DepositZapMetaBtcPolygon_json_1.default),
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
var metaSBtcZapAddress = "0x7abdbaf29929e7f8621b757d2a7c04d78d633834".toLowerCase();
|
|
500
|
-
this.contracts[metaSBtcZapAddress] = {
|
|
501
|
-
contract: new ethers_1.Contract(metaSBtcZapAddress, deposit_json_1.default, this.signer || this.provider),
|
|
502
|
-
multicallContract: new ethcall_1.Contract(metaSBtcZapAddress, deposit_json_1.default),
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
371
|
function getFactoryPoolData() {
|
|
507
372
|
return __awaiter(this, void 0, void 0, function () {
|
|
508
|
-
var _a, poolIds, swapAddresses, swapABIs, gaugeAddresses, _b, poolSymbols, poolNames, referenceAssets, coinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, isMeta, basePoolAddresses,
|
|
509
|
-
var
|
|
510
|
-
return __generator(this, function (
|
|
511
|
-
switch (
|
|
373
|
+
var _a, poolIds, swapAddresses, swapABIs, gaugeAddresses, _b, poolSymbols, poolNames, referenceAssets, coinAddresses, existingCoinAddressNameDict, coinAddressNameDict, coinAddressDecimalsDict, isMeta, basePoolAddresses, basePoolAddressIdDict, basePoolIds, basePoolIdCoinsDict, basePoolIdCoinAddressesDict, basePoolIdDecimalsDict, basePoolIdZapDict, FACTORY_POOLS_DATA, i;
|
|
374
|
+
var _this = this;
|
|
375
|
+
return __generator(this, function (_c) {
|
|
376
|
+
switch (_c.label) {
|
|
512
377
|
case 0: return [4 /*yield*/, getFactoryIdsAndSwapAddresses.call(this)];
|
|
513
378
|
case 1:
|
|
514
|
-
_a =
|
|
379
|
+
_a = _c.sent(), poolIds = _a[0], swapAddresses = _a[1];
|
|
515
380
|
return [4 /*yield*/, getFactorySwapABIs.call(this, swapAddresses)];
|
|
516
381
|
case 2:
|
|
517
|
-
swapABIs =
|
|
382
|
+
swapABIs = _c.sent();
|
|
518
383
|
setFactorySwapContracts.call(this, swapAddresses, swapABIs);
|
|
519
|
-
(_c = this.constants.LP_TOKENS).push.apply(_c, swapAddresses); // TODO move to another place
|
|
520
384
|
return [4 /*yield*/, getFactoryGaugeAddresses.call(this, swapAddresses)];
|
|
521
385
|
case 3:
|
|
522
|
-
gaugeAddresses =
|
|
386
|
+
gaugeAddresses = _c.sent();
|
|
523
387
|
setFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
524
|
-
(_e = this.constants.GAUGES).push.apply(_e, gaugeAddresses.filter(function (addr) { return addr !== ethers_1.ethers.constants.AddressZero; })); // TODO move to another place
|
|
525
388
|
return [4 /*yield*/, getFactorySymbolsAndNames.call(this, swapAddresses)];
|
|
526
389
|
case 4:
|
|
527
|
-
_b =
|
|
390
|
+
_b = _c.sent(), poolSymbols = _b[0], poolNames = _b[1];
|
|
528
391
|
return [4 /*yield*/, getFactoryReferenceAssets.call(this, swapAddresses)];
|
|
529
392
|
case 5:
|
|
530
|
-
referenceAssets =
|
|
393
|
+
referenceAssets = _c.sent();
|
|
531
394
|
return [4 /*yield*/, getFactoryCoinAddresses.call(this, swapAddresses)];
|
|
532
395
|
case 6:
|
|
533
|
-
coinAddresses =
|
|
396
|
+
coinAddresses = _c.sent();
|
|
534
397
|
setFactoryCoinsContracts.call(this, coinAddresses);
|
|
535
398
|
existingCoinAddressNameDict = getExistingCoinAddressNameDict.call(this);
|
|
536
399
|
return [4 /*yield*/, getCoinAddressNameDict.call(this, coinAddresses, existingCoinAddressNameDict)];
|
|
537
400
|
case 7:
|
|
538
|
-
coinAddressNameDict =
|
|
539
|
-
return [4 /*yield*/, getCoinAddressDecimalsDict.call(this, coinAddresses, this.constants.
|
|
401
|
+
coinAddressNameDict = _c.sent();
|
|
402
|
+
return [4 /*yield*/, getCoinAddressDecimalsDict.call(this, coinAddresses, this.constants.DECIMALS)];
|
|
540
403
|
case 8:
|
|
541
|
-
coinAddressDecimalsDict =
|
|
404
|
+
coinAddressDecimalsDict = _c.sent();
|
|
542
405
|
return [4 /*yield*/, getFactoryIsMeta.call(this, swapAddresses)];
|
|
543
406
|
case 9:
|
|
544
|
-
isMeta =
|
|
407
|
+
isMeta = _c.sent();
|
|
545
408
|
return [4 /*yield*/, getFactoryBasePoolAddresses.call(this, swapAddresses)];
|
|
546
409
|
case 10:
|
|
547
|
-
basePoolAddresses =
|
|
548
|
-
setFactoryZapContracts.call(this);
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
410
|
+
basePoolAddresses = _c.sent();
|
|
411
|
+
common_1.setFactoryZapContracts.call(this);
|
|
412
|
+
basePoolAddressIdDict = constants_1.FACTORY_CONSTANTS[this.chainId].basePoolAddressIdDict;
|
|
413
|
+
basePoolIds = basePoolAddresses.map(function (addr) { return basePoolAddressIdDict[addr]; });
|
|
414
|
+
basePoolIdCoinsDict = Object.fromEntries(Object.values(basePoolAddressIdDict).map(function (poolId) { return [poolId, _this.constants.POOLS_DATA[poolId].underlying_coins]; }));
|
|
415
|
+
basePoolIdCoinAddressesDict = Object.fromEntries(Object.values(basePoolAddressIdDict).map(function (poolId) { return [poolId, _this.constants.POOLS_DATA[poolId].underlying_coin_addresses]; }));
|
|
416
|
+
basePoolIdDecimalsDict = Object.fromEntries(Object.values(basePoolAddressIdDict).map(function (poolId) { return [poolId, _this.constants.POOLS_DATA[poolId].underlying_decimals]; }));
|
|
417
|
+
basePoolIdZapDict = constants_1.FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
|
|
554
418
|
FACTORY_POOLS_DATA = {};
|
|
555
419
|
for (i = 0; i < poolIds.length; i++) {
|
|
556
420
|
if (!isMeta[i]) {
|
|
@@ -559,22 +423,19 @@ function getFactoryPoolData() {
|
|
|
559
423
|
full_name: poolNames[i],
|
|
560
424
|
symbol: poolSymbols[i],
|
|
561
425
|
reference_asset: referenceAssets[i],
|
|
562
|
-
N_COINS: coinAddresses[i].length,
|
|
563
|
-
underlying_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
564
|
-
decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
565
|
-
use_lending: coinAddresses[i].map(function () { return false; }),
|
|
566
|
-
is_plain: coinAddresses[i].map(function () { return true; }),
|
|
567
426
|
swap_address: swapAddresses[i],
|
|
568
427
|
token_address: swapAddresses[i],
|
|
569
428
|
gauge_address: gaugeAddresses[i],
|
|
429
|
+
is_plain: true,
|
|
430
|
+
is_factory: true,
|
|
570
431
|
underlying_coins: coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
|
|
571
|
-
|
|
432
|
+
wrapped_coins: coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
|
|
572
433
|
underlying_coin_addresses: coinAddresses[i],
|
|
573
|
-
|
|
434
|
+
wrapped_coin_addresses: coinAddresses[i],
|
|
435
|
+
underlying_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
436
|
+
wrapped_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
574
437
|
swap_abi: swapABIs[i],
|
|
575
438
|
gauge_abi: gauge_factory_json_1.default,
|
|
576
|
-
is_factory: true,
|
|
577
|
-
is_plain_factory: true,
|
|
578
439
|
};
|
|
579
440
|
}
|
|
580
441
|
else {
|
|
@@ -583,27 +444,21 @@ function getFactoryPoolData() {
|
|
|
583
444
|
full_name: poolNames[i],
|
|
584
445
|
symbol: poolSymbols[i],
|
|
585
446
|
reference_asset: referenceAssets[i],
|
|
586
|
-
N_COINS: coinAddresses[i].length,
|
|
587
|
-
underlying_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
588
|
-
decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
589
|
-
use_lending: coinAddresses[i].map(function () { return false; }),
|
|
590
|
-
is_plain: coinAddresses[i].map(function () { return true; }),
|
|
591
447
|
swap_address: swapAddresses[i],
|
|
592
448
|
token_address: swapAddresses[i],
|
|
593
449
|
gauge_address: gaugeAddresses[i],
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
450
|
+
deposit_address: basePoolIdZapDict[basePoolIds[i]],
|
|
451
|
+
is_meta: true,
|
|
452
|
+
is_factory: true,
|
|
453
|
+
base_pool: basePoolIds[i],
|
|
454
|
+
underlying_coins: __spreadArray([coinAddressNameDict[coinAddresses[i][0]]], basePoolIdCoinsDict[basePoolIds[i]], true),
|
|
455
|
+
wrapped_coins: coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }),
|
|
456
|
+
underlying_coin_addresses: __spreadArray([coinAddresses[i][0]], basePoolIdCoinAddressesDict[basePoolIds[i]], true),
|
|
457
|
+
wrapped_coin_addresses: coinAddresses[i],
|
|
458
|
+
underlying_decimals: __spreadArray([coinAddressDecimalsDict[coinAddresses[i][0]]], basePoolIdDecimalsDict[basePoolIds[i]], true),
|
|
459
|
+
wrapped_decimals: coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }),
|
|
598
460
|
swap_abi: swapABIs[i],
|
|
599
461
|
gauge_abi: gauge_factory_json_1.default,
|
|
600
|
-
is_factory: true,
|
|
601
|
-
is_meta_factory: true,
|
|
602
|
-
is_meta: true,
|
|
603
|
-
base_pool: basePoolAddressNameDict[basePoolAddresses[i]],
|
|
604
|
-
meta_coin_addresses: basePoolAddressCoinAddressesDict[basePoolAddresses[i]],
|
|
605
|
-
meta_coin_decimals: __spreadArray([coinAddressDecimalsDict[coinAddresses[i][0]]], basePoolAddressDecimalsDict[basePoolAddresses[i]], true),
|
|
606
|
-
deposit_address: basePoolAddressZapDict[basePoolAddresses[i]],
|
|
607
462
|
deposit_abi: deposit_json_1.default,
|
|
608
463
|
};
|
|
609
464
|
}
|