@curvefi/api 1.25.2 → 2.0.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 +775 -589
- 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 +2 -24
- package/lib/constants/aliases.js +5 -4
- 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/ethereum.d.ts +2 -0
- package/lib/constants/{abis/abis-ethereum.js → pools/ethereum.js} +517 -1012
- package/lib/constants/pools/index.d.ts +3 -0
- package/lib/constants/pools/index.js +7 -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 +10 -32
- package/lib/curve.js +188 -232
- package/lib/external-api.d.ts +3 -2
- package/lib/external-api.js +18 -1
- package/lib/factory/constants.d.ts +15 -15
- package/lib/factory/constants.js +19 -19
- package/lib/factory/factory-api.d.ts +2 -2
- package/lib/factory/factory-api.js +34 -49
- package/lib/factory/factory-crypto.d.ts +2 -2
- package/lib/factory/factory-crypto.js +23 -31
- package/lib/factory/factory.d.ts +2 -2
- package/lib/factory/factory.js +53 -66
- package/lib/index.d.ts +36 -53
- package/lib/index.js +27 -35
- package/lib/interfaces.d.ts +25 -67
- package/lib/pools/PoolTemplate.d.ts +210 -0
- package/lib/pools/PoolTemplate.js +2292 -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 +12 -0
- package/lib/router.js +624 -0
- package/lib/utils.d.ts +10 -16
- package/lib/utils.js +33 -126
- 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
package/lib/utils.d.ts
CHANGED
|
@@ -1,35 +1,29 @@
|
|
|
1
|
-
import memoize from 'memoizee';
|
|
2
1
|
import { ethers } from 'ethers';
|
|
3
2
|
import BigNumber from 'bignumber.js';
|
|
4
|
-
import {
|
|
3
|
+
import { IDict } from './interfaces';
|
|
5
4
|
export declare const MAX_ALLOWANCE: ethers.BigNumber;
|
|
6
5
|
export declare const BN: (val: number | string) => BigNumber;
|
|
7
6
|
export declare const toBN: (n: ethers.BigNumber, decimals?: number) => BigNumber;
|
|
8
7
|
export declare const toStringFromBN: (bn: BigNumber, decimals?: number) => string;
|
|
9
8
|
export declare const fromBN: (bn: BigNumber, decimals?: number) => ethers.BigNumber;
|
|
9
|
+
export declare const checkNumber: (n: number | string) => number | string;
|
|
10
|
+
export declare const formatNumber: (n: number | string, decimals?: number) => string;
|
|
11
|
+
export declare const parseUnits: (n: number | string, decimals?: number) => ethers.BigNumber;
|
|
10
12
|
export declare const isEth: (address: string) => boolean;
|
|
11
13
|
export declare const getEthIndex: (addresses: string[]) => number;
|
|
12
14
|
export declare const _getCoinAddresses: (...coins: string[] | string[][]) => string[];
|
|
13
15
|
export declare const _getCoinDecimals: (...coinAddresses: string[] | string[][]) => number[];
|
|
14
|
-
export declare const _getBalances: (coins: string[], addresses: string[]) => Promise<
|
|
16
|
+
export declare const _getBalances: (coins: string[], addresses: string[]) => Promise<IDict<string[]>>;
|
|
15
17
|
export declare const _prepareAddresses: (addresses: string[] | string[][]) => string[];
|
|
16
|
-
export declare const getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<
|
|
18
|
+
export declare const getBalances: (coins: string[], ...addresses: string[] | string[][]) => Promise<IDict<string[]> | string[]>;
|
|
17
19
|
export declare const _getAllowance: (coins: string[], address: string, spender: string) => Promise<ethers.BigNumber[]>;
|
|
18
20
|
export declare const getAllowance: (coins: string[], address: string, spender: string) => Promise<string[]>;
|
|
19
|
-
export declare const hasAllowance: (coins: string[], amounts: string[], address: string, spender: string) => Promise<boolean>;
|
|
21
|
+
export declare const hasAllowance: (coins: string[], amounts: (number | string)[], address: string, spender: string) => Promise<boolean>;
|
|
20
22
|
export declare const _ensureAllowance: (coins: string[], amounts: ethers.BigNumber[], spender: string) => Promise<string[]>;
|
|
21
|
-
export declare const ensureAllowanceEstimateGas: (coins: string[], amounts: string[], spender: string) => Promise<number>;
|
|
22
|
-
export declare const ensureAllowance: (coins: string[], amounts: string[], spender: string) => Promise<string[]>;
|
|
23
|
+
export declare const ensureAllowanceEstimateGas: (coins: string[], amounts: (number | string)[], spender: string) => Promise<number>;
|
|
24
|
+
export declare const ensureAllowance: (coins: string[], amounts: (number | string)[], spender: string) => Promise<string[]>;
|
|
23
25
|
export declare const getPoolNameBySwapAddress: (swapAddress: string) => string;
|
|
24
|
-
export declare const _getUsdPricesFromApi: () => Promise<
|
|
26
|
+
export declare const _getUsdPricesFromApi: () => Promise<IDict<number>>;
|
|
25
27
|
export declare const _getUsdRate: (assetId: string) => Promise<number>;
|
|
26
|
-
export declare const _getFactoryStatsUrl: () => string;
|
|
27
|
-
export declare const _getStatsUrl: (isCrypto?: boolean) => string;
|
|
28
|
-
export declare const _getStats: ((statsUrl: string) => Promise<IStats>) & memoize.Memoized<(statsUrl: string) => Promise<IStats>>;
|
|
29
|
-
export declare const _getFactoryStatsEthereum: ((statsUrl: string) => Promise<IStats>) & memoize.Memoized<(statsUrl: string) => Promise<IStats>>;
|
|
30
|
-
export declare const _getFactoryStatsPolygon: ((statsUrl: string) => Promise<IStats>) & memoize.Memoized<(statsUrl: string) => Promise<IStats>>;
|
|
31
|
-
export declare const getPoolList: () => string[];
|
|
32
|
-
export declare const getFactoryPoolList: () => string[];
|
|
33
|
-
export declare const getCryptoFactoryPoolList: () => string[];
|
|
34
28
|
export declare const getUsdRate: (coin: string) => Promise<number>;
|
|
35
29
|
export declare const getTVL: (chainId?: number) => Promise<number>;
|
package/lib/utils.js
CHANGED
|
@@ -59,13 +59,11 @@ 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.getTVL = exports.getUsdRate = exports.
|
|
62
|
+
exports.getTVL = exports.getUsdRate = exports._getUsdRate = exports._getUsdPricesFromApi = exports.getPoolNameBySwapAddress = exports.ensureAllowance = exports.ensureAllowanceEstimateGas = exports._ensureAllowance = exports.hasAllowance = exports.getAllowance = exports._getAllowance = exports.getBalances = exports._prepareAddresses = exports._getBalances = exports._getCoinDecimals = exports._getCoinAddresses = exports.getEthIndex = exports.isEth = exports.parseUnits = exports.formatNumber = exports.checkNumber = exports.fromBN = exports.toStringFromBN = exports.toBN = exports.BN = exports.MAX_ALLOWANCE = void 0;
|
|
63
63
|
var axios_1 = __importDefault(require("axios"));
|
|
64
|
-
var memoizee_1 = __importDefault(require("memoizee"));
|
|
65
64
|
var ethers_1 = require("ethers");
|
|
66
65
|
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
67
66
|
var curve_1 = require("./curve");
|
|
68
|
-
var curve_2 = require("./curve");
|
|
69
67
|
var external_api_1 = require("./external-api");
|
|
70
68
|
var ETH_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
71
69
|
exports.MAX_ALLOWANCE = ethers_1.ethers.BigNumber.from(2).pow(ethers_1.ethers.BigNumber.from(256)).sub(ethers_1.ethers.BigNumber.from(1));
|
|
@@ -87,6 +85,26 @@ var fromBN = function (bn, decimals) {
|
|
|
87
85
|
return ethers_1.ethers.utils.parseUnits((0, exports.toStringFromBN)(bn, decimals), decimals);
|
|
88
86
|
};
|
|
89
87
|
exports.fromBN = fromBN;
|
|
88
|
+
// Formatting numbers
|
|
89
|
+
var checkNumber = function (n) {
|
|
90
|
+
if (Number(n) !== Number(n))
|
|
91
|
+
throw Error("".concat(n, " is not a number")); // NaN
|
|
92
|
+
return n;
|
|
93
|
+
};
|
|
94
|
+
exports.checkNumber = checkNumber;
|
|
95
|
+
var formatNumber = function (n, decimals) {
|
|
96
|
+
if (decimals === void 0) { decimals = 18; }
|
|
97
|
+
if (Number(n) !== Number(n))
|
|
98
|
+
throw Error("".concat(n, " is not a number")); // NaN
|
|
99
|
+
var _a = String(n).split("."), integer = _a[0], fractional = _a[1];
|
|
100
|
+
return !fractional ? integer : integer + "." + fractional.slice(0, decimals);
|
|
101
|
+
};
|
|
102
|
+
exports.formatNumber = formatNumber;
|
|
103
|
+
var parseUnits = function (n, decimals) {
|
|
104
|
+
if (decimals === void 0) { decimals = 18; }
|
|
105
|
+
return ethers_1.ethers.utils.parseUnits((0, exports.formatNumber)(n, decimals), decimals);
|
|
106
|
+
};
|
|
107
|
+
exports.parseUnits = parseUnits;
|
|
90
108
|
// -------------------
|
|
91
109
|
var isEth = function (address) { return address.toLowerCase() === ETH_ADDRESS.toLowerCase(); };
|
|
92
110
|
exports.isEth = isEth;
|
|
@@ -101,11 +119,11 @@ var _getCoinAddresses = function () {
|
|
|
101
119
|
if (coins.length == 1 && Array.isArray(coins[0]))
|
|
102
120
|
coins = coins[0];
|
|
103
121
|
coins = coins;
|
|
104
|
-
var coinAddresses = coins.map(function (c) { return
|
|
105
|
-
var availableAddresses = __spreadArray(__spreadArray(
|
|
122
|
+
var coinAddresses = coins.map(function (c) { return c.toLowerCase(); }).map(function (c) { return curve_1.curve.constants.COINS[c] || c; });
|
|
123
|
+
var availableAddresses = __spreadArray(__spreadArray([], Object.keys(curve_1.curve.constants.DECIMALS), true), curve_1.curve.constants.GAUGES, true);
|
|
106
124
|
for (var _a = 0, coinAddresses_1 = coinAddresses; _a < coinAddresses_1.length; _a++) {
|
|
107
125
|
var coinAddr = coinAddresses_1[_a];
|
|
108
|
-
if (!availableAddresses.includes(coinAddr
|
|
126
|
+
if (!availableAddresses.includes(coinAddr))
|
|
109
127
|
throw Error("Coin with address '".concat(coinAddr, "' is not available"));
|
|
110
128
|
}
|
|
111
129
|
return coinAddresses;
|
|
@@ -119,7 +137,7 @@ var _getCoinDecimals = function () {
|
|
|
119
137
|
if (coinAddresses.length == 1 && Array.isArray(coinAddresses[0]))
|
|
120
138
|
coinAddresses = coinAddresses[0];
|
|
121
139
|
coinAddresses = coinAddresses;
|
|
122
|
-
return coinAddresses.map(function (coinAddr) { var _a; return (_a =
|
|
140
|
+
return coinAddresses.map(function (coinAddr) { var _a; return (_a = curve_1.curve.constants.DECIMALS[coinAddr.toLowerCase()]) !== null && _a !== void 0 ? _a : 18; }); // 18 for gauges
|
|
123
141
|
};
|
|
124
142
|
exports._getCoinDecimals = _getCoinDecimals;
|
|
125
143
|
var _getBalances = function (coins, addresses) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -263,7 +281,7 @@ var hasAllowance = function (coins, amounts, address, spender) { return __awaite
|
|
|
263
281
|
return [4 /*yield*/, (0, exports._getAllowance)(coinAddresses, address, spender)];
|
|
264
282
|
case 1:
|
|
265
283
|
_allowance = _a.sent();
|
|
266
|
-
_amounts = amounts.map(function (a, i) { return
|
|
284
|
+
_amounts = amounts.map(function (a, i) { return (0, exports.parseUnits)(a, decimals[i]); });
|
|
267
285
|
return [2 /*return*/, _allowance.map(function (a, i) { return a.gte(_amounts[i]); }).reduce(function (a, b) { return a && b; })];
|
|
268
286
|
}
|
|
269
287
|
});
|
|
@@ -321,7 +339,7 @@ var ensureAllowanceEstimateGas = function (coins, amounts, spender) { return __a
|
|
|
321
339
|
case 0:
|
|
322
340
|
coinAddresses = (0, exports._getCoinAddresses)(coins);
|
|
323
341
|
decimals = (0, exports._getCoinDecimals)(coinAddresses);
|
|
324
|
-
_amounts = amounts.map(function (a, i) { return
|
|
342
|
+
_amounts = amounts.map(function (a, i) { return (0, exports.parseUnits)(a, decimals[i]); });
|
|
325
343
|
address = curve_1.curve.signerAddress;
|
|
326
344
|
return [4 /*yield*/, (0, exports._getAllowance)(coinAddresses, address, spender)];
|
|
327
345
|
case 1:
|
|
@@ -361,7 +379,7 @@ var ensureAllowance = function (coins, amounts, spender) { return __awaiter(void
|
|
|
361
379
|
case 0:
|
|
362
380
|
coinAddresses = (0, exports._getCoinAddresses)(coins);
|
|
363
381
|
decimals = (0, exports._getCoinDecimals)(coinAddresses);
|
|
364
|
-
_amounts = amounts.map(function (a, i) { return
|
|
382
|
+
_amounts = amounts.map(function (a, i) { return (0, exports.parseUnits)(a, decimals[i]); });
|
|
365
383
|
return [4 /*yield*/, (0, exports._ensureAllowance)(coinAddresses, _amounts, spender)];
|
|
366
384
|
case 1: return [2 /*return*/, _a.sent()];
|
|
367
385
|
}
|
|
@@ -369,7 +387,8 @@ var ensureAllowance = function (coins, amounts, spender) { return __awaiter(void
|
|
|
369
387
|
}); };
|
|
370
388
|
exports.ensureAllowance = ensureAllowance;
|
|
371
389
|
var getPoolNameBySwapAddress = function (swapAddress) {
|
|
372
|
-
|
|
390
|
+
var poolsData = __assign(__assign(__assign({}, curve_1.curve.constants.POOLS_DATA), curve_1.curve.constants.FACTORY_POOLS_DATA), curve_1.curve.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
391
|
+
return Object.entries(poolsData).filter(function (_a) {
|
|
373
392
|
var _ = _a[0], poolData = _a[1];
|
|
374
393
|
return poolData.swap_address.toLowerCase() === swapAddress.toLowerCase();
|
|
375
394
|
})[0][0];
|
|
@@ -424,7 +443,7 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
|
|
|
424
443
|
pricesFromApi = _c.sent();
|
|
425
444
|
if (assetId.toLowerCase() in pricesFromApi)
|
|
426
445
|
return [2 /*return*/, pricesFromApi[assetId.toLowerCase()]];
|
|
427
|
-
if (assetId === 'USD' || (curve_1.curve.chainId === 137 && (assetId.toLowerCase() ===
|
|
446
|
+
if (assetId === 'USD' || (curve_1.curve.chainId === 137 && (assetId.toLowerCase() === curve_1.curve.constants.COINS.am3crv.toLowerCase())))
|
|
428
447
|
return [2 /*return*/, 1];
|
|
429
448
|
chainName = {
|
|
430
449
|
1: 'ethereum',
|
|
@@ -435,14 +454,14 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
|
|
|
435
454
|
throw Error('curve object is not initialized');
|
|
436
455
|
}
|
|
437
456
|
assetId = {
|
|
438
|
-
'EUR':
|
|
457
|
+
'EUR': curve_1.curve.constants.COINS.eurt,
|
|
439
458
|
'BTC': 'bitcoin',
|
|
440
459
|
'ETH': 'ethereum',
|
|
441
460
|
'LINK': 'link',
|
|
442
461
|
}[assetId] || assetId;
|
|
443
462
|
assetId = (0, exports.isEth)(assetId) ? "ethereum" : assetId.toLowerCase();
|
|
444
463
|
// No EURT on Coingecko Polygon
|
|
445
|
-
if (assetId.toLowerCase() ===
|
|
464
|
+
if (assetId.toLowerCase() === curve_1.curve.constants.COINS.eurt.toLowerCase()) {
|
|
446
465
|
chainName = 'ethereum';
|
|
447
466
|
assetId = '0xC581b735A1688071A1746c968e0798D642EDE491'.toLowerCase(); // EURT Ethereum
|
|
448
467
|
}
|
|
@@ -465,118 +484,6 @@ var _getUsdRate = function (assetId) { return __awaiter(void 0, void 0, void 0,
|
|
|
465
484
|
});
|
|
466
485
|
}); };
|
|
467
486
|
exports._getUsdRate = _getUsdRate;
|
|
468
|
-
var _getFactoryStatsUrl = function () {
|
|
469
|
-
if (curve_1.curve.chainId === 1 || curve_1.curve.chainId === 1337) {
|
|
470
|
-
return "https://curve-api-hplkiejxx-curvefi.vercel.app/api/getSubgraphData";
|
|
471
|
-
}
|
|
472
|
-
else if (curve_1.curve.chainId === 137) {
|
|
473
|
-
return "https://api.curve.fi/api/getFactoryAPYs-polygon";
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
throw Error("Unsupported network id".concat(curve_1.curve.chainId));
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
exports._getFactoryStatsUrl = _getFactoryStatsUrl;
|
|
480
|
-
var _getStatsUrl = function (isCrypto) {
|
|
481
|
-
if (isCrypto === void 0) { isCrypto = false; }
|
|
482
|
-
if (curve_1.curve.chainId === 1 || curve_1.curve.chainId === 1337) {
|
|
483
|
-
return isCrypto ? "https://stats.curve.fi/raw-stats-crypto/apys.json" : "https://stats.curve.fi/raw-stats/apys.json";
|
|
484
|
-
}
|
|
485
|
-
else if (curve_1.curve.chainId === 137) {
|
|
486
|
-
return "https://stats.curve.fi/raw-stats-polygon/apys.json";
|
|
487
|
-
}
|
|
488
|
-
else {
|
|
489
|
-
throw Error("Unsupported network id".concat(curve_1.curve.chainId));
|
|
490
|
-
}
|
|
491
|
-
};
|
|
492
|
-
exports._getStatsUrl = _getStatsUrl;
|
|
493
|
-
exports._getStats = (0, memoizee_1.default)(function (statsUrl) { return __awaiter(void 0, void 0, void 0, function () {
|
|
494
|
-
var rawData, data;
|
|
495
|
-
return __generator(this, function (_a) {
|
|
496
|
-
switch (_a.label) {
|
|
497
|
-
case 0: return [4 /*yield*/, axios_1.default.get(statsUrl)];
|
|
498
|
-
case 1:
|
|
499
|
-
rawData = (_a.sent()).data;
|
|
500
|
-
data = {};
|
|
501
|
-
Object.keys(rawData.apy.day).forEach(function (poolName) {
|
|
502
|
-
var _a;
|
|
503
|
-
data[poolName] = {
|
|
504
|
-
volume: (_a = rawData.volume[poolName]) !== null && _a !== void 0 ? _a : 0,
|
|
505
|
-
apy: {
|
|
506
|
-
day: rawData.apy.day[poolName],
|
|
507
|
-
week: rawData.apy.week[poolName],
|
|
508
|
-
month: rawData.apy.month[poolName],
|
|
509
|
-
total: rawData.apy.total[poolName],
|
|
510
|
-
},
|
|
511
|
-
};
|
|
512
|
-
});
|
|
513
|
-
return [2 /*return*/, data];
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
}); }, {
|
|
517
|
-
promise: true,
|
|
518
|
-
maxAge: 10 * 60 * 1000, // 10m
|
|
519
|
-
});
|
|
520
|
-
exports._getFactoryStatsEthereum = (0, memoizee_1.default)(function (statsUrl) { return __awaiter(void 0, void 0, void 0, function () {
|
|
521
|
-
var rawData, data;
|
|
522
|
-
return __generator(this, function (_a) {
|
|
523
|
-
switch (_a.label) {
|
|
524
|
-
case 0: return [4 /*yield*/, axios_1.default.get(statsUrl)];
|
|
525
|
-
case 1:
|
|
526
|
-
rawData = (_a.sent()).data.data.poolList;
|
|
527
|
-
data = {};
|
|
528
|
-
rawData.forEach(function (item) {
|
|
529
|
-
var _a, _b, _c, _d, _e;
|
|
530
|
-
data[item.address.toLowerCase()] = {
|
|
531
|
-
volume: (_a = item.volumeUSD) !== null && _a !== void 0 ? _a : 0,
|
|
532
|
-
apy: {
|
|
533
|
-
day: (_b = item.latestDailyApy) !== null && _b !== void 0 ? _b : 0,
|
|
534
|
-
week: (_c = item.latestWeeklyApy) !== null && _c !== void 0 ? _c : 0,
|
|
535
|
-
month: (_d = item.latestWeeklyApy) !== null && _d !== void 0 ? _d : 0,
|
|
536
|
-
total: (_e = item.latestWeeklyApy) !== null && _e !== void 0 ? _e : 0,
|
|
537
|
-
},
|
|
538
|
-
};
|
|
539
|
-
});
|
|
540
|
-
return [2 /*return*/, data];
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
}); }, {
|
|
544
|
-
promise: true,
|
|
545
|
-
maxAge: 10 * 60 * 1000, // 10m
|
|
546
|
-
});
|
|
547
|
-
exports._getFactoryStatsPolygon = (0, memoizee_1.default)(function (statsUrl) { return __awaiter(void 0, void 0, void 0, function () {
|
|
548
|
-
var rawData, data;
|
|
549
|
-
return __generator(this, function (_a) {
|
|
550
|
-
switch (_a.label) {
|
|
551
|
-
case 0: return [4 /*yield*/, axios_1.default.get(statsUrl)];
|
|
552
|
-
case 1:
|
|
553
|
-
rawData = (_a.sent()).data.data.poolDetails;
|
|
554
|
-
data = {};
|
|
555
|
-
rawData.forEach(function (item) {
|
|
556
|
-
var _a, _b, _c, _d, _e;
|
|
557
|
-
data[item.poolAddress.toLowerCase()] = {
|
|
558
|
-
volume: (_a = item.volume) !== null && _a !== void 0 ? _a : 0,
|
|
559
|
-
apy: {
|
|
560
|
-
day: (_b = item.apy) !== null && _b !== void 0 ? _b : 0,
|
|
561
|
-
week: (_c = item.apy) !== null && _c !== void 0 ? _c : 0,
|
|
562
|
-
month: (_d = item.apy) !== null && _d !== void 0 ? _d : 0,
|
|
563
|
-
total: (_e = item.apy) !== null && _e !== void 0 ? _e : 0,
|
|
564
|
-
},
|
|
565
|
-
};
|
|
566
|
-
});
|
|
567
|
-
return [2 /*return*/, data];
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
}); }, {
|
|
571
|
-
promise: true,
|
|
572
|
-
maxAge: 10 * 60 * 1000, // 10m
|
|
573
|
-
});
|
|
574
|
-
var getPoolList = function () { return Object.keys(curve_1.POOLS_DATA); };
|
|
575
|
-
exports.getPoolList = getPoolList;
|
|
576
|
-
var getFactoryPoolList = function () { return Object.keys(curve_1.curve.constants.FACTORY_POOLS_DATA); };
|
|
577
|
-
exports.getFactoryPoolList = getFactoryPoolList;
|
|
578
|
-
var getCryptoFactoryPoolList = function () { return Object.keys(curve_1.curve.constants.CRYPTO_FACTORY_POOLS_DATA); };
|
|
579
|
-
exports.getCryptoFactoryPoolList = getCryptoFactoryPoolList;
|
|
580
487
|
var getUsdRate = function (coin) { return __awaiter(void 0, void 0, void 0, function () {
|
|
581
488
|
var coinAddress;
|
|
582
489
|
return __generator(this, function (_a) {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{ "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": true, "inputs": [], "name": "adai", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], "name": "claim", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [{ "internalType": "address", "name": "_claimer", "type": "address" }], "name": "claimable", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "governance", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "internalType": "address", "name": "_token", "type": "address" }, { "internalType": "uint256", "name": "_amount", "type": "uint256" }], "name": "seize", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "yfi", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }]
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"outputs": [],
|
|
4
|
-
"inputs": [
|
|
5
|
-
{
|
|
6
|
-
"type": "address",
|
|
7
|
-
"name": "_old"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"type": "address",
|
|
11
|
-
"name": "_old_token"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"type": "address",
|
|
15
|
-
"name": "_new"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"type": "address",
|
|
19
|
-
"name": "_new_token"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"type": "address[2]",
|
|
23
|
-
"name": "_coins"
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
"constant": false,
|
|
27
|
-
"payable": false,
|
|
28
|
-
"type": "constructor"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"name": "migrate",
|
|
32
|
-
"outputs": [],
|
|
33
|
-
"inputs": [],
|
|
34
|
-
"constant": false,
|
|
35
|
-
"payable": false,
|
|
36
|
-
"type": "function",
|
|
37
|
-
"gas": "106812"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"name": "coins",
|
|
41
|
-
"outputs": [
|
|
42
|
-
{
|
|
43
|
-
"type": "address",
|
|
44
|
-
"name": "out"
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
"inputs": [
|
|
48
|
-
{
|
|
49
|
-
"type": "int128",
|
|
50
|
-
"name": "arg0"
|
|
51
|
-
}
|
|
52
|
-
],
|
|
53
|
-
"stateMutability": "view",
|
|
54
|
-
"type": "function",
|
|
55
|
-
"gas": "1380"
|
|
56
|
-
}
|
|
57
|
-
]
|