@curvefi/api 1.25.0 → 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} +53 -81
- 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 +189 -232
- package/lib/external-api.d.ts +3 -1
- package/lib/external-api.js +34 -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 +52 -45
- 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 +35 -72
- 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 +43 -130
- 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 -4742
package/lib/curve.js
CHANGED
|
@@ -59,41 +59,49 @@ 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 =
|
|
62
|
+
exports.curve = void 0;
|
|
63
63
|
var ethers_1 = require("ethers");
|
|
64
64
|
var ethcall_1 = require("ethcall");
|
|
65
65
|
var factory_1 = require("./factory/factory");
|
|
66
66
|
var factory_api_1 = require("./factory/factory-api");
|
|
67
67
|
var factory_crypto_1 = require("./factory/factory-crypto");
|
|
68
|
-
var ERC20_json_1 = __importDefault(require("./constants/abis/
|
|
69
|
-
var cERC20_json_1 = __importDefault(require("./constants/abis/
|
|
70
|
-
var yERC20_json_1 = __importDefault(require("./constants/abis/
|
|
71
|
-
var minter_json_1 = __importDefault(require("./constants/abis/
|
|
72
|
-
var votingescrow_json_1 = __importDefault(require("./constants/abis/
|
|
73
|
-
var address_provider_json_1 = __importDefault(require("./constants/abis/
|
|
74
|
-
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/
|
|
75
|
-
var router_json_1 = __importDefault(require("./constants/abis/
|
|
76
|
-
var deposit_and_stake_json_1 = __importDefault(require("./constants/abis/
|
|
77
|
-
var registry_exchange_json_1 = __importDefault(require("./constants/abis/
|
|
78
|
-
var streamer_json_1 = __importDefault(require("./constants/abis/
|
|
79
|
-
var factory_json_1 = __importDefault(require("./constants/abis/
|
|
80
|
-
var factory_crypto_json_1 = __importDefault(require("./constants/abis/
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var coins_polygon_1 = require("./constants/coins-polygon");
|
|
68
|
+
var ERC20_json_1 = __importDefault(require("./constants/abis/ERC20.json"));
|
|
69
|
+
var cERC20_json_1 = __importDefault(require("./constants/abis/cERC20.json"));
|
|
70
|
+
var yERC20_json_1 = __importDefault(require("./constants/abis/yERC20.json"));
|
|
71
|
+
var minter_json_1 = __importDefault(require("./constants/abis/minter.json"));
|
|
72
|
+
var votingescrow_json_1 = __importDefault(require("./constants/abis/votingescrow.json"));
|
|
73
|
+
var address_provider_json_1 = __importDefault(require("./constants/abis/address_provider.json"));
|
|
74
|
+
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/gaugecontroller.json"));
|
|
75
|
+
var router_json_1 = __importDefault(require("./constants/abis/router.json"));
|
|
76
|
+
var deposit_and_stake_json_1 = __importDefault(require("./constants/abis/deposit_and_stake.json"));
|
|
77
|
+
var registry_exchange_json_1 = __importDefault(require("./constants/abis/registry_exchange.json"));
|
|
78
|
+
var streamer_json_1 = __importDefault(require("./constants/abis/streamer.json"));
|
|
79
|
+
var factory_json_1 = __importDefault(require("./constants/abis/factory.json"));
|
|
80
|
+
var factory_crypto_json_1 = __importDefault(require("./constants/abis/factory-crypto.json"));
|
|
81
|
+
var pools_1 = require("./constants/pools");
|
|
82
|
+
var ethereum_1 = require("./constants/coins/ethereum");
|
|
83
|
+
var polygon_1 = require("./constants/coins/polygon");
|
|
85
84
|
var aliases_1 = require("./constants/aliases");
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
var utils_1 = require("./constants/utils");
|
|
86
|
+
var CONSTANTS = {
|
|
87
|
+
1: {
|
|
88
|
+
ALIASES: aliases_1.ALIASES_ETHEREUM,
|
|
89
|
+
POOLS_DATA: pools_1.POOLS_DATA_ETHEREUM,
|
|
90
|
+
COINS: ethereum_1.COINS_ETHEREUM,
|
|
91
|
+
cTokens: ethereum_1.cTokensEthereum,
|
|
92
|
+
yTokens: ethereum_1.yTokensEthereum,
|
|
93
|
+
ycTokens: ethereum_1.ycTokensEthereum,
|
|
94
|
+
aTokens: ethereum_1.aTokensEthereum,
|
|
95
|
+
},
|
|
96
|
+
137: {
|
|
97
|
+
ALIASES: aliases_1.ALIASES_POLYGON,
|
|
98
|
+
POOLS_DATA: pools_1.POOLS_DATA_POLYGON,
|
|
99
|
+
COINS: polygon_1.COINS_POLYGON,
|
|
100
|
+
cTokens: polygon_1.cTokensPolygon,
|
|
101
|
+
yTokens: polygon_1.yTokensPolygon,
|
|
102
|
+
ycTokens: polygon_1.ycTokensPolygon,
|
|
103
|
+
aTokens: polygon_1.aTokensPolygon,
|
|
104
|
+
},
|
|
97
105
|
};
|
|
98
106
|
var Curve = /** @class */ (function () {
|
|
99
107
|
function Curve() {
|
|
@@ -109,16 +117,45 @@ var Curve = /** @class */ (function () {
|
|
|
109
117
|
this.feeData = {};
|
|
110
118
|
this.constantOptions = { gasLimit: 12000000 };
|
|
111
119
|
this.options = {};
|
|
112
|
-
this.constants = {
|
|
120
|
+
this.constants = {
|
|
121
|
+
ALIASES: {},
|
|
122
|
+
POOLS_DATA: {},
|
|
123
|
+
FACTORY_POOLS_DATA: {},
|
|
124
|
+
CRYPTO_FACTORY_POOLS_DATA: {},
|
|
125
|
+
COINS: {},
|
|
126
|
+
DECIMALS: {},
|
|
127
|
+
GAUGES: [],
|
|
128
|
+
};
|
|
113
129
|
}
|
|
114
130
|
Curve.prototype.init = function (providerType, providerSettings, options // gasPrice in Gwei
|
|
115
131
|
) {
|
|
116
132
|
if (options === void 0) { options = {}; }
|
|
117
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
-
var cTokens, yTokens, ycTokens, aTokens,
|
|
119
|
-
return __generator(this, function (
|
|
120
|
-
switch (
|
|
134
|
+
var network, _a, _b, cTokens, yTokens, ycTokens, aTokens, customAbiTokens, _c, _i, _d, pool, _e, _f, coinAddr, _g, _h, coinAddr, _j, _k, coinAddr, _l, _m, rewardTokenAddr, addressProviderContract, _o;
|
|
135
|
+
return __generator(this, function (_p) {
|
|
136
|
+
switch (_p.label) {
|
|
121
137
|
case 0:
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
this.provider = null;
|
|
140
|
+
// @ts-ignore
|
|
141
|
+
this.signer = null;
|
|
142
|
+
this.signerAddress = '';
|
|
143
|
+
this.chainId = 0;
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
this.multicallProvider = null;
|
|
146
|
+
this.contracts = {};
|
|
147
|
+
this.feeData = {};
|
|
148
|
+
this.constantOptions = { gasLimit: 12000000 };
|
|
149
|
+
this.options = {};
|
|
150
|
+
this.constants = {
|
|
151
|
+
ALIASES: {},
|
|
152
|
+
POOLS_DATA: {},
|
|
153
|
+
FACTORY_POOLS_DATA: {},
|
|
154
|
+
CRYPTO_FACTORY_POOLS_DATA: {},
|
|
155
|
+
COINS: {},
|
|
156
|
+
DECIMALS: {},
|
|
157
|
+
GAUGES: [],
|
|
158
|
+
};
|
|
122
159
|
// JsonRpc provider
|
|
123
160
|
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
124
161
|
providerSettings = providerSettings;
|
|
@@ -160,173 +197,100 @@ var Curve = /** @class */ (function () {
|
|
|
160
197
|
if (_a) return [3 /*break*/, 2];
|
|
161
198
|
return [4 /*yield*/, this.provider._networkPromise];
|
|
162
199
|
case 1:
|
|
163
|
-
_a = (
|
|
164
|
-
|
|
200
|
+
_a = (_p.sent());
|
|
201
|
+
_p.label = 2;
|
|
165
202
|
case 2:
|
|
166
203
|
network = _a;
|
|
167
204
|
console.log("CURVE-JS IS CONNECTED TO NETWORK:", network);
|
|
168
|
-
this.chainId = network.chainId;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
exports.LINK_COINS = coins_ethereum_1.LINK_COINS_ETHEREUM;
|
|
181
|
-
exports.LINK_COINS_LOWER_CASE = coins_ethereum_1.LINK_COINS_LOWER_CASE_ETHEREUM;
|
|
182
|
-
exports.EUR_COINS = coins_ethereum_1.EUR_COINS_ETHEREUM;
|
|
183
|
-
exports.EUR_COINS_LOWER_CASE = coins_ethereum_1.EUR_COINS_LOWER_CASE_ETHEREUM;
|
|
184
|
-
exports.USD_COINS = coins_ethereum_1.USD_COINS_ETHEREUM;
|
|
185
|
-
exports.USD_COINS_LOWER_CASE = coins_ethereum_1.USD_COINS_LOWER_CASE_ETHEREUM;
|
|
186
|
-
exports.COINS = coins_ethereum_1.COINS_ETHEREUM;
|
|
187
|
-
exports.DECIMALS = coins_ethereum_1.DECIMALS_ETHEREUM;
|
|
188
|
-
exports.DECIMALS_LOWER_CASE = coins_ethereum_1.DECIMALS_LOWER_CASE_ETHEREUM;
|
|
189
|
-
}
|
|
190
|
-
else if (network.chainId === 137) {
|
|
191
|
-
cTokens = coins_polygon_1.cTokensPolygon;
|
|
192
|
-
yTokens = coins_polygon_1.yTokensPolygon;
|
|
193
|
-
ycTokens = coins_polygon_1.ycTokensPolygon;
|
|
194
|
-
aTokens = coins_polygon_1.aTokensPolygon;
|
|
195
|
-
exports.ALIASES = aliases_1.ALIASES_POLYGON;
|
|
196
|
-
exports.POOLS_DATA = abis_polygon_1.POOLS_DATA_POLYGON;
|
|
197
|
-
exports.BTC_COINS = coins_polygon_1.BTC_COINS_POLYGON;
|
|
198
|
-
exports.BTC_COINS_LOWER_CASE = coins_polygon_1.BTC_COINS_LOWER_CASE_POLYGON;
|
|
199
|
-
exports.ETH_COINS = coins_polygon_1.ETH_COINS_POLYGON;
|
|
200
|
-
exports.ETH_COINS_LOWER_CASE = coins_polygon_1.ETH_COINS_LOWER_CASE_POLYGON;
|
|
201
|
-
exports.LINK_COINS = coins_polygon_1.LINK_COINS_POLYGON;
|
|
202
|
-
exports.LINK_COINS_LOWER_CASE = coins_polygon_1.LINK_COINS_LOWER_CASE_POLYGON;
|
|
203
|
-
exports.EUR_COINS = coins_polygon_1.EUR_COINS_POLYGON;
|
|
204
|
-
exports.EUR_COINS_LOWER_CASE = coins_polygon_1.EUR_COINS_LOWER_CASE_POLYGON;
|
|
205
|
-
exports.USD_COINS = coins_polygon_1.USD_COINS_POLYGON;
|
|
206
|
-
exports.USD_COINS_LOWER_CASE = coins_polygon_1.USD_COINS_LOWER_CASE_POLYGON;
|
|
207
|
-
exports.COINS = coins_polygon_1.COINS_POLYGON;
|
|
208
|
-
exports.DECIMALS = coins_polygon_1.DECIMALS_POLYGON;
|
|
209
|
-
exports.DECIMALS_LOWER_CASE = coins_polygon_1.DECIMALS_LOWER_CASE_POLYGON;
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
throw Error("Network with chainId ".concat(this.provider.network.chainId, " is not supported"));
|
|
213
|
-
}
|
|
214
|
-
exports.LP_TOKENS = Object.values(exports.POOLS_DATA).map(function (data) { return data.token_address.toLowerCase(); });
|
|
215
|
-
exports.GAUGES = Object.values(exports.POOLS_DATA).map(function (data) { return data.gauge_address.toLowerCase(); });
|
|
205
|
+
this.chainId = network.chainId === 1337 ? 1 : network.chainId;
|
|
206
|
+
this.constants.ALIASES = CONSTANTS[this.chainId].ALIASES;
|
|
207
|
+
this.constants.POOLS_DATA = CONSTANTS[this.chainId].POOLS_DATA;
|
|
208
|
+
this.constants.COINS = CONSTANTS[this.chainId].COINS;
|
|
209
|
+
this.constants.DECIMALS = (0, utils_1.extractDecimals)(this.constants.POOLS_DATA);
|
|
210
|
+
this.constants.GAUGES = (0, utils_1.extractGauges)(this.constants.POOLS_DATA);
|
|
211
|
+
_b = [
|
|
212
|
+
CONSTANTS[this.chainId].cTokens,
|
|
213
|
+
CONSTANTS[this.chainId].yTokens,
|
|
214
|
+
CONSTANTS[this.chainId].ycTokens,
|
|
215
|
+
CONSTANTS[this.chainId].aTokens,
|
|
216
|
+
], cTokens = _b[0], yTokens = _b[1], ycTokens = _b[2], aTokens = _b[3];
|
|
216
217
|
customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
|
|
217
218
|
this.multicallProvider = new ethcall_1.Provider();
|
|
218
219
|
return [4 /*yield*/, this.multicallProvider.init(this.provider)];
|
|
219
220
|
case 3:
|
|
220
|
-
|
|
221
|
+
_p.sent();
|
|
221
222
|
if (!this.signer) return [3 /*break*/, 5];
|
|
222
|
-
|
|
223
|
+
_c = this;
|
|
223
224
|
return [4 /*yield*/, this.signer.getAddress()];
|
|
224
225
|
case 4:
|
|
225
|
-
|
|
226
|
+
_c.signerAddress = _p.sent();
|
|
226
227
|
return [3 /*break*/, 6];
|
|
227
228
|
case 5:
|
|
228
229
|
this.signerAddress = '';
|
|
229
|
-
|
|
230
|
+
_p.label = 6;
|
|
230
231
|
case 6:
|
|
231
232
|
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
232
233
|
return [4 /*yield*/, this.updateFeeData()];
|
|
233
234
|
case 7:
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
pool = _c[_i];
|
|
235
|
+
_p.sent();
|
|
236
|
+
for (_i = 0, _d = Object.values(this.constants.POOLS_DATA); _i < _d.length; _i++) {
|
|
237
|
+
pool = _d[_i];
|
|
238
238
|
this.contracts[pool.swap_address] = {
|
|
239
239
|
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
240
240
|
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
241
241
|
};
|
|
242
|
-
this.contracts[pool.swap_address.toLowerCase()] = {
|
|
243
|
-
contract: new ethers_1.Contract(pool.swap_address, pool.swap_abi, this.signer || this.provider),
|
|
244
|
-
multicallContract: new ethcall_1.Contract(pool.swap_address, pool.swap_abi),
|
|
245
|
-
};
|
|
246
242
|
if (pool.token_address !== pool.swap_address) {
|
|
247
243
|
this.contracts[pool.token_address] = {
|
|
248
244
|
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
249
245
|
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
250
246
|
};
|
|
251
|
-
this.contracts[pool.token_address.toLowerCase()] = {
|
|
252
|
-
contract: new ethers_1.Contract(pool.token_address, ERC20_json_1.default, this.signer || this.provider),
|
|
253
|
-
multicallContract: new ethcall_1.Contract(pool.token_address, ERC20_json_1.default),
|
|
254
|
-
};
|
|
255
247
|
}
|
|
256
248
|
this.contracts[pool.gauge_address] = {
|
|
257
249
|
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
258
250
|
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
259
251
|
};
|
|
260
|
-
this.contracts[pool.
|
|
261
|
-
contract: new ethers_1.Contract(pool.gauge_address, pool.gauge_abi, this.signer || this.provider),
|
|
262
|
-
multicallContract: new ethcall_1.Contract(pool.gauge_address, pool.gauge_abi),
|
|
263
|
-
};
|
|
264
|
-
if (pool.deposit_address && this.contracts[pool.deposit_address] === undefined) {
|
|
252
|
+
if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
|
|
265
253
|
this.contracts[pool.deposit_address] = {
|
|
266
254
|
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
267
255
|
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
268
256
|
};
|
|
269
|
-
this.contracts[pool.deposit_address.toLowerCase()] = {
|
|
270
|
-
contract: new ethers_1.Contract(pool.deposit_address, pool.deposit_abi, this.signer || this.provider),
|
|
271
|
-
multicallContract: new ethcall_1.Contract(pool.deposit_address, pool.deposit_abi),
|
|
272
|
-
};
|
|
273
257
|
}
|
|
274
|
-
for (
|
|
275
|
-
coinAddr = _e
|
|
258
|
+
for (_e = 0, _f = pool.underlying_coin_addresses; _e < _f.length; _e++) {
|
|
259
|
+
coinAddr = _f[_e];
|
|
276
260
|
this.contracts[coinAddr] = {
|
|
277
261
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
278
262
|
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
279
263
|
};
|
|
280
|
-
this.contracts[coinAddr.toLowerCase()] = {
|
|
281
|
-
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
282
|
-
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
283
|
-
};
|
|
284
264
|
}
|
|
285
|
-
for (
|
|
286
|
-
coinAddr = _g
|
|
265
|
+
for (_g = 0, _h = pool.wrapped_coin_addresses; _g < _h.length; _g++) {
|
|
266
|
+
coinAddr = _h[_g];
|
|
287
267
|
if (customAbiTokens.includes(coinAddr))
|
|
288
268
|
continue;
|
|
289
269
|
this.contracts[coinAddr] = {
|
|
290
270
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
291
271
|
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
292
272
|
};
|
|
293
|
-
this.contracts[coinAddr.toLowerCase()] = {
|
|
294
|
-
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
295
|
-
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
296
|
-
};
|
|
297
273
|
}
|
|
298
274
|
// TODO add all coins
|
|
299
|
-
for (
|
|
300
|
-
coinAddr = _j
|
|
275
|
+
for (_j = 0, _k = pool.wrapped_coin_addresses; _j < _k.length; _j++) {
|
|
276
|
+
coinAddr = _k[_j];
|
|
301
277
|
if (cTokens.includes(coinAddr)) {
|
|
302
278
|
this.contracts[coinAddr] = {
|
|
303
279
|
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
304
280
|
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
305
281
|
};
|
|
306
|
-
this.contracts[coinAddr.toLowerCase()] = {
|
|
307
|
-
contract: new ethers_1.Contract(coinAddr, cERC20_json_1.default, this.signer || this.provider),
|
|
308
|
-
multicallContract: new ethcall_1.Contract(coinAddr, cERC20_json_1.default),
|
|
309
|
-
};
|
|
310
282
|
}
|
|
311
283
|
if (aTokens.includes(coinAddr)) {
|
|
312
284
|
this.contracts[coinAddr] = {
|
|
313
285
|
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
314
286
|
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
315
287
|
};
|
|
316
|
-
this.contracts[coinAddr.toLowerCase()] = {
|
|
317
|
-
contract: new ethers_1.Contract(coinAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
318
|
-
multicallContract: new ethcall_1.Contract(coinAddr, ERC20_json_1.default),
|
|
319
|
-
};
|
|
320
288
|
}
|
|
321
289
|
if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
|
|
322
290
|
this.contracts[coinAddr] = {
|
|
323
291
|
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
324
292
|
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
325
293
|
};
|
|
326
|
-
this.contracts[coinAddr.toLowerCase()] = {
|
|
327
|
-
contract: new ethers_1.Contract(coinAddr, yERC20_json_1.default, this.signer || this.provider),
|
|
328
|
-
multicallContract: new ethcall_1.Contract(coinAddr, yERC20_json_1.default),
|
|
329
|
-
};
|
|
330
294
|
}
|
|
331
295
|
}
|
|
332
296
|
if (pool.reward_contract) {
|
|
@@ -334,116 +298,99 @@ var Curve = /** @class */ (function () {
|
|
|
334
298
|
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
335
299
|
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
336
300
|
};
|
|
337
|
-
this.contracts[pool.reward_contract.toLowerCase()] = {
|
|
338
|
-
contract: new ethers_1.Contract(pool.reward_contract, streamer_json_1.default, this.signer || this.provider),
|
|
339
|
-
multicallContract: new ethcall_1.Contract(pool.reward_contract, streamer_json_1.default),
|
|
340
|
-
};
|
|
341
301
|
}
|
|
342
|
-
for (
|
|
343
|
-
rewardTokenAddr = _l
|
|
302
|
+
for (_l = 0, _m = pool.reward_tokens || []; _l < _m.length; _l++) {
|
|
303
|
+
rewardTokenAddr = _m[_l];
|
|
344
304
|
this.contracts[rewardTokenAddr] = {
|
|
345
305
|
contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
346
306
|
multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
|
|
347
307
|
};
|
|
348
|
-
this.contracts[rewardTokenAddr.toLowerCase()] = {
|
|
349
|
-
contract: new ethers_1.Contract(rewardTokenAddr, ERC20_json_1.default, this.signer || this.provider),
|
|
350
|
-
multicallContract: new ethcall_1.Contract(rewardTokenAddr, ERC20_json_1.default),
|
|
351
|
-
};
|
|
352
308
|
}
|
|
353
309
|
}
|
|
354
|
-
this.contracts[
|
|
355
|
-
contract: new ethers_1.Contract(
|
|
356
|
-
multicallContract: new ethcall_1.Contract(
|
|
310
|
+
this.contracts[this.constants.ALIASES.crv] = {
|
|
311
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
312
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.crv, ERC20_json_1.default),
|
|
357
313
|
};
|
|
358
|
-
this.contracts[
|
|
359
|
-
contract: new ethers_1.Contract(
|
|
360
|
-
multicallContract: new ethcall_1.Contract(
|
|
314
|
+
this.contracts[this.constants.ALIASES.crv.toLowerCase()] = {
|
|
315
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.crv, ERC20_json_1.default, this.signer || this.provider),
|
|
316
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.crv, ERC20_json_1.default),
|
|
361
317
|
};
|
|
362
|
-
this.contracts[
|
|
363
|
-
contract: new ethers_1.Contract(
|
|
364
|
-
multicallContract: new ethcall_1.Contract(
|
|
318
|
+
this.contracts[this.constants.ALIASES.minter] = {
|
|
319
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.minter, minter_json_1.default, this.signer || this.provider),
|
|
320
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.minter, minter_json_1.default),
|
|
365
321
|
};
|
|
366
|
-
this.contracts[
|
|
367
|
-
contract: new ethers_1.Contract(
|
|
368
|
-
multicallContract: new ethcall_1.Contract(
|
|
322
|
+
this.contracts[this.constants.ALIASES.minter.toLowerCase()] = {
|
|
323
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.minter, minter_json_1.default, this.signer || this.provider),
|
|
324
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.minter, minter_json_1.default),
|
|
369
325
|
};
|
|
370
|
-
this.contracts[
|
|
371
|
-
contract: new ethers_1.Contract(
|
|
372
|
-
multicallContract: new ethcall_1.Contract(
|
|
326
|
+
this.contracts[this.constants.ALIASES.voting_escrow] = {
|
|
327
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
328
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
373
329
|
};
|
|
374
|
-
this.contracts[
|
|
375
|
-
contract: new ethers_1.Contract(
|
|
376
|
-
multicallContract: new ethcall_1.Contract(
|
|
330
|
+
this.contracts[this.constants.ALIASES.voting_escrow.toLowerCase()] = {
|
|
331
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default, this.signer || this.provider),
|
|
332
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default),
|
|
377
333
|
};
|
|
378
|
-
this.contracts[
|
|
379
|
-
contract: new ethers_1.Contract(
|
|
380
|
-
multicallContract: new ethcall_1.Contract(
|
|
334
|
+
this.contracts[this.constants.ALIASES.address_provider] = {
|
|
335
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
336
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default),
|
|
381
337
|
};
|
|
382
|
-
this.contracts[
|
|
383
|
-
contract: new ethers_1.Contract(
|
|
384
|
-
multicallContract: new ethcall_1.Contract(
|
|
338
|
+
this.contracts[this.constants.ALIASES.address_provider.toLowerCase()] = {
|
|
339
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default, this.signer || this.provider),
|
|
340
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.address_provider, address_provider_json_1.default),
|
|
385
341
|
};
|
|
386
|
-
addressProviderContract = this.contracts[
|
|
387
|
-
|
|
342
|
+
addressProviderContract = this.contracts[this.constants.ALIASES.address_provider].contract;
|
|
343
|
+
_o = this.constants.ALIASES;
|
|
388
344
|
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
389
345
|
case 8:
|
|
390
|
-
|
|
391
|
-
this.contracts[
|
|
392
|
-
contract: new ethers_1.Contract(
|
|
393
|
-
multicallContract: new ethcall_1.Contract(
|
|
346
|
+
_o.registry_exchange = _p.sent();
|
|
347
|
+
this.contracts[this.constants.ALIASES.registry_exchange] = {
|
|
348
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
349
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
394
350
|
};
|
|
395
|
-
this.contracts[
|
|
396
|
-
contract: new ethers_1.Contract(
|
|
397
|
-
multicallContract: new ethcall_1.Contract(
|
|
351
|
+
this.contracts[this.constants.ALIASES.registry_exchange.toLowerCase()] = {
|
|
352
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.registry_exchange, registry_exchange_json_1.default, this.signer || this.provider),
|
|
353
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.registry_exchange, registry_exchange_json_1.default),
|
|
398
354
|
};
|
|
399
|
-
this.contracts[
|
|
400
|
-
contract: new ethers_1.Contract(
|
|
401
|
-
multicallContract: new ethcall_1.Contract(
|
|
355
|
+
this.contracts[this.constants.ALIASES.gauge_controller] = {
|
|
356
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
357
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
402
358
|
};
|
|
403
|
-
this.contracts[
|
|
404
|
-
contract: new ethers_1.Contract(
|
|
405
|
-
multicallContract: new ethcall_1.Contract(
|
|
359
|
+
this.contracts[this.constants.ALIASES.gauge_controller.toLowerCase()] = {
|
|
360
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default, this.signer || this.provider),
|
|
361
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default),
|
|
406
362
|
};
|
|
407
|
-
this.contracts[
|
|
408
|
-
contract: new ethers_1.Contract(
|
|
409
|
-
multicallContract: new ethcall_1.Contract(
|
|
363
|
+
this.contracts[this.constants.ALIASES.router] = {
|
|
364
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.router, router_json_1.default, this.signer || this.provider),
|
|
365
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.router, router_json_1.default),
|
|
410
366
|
};
|
|
411
|
-
this.contracts[
|
|
412
|
-
contract: new ethers_1.Contract(
|
|
413
|
-
multicallContract: new ethcall_1.Contract(
|
|
367
|
+
this.contracts[this.constants.ALIASES.router.toLowerCase()] = {
|
|
368
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.router, router_json_1.default, this.signer || this.provider),
|
|
369
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.router, router_json_1.default),
|
|
414
370
|
};
|
|
415
|
-
this.contracts[
|
|
416
|
-
contract: new ethers_1.Contract(
|
|
417
|
-
multicallContract: new ethcall_1.Contract(
|
|
371
|
+
this.contracts[this.constants.ALIASES.deposit_and_stake] = {
|
|
372
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default, this.signer || this.provider),
|
|
373
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default),
|
|
418
374
|
};
|
|
419
|
-
this.contracts[
|
|
420
|
-
contract: new ethers_1.Contract(
|
|
421
|
-
multicallContract: new ethcall_1.Contract(
|
|
375
|
+
this.contracts[this.constants.ALIASES.deposit_and_stake.toLowerCase()] = {
|
|
376
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default, this.signer || this.provider),
|
|
377
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default),
|
|
422
378
|
};
|
|
423
|
-
this.contracts[
|
|
424
|
-
contract: new ethers_1.Contract(
|
|
425
|
-
multicallContract: new ethcall_1.Contract(
|
|
379
|
+
this.contracts[this.constants.ALIASES.factory] = {
|
|
380
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.factory, factory_json_1.default, this.signer || this.provider),
|
|
381
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.factory, factory_json_1.default),
|
|
426
382
|
};
|
|
427
|
-
this.contracts[
|
|
428
|
-
contract: new ethers_1.Contract(
|
|
429
|
-
multicallContract: new ethcall_1.Contract(
|
|
383
|
+
this.contracts[this.constants.ALIASES.factory.toLowerCase()] = {
|
|
384
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.factory, factory_json_1.default, this.signer || this.provider),
|
|
385
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.factory, factory_json_1.default),
|
|
430
386
|
};
|
|
431
|
-
this.contracts[
|
|
432
|
-
contract: new ethers_1.Contract(
|
|
433
|
-
multicallContract: new ethcall_1.Contract(
|
|
387
|
+
this.contracts[this.constants.ALIASES.crypto_factory] = {
|
|
388
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default, this.signer || this.provider),
|
|
389
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default),
|
|
434
390
|
};
|
|
435
|
-
this.contracts[
|
|
436
|
-
contract: new ethers_1.Contract(
|
|
437
|
-
multicallContract: new ethcall_1.Contract(
|
|
438
|
-
};
|
|
439
|
-
this.constants = {
|
|
440
|
-
ALIASES: exports.ALIASES,
|
|
441
|
-
POOLS_DATA: exports.POOLS_DATA,
|
|
442
|
-
DECIMALS_LOWER_CASE: exports.DECIMALS_LOWER_CASE,
|
|
443
|
-
LP_TOKENS: exports.LP_TOKENS,
|
|
444
|
-
GAUGES: exports.GAUGES,
|
|
445
|
-
FACTORY_POOLS_DATA: [],
|
|
446
|
-
CRYPTO_FACTORY_POOLS_DATA: [],
|
|
391
|
+
this.contracts[this.constants.ALIASES.crypto_factory.toLowerCase()] = {
|
|
392
|
+
contract: new ethers_1.Contract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default, this.signer || this.provider),
|
|
393
|
+
multicallContract: new ethcall_1.Contract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default),
|
|
447
394
|
};
|
|
448
395
|
return [2 /*return*/];
|
|
449
396
|
}
|
|
@@ -453,23 +400,28 @@ var Curve = /** @class */ (function () {
|
|
|
453
400
|
Curve.prototype.fetchFactoryPools = function (useApi) {
|
|
454
401
|
if (useApi === void 0) { useApi = true; }
|
|
455
402
|
return __awaiter(this, void 0, void 0, function () {
|
|
456
|
-
var _a, _b;
|
|
457
|
-
return __generator(this, function (
|
|
458
|
-
switch (
|
|
403
|
+
var _a, _b, _c, _d;
|
|
404
|
+
return __generator(this, function (_e) {
|
|
405
|
+
switch (_e.label) {
|
|
459
406
|
case 0:
|
|
460
407
|
if (!useApi) return [3 /*break*/, 2];
|
|
461
408
|
_a = this.constants;
|
|
409
|
+
_b = utils_1.lowerCasePoolDataAddresses;
|
|
462
410
|
return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, false)];
|
|
463
411
|
case 1:
|
|
464
|
-
_a.FACTORY_POOLS_DATA =
|
|
412
|
+
_a.FACTORY_POOLS_DATA = _b.apply(void 0, [_e.sent()]);
|
|
465
413
|
return [3 /*break*/, 4];
|
|
466
414
|
case 2:
|
|
467
|
-
|
|
415
|
+
_c = this.constants;
|
|
416
|
+
_d = utils_1.lowerCasePoolDataAddresses;
|
|
468
417
|
return [4 /*yield*/, factory_1.getFactoryPoolData.call(this)];
|
|
469
418
|
case 3:
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
case 4:
|
|
419
|
+
_c.FACTORY_POOLS_DATA = _d.apply(void 0, [_e.sent()]);
|
|
420
|
+
_e.label = 4;
|
|
421
|
+
case 4:
|
|
422
|
+
this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.FACTORY_POOLS_DATA));
|
|
423
|
+
this.constants.GAUGES = __assign(__assign({}, this.constants.GAUGES), (0, utils_1.extractGauges)(this.constants.FACTORY_POOLS_DATA));
|
|
424
|
+
return [2 /*return*/];
|
|
473
425
|
}
|
|
474
426
|
});
|
|
475
427
|
});
|
|
@@ -477,25 +429,30 @@ var Curve = /** @class */ (function () {
|
|
|
477
429
|
Curve.prototype.fetchCryptoFactoryPools = function (useApi) {
|
|
478
430
|
if (useApi === void 0) { useApi = true; }
|
|
479
431
|
return __awaiter(this, void 0, void 0, function () {
|
|
480
|
-
var _a, _b;
|
|
481
|
-
return __generator(this, function (
|
|
482
|
-
switch (
|
|
432
|
+
var _a, _b, _c, _d;
|
|
433
|
+
return __generator(this, function (_e) {
|
|
434
|
+
switch (_e.label) {
|
|
483
435
|
case 0:
|
|
484
436
|
if (this.chainId !== 1 && this.chainId !== 1337)
|
|
485
437
|
return [2 /*return*/];
|
|
486
438
|
if (!useApi) return [3 /*break*/, 2];
|
|
487
439
|
_a = this.constants;
|
|
440
|
+
_b = utils_1.lowerCasePoolDataAddresses;
|
|
488
441
|
return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, true)];
|
|
489
442
|
case 1:
|
|
490
|
-
_a.CRYPTO_FACTORY_POOLS_DATA =
|
|
443
|
+
_a.CRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_e.sent()]);
|
|
491
444
|
return [3 /*break*/, 4];
|
|
492
445
|
case 2:
|
|
493
|
-
|
|
446
|
+
_c = this.constants;
|
|
447
|
+
_d = utils_1.lowerCasePoolDataAddresses;
|
|
494
448
|
return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this)];
|
|
495
449
|
case 3:
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
case 4:
|
|
450
|
+
_c.CRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_e.sent()]);
|
|
451
|
+
_e.label = 4;
|
|
452
|
+
case 4:
|
|
453
|
+
this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(this.constants.CRYPTO_FACTORY_POOLS_DATA));
|
|
454
|
+
this.constants.GAUGES = __assign(__assign({}, this.constants.GAUGES), (0, utils_1.extractGauges)(this.constants.CRYPTO_FACTORY_POOLS_DATA));
|
|
455
|
+
return [2 /*return*/];
|
|
499
456
|
}
|
|
500
457
|
});
|
|
501
458
|
});
|
package/lib/external-api.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import { IExtendedPoolDataFromApi } from "./interfaces";
|
|
1
|
+
import { IExtendedPoolDataFromApi, ISubgraphPoolData, IReward, IDict } from "./interfaces";
|
|
2
2
|
import memoize from "memoizee";
|
|
3
3
|
export declare const _getPoolsFromApi: ((network: "ethereum" | "polygon", poolType: "main" | "crypto" | "factory" | "factory-crypto") => Promise<IExtendedPoolDataFromApi>) & memoize.Memoized<(network: "ethereum" | "polygon", poolType: "main" | "crypto" | "factory" | "factory-crypto") => Promise<IExtendedPoolDataFromApi>>;
|
|
4
|
+
export declare const _getSubgraphData: ((network: "ethereum" | "polygon") => Promise<ISubgraphPoolData[]>) & memoize.Memoized<(network: "ethereum" | "polygon") => Promise<ISubgraphPoolData[]>>;
|
|
5
|
+
export declare const _getMainPoolsGaugeRewards: (() => Promise<IDict<IReward[]>>) & memoize.Memoized<() => Promise<IDict<IReward[]>>>;
|