@curvefi/api 2.31.0 → 2.32.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/lib/boosting.js +137 -402
- package/lib/constants/abis/stable_calc.json +151 -0
- package/lib/constants/abis/wbeth/swap.json +1086 -0
- package/lib/constants/aliases.d.ts +11 -11
- package/lib/constants/aliases.js +23 -15
- package/lib/constants/coins/arbitrum.js +6 -9
- package/lib/constants/coins/aurora.js +6 -9
- package/lib/constants/coins/avalanche.js +7 -10
- package/lib/constants/coins/celo.js +6 -9
- package/lib/constants/coins/ethereum.js +10 -13
- package/lib/constants/coins/fantom.js +8 -11
- package/lib/constants/coins/kava.js +6 -9
- package/lib/constants/coins/moonbeam.js +6 -9
- package/lib/constants/coins/optimism.js +6 -9
- package/lib/constants/coins/polygon.js +7 -10
- package/lib/constants/coins/xdai.js +6 -9
- package/lib/constants/pools/arbitrum.d.ts +2 -4
- package/lib/constants/pools/arbitrum.js +22 -28
- package/lib/constants/pools/aurora.d.ts +2 -4
- package/lib/constants/pools/aurora.js +6 -12
- package/lib/constants/pools/avalanche.d.ts +2 -4
- package/lib/constants/pools/avalanche.js +21 -27
- package/lib/constants/pools/celo.d.ts +2 -4
- package/lib/constants/pools/celo.js +2 -5
- package/lib/constants/pools/ethereum.js +272 -253
- package/lib/constants/pools/fantom.d.ts +2 -4
- package/lib/constants/pools/fantom.js +28 -34
- package/lib/constants/pools/index.d.ts +11 -11
- package/lib/constants/pools/index.js +12 -25
- package/lib/constants/pools/kava.d.ts +2 -4
- package/lib/constants/pools/kava.js +2 -5
- package/lib/constants/pools/moonbeam.d.ts +2 -4
- package/lib/constants/pools/moonbeam.js +6 -12
- package/lib/constants/pools/optimism.d.ts +2 -4
- package/lib/constants/pools/optimism.js +9 -15
- package/lib/constants/pools/polygon.d.ts +2 -4
- package/lib/constants/pools/polygon.js +22 -28
- package/lib/constants/pools/xdai.d.ts +2 -4
- package/lib/constants/pools/xdai.js +24 -30
- package/lib/constants/utils.d.ts +1 -1
- package/lib/constants/utils.js +20 -29
- package/lib/curve.d.ts +9 -7
- package/lib/curve.js +399 -615
- package/lib/external-api.d.ts +1 -1
- package/lib/external-api.js +47 -140
- package/lib/factory/common.js +6 -10
- package/lib/factory/constants-crypto.js +48 -54
- package/lib/factory/constants.js +274 -280
- package/lib/factory/deploy.d.ts +8 -8
- package/lib/factory/deploy.js +177 -347
- package/lib/factory/factory-api.js +195 -278
- package/lib/factory/factory-crypto.js +170 -323
- package/lib/factory/factory.js +195 -350
- package/lib/index.d.ts +24 -25
- package/lib/index.js +87 -143
- package/lib/interfaces.d.ts +6 -11
- package/lib/interfaces.js +1 -2
- package/lib/pools/PoolTemplate.js +1478 -2931
- package/lib/pools/index.d.ts +2 -2
- package/lib/pools/index.js +3 -7
- package/lib/pools/mixins/common.d.ts +3 -4
- package/lib/pools/mixins/common.js +23 -112
- package/lib/pools/mixins/depositBalancedAmountsMixins.d.ts +1 -1
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +50 -139
- package/lib/pools/mixins/depositMixins.d.ts +1 -1
- package/lib/pools/mixins/depositMixins.js +144 -417
- package/lib/pools/mixins/depositWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/depositWrappedMixins.js +72 -227
- package/lib/pools/mixins/poolBalancesMixin.d.ts +1 -1
- package/lib/pools/mixins/poolBalancesMixin.js +25 -105
- package/lib/pools/mixins/swapMixins.d.ts +1 -1
- package/lib/pools/mixins/swapMixins.js +127 -353
- package/lib/pools/mixins/swapWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/swapWrappedMixins.js +90 -276
- package/lib/pools/mixins/withdrawExpectedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawExpectedMixins.js +26 -110
- package/lib/pools/mixins/withdrawImbalanceMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawImbalanceMixins.js +99 -321
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +53 -192
- package/lib/pools/mixins/withdrawMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawMixins.js +123 -390
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +17 -92
- package/lib/pools/mixins/withdrawOneCoinMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawOneCoinMixins.js +124 -390
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +9 -66
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +55 -190
- package/lib/pools/mixins/withdrawWrappedMixins.d.ts +1 -1
- package/lib/pools/mixins/withdrawWrappedMixins.js +52 -191
- package/lib/pools/poolConstructor.d.ts +1 -1
- package/lib/pools/poolConstructor.js +77 -101
- package/lib/pools/utils.js +299 -500
- package/lib/router.d.ts +2 -2
- package/lib/router.js +221 -689
- package/lib/utils.d.ts +9 -9
- package/lib/utils.js +377 -731
- package/package.json +9 -8
package/lib/curve.js
CHANGED
|
@@ -1,123 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { ethers, Contract } from "ethers";
|
|
2
|
+
import { Provider as MulticallProvider, Contract as MulticallContract } from 'ethcall';
|
|
3
|
+
import { getFactoryPoolData } from "./factory/factory.js";
|
|
4
|
+
import { getFactoryPoolsDataFromApi } from "./factory/factory-api.js";
|
|
5
|
+
import { getCryptoFactoryPoolData } from "./factory/factory-crypto.js";
|
|
6
|
+
import ERC20Abi from './constants/abis/ERC20.json' assert { type: 'json' };
|
|
7
|
+
import cERC20Abi from './constants/abis/cERC20.json' assert { type: 'json' };
|
|
8
|
+
import yERC20Abi from './constants/abis/yERC20.json' assert { type: 'json' };
|
|
9
|
+
import minterABI from './constants/abis/minter.json' assert { type: 'json' };
|
|
10
|
+
import minterChildABI from './constants/abis/minter_child.json' assert { type: 'json' };
|
|
11
|
+
import votingEscrowABI from './constants/abis/votingescrow.json' assert { type: 'json' };
|
|
12
|
+
import feeDistributorABI from './constants/abis/fee_distributor.json' assert { type: 'json' };
|
|
13
|
+
import addressProviderABI from './constants/abis/address_provider.json' assert { type: 'json' };
|
|
14
|
+
import gaugeControllerABI from './constants/abis/gaugecontroller.json' assert { type: 'json' };
|
|
15
|
+
import routerABI from './constants/abis/router.json' assert { type: 'json' };
|
|
16
|
+
import depositAndStakeABI from './constants/abis/deposit_and_stake.json' assert { type: 'json' };
|
|
17
|
+
import depositAndStake6CoinsABI from './constants/abis/deposit_and_stake_6coins.json' assert { type: 'json' };
|
|
18
|
+
import StableCalcZapABI from './constants/abis/stable_calc.json' assert { type: 'json' };
|
|
19
|
+
import registryExchangeABI from './constants/abis/registry_exchange.json' assert { type: 'json' };
|
|
20
|
+
import streamerABI from './constants/abis/streamer.json' assert { type: 'json' };
|
|
21
|
+
import factoryABI from './constants/abis/factory.json' assert { type: 'json' };
|
|
22
|
+
import cryptoFactoryABI from './constants/abis/factory-crypto.json' assert { type: 'json' };
|
|
23
|
+
import { POOLS_DATA_ETHEREUM, POOLS_DATA_POLYGON, POOLS_DATA_FANTOM, POOLS_DATA_AVALANCHE, POOLS_DATA_ARBITRUM, POOLS_DATA_OPTIMISM, POOLS_DATA_XDAI, POOLS_DATA_MOONBEAM, POOLS_DATA_AURORA, POOLS_DATA_KAVA, POOLS_DATA_CELO, } from './constants/pools/index.js';
|
|
24
|
+
import { ALIASES_ETHEREUM, ALIASES_OPTIMISM, ALIASES_POLYGON, ALIASES_FANTOM, ALIASES_AVALANCHE, ALIASES_ARBITRUM, ALIASES_XDAI, ALIASES_MOONBEAM, ALIASES_AURORA, ALIASES_KAVA, ALIASES_CELO, } from "./constants/aliases.js";
|
|
25
|
+
import { COINS_ETHEREUM, cTokensEthereum, yTokensEthereum, ycTokensEthereum, aTokensEthereum } from "./constants/coins/ethereum.js";
|
|
26
|
+
import { COINS_OPTIMISM, cTokensOptimism, yTokensOptimism, ycTokensOptimism, aTokensOptimism } from "./constants/coins/optimism.js";
|
|
27
|
+
import { COINS_POLYGON, cTokensPolygon, yTokensPolygon, ycTokensPolygon, aTokensPolygon } from "./constants/coins/polygon.js";
|
|
28
|
+
import { COINS_FANTOM, cTokensFantom, yTokensFantom, ycTokensFantom, aTokensFantom } from "./constants/coins/fantom.js";
|
|
29
|
+
import { COINS_AVALANCHE, cTokensAvalanche, yTokensAvalanche, ycTokensAvalanche, aTokensAvalanche } from "./constants/coins/avalanche.js";
|
|
30
|
+
import { COINS_ARBITRUM, cTokensArbitrum, yTokensArbitrum, ycTokensArbitrum, aTokensArbitrum } from "./constants/coins/arbitrum.js";
|
|
31
|
+
import { COINS_XDAI, cTokensXDai, yTokensXDai, ycTokensXDai, aTokensXDai } from "./constants/coins/xdai.js";
|
|
32
|
+
import { COINS_MOONBEAM, cTokensMoonbeam, yTokensMoonbeam, ycTokensMoonbeam, aTokensMoonbeam } from "./constants/coins/moonbeam.js";
|
|
33
|
+
import { COINS_AURORA, cTokensAurora, yTokensAurora, ycTokensAurora, aTokensAurora } from "./constants/coins/aurora.js";
|
|
34
|
+
import { COINS_KAVA, cTokensKava, yTokensKava, ycTokensKava, aTokensKava } from "./constants/coins/kava.js";
|
|
35
|
+
import { COINS_CELO, cTokensCelo, yTokensCelo, ycTokensCelo, aTokensCelo } from "./constants/coins/celo.js";
|
|
36
|
+
import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./constants/utils.js";
|
|
37
|
+
import { _getAllGauges, _getHiddenPools } from "./external-api.js";
|
|
38
|
+
const _killGauges = async (poolsData) => {
|
|
39
|
+
const gaugeData = await _getAllGauges();
|
|
40
|
+
const isKilled = {};
|
|
41
|
+
Object.values(gaugeData).forEach((d) => {
|
|
42
|
+
isKilled[d.gauge.toLowerCase()] = d.is_killed ?? false;
|
|
20
43
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
44
|
+
for (const poolId in poolsData) {
|
|
45
|
+
if (isKilled[poolsData[poolId].gauge_address]) {
|
|
46
|
+
poolsData[poolId].gauge_address = ethers.ZeroAddress;
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
49
|
};
|
|
58
|
-
|
|
59
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
-
};
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
exports.curve = exports.NETWORK_CONSTANTS = exports.NATIVE_TOKENS = void 0;
|
|
63
|
-
var ethers_1 = require("ethers");
|
|
64
|
-
var ethcall_1 = require("ethcall");
|
|
65
|
-
var factory_1 = require("./factory/factory");
|
|
66
|
-
var factory_api_1 = require("./factory/factory-api");
|
|
67
|
-
var factory_crypto_1 = require("./factory/factory-crypto");
|
|
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 minter_child_json_1 = __importDefault(require("./constants/abis/minter_child.json"));
|
|
73
|
-
var votingescrow_json_1 = __importDefault(require("./constants/abis/votingescrow.json"));
|
|
74
|
-
var fee_distributor_json_1 = __importDefault(require("./constants/abis/fee_distributor.json"));
|
|
75
|
-
var address_provider_json_1 = __importDefault(require("./constants/abis/address_provider.json"));
|
|
76
|
-
var gaugecontroller_json_1 = __importDefault(require("./constants/abis/gaugecontroller.json"));
|
|
77
|
-
var router_json_1 = __importDefault(require("./constants/abis/router.json"));
|
|
78
|
-
var deposit_and_stake_json_1 = __importDefault(require("./constants/abis/deposit_and_stake.json"));
|
|
79
|
-
var deposit_and_stake_6coins_json_1 = __importDefault(require("./constants/abis/deposit_and_stake_6coins.json"));
|
|
80
|
-
var registry_exchange_json_1 = __importDefault(require("./constants/abis/registry_exchange.json"));
|
|
81
|
-
var streamer_json_1 = __importDefault(require("./constants/abis/streamer.json"));
|
|
82
|
-
var factory_json_1 = __importDefault(require("./constants/abis/factory.json"));
|
|
83
|
-
var factory_crypto_json_1 = __importDefault(require("./constants/abis/factory-crypto.json"));
|
|
84
|
-
var pools_1 = require("./constants/pools");
|
|
85
|
-
var aliases_1 = require("./constants/aliases");
|
|
86
|
-
var ethereum_1 = require("./constants/coins/ethereum");
|
|
87
|
-
var optimism_1 = require("./constants/coins/optimism");
|
|
88
|
-
var polygon_1 = require("./constants/coins/polygon");
|
|
89
|
-
var fantom_1 = require("./constants/coins/fantom");
|
|
90
|
-
var avalanche_1 = require("./constants/coins/avalanche");
|
|
91
|
-
var arbitrum_1 = require("./constants/coins/arbitrum");
|
|
92
|
-
var xdai_1 = require("./constants/coins/xdai");
|
|
93
|
-
var moonbeam_1 = require("./constants/coins/moonbeam");
|
|
94
|
-
var aurora_1 = require("./constants/coins/aurora");
|
|
95
|
-
var kava_1 = require("./constants/coins/kava");
|
|
96
|
-
var celo_1 = require("./constants/coins/celo");
|
|
97
|
-
var utils_1 = require("./constants/utils");
|
|
98
|
-
var external_api_1 = require("./external-api");
|
|
99
|
-
var _killGauges = function (poolsData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
-
var gaugeData, isKilled, poolId;
|
|
101
|
-
return __generator(this, function (_a) {
|
|
102
|
-
switch (_a.label) {
|
|
103
|
-
case 0: return [4 /*yield*/, (0, external_api_1._getAllGauges)()];
|
|
104
|
-
case 1:
|
|
105
|
-
gaugeData = _a.sent();
|
|
106
|
-
isKilled = {};
|
|
107
|
-
Object.values(gaugeData).forEach(function (d) {
|
|
108
|
-
var _a;
|
|
109
|
-
isKilled[d.gauge.toLowerCase()] = (_a = d.is_killed) !== null && _a !== void 0 ? _a : false;
|
|
110
|
-
});
|
|
111
|
-
for (poolId in poolsData) {
|
|
112
|
-
if (isKilled[poolsData[poolId].gauge_address]) {
|
|
113
|
-
poolsData[poolId].gauge_address = ethers_1.ethers.constants.AddressZero;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return [2 /*return*/];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}); };
|
|
120
|
-
exports.NATIVE_TOKENS = {
|
|
50
|
+
export const NATIVE_TOKENS = {
|
|
121
51
|
1: {
|
|
122
52
|
symbol: 'ETH',
|
|
123
53
|
wrappedSymbol: 'WETH',
|
|
@@ -185,270 +115,185 @@ exports.NATIVE_TOKENS = {
|
|
|
185
115
|
wrappedAddress: '0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB'.toLowerCase(),
|
|
186
116
|
},
|
|
187
117
|
};
|
|
188
|
-
|
|
118
|
+
export const NETWORK_CONSTANTS = {
|
|
189
119
|
1: {
|
|
190
120
|
NAME: 'ethereum',
|
|
191
|
-
ALIASES:
|
|
192
|
-
POOLS_DATA:
|
|
193
|
-
COINS:
|
|
194
|
-
cTokens:
|
|
195
|
-
yTokens:
|
|
196
|
-
ycTokens:
|
|
197
|
-
aTokens:
|
|
121
|
+
ALIASES: ALIASES_ETHEREUM,
|
|
122
|
+
POOLS_DATA: POOLS_DATA_ETHEREUM,
|
|
123
|
+
COINS: COINS_ETHEREUM,
|
|
124
|
+
cTokens: cTokensEthereum,
|
|
125
|
+
yTokens: yTokensEthereum,
|
|
126
|
+
ycTokens: ycTokensEthereum,
|
|
127
|
+
aTokens: aTokensEthereum,
|
|
198
128
|
},
|
|
199
129
|
10: {
|
|
200
130
|
NAME: 'optimism',
|
|
201
|
-
ALIASES:
|
|
202
|
-
POOLS_DATA:
|
|
203
|
-
COINS:
|
|
204
|
-
cTokens:
|
|
205
|
-
yTokens:
|
|
206
|
-
ycTokens:
|
|
207
|
-
aTokens:
|
|
131
|
+
ALIASES: ALIASES_OPTIMISM,
|
|
132
|
+
POOLS_DATA: POOLS_DATA_OPTIMISM,
|
|
133
|
+
COINS: COINS_OPTIMISM,
|
|
134
|
+
cTokens: cTokensOptimism,
|
|
135
|
+
yTokens: yTokensOptimism,
|
|
136
|
+
ycTokens: ycTokensOptimism,
|
|
137
|
+
aTokens: aTokensOptimism,
|
|
208
138
|
},
|
|
209
139
|
100: {
|
|
210
140
|
NAME: 'xdai',
|
|
211
|
-
ALIASES:
|
|
212
|
-
POOLS_DATA:
|
|
213
|
-
COINS:
|
|
214
|
-
cTokens:
|
|
215
|
-
yTokens:
|
|
216
|
-
ycTokens:
|
|
217
|
-
aTokens:
|
|
141
|
+
ALIASES: ALIASES_XDAI,
|
|
142
|
+
POOLS_DATA: POOLS_DATA_XDAI,
|
|
143
|
+
COINS: COINS_XDAI,
|
|
144
|
+
cTokens: cTokensXDai,
|
|
145
|
+
yTokens: yTokensXDai,
|
|
146
|
+
ycTokens: ycTokensXDai,
|
|
147
|
+
aTokens: aTokensXDai,
|
|
218
148
|
},
|
|
219
149
|
137: {
|
|
220
150
|
NAME: 'polygon',
|
|
221
|
-
ALIASES:
|
|
222
|
-
POOLS_DATA:
|
|
223
|
-
COINS:
|
|
224
|
-
cTokens:
|
|
225
|
-
yTokens:
|
|
226
|
-
ycTokens:
|
|
227
|
-
aTokens:
|
|
151
|
+
ALIASES: ALIASES_POLYGON,
|
|
152
|
+
POOLS_DATA: POOLS_DATA_POLYGON,
|
|
153
|
+
COINS: COINS_POLYGON,
|
|
154
|
+
cTokens: cTokensPolygon,
|
|
155
|
+
yTokens: yTokensPolygon,
|
|
156
|
+
ycTokens: ycTokensPolygon,
|
|
157
|
+
aTokens: aTokensPolygon,
|
|
228
158
|
},
|
|
229
159
|
250: {
|
|
230
160
|
NAME: 'fantom',
|
|
231
|
-
ALIASES:
|
|
232
|
-
POOLS_DATA:
|
|
233
|
-
COINS:
|
|
234
|
-
cTokens:
|
|
235
|
-
yTokens:
|
|
236
|
-
ycTokens:
|
|
237
|
-
aTokens:
|
|
161
|
+
ALIASES: ALIASES_FANTOM,
|
|
162
|
+
POOLS_DATA: POOLS_DATA_FANTOM,
|
|
163
|
+
COINS: COINS_FANTOM,
|
|
164
|
+
cTokens: cTokensFantom,
|
|
165
|
+
yTokens: yTokensFantom,
|
|
166
|
+
ycTokens: ycTokensFantom,
|
|
167
|
+
aTokens: aTokensFantom,
|
|
238
168
|
},
|
|
239
169
|
1284: {
|
|
240
170
|
NAME: 'moonbeam',
|
|
241
|
-
ALIASES:
|
|
242
|
-
POOLS_DATA:
|
|
243
|
-
COINS:
|
|
244
|
-
cTokens:
|
|
245
|
-
yTokens:
|
|
246
|
-
ycTokens:
|
|
247
|
-
aTokens:
|
|
171
|
+
ALIASES: ALIASES_MOONBEAM,
|
|
172
|
+
POOLS_DATA: POOLS_DATA_MOONBEAM,
|
|
173
|
+
COINS: COINS_MOONBEAM,
|
|
174
|
+
cTokens: cTokensMoonbeam,
|
|
175
|
+
yTokens: yTokensMoonbeam,
|
|
176
|
+
ycTokens: ycTokensMoonbeam,
|
|
177
|
+
aTokens: aTokensMoonbeam,
|
|
248
178
|
},
|
|
249
179
|
2222: {
|
|
250
180
|
NAME: 'kava',
|
|
251
|
-
ALIASES:
|
|
252
|
-
POOLS_DATA:
|
|
253
|
-
COINS:
|
|
254
|
-
cTokens:
|
|
255
|
-
yTokens:
|
|
256
|
-
ycTokens:
|
|
257
|
-
aTokens:
|
|
181
|
+
ALIASES: ALIASES_KAVA,
|
|
182
|
+
POOLS_DATA: POOLS_DATA_KAVA,
|
|
183
|
+
COINS: COINS_KAVA,
|
|
184
|
+
cTokens: cTokensKava,
|
|
185
|
+
yTokens: yTokensKava,
|
|
186
|
+
ycTokens: ycTokensKava,
|
|
187
|
+
aTokens: aTokensKava,
|
|
258
188
|
},
|
|
259
189
|
42161: {
|
|
260
190
|
NAME: 'arbitrum',
|
|
261
|
-
ALIASES:
|
|
262
|
-
POOLS_DATA:
|
|
263
|
-
COINS:
|
|
264
|
-
cTokens:
|
|
265
|
-
yTokens:
|
|
266
|
-
ycTokens:
|
|
267
|
-
aTokens:
|
|
191
|
+
ALIASES: ALIASES_ARBITRUM,
|
|
192
|
+
POOLS_DATA: POOLS_DATA_ARBITRUM,
|
|
193
|
+
COINS: COINS_ARBITRUM,
|
|
194
|
+
cTokens: cTokensArbitrum,
|
|
195
|
+
yTokens: yTokensArbitrum,
|
|
196
|
+
ycTokens: ycTokensArbitrum,
|
|
197
|
+
aTokens: aTokensArbitrum,
|
|
268
198
|
},
|
|
269
199
|
42220: {
|
|
270
200
|
NAME: 'celo',
|
|
271
|
-
ALIASES:
|
|
272
|
-
POOLS_DATA:
|
|
273
|
-
COINS:
|
|
274
|
-
cTokens:
|
|
275
|
-
yTokens:
|
|
276
|
-
ycTokens:
|
|
277
|
-
aTokens:
|
|
201
|
+
ALIASES: ALIASES_CELO,
|
|
202
|
+
POOLS_DATA: POOLS_DATA_CELO,
|
|
203
|
+
COINS: COINS_CELO,
|
|
204
|
+
cTokens: cTokensCelo,
|
|
205
|
+
yTokens: yTokensCelo,
|
|
206
|
+
ycTokens: ycTokensCelo,
|
|
207
|
+
aTokens: aTokensCelo,
|
|
278
208
|
},
|
|
279
209
|
43114: {
|
|
280
210
|
NAME: 'avalanche',
|
|
281
|
-
ALIASES:
|
|
282
|
-
POOLS_DATA:
|
|
283
|
-
COINS:
|
|
284
|
-
cTokens:
|
|
285
|
-
yTokens:
|
|
286
|
-
ycTokens:
|
|
287
|
-
aTokens:
|
|
211
|
+
ALIASES: ALIASES_AVALANCHE,
|
|
212
|
+
POOLS_DATA: POOLS_DATA_AVALANCHE,
|
|
213
|
+
COINS: COINS_AVALANCHE,
|
|
214
|
+
cTokens: cTokensAvalanche,
|
|
215
|
+
yTokens: yTokensAvalanche,
|
|
216
|
+
ycTokens: ycTokensAvalanche,
|
|
217
|
+
aTokens: aTokensAvalanche,
|
|
288
218
|
},
|
|
289
219
|
1313161554: {
|
|
290
220
|
NAME: 'aurora',
|
|
291
|
-
ALIASES:
|
|
292
|
-
POOLS_DATA:
|
|
293
|
-
COINS:
|
|
294
|
-
cTokens:
|
|
295
|
-
yTokens:
|
|
296
|
-
ycTokens:
|
|
297
|
-
aTokens:
|
|
221
|
+
ALIASES: ALIASES_AURORA,
|
|
222
|
+
POOLS_DATA: POOLS_DATA_AURORA,
|
|
223
|
+
COINS: COINS_AURORA,
|
|
224
|
+
cTokens: cTokensAurora,
|
|
225
|
+
yTokens: yTokensAurora,
|
|
226
|
+
ycTokens: ycTokensAurora,
|
|
227
|
+
aTokens: aTokensAurora,
|
|
298
228
|
},
|
|
299
229
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
_b = utils_1.lowerCasePoolDataAddresses;
|
|
315
|
-
return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, false)];
|
|
316
|
-
case 1:
|
|
317
|
-
_a.FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
|
|
318
|
-
return [3 /*break*/, 4];
|
|
319
|
-
case 2:
|
|
320
|
-
_c = this.constants;
|
|
321
|
-
_d = utils_1.lowerCasePoolDataAddresses;
|
|
322
|
-
return [4 /*yield*/, factory_1.getFactoryPoolData.call(this)];
|
|
323
|
-
case 3:
|
|
324
|
-
_c.FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
|
|
325
|
-
_f.label = 4;
|
|
326
|
-
case 4:
|
|
327
|
-
_e = this.constants;
|
|
328
|
-
return [4 /*yield*/, this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA)];
|
|
329
|
-
case 5:
|
|
330
|
-
_e.FACTORY_POOLS_DATA = _f.sent();
|
|
331
|
-
this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
|
|
332
|
-
return [4 /*yield*/, _killGauges(this.constants.FACTORY_POOLS_DATA)];
|
|
333
|
-
case 6:
|
|
334
|
-
_f.sent();
|
|
335
|
-
return [2 /*return*/];
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
});
|
|
230
|
+
class Curve {
|
|
231
|
+
constructor() {
|
|
232
|
+
this.fetchFactoryPools = async (useApi = true) => {
|
|
233
|
+
if (this.chainId === 1313161554)
|
|
234
|
+
return;
|
|
235
|
+
if (useApi) {
|
|
236
|
+
this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolsDataFromApi.call(this, false));
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.constants.FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this));
|
|
240
|
+
}
|
|
241
|
+
this.constants.FACTORY_POOLS_DATA = await this._filterHiddenPools(this.constants.FACTORY_POOLS_DATA);
|
|
242
|
+
this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
|
|
243
|
+
await _killGauges(this.constants.FACTORY_POOLS_DATA);
|
|
339
244
|
};
|
|
340
|
-
this.fetchCryptoFactoryPools =
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return [4 /*yield*/, factory_api_1.getFactoryPoolsDataFromApi.call(this, true)];
|
|
353
|
-
case 1:
|
|
354
|
-
_a.CRYPTO_FACTORY_POOLS_DATA = _b.apply(void 0, [_f.sent()]);
|
|
355
|
-
return [3 /*break*/, 4];
|
|
356
|
-
case 2:
|
|
357
|
-
_c = this.constants;
|
|
358
|
-
_d = utils_1.lowerCasePoolDataAddresses;
|
|
359
|
-
return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this)];
|
|
360
|
-
case 3:
|
|
361
|
-
_c.CRYPTO_FACTORY_POOLS_DATA = _d.apply(void 0, [_f.sent()]);
|
|
362
|
-
_f.label = 4;
|
|
363
|
-
case 4:
|
|
364
|
-
_e = this.constants;
|
|
365
|
-
return [4 /*yield*/, this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
|
|
366
|
-
case 5:
|
|
367
|
-
_e.CRYPTO_FACTORY_POOLS_DATA = _f.sent();
|
|
368
|
-
this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
369
|
-
return [4 /*yield*/, _killGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA)];
|
|
370
|
-
case 6:
|
|
371
|
-
_f.sent();
|
|
372
|
-
return [2 /*return*/];
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
});
|
|
245
|
+
this.fetchCryptoFactoryPools = async (useApi = true) => {
|
|
246
|
+
if (![1, 137, 250].includes(this.chainId))
|
|
247
|
+
return;
|
|
248
|
+
if (useApi) {
|
|
249
|
+
this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getFactoryPoolsDataFromApi.call(this, true));
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this.constants.CRYPTO_FACTORY_POOLS_DATA = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this));
|
|
253
|
+
}
|
|
254
|
+
this.constants.CRYPTO_FACTORY_POOLS_DATA = await this._filterHiddenPools(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
255
|
+
this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
256
|
+
await _killGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
376
257
|
};
|
|
377
|
-
this.fetchNewFactoryPools =
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
this.
|
|
416
|
-
var poolData, _a;
|
|
417
|
-
return __generator(this, function (_b) {
|
|
418
|
-
switch (_b.label) {
|
|
419
|
-
case 0:
|
|
420
|
-
if (this.chainId === 1313161554)
|
|
421
|
-
return [2 /*return*/, ''];
|
|
422
|
-
_a = utils_1.lowerCasePoolDataAddresses;
|
|
423
|
-
return [4 /*yield*/, factory_1.getFactoryPoolData.call(this, 0, poolAddress)];
|
|
424
|
-
case 1:
|
|
425
|
-
poolData = _a.apply(void 0, [_b.sent()]);
|
|
426
|
-
this.constants.FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.FACTORY_POOLS_DATA), poolData);
|
|
427
|
-
this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
|
|
428
|
-
return [2 /*return*/, Object.keys(poolData)[0]]; // id
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
}); };
|
|
432
|
-
this.fetchRecentlyDeployedCryptoFactoryPool = function (poolAddress) { return __awaiter(_this, void 0, void 0, function () {
|
|
433
|
-
var poolData, _a;
|
|
434
|
-
return __generator(this, function (_b) {
|
|
435
|
-
switch (_b.label) {
|
|
436
|
-
case 0:
|
|
437
|
-
if (![1, 137, 250].includes(this.chainId))
|
|
438
|
-
return [2 /*return*/, ''];
|
|
439
|
-
_a = utils_1.lowerCasePoolDataAddresses;
|
|
440
|
-
return [4 /*yield*/, factory_crypto_1.getCryptoFactoryPoolData.call(this, 0, poolAddress)];
|
|
441
|
-
case 1:
|
|
442
|
-
poolData = _a.apply(void 0, [_b.sent()]);
|
|
443
|
-
this.constants.CRYPTO_FACTORY_POOLS_DATA = __assign(__assign({}, this.constants.CRYPTO_FACTORY_POOLS_DATA), poolData);
|
|
444
|
-
this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
445
|
-
return [2 /*return*/, Object.keys(poolData)[0]]; // id
|
|
446
|
-
}
|
|
447
|
-
});
|
|
448
|
-
}); };
|
|
449
|
-
this.getPoolList = function () { return Object.keys(_this.constants.POOLS_DATA); };
|
|
450
|
-
this.getFactoryPoolList = function () { return Object.keys(_this.constants.FACTORY_POOLS_DATA); };
|
|
451
|
-
this.getCryptoFactoryPoolList = function () { return Object.keys(_this.constants.CRYPTO_FACTORY_POOLS_DATA); };
|
|
258
|
+
this.fetchNewFactoryPools = async () => {
|
|
259
|
+
if (this.chainId === 1313161554)
|
|
260
|
+
return [];
|
|
261
|
+
const currentPoolIds = Object.keys(this.constants.FACTORY_POOLS_DATA);
|
|
262
|
+
const lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
|
|
263
|
+
const poolData = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this, lastPoolIdx + 1));
|
|
264
|
+
this.constants.FACTORY_POOLS_DATA = { ...this.constants.FACTORY_POOLS_DATA, ...poolData };
|
|
265
|
+
this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
|
|
266
|
+
return Object.keys(poolData);
|
|
267
|
+
};
|
|
268
|
+
this.fetchNewCryptoFactoryPools = async () => {
|
|
269
|
+
if (![1, 137, 250].includes(this.chainId))
|
|
270
|
+
return [];
|
|
271
|
+
const currentPoolIds = Object.keys(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
272
|
+
const lastPoolIdx = Number(currentPoolIds[currentPoolIds.length - 1].split("-")[2]);
|
|
273
|
+
const poolData = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this, lastPoolIdx + 1));
|
|
274
|
+
this.constants.CRYPTO_FACTORY_POOLS_DATA = { ...this.constants.CRYPTO_FACTORY_POOLS_DATA, ...poolData };
|
|
275
|
+
this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
276
|
+
return Object.keys(poolData);
|
|
277
|
+
};
|
|
278
|
+
this.fetchRecentlyDeployedFactoryPool = async (poolAddress) => {
|
|
279
|
+
if (this.chainId === 1313161554)
|
|
280
|
+
return '';
|
|
281
|
+
const poolData = lowerCasePoolDataAddresses(await getFactoryPoolData.call(this, 0, poolAddress));
|
|
282
|
+
this.constants.FACTORY_POOLS_DATA = { ...this.constants.FACTORY_POOLS_DATA, ...poolData };
|
|
283
|
+
this._updateDecimalsAndGauges(this.constants.FACTORY_POOLS_DATA);
|
|
284
|
+
return Object.keys(poolData)[0]; // id
|
|
285
|
+
};
|
|
286
|
+
this.fetchRecentlyDeployedCryptoFactoryPool = async (poolAddress) => {
|
|
287
|
+
if (![1, 137, 250].includes(this.chainId))
|
|
288
|
+
return '';
|
|
289
|
+
const poolData = lowerCasePoolDataAddresses(await getCryptoFactoryPoolData.call(this, 0, poolAddress));
|
|
290
|
+
this.constants.CRYPTO_FACTORY_POOLS_DATA = { ...this.constants.CRYPTO_FACTORY_POOLS_DATA, ...poolData };
|
|
291
|
+
this._updateDecimalsAndGauges(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
292
|
+
return Object.keys(poolData)[0]; // id
|
|
293
|
+
};
|
|
294
|
+
this.getPoolList = () => Object.keys(this.constants.POOLS_DATA);
|
|
295
|
+
this.getFactoryPoolList = () => Object.keys(this.constants.FACTORY_POOLS_DATA);
|
|
296
|
+
this.getCryptoFactoryPoolList = () => Object.keys(this.constants.CRYPTO_FACTORY_POOLS_DATA);
|
|
452
297
|
// @ts-ignore
|
|
453
298
|
this.provider = null;
|
|
454
299
|
// @ts-ignore
|
|
@@ -462,7 +307,7 @@ var Curve = /** @class */ (function () {
|
|
|
462
307
|
this.constantOptions = { gasLimit: 12000000 };
|
|
463
308
|
this.options = {};
|
|
464
309
|
this.constants = {
|
|
465
|
-
NATIVE_TOKEN:
|
|
310
|
+
NATIVE_TOKEN: NATIVE_TOKENS[1],
|
|
466
311
|
NETWORK_NAME: 'ethereum',
|
|
467
312
|
ALIASES: {},
|
|
468
313
|
POOLS_DATA: {},
|
|
@@ -471,279 +316,218 @@ var Curve = /** @class */ (function () {
|
|
|
471
316
|
COINS: {},
|
|
472
317
|
DECIMALS: {},
|
|
473
318
|
GAUGES: [],
|
|
319
|
+
ZERO_ADDRESS: ethers.ZeroAddress,
|
|
474
320
|
};
|
|
475
321
|
}
|
|
476
|
-
|
|
322
|
+
async init(providerType, providerSettings, options = {} // gasPrice in Gwei
|
|
477
323
|
) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
POOLS_DATA: {},
|
|
502
|
-
FACTORY_POOLS_DATA: {},
|
|
503
|
-
CRYPTO_FACTORY_POOLS_DATA: {},
|
|
504
|
-
COINS: {},
|
|
505
|
-
DECIMALS: {},
|
|
506
|
-
GAUGES: [],
|
|
507
|
-
};
|
|
508
|
-
// JsonRpc provider
|
|
509
|
-
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
510
|
-
providerSettings = providerSettings;
|
|
511
|
-
if (providerSettings.url) {
|
|
512
|
-
this.provider = new ethers_1.ethers.providers.JsonRpcProvider(providerSettings.url);
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
this.provider = new ethers_1.ethers.providers.JsonRpcProvider('http://localhost:8545/');
|
|
516
|
-
}
|
|
517
|
-
if (providerSettings.privateKey) {
|
|
518
|
-
this.signer = new ethers_1.ethers.Wallet(providerSettings.privateKey, this.provider);
|
|
519
|
-
}
|
|
520
|
-
else if (!((_a = providerSettings.url) === null || _a === void 0 ? void 0 : _a.startsWith("https://rpc.gnosischain.com"))) {
|
|
521
|
-
this.signer = this.provider.getSigner();
|
|
522
|
-
}
|
|
523
|
-
// Web3 provider
|
|
524
|
-
}
|
|
525
|
-
else if (providerType.toLowerCase() === 'Web3'.toLowerCase()) {
|
|
526
|
-
providerSettings = providerSettings;
|
|
527
|
-
this.provider = new ethers_1.ethers.providers.Web3Provider(providerSettings.externalProvider);
|
|
528
|
-
this.signer = this.provider.getSigner();
|
|
529
|
-
// Infura provider
|
|
530
|
-
}
|
|
531
|
-
else if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
|
|
532
|
-
providerSettings = providerSettings;
|
|
533
|
-
this.provider = new ethers_1.ethers.providers.InfuraProvider(providerSettings.network, providerSettings.apiKey);
|
|
534
|
-
this.signer = null;
|
|
535
|
-
// Alchemy provider
|
|
536
|
-
}
|
|
537
|
-
else if (providerType.toLowerCase() === 'Alchemy'.toLowerCase()) {
|
|
538
|
-
providerSettings = providerSettings;
|
|
539
|
-
this.provider = new ethers_1.ethers.providers.AlchemyProvider(providerSettings.network, providerSettings.apiKey);
|
|
540
|
-
this.signer = null;
|
|
541
|
-
}
|
|
542
|
-
else {
|
|
543
|
-
throw Error('Wrong providerType');
|
|
544
|
-
}
|
|
545
|
-
_b = this.provider.network;
|
|
546
|
-
if (_b) return [3 /*break*/, 2];
|
|
547
|
-
return [4 /*yield*/, this.provider._networkPromise];
|
|
548
|
-
case 1:
|
|
549
|
-
_b = (_o.sent());
|
|
550
|
-
_o.label = 2;
|
|
551
|
-
case 2:
|
|
552
|
-
network = _b;
|
|
553
|
-
console.log("CURVE-JS IS CONNECTED TO NETWORK:", network);
|
|
554
|
-
this.chainId = network.chainId === 1337 ? 1 : network.chainId;
|
|
555
|
-
this.constants.NATIVE_TOKEN = exports.NATIVE_TOKENS[this.chainId];
|
|
556
|
-
this.constants.NETWORK_NAME = exports.NETWORK_CONSTANTS[this.chainId].NAME;
|
|
557
|
-
this.constants.ALIASES = exports.NETWORK_CONSTANTS[this.chainId].ALIASES;
|
|
558
|
-
this.constants.POOLS_DATA = exports.NETWORK_CONSTANTS[this.chainId].POOLS_DATA;
|
|
559
|
-
for (poolId in this.constants.POOLS_DATA)
|
|
560
|
-
this.constants.POOLS_DATA[poolId].in_api = true;
|
|
561
|
-
this.constants.COINS = exports.NETWORK_CONSTANTS[this.chainId].COINS;
|
|
562
|
-
this.constants.DECIMALS = (0, utils_1.extractDecimals)(this.constants.POOLS_DATA);
|
|
563
|
-
this.constants.DECIMALS[this.constants.NATIVE_TOKEN.address] = 18;
|
|
564
|
-
this.constants.DECIMALS[this.constants.NATIVE_TOKEN.wrappedAddress] = 18;
|
|
565
|
-
this.constants.GAUGES = (0, utils_1.extractGauges)(this.constants.POOLS_DATA);
|
|
566
|
-
_c = [
|
|
567
|
-
exports.NETWORK_CONSTANTS[this.chainId].cTokens,
|
|
568
|
-
exports.NETWORK_CONSTANTS[this.chainId].yTokens,
|
|
569
|
-
exports.NETWORK_CONSTANTS[this.chainId].ycTokens,
|
|
570
|
-
exports.NETWORK_CONSTANTS[this.chainId].aTokens,
|
|
571
|
-
], cTokens = _c[0], yTokens = _c[1], ycTokens = _c[2], aTokens = _c[3];
|
|
572
|
-
customAbiTokens = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], cTokens, true), yTokens, true), ycTokens, true), aTokens, true);
|
|
573
|
-
return [4 /*yield*/, _killGauges(this.constants.POOLS_DATA)];
|
|
574
|
-
case 3:
|
|
575
|
-
_o.sent();
|
|
576
|
-
this.multicallProvider = new ethcall_1.Provider();
|
|
577
|
-
return [4 /*yield*/, this.multicallProvider.init(this.provider)];
|
|
578
|
-
case 4:
|
|
579
|
-
_o.sent();
|
|
580
|
-
if (!this.signer) return [3 /*break*/, 9];
|
|
581
|
-
_o.label = 5;
|
|
582
|
-
case 5:
|
|
583
|
-
_o.trys.push([5, 7, , 8]);
|
|
584
|
-
_d = this;
|
|
585
|
-
return [4 /*yield*/, this.signer.getAddress()];
|
|
586
|
-
case 6:
|
|
587
|
-
_d.signerAddress = _o.sent();
|
|
588
|
-
return [3 /*break*/, 8];
|
|
589
|
-
case 7:
|
|
590
|
-
err_1 = _o.sent();
|
|
591
|
-
this.signer = null;
|
|
592
|
-
return [3 /*break*/, 8];
|
|
593
|
-
case 8: return [3 /*break*/, 10];
|
|
594
|
-
case 9:
|
|
595
|
-
this.signerAddress = '';
|
|
596
|
-
_o.label = 10;
|
|
597
|
-
case 10:
|
|
598
|
-
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
599
|
-
return [4 /*yield*/, this.updateFeeData()];
|
|
600
|
-
case 11:
|
|
601
|
-
_o.sent();
|
|
602
|
-
for (_i = 0, _e = Object.values(this.constants.POOLS_DATA); _i < _e.length; _i++) {
|
|
603
|
-
pool = _e[_i];
|
|
604
|
-
this.setContract(pool.swap_address, pool.swap_abi);
|
|
605
|
-
if (pool.token_address !== pool.swap_address) {
|
|
606
|
-
this.setContract(pool.token_address, ERC20_json_1.default);
|
|
607
|
-
}
|
|
608
|
-
if (pool.gauge_address !== ethers_1.ethers.constants.AddressZero) {
|
|
609
|
-
this.setContract(pool.gauge_address, pool.gauge_abi);
|
|
610
|
-
}
|
|
611
|
-
if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
|
|
612
|
-
this.setContract(pool.deposit_address, pool.deposit_abi);
|
|
613
|
-
}
|
|
614
|
-
for (_f = 0, _g = pool.underlying_coin_addresses; _f < _g.length; _f++) {
|
|
615
|
-
coinAddr = _g[_f];
|
|
616
|
-
this.setContract(coinAddr, ERC20_json_1.default);
|
|
617
|
-
}
|
|
618
|
-
for (_h = 0, _j = pool.wrapped_coin_addresses; _h < _j.length; _h++) {
|
|
619
|
-
coinAddr = _j[_h];
|
|
620
|
-
if (customAbiTokens.includes(coinAddr))
|
|
621
|
-
continue;
|
|
622
|
-
if (coinAddr in this.contracts)
|
|
623
|
-
continue;
|
|
624
|
-
this.setContract(coinAddr, ERC20_json_1.default);
|
|
625
|
-
}
|
|
626
|
-
// TODO add all coins
|
|
627
|
-
for (_k = 0, _l = pool.wrapped_coin_addresses; _k < _l.length; _k++) {
|
|
628
|
-
coinAddr = _l[_k];
|
|
629
|
-
if (cTokens.includes(coinAddr)) {
|
|
630
|
-
this.setContract(coinAddr, cERC20_json_1.default);
|
|
631
|
-
}
|
|
632
|
-
if (aTokens.includes(coinAddr)) {
|
|
633
|
-
this.setContract(coinAddr, ERC20_json_1.default);
|
|
634
|
-
}
|
|
635
|
-
if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
|
|
636
|
-
this.setContract(coinAddr, yERC20_json_1.default);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
if (pool.reward_contract) {
|
|
640
|
-
this.setContract(pool.reward_contract, streamer_json_1.default);
|
|
641
|
-
}
|
|
642
|
-
if (pool.sCurveRewards_address) {
|
|
643
|
-
this.setContract(pool.sCurveRewards_address, pool.sCurveRewards_abi);
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
this.setContract(this.constants.NATIVE_TOKEN.wrappedAddress, ERC20_json_1.default);
|
|
647
|
-
this.setContract(this.constants.ALIASES.crv, ERC20_json_1.default);
|
|
648
|
-
this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
|
|
649
|
-
_minterABI = this.chainId === 1 ? minter_json_1.default : minter_child_json_1.default;
|
|
650
|
-
this.setContract(this.constants.ALIASES.minter, _minterABI);
|
|
651
|
-
this.setContract(this.constants.ALIASES.voting_escrow, votingescrow_json_1.default);
|
|
652
|
-
this.setContract(this.constants.ALIASES.fee_distributor, fee_distributor_json_1.default);
|
|
653
|
-
this.setContract(this.constants.ALIASES.address_provider, address_provider_json_1.default);
|
|
654
|
-
addressProviderContract = this.contracts[this.constants.ALIASES.address_provider].contract;
|
|
655
|
-
_m = this.constants.ALIASES;
|
|
656
|
-
return [4 /*yield*/, addressProviderContract.get_address(2, this.constantOptions)];
|
|
657
|
-
case 12:
|
|
658
|
-
_m.registry_exchange = (_o.sent()).toLowerCase();
|
|
659
|
-
this.setContract(this.constants.ALIASES.registry_exchange, registry_exchange_json_1.default);
|
|
660
|
-
this.setContract(this.constants.ALIASES.gauge_controller, gaugecontroller_json_1.default);
|
|
661
|
-
this.setContract(this.constants.ALIASES.router, router_json_1.default);
|
|
662
|
-
if (this.chainId === 137) {
|
|
663
|
-
this.setContract(this.constants.ALIASES.deposit_and_stake, deposit_and_stake_6coins_json_1.default);
|
|
664
|
-
}
|
|
665
|
-
else {
|
|
666
|
-
this.setContract(this.constants.ALIASES.deposit_and_stake, deposit_and_stake_json_1.default);
|
|
667
|
-
}
|
|
668
|
-
this.setContract(this.constants.ALIASES.factory, factory_json_1.default);
|
|
669
|
-
this.setContract(this.constants.ALIASES.crypto_factory, factory_crypto_json_1.default);
|
|
670
|
-
return [2 /*return*/];
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
});
|
|
674
|
-
};
|
|
675
|
-
Curve.prototype.setContract = function (address, abi) {
|
|
676
|
-
this.contracts[address] = {
|
|
677
|
-
contract: new ethers_1.Contract(address, abi, this.signer || this.provider),
|
|
678
|
-
multicallContract: new ethcall_1.Contract(address, abi),
|
|
324
|
+
// @ts-ignore
|
|
325
|
+
this.provider = null;
|
|
326
|
+
// @ts-ignore
|
|
327
|
+
this.signer = null;
|
|
328
|
+
this.signerAddress = '';
|
|
329
|
+
this.chainId = 1;
|
|
330
|
+
// @ts-ignore
|
|
331
|
+
this.multicallProvider = null;
|
|
332
|
+
this.contracts = {};
|
|
333
|
+
this.feeData = {};
|
|
334
|
+
this.constantOptions = { gasLimit: 12000000 };
|
|
335
|
+
this.options = {};
|
|
336
|
+
this.constants = {
|
|
337
|
+
NATIVE_TOKEN: NATIVE_TOKENS[1],
|
|
338
|
+
NETWORK_NAME: 'ethereum',
|
|
339
|
+
ALIASES: {},
|
|
340
|
+
POOLS_DATA: {},
|
|
341
|
+
FACTORY_POOLS_DATA: {},
|
|
342
|
+
CRYPTO_FACTORY_POOLS_DATA: {},
|
|
343
|
+
COINS: {},
|
|
344
|
+
DECIMALS: {},
|
|
345
|
+
GAUGES: [],
|
|
346
|
+
ZERO_ADDRESS: ethers.ZeroAddress,
|
|
679
347
|
};
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
348
|
+
// JsonRpc provider
|
|
349
|
+
if (providerType.toLowerCase() === 'JsonRpc'.toLowerCase()) {
|
|
350
|
+
providerSettings = providerSettings;
|
|
351
|
+
if (providerSettings.url) {
|
|
352
|
+
this.provider = new ethers.JsonRpcProvider(providerSettings.url);
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
this.provider = new ethers.JsonRpcProvider('http://localhost:8545/');
|
|
356
|
+
}
|
|
357
|
+
if (providerSettings.privateKey) {
|
|
358
|
+
this.signer = new ethers.Wallet(providerSettings.privateKey, this.provider);
|
|
359
|
+
}
|
|
360
|
+
else if (!providerSettings.url?.startsWith("https://rpc.gnosischain.com")) {
|
|
361
|
+
try {
|
|
362
|
+
this.signer = await this.provider.getSigner();
|
|
363
|
+
}
|
|
364
|
+
catch (e) {
|
|
365
|
+
this.signer = null;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
// Web3 provider
|
|
369
|
+
}
|
|
370
|
+
else if (providerType.toLowerCase() === 'Web3'.toLowerCase()) {
|
|
371
|
+
providerSettings = providerSettings;
|
|
372
|
+
this.provider = new ethers.BrowserProvider(providerSettings.externalProvider);
|
|
373
|
+
this.signer = await this.provider.getSigner();
|
|
374
|
+
// Infura provider
|
|
375
|
+
}
|
|
376
|
+
else if (providerType.toLowerCase() === 'Infura'.toLowerCase()) {
|
|
377
|
+
providerSettings = providerSettings;
|
|
378
|
+
this.provider = new ethers.InfuraProvider(providerSettings.network, providerSettings.apiKey);
|
|
379
|
+
this.signer = null;
|
|
380
|
+
// Alchemy provider
|
|
381
|
+
}
|
|
382
|
+
else if (providerType.toLowerCase() === 'Alchemy'.toLowerCase()) {
|
|
383
|
+
providerSettings = providerSettings;
|
|
384
|
+
this.provider = new ethers.AlchemyProvider(providerSettings.network, providerSettings.apiKey);
|
|
385
|
+
this.signer = null;
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
throw Error('Wrong providerType');
|
|
389
|
+
}
|
|
390
|
+
const network = await this.provider.getNetwork();
|
|
391
|
+
console.log("CURVE-JS IS CONNECTED TO NETWORK:", { name: network.name.toUpperCase(), chainId: Number(network.chainId) });
|
|
392
|
+
this.chainId = Number(network.chainId) === 1337 ? 1 : Number(network.chainId);
|
|
393
|
+
this.constants.NATIVE_TOKEN = NATIVE_TOKENS[this.chainId];
|
|
394
|
+
this.constants.NETWORK_NAME = NETWORK_CONSTANTS[this.chainId].NAME;
|
|
395
|
+
this.constants.ALIASES = NETWORK_CONSTANTS[this.chainId].ALIASES;
|
|
396
|
+
this.constants.POOLS_DATA = NETWORK_CONSTANTS[this.chainId].POOLS_DATA;
|
|
397
|
+
for (const poolId in this.constants.POOLS_DATA)
|
|
398
|
+
this.constants.POOLS_DATA[poolId].in_api = true;
|
|
399
|
+
this.constants.COINS = NETWORK_CONSTANTS[this.chainId].COINS;
|
|
400
|
+
this.constants.DECIMALS = extractDecimals(this.constants.POOLS_DATA);
|
|
401
|
+
this.constants.DECIMALS[this.constants.NATIVE_TOKEN.address] = 18;
|
|
402
|
+
this.constants.DECIMALS[this.constants.NATIVE_TOKEN.wrappedAddress] = 18;
|
|
403
|
+
this.constants.GAUGES = extractGauges(this.constants.POOLS_DATA);
|
|
404
|
+
const [cTokens, yTokens, ycTokens, aTokens] = [
|
|
405
|
+
NETWORK_CONSTANTS[this.chainId].cTokens,
|
|
406
|
+
NETWORK_CONSTANTS[this.chainId].yTokens,
|
|
407
|
+
NETWORK_CONSTANTS[this.chainId].ycTokens,
|
|
408
|
+
NETWORK_CONSTANTS[this.chainId].aTokens,
|
|
409
|
+
];
|
|
410
|
+
const customAbiTokens = [...cTokens, ...yTokens, ...ycTokens, ...aTokens];
|
|
411
|
+
await _killGauges(this.constants.POOLS_DATA);
|
|
412
|
+
this.multicallProvider = new MulticallProvider(this.chainId, this.provider);
|
|
413
|
+
if (this.signer) {
|
|
414
|
+
try {
|
|
415
|
+
this.signerAddress = await this.signer.getAddress();
|
|
416
|
+
}
|
|
417
|
+
catch (err) {
|
|
418
|
+
this.signer = null;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
this.signerAddress = '';
|
|
423
|
+
}
|
|
424
|
+
this.feeData = { gasPrice: options.gasPrice, maxFeePerGas: options.maxFeePerGas, maxPriorityFeePerGas: options.maxPriorityFeePerGas };
|
|
425
|
+
await this.updateFeeData();
|
|
426
|
+
for (const pool of Object.values(this.constants.POOLS_DATA)) {
|
|
427
|
+
this.setContract(pool.swap_address, pool.swap_abi);
|
|
428
|
+
if (pool.token_address !== pool.swap_address) {
|
|
429
|
+
this.setContract(pool.token_address, ERC20Abi);
|
|
430
|
+
}
|
|
431
|
+
if (pool.gauge_address !== this.constants.ZERO_ADDRESS) {
|
|
432
|
+
this.setContract(pool.gauge_address, pool.gauge_abi);
|
|
433
|
+
}
|
|
434
|
+
if (pool.deposit_address && !this.contracts[pool.deposit_address]) {
|
|
435
|
+
this.setContract(pool.deposit_address, pool.deposit_abi);
|
|
436
|
+
}
|
|
437
|
+
for (const coinAddr of pool.underlying_coin_addresses) {
|
|
438
|
+
this.setContract(coinAddr, ERC20Abi);
|
|
439
|
+
}
|
|
440
|
+
for (const coinAddr of pool.wrapped_coin_addresses) {
|
|
441
|
+
if (customAbiTokens.includes(coinAddr))
|
|
442
|
+
continue;
|
|
443
|
+
if (coinAddr in this.contracts)
|
|
444
|
+
continue;
|
|
445
|
+
this.setContract(coinAddr, ERC20Abi);
|
|
446
|
+
}
|
|
447
|
+
// TODO add all coins
|
|
448
|
+
for (const coinAddr of pool.wrapped_coin_addresses) {
|
|
449
|
+
if (cTokens.includes(coinAddr)) {
|
|
450
|
+
this.setContract(coinAddr, cERC20Abi);
|
|
451
|
+
}
|
|
452
|
+
if (aTokens.includes(coinAddr)) {
|
|
453
|
+
this.setContract(coinAddr, ERC20Abi);
|
|
694
454
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
};
|
|
698
|
-
Curve.prototype._updateDecimalsAndGauges = function (pools) {
|
|
699
|
-
this.constants.DECIMALS = __assign(__assign({}, this.constants.DECIMALS), (0, utils_1.extractDecimals)(pools));
|
|
700
|
-
this.constants.GAUGES = __spreadArray(__spreadArray([], this.constants.GAUGES, true), (0, utils_1.extractGauges)(pools), true);
|
|
701
|
-
};
|
|
702
|
-
Curve.prototype.setCustomFeeData = function (customFeeData) {
|
|
703
|
-
this.feeData = __assign(__assign({}, this.feeData), customFeeData);
|
|
704
|
-
};
|
|
705
|
-
Curve.prototype.updateFeeData = function () {
|
|
706
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
707
|
-
var feeData, _a, _b, _c;
|
|
708
|
-
return __generator(this, function (_d) {
|
|
709
|
-
switch (_d.label) {
|
|
710
|
-
case 0: return [4 /*yield*/, this.provider.getFeeData()];
|
|
711
|
-
case 1:
|
|
712
|
-
feeData = _d.sent();
|
|
713
|
-
if (!(feeData.maxFeePerGas === null || feeData.maxPriorityFeePerGas === null)) return [3 /*break*/, 6];
|
|
714
|
-
delete this.options.maxFeePerGas;
|
|
715
|
-
delete this.options.maxPriorityFeePerGas;
|
|
716
|
-
_a = this.options;
|
|
717
|
-
if (!(this.feeData.gasPrice !== undefined)) return [3 /*break*/, 2];
|
|
718
|
-
_b = ethers_1.ethers.utils.parseUnits(this.feeData.gasPrice.toString(), "gwei");
|
|
719
|
-
return [3 /*break*/, 5];
|
|
720
|
-
case 2:
|
|
721
|
-
_c = feeData.gasPrice;
|
|
722
|
-
if (_c) return [3 /*break*/, 4];
|
|
723
|
-
return [4 /*yield*/, this.provider.getGasPrice()];
|
|
724
|
-
case 3:
|
|
725
|
-
_c = (_d.sent());
|
|
726
|
-
_d.label = 4;
|
|
727
|
-
case 4:
|
|
728
|
-
_b = (_c);
|
|
729
|
-
_d.label = 5;
|
|
730
|
-
case 5:
|
|
731
|
-
_a.gasPrice = _b;
|
|
732
|
-
return [3 /*break*/, 7];
|
|
733
|
-
case 6:
|
|
734
|
-
delete this.options.gasPrice;
|
|
735
|
-
this.options.maxFeePerGas = this.feeData.maxFeePerGas !== undefined ?
|
|
736
|
-
ethers_1.ethers.utils.parseUnits(this.feeData.maxFeePerGas.toString(), "gwei") :
|
|
737
|
-
feeData.maxFeePerGas;
|
|
738
|
-
this.options.maxPriorityFeePerGas = this.feeData.maxPriorityFeePerGas !== undefined ?
|
|
739
|
-
ethers_1.ethers.utils.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
|
|
740
|
-
feeData.maxPriorityFeePerGas;
|
|
741
|
-
_d.label = 7;
|
|
742
|
-
case 7: return [2 /*return*/];
|
|
455
|
+
if (yTokens.includes(coinAddr) || ycTokens.includes(coinAddr)) {
|
|
456
|
+
this.setContract(coinAddr, yERC20Abi);
|
|
743
457
|
}
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
458
|
+
}
|
|
459
|
+
if (pool.reward_contract) {
|
|
460
|
+
this.setContract(pool.reward_contract, streamerABI);
|
|
461
|
+
}
|
|
462
|
+
if (pool.sCurveRewards_address) {
|
|
463
|
+
this.setContract(pool.sCurveRewards_address, pool.sCurveRewards_abi);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
this.setContract(this.constants.NATIVE_TOKEN.wrappedAddress, ERC20Abi);
|
|
467
|
+
this.setContract(this.constants.ALIASES.crv, ERC20Abi);
|
|
468
|
+
this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
|
|
469
|
+
const _minterABI = this.chainId === 1 ? minterABI : minterChildABI;
|
|
470
|
+
this.setContract(this.constants.ALIASES.minter, _minterABI);
|
|
471
|
+
this.setContract(this.constants.ALIASES.voting_escrow, votingEscrowABI);
|
|
472
|
+
this.setContract(this.constants.ALIASES.fee_distributor, feeDistributorABI);
|
|
473
|
+
this.setContract(this.constants.ALIASES.address_provider, addressProviderABI);
|
|
474
|
+
const addressProviderContract = this.contracts[this.constants.ALIASES.address_provider].contract;
|
|
475
|
+
this.constants.ALIASES.registry_exchange = (await addressProviderContract.get_address(2, this.constantOptions)).toLowerCase();
|
|
476
|
+
this.setContract(this.constants.ALIASES.registry_exchange, registryExchangeABI);
|
|
477
|
+
this.setContract(this.constants.ALIASES.gauge_controller, gaugeControllerABI);
|
|
478
|
+
this.setContract(this.constants.ALIASES.router, routerABI);
|
|
479
|
+
if (this.chainId === 137) {
|
|
480
|
+
this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStake6CoinsABI);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStakeABI);
|
|
484
|
+
}
|
|
485
|
+
this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
|
|
486
|
+
this.setContract(this.constants.ALIASES.factory, factoryABI);
|
|
487
|
+
this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
|
|
488
|
+
}
|
|
489
|
+
setContract(address, abi) {
|
|
490
|
+
this.contracts[address] = {
|
|
491
|
+
contract: new Contract(address, abi, this.signer || this.provider),
|
|
492
|
+
multicallContract: new MulticallContract(address, abi),
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
async _filterHiddenPools(pools) {
|
|
496
|
+
const hiddenPools = (await _getHiddenPools())[this.constants.NETWORK_NAME] || [];
|
|
497
|
+
// @ts-ignore
|
|
498
|
+
return Object.fromEntries(Object.entries(pools).filter(([id]) => !hiddenPools.includes(id)));
|
|
499
|
+
}
|
|
500
|
+
_updateDecimalsAndGauges(pools) {
|
|
501
|
+
this.constants.DECIMALS = { ...this.constants.DECIMALS, ...extractDecimals(pools) };
|
|
502
|
+
this.constants.GAUGES = [...this.constants.GAUGES, ...extractGauges(pools)];
|
|
503
|
+
}
|
|
504
|
+
setCustomFeeData(customFeeData) {
|
|
505
|
+
this.feeData = { ...this.feeData, ...customFeeData };
|
|
506
|
+
}
|
|
507
|
+
formatUnits(value, unit) {
|
|
508
|
+
return ethers.formatUnits(value, unit);
|
|
509
|
+
}
|
|
510
|
+
parseUnits(value, unit) {
|
|
511
|
+
return ethers.parseUnits(value, unit);
|
|
512
|
+
}
|
|
513
|
+
async updateFeeData() {
|
|
514
|
+
const feeData = await this.provider.getFeeData();
|
|
515
|
+
if (feeData.maxFeePerGas === null || feeData.maxPriorityFeePerGas === null) {
|
|
516
|
+
delete this.options.maxFeePerGas;
|
|
517
|
+
delete this.options.maxPriorityFeePerGas;
|
|
518
|
+
this.options.gasPrice = this.feeData.gasPrice !== undefined ?
|
|
519
|
+
this.parseUnits(this.feeData.gasPrice.toString(), "gwei") :
|
|
520
|
+
(feeData.gasPrice || this.parseUnits("20", "gwei"));
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
delete this.options.gasPrice;
|
|
524
|
+
this.options.maxFeePerGas = this.feeData.maxFeePerGas !== undefined ?
|
|
525
|
+
this.parseUnits(this.feeData.maxFeePerGas.toString(), "gwei") :
|
|
526
|
+
feeData.maxFeePerGas;
|
|
527
|
+
this.options.maxPriorityFeePerGas = this.feeData.maxPriorityFeePerGas !== undefined ?
|
|
528
|
+
this.parseUnits(this.feeData.maxPriorityFeePerGas.toString(), "gwei") :
|
|
529
|
+
feeData.maxPriorityFeePerGas;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
export const curve = new Curve();
|