@curvefi/api 2.31.1 → 2.33.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 +385 -135
- package/lib/constants/abis/stable_calc.json +151 -0
- package/lib/constants/abis/wbeth/swap.json +1086 -0
- package/lib/constants/aliases.js +33 -11
- package/lib/constants/coins/arbitrum.js +5 -5
- package/lib/constants/coins/aurora.js +5 -5
- package/lib/constants/coins/avalanche.js +6 -6
- package/lib/constants/coins/celo.js +5 -5
- package/lib/constants/coins/ethereum.js +10 -9
- package/lib/constants/coins/fantom.js +7 -7
- package/lib/constants/coins/kava.js +5 -5
- package/lib/constants/coins/moonbeam.js +5 -5
- package/lib/constants/coins/optimism.js +5 -5
- package/lib/constants/coins/polygon.js +6 -6
- package/lib/constants/coins/xdai.js +5 -5
- package/lib/constants/pools/arbitrum.js +1 -1
- package/lib/constants/pools/aurora.js +1 -1
- package/lib/constants/pools/avalanche.js +1 -1
- package/lib/constants/pools/celo.js +1 -1
- package/lib/constants/pools/ethereum.js +26 -1
- package/lib/constants/pools/fantom.js +1 -1
- package/lib/constants/pools/kava.js +1 -1
- package/lib/constants/pools/moonbeam.js +1 -1
- package/lib/constants/pools/optimism.js +1 -1
- package/lib/constants/pools/polygon.js +1 -1
- package/lib/constants/pools/xdai.js +1 -1
- package/lib/constants/utils.d.ts +1 -1
- package/lib/constants/utils.js +19 -18
- package/lib/curve.js +507 -281
- package/lib/external-api.js +132 -45
- package/lib/factory/common.js +3 -3
- package/lib/factory/constants-crypto.js +21 -21
- package/lib/factory/constants.js +32 -31
- package/lib/factory/deploy.js +336 -176
- package/lib/factory/factory-api.js +256 -180
- package/lib/factory/factory-crypto.js +309 -163
- package/lib/factory/factory.d.ts +1 -1
- package/lib/factory/factory.js +336 -186
- package/lib/index.js +98 -44
- package/lib/interfaces.d.ts +1 -1
- package/lib/pools/PoolTemplate.js +2882 -1511
- package/lib/pools/mixins/common.js +106 -22
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +131 -48
- package/lib/pools/mixins/depositMixins.js +413 -144
- package/lib/pools/mixins/depositWrappedMixins.js +223 -72
- package/lib/pools/mixins/poolBalancesMixin.js +98 -22
- package/lib/pools/mixins/swapMixins.js +347 -125
- package/lib/pools/mixins/swapWrappedMixins.js +270 -88
- package/lib/pools/mixins/withdrawExpectedMixins.js +104 -23
- package/lib/pools/mixins/withdrawImbalanceMixins.js +316 -97
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +187 -51
- package/lib/pools/mixins/withdrawMixins.js +385 -122
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +88 -16
- package/lib/pools/mixins/withdrawOneCoinMixins.js +386 -123
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +62 -8
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +185 -53
- package/lib/pools/mixins/withdrawWrappedMixins.js +185 -50
- package/lib/pools/poolConstructor.js +25 -5
- package/lib/pools/utils.js +488 -298
- package/lib/router.js +636 -378
- package/lib/utils.js +675 -354
- package/package.json +1 -1
|
@@ -1,3 +1,59 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
1
57
|
import { Contract } from "ethers";
|
|
2
58
|
import { Contract as MulticallContract } from "ethcall";
|
|
3
59
|
import { curve } from "../curve.js";
|
|
@@ -9,18 +65,22 @@ import { FACTORY_CONSTANTS } from "./constants.js";
|
|
|
9
65
|
import { CRYPTO_FACTORY_CONSTANTS } from "./constants-crypto.js";
|
|
10
66
|
import { setFactoryZapContracts } from "./common.js";
|
|
11
67
|
import { _getPoolsFromApi } from "../external-api.js";
|
|
12
|
-
export
|
|
13
|
-
|
|
68
|
+
export var lowerCasePoolDataAddresses = function (poolsData) {
|
|
69
|
+
var _a;
|
|
70
|
+
for (var _i = 0, poolsData_1 = poolsData; _i < poolsData_1.length; _i++) {
|
|
71
|
+
var poolData = poolsData_1[_i];
|
|
14
72
|
poolData.address = poolData.address.toLowerCase();
|
|
15
73
|
if (poolData.lpTokenAddress)
|
|
16
74
|
poolData.lpTokenAddress = poolData.lpTokenAddress.toLowerCase();
|
|
17
75
|
if (poolData.gaugeAddress)
|
|
18
76
|
poolData.gaugeAddress = poolData.gaugeAddress.toLowerCase();
|
|
19
77
|
poolData.implementationAddress = poolData.implementationAddress.toLowerCase();
|
|
20
|
-
for (
|
|
78
|
+
for (var _b = 0, _c = poolData.coins; _b < _c.length; _b++) {
|
|
79
|
+
var coin = _c[_b];
|
|
21
80
|
coin.address = coin.address.toLowerCase();
|
|
22
81
|
}
|
|
23
|
-
for (
|
|
82
|
+
for (var _d = 0, _e = (_a = poolData.gaugeRewards) !== null && _a !== void 0 ? _a : []; _d < _e.length; _d++) {
|
|
83
|
+
var reward = _e[_d];
|
|
24
84
|
reward.gaugeAddress = reward.gaugeAddress.toLowerCase();
|
|
25
85
|
reward.tokenAddress = reward.tokenAddress.toLowerCase();
|
|
26
86
|
}
|
|
@@ -28,50 +88,55 @@ export const lowerCasePoolDataAddresses = (poolsData) => {
|
|
|
28
88
|
return poolsData;
|
|
29
89
|
};
|
|
30
90
|
function setFactorySwapContracts(rawPoolList, isCrypto) {
|
|
91
|
+
var _this = this;
|
|
31
92
|
if (isCrypto) {
|
|
32
|
-
rawPoolList.forEach((pool)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
contract: new Contract(addr, cryptoFactorySwapABI,
|
|
93
|
+
rawPoolList.forEach(function (pool) {
|
|
94
|
+
var addr = pool.address;
|
|
95
|
+
_this.contracts[addr] = {
|
|
96
|
+
contract: new Contract(addr, cryptoFactorySwapABI, _this.signer || _this.provider),
|
|
36
97
|
multicallContract: new MulticallContract(addr, cryptoFactorySwapABI),
|
|
37
98
|
};
|
|
38
99
|
});
|
|
39
100
|
}
|
|
40
101
|
else {
|
|
41
|
-
|
|
42
|
-
rawPoolList.forEach((pool)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
contract: new Contract(addr,
|
|
46
|
-
multicallContract: new MulticallContract(addr,
|
|
102
|
+
var implementationABIDict_1 = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
103
|
+
rawPoolList.forEach(function (pool) {
|
|
104
|
+
var addr = pool.address;
|
|
105
|
+
_this.contracts[addr] = {
|
|
106
|
+
contract: new Contract(addr, implementationABIDict_1[pool.implementationAddress], _this.signer || _this.provider),
|
|
107
|
+
multicallContract: new MulticallContract(addr, implementationABIDict_1[pool.implementationAddress]),
|
|
47
108
|
};
|
|
48
109
|
});
|
|
49
110
|
}
|
|
50
111
|
}
|
|
51
112
|
function setCryptoFactoryTokenContracts(rawPoolList) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
113
|
+
var _this = this;
|
|
114
|
+
rawPoolList.forEach(function (pool) {
|
|
115
|
+
var addr = pool.lpTokenAddress;
|
|
116
|
+
_this.contracts[addr] = {
|
|
117
|
+
contract: new Contract(addr, ERC20ABI, _this.signer || _this.provider),
|
|
56
118
|
multicallContract: new MulticallContract(addr, ERC20ABI),
|
|
57
119
|
};
|
|
58
120
|
});
|
|
59
121
|
}
|
|
60
122
|
function setFactoryGaugeContracts(rawPoolList) {
|
|
61
|
-
|
|
123
|
+
var _this = this;
|
|
124
|
+
rawPoolList.forEach(function (pool) {
|
|
62
125
|
if (pool.gaugeAddress) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
contract: new Contract(addr,
|
|
66
|
-
multicallContract: new MulticallContract(addr,
|
|
126
|
+
var addr = pool.gaugeAddress;
|
|
127
|
+
_this.contracts[addr] = {
|
|
128
|
+
contract: new Contract(addr, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI, _this.signer || _this.provider),
|
|
129
|
+
multicallContract: new MulticallContract(addr, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI),
|
|
67
130
|
};
|
|
68
131
|
}
|
|
69
132
|
});
|
|
70
133
|
}
|
|
71
134
|
function setFactoryCoinsContracts(rawPoolList) {
|
|
72
|
-
for (
|
|
73
|
-
|
|
74
|
-
|
|
135
|
+
for (var _i = 0, rawPoolList_1 = rawPoolList; _i < rawPoolList_1.length; _i++) {
|
|
136
|
+
var pool = rawPoolList_1[_i];
|
|
137
|
+
for (var _a = 0, _b = pool.coins; _a < _b.length; _a++) {
|
|
138
|
+
var coin = _b[_a];
|
|
139
|
+
var addr = coin.address;
|
|
75
140
|
if (addr in this.contracts)
|
|
76
141
|
continue;
|
|
77
142
|
this.contracts[addr] = {
|
|
@@ -81,160 +146,171 @@ function setFactoryCoinsContracts(rawPoolList) {
|
|
|
81
146
|
}
|
|
82
147
|
}
|
|
83
148
|
}
|
|
84
|
-
export
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
149
|
+
export function getFactoryPoolsDataFromApi(isCrypto) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var network, factoryType, rawPoolList, _a, mainAddresses, FACTORY_POOLS_DATA;
|
|
152
|
+
var _this = this;
|
|
153
|
+
return __generator(this, function (_b) {
|
|
154
|
+
switch (_b.label) {
|
|
155
|
+
case 0:
|
|
156
|
+
network = this.constants.NETWORK_NAME;
|
|
157
|
+
factoryType = isCrypto ? "factory-crypto" : "factory";
|
|
158
|
+
_a = lowerCasePoolDataAddresses;
|
|
159
|
+
return [4 /*yield*/, _getPoolsFromApi(network, factoryType)];
|
|
160
|
+
case 1:
|
|
161
|
+
rawPoolList = _a.apply(void 0, [(_b.sent()).poolData]);
|
|
162
|
+
if (!isCrypto) {
|
|
163
|
+
rawPoolList = rawPoolList.filter(function (p) { return p.implementationAddress in FACTORY_CONSTANTS[_this.chainId].implementationABIDict; });
|
|
164
|
+
}
|
|
165
|
+
mainAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address; });
|
|
166
|
+
rawPoolList = rawPoolList.filter(function (p) { return !mainAddresses.includes(p.address); });
|
|
167
|
+
setFactorySwapContracts.call(this, rawPoolList, isCrypto);
|
|
168
|
+
if (isCrypto)
|
|
169
|
+
setCryptoFactoryTokenContracts.call(this, rawPoolList);
|
|
170
|
+
setFactoryGaugeContracts.call(this, rawPoolList);
|
|
171
|
+
setFactoryCoinsContracts.call(this, rawPoolList);
|
|
172
|
+
setFactoryZapContracts.call(this, isCrypto);
|
|
173
|
+
FACTORY_POOLS_DATA = {};
|
|
174
|
+
rawPoolList.forEach(function (pool) {
|
|
175
|
+
var nativeToken = _this.constants.NATIVE_TOKEN;
|
|
176
|
+
var coinAddresses = pool.coins.map(function (c) { return c.address; });
|
|
177
|
+
if (_this.chainId === 137) {
|
|
178
|
+
coinAddresses = coinAddresses.map(function (a) { return a === "0x0000000000000000000000000000000000001010" ? nativeToken.wrappedAddress : a; });
|
|
179
|
+
}
|
|
180
|
+
var coinNames = pool.coins.map(function (c) { return c.symbol; });
|
|
181
|
+
var coinDecimals = pool.coins.map(function (c) { return Number(c.decimals); });
|
|
182
|
+
if (isCrypto) {
|
|
183
|
+
var wrappedCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.symbol ? nativeToken.wrappedSymbol : c.symbol; });
|
|
184
|
+
var underlyingCoinNames = pool.coins.map(function (c) { return c.symbol === nativeToken.wrappedSymbol ? nativeToken.symbol : c.symbol; });
|
|
185
|
+
var underlyingCoinAddresses = coinAddresses.map(function (addr) { return addr === nativeToken.wrappedAddress ? nativeToken.address : addr; });
|
|
186
|
+
var isPlain = !coinAddresses.includes(nativeToken.wrappedAddress);
|
|
187
|
+
var lpTokenBasePoolIdDict = CRYPTO_FACTORY_CONSTANTS[_this.chainId].lpTokenBasePoolIdDict;
|
|
188
|
+
var basePoolIdZapDict = CRYPTO_FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
|
|
189
|
+
var basePoolId = lpTokenBasePoolIdDict[coinAddresses[1]];
|
|
190
|
+
if (basePoolId) { // isMeta
|
|
191
|
+
var allPoolsData = __assign(__assign({}, _this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
|
|
192
|
+
var basePoolCoinNames = __spreadArray([], allPoolsData[basePoolId].underlying_coins, true);
|
|
193
|
+
var basePoolCoinAddresses = __spreadArray([], allPoolsData[basePoolId].underlying_coin_addresses, true);
|
|
194
|
+
var basePoolDecimals = __spreadArray([], allPoolsData[basePoolId].underlying_decimals, true);
|
|
195
|
+
var basePoolZap = basePoolIdZapDict[basePoolId];
|
|
196
|
+
FACTORY_POOLS_DATA[pool.id] = {
|
|
197
|
+
name: pool.name.split(": ")[1].trim(),
|
|
198
|
+
full_name: pool.name,
|
|
199
|
+
symbol: pool.symbol,
|
|
200
|
+
reference_asset: "CRYPTO",
|
|
201
|
+
swap_address: pool.address,
|
|
202
|
+
token_address: pool.lpTokenAddress,
|
|
203
|
+
gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
|
|
204
|
+
deposit_address: basePoolZap.address,
|
|
205
|
+
is_meta: true,
|
|
206
|
+
is_crypto: true,
|
|
207
|
+
is_factory: true,
|
|
208
|
+
base_pool: basePoolId,
|
|
209
|
+
underlying_coins: __spreadArray([underlyingCoinNames[0]], basePoolCoinNames, true),
|
|
210
|
+
wrapped_coins: wrappedCoinNames,
|
|
211
|
+
underlying_coin_addresses: __spreadArray([underlyingCoinAddresses[0]], basePoolCoinAddresses, true),
|
|
212
|
+
wrapped_coin_addresses: coinAddresses,
|
|
213
|
+
underlying_decimals: __spreadArray([coinDecimals[0]], basePoolDecimals, true),
|
|
214
|
+
wrapped_decimals: coinDecimals,
|
|
215
|
+
swap_abi: cryptoFactorySwapABI,
|
|
216
|
+
gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
217
|
+
deposit_abi: basePoolZap.ABI,
|
|
218
|
+
in_api: true,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
FACTORY_POOLS_DATA[pool.id] = {
|
|
223
|
+
name: pool.name.split(": ")[1].trim(),
|
|
224
|
+
full_name: pool.name,
|
|
225
|
+
symbol: pool.symbol,
|
|
226
|
+
reference_asset: "CRYPTO",
|
|
227
|
+
swap_address: pool.address,
|
|
228
|
+
token_address: pool.lpTokenAddress,
|
|
229
|
+
gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
|
|
230
|
+
is_crypto: true,
|
|
231
|
+
is_plain: isPlain,
|
|
232
|
+
is_factory: true,
|
|
233
|
+
underlying_coins: underlyingCoinNames,
|
|
234
|
+
wrapped_coins: wrappedCoinNames,
|
|
235
|
+
underlying_coin_addresses: underlyingCoinAddresses,
|
|
236
|
+
wrapped_coin_addresses: coinAddresses,
|
|
237
|
+
underlying_decimals: coinDecimals,
|
|
238
|
+
wrapped_decimals: coinDecimals,
|
|
239
|
+
swap_abi: cryptoFactorySwapABI,
|
|
240
|
+
gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
241
|
+
in_api: true,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else if (pool.implementation.includes("meta")) {
|
|
246
|
+
var implementationABIDict = FACTORY_CONSTANTS[_this.chainId].implementationABIDict;
|
|
247
|
+
var implementationBasePoolIdDict = FACTORY_CONSTANTS[_this.chainId].implementationBasePoolIdDict;
|
|
248
|
+
var basePoolIds = Object.values(implementationBasePoolIdDict).filter(function (poolId, i, arr) { return arr.indexOf(poolId) === i; });
|
|
249
|
+
var allPoolsData_1 = __assign(__assign({}, _this.constants.POOLS_DATA), FACTORY_POOLS_DATA);
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
var basePoolIdCoinsDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins]; }));
|
|
252
|
+
// @ts-ignore
|
|
253
|
+
var basePoolIdCoinAddressesDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coin_addresses]; }));
|
|
254
|
+
// @ts-ignore
|
|
255
|
+
var basePoolIdDecimalsDict = Object.fromEntries(basePoolIds.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_decimals]; }));
|
|
256
|
+
var basePoolIdZapDict = FACTORY_CONSTANTS[_this.chainId].basePoolIdZapDict;
|
|
257
|
+
var basePoolId = implementationBasePoolIdDict[pool.implementationAddress];
|
|
258
|
+
var basePoolCoinNames = basePoolIdCoinsDict[basePoolId];
|
|
259
|
+
var basePoolCoinAddresses = basePoolIdCoinAddressesDict[basePoolId];
|
|
260
|
+
var basePoolDecimals = basePoolIdDecimalsDict[basePoolId];
|
|
261
|
+
var basePoolZap = basePoolIdZapDict[basePoolId];
|
|
262
|
+
FACTORY_POOLS_DATA[pool.id] = {
|
|
263
|
+
name: pool.name.split(": ")[1].trim(),
|
|
264
|
+
full_name: pool.name,
|
|
265
|
+
symbol: pool.symbol,
|
|
266
|
+
reference_asset: pool.assetTypeName.toUpperCase(),
|
|
267
|
+
swap_address: pool.address,
|
|
268
|
+
token_address: pool.address,
|
|
269
|
+
gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
|
|
270
|
+
deposit_address: basePoolZap.address,
|
|
271
|
+
implementation_address: pool.implementationAddress,
|
|
272
|
+
is_meta: true,
|
|
273
|
+
is_factory: true,
|
|
274
|
+
base_pool: basePoolId,
|
|
275
|
+
underlying_coins: __spreadArray([coinNames[0]], basePoolCoinNames, true),
|
|
276
|
+
wrapped_coins: coinNames,
|
|
277
|
+
underlying_coin_addresses: __spreadArray([coinAddresses[0]], basePoolCoinAddresses, true),
|
|
278
|
+
wrapped_coin_addresses: coinAddresses,
|
|
279
|
+
underlying_decimals: __spreadArray([coinDecimals[0]], basePoolDecimals, true),
|
|
280
|
+
wrapped_decimals: coinDecimals,
|
|
281
|
+
swap_abi: implementationABIDict[pool.implementationAddress],
|
|
282
|
+
gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
283
|
+
deposit_abi: basePoolZap.ABI,
|
|
284
|
+
in_api: true,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
var implementationABIDict = FACTORY_CONSTANTS[_this.chainId].implementationABIDict;
|
|
289
|
+
FACTORY_POOLS_DATA[pool.id] = {
|
|
290
|
+
name: pool.name.split(": ")[1].trim(),
|
|
291
|
+
full_name: pool.name,
|
|
292
|
+
symbol: pool.symbol,
|
|
293
|
+
reference_asset: pool.assetTypeName.toUpperCase(),
|
|
294
|
+
swap_address: pool.address,
|
|
295
|
+
token_address: pool.address,
|
|
296
|
+
gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
|
|
297
|
+
implementation_address: pool.implementationAddress,
|
|
298
|
+
is_plain: true,
|
|
299
|
+
is_factory: true,
|
|
300
|
+
underlying_coins: coinNames,
|
|
301
|
+
wrapped_coins: coinNames,
|
|
302
|
+
underlying_coin_addresses: coinAddresses,
|
|
303
|
+
wrapped_coin_addresses: coinAddresses,
|
|
304
|
+
underlying_decimals: coinDecimals,
|
|
305
|
+
wrapped_decimals: coinDecimals,
|
|
306
|
+
swap_abi: implementationABIDict[pool.implementationAddress],
|
|
307
|
+
gauge_abi: _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
308
|
+
in_api: true,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
return [2 /*return*/, FACTORY_POOLS_DATA];
|
|
170
313
|
}
|
|
171
|
-
}
|
|
172
|
-
else if (pool.implementation.includes("meta")) {
|
|
173
|
-
const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
174
|
-
const implementationBasePoolIdDict = FACTORY_CONSTANTS[this.chainId].implementationBasePoolIdDict;
|
|
175
|
-
const basePoolIds = Object.values(implementationBasePoolIdDict).filter((poolId, i, arr) => arr.indexOf(poolId) === i);
|
|
176
|
-
const allPoolsData = { ...this.constants.POOLS_DATA, ...FACTORY_POOLS_DATA };
|
|
177
|
-
// @ts-ignore
|
|
178
|
-
const basePoolIdCoinsDict = Object.fromEntries(basePoolIds.map((poolId) => [poolId, allPoolsData[poolId]?.underlying_coins]));
|
|
179
|
-
// @ts-ignore
|
|
180
|
-
const basePoolIdCoinAddressesDict = Object.fromEntries(basePoolIds.map((poolId) => [poolId, allPoolsData[poolId]?.underlying_coin_addresses]));
|
|
181
|
-
// @ts-ignore
|
|
182
|
-
const basePoolIdDecimalsDict = Object.fromEntries(basePoolIds.map((poolId) => [poolId, allPoolsData[poolId]?.underlying_decimals]));
|
|
183
|
-
const basePoolIdZapDict = FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
|
|
184
|
-
const basePoolId = implementationBasePoolIdDict[pool.implementationAddress];
|
|
185
|
-
const basePoolCoinNames = basePoolIdCoinsDict[basePoolId];
|
|
186
|
-
const basePoolCoinAddresses = basePoolIdCoinAddressesDict[basePoolId];
|
|
187
|
-
const basePoolDecimals = basePoolIdDecimalsDict[basePoolId];
|
|
188
|
-
const basePoolZap = basePoolIdZapDict[basePoolId];
|
|
189
|
-
FACTORY_POOLS_DATA[pool.id] = {
|
|
190
|
-
name: pool.name.split(": ")[1].trim(),
|
|
191
|
-
full_name: pool.name,
|
|
192
|
-
symbol: pool.symbol,
|
|
193
|
-
reference_asset: pool.assetTypeName.toUpperCase(),
|
|
194
|
-
swap_address: pool.address,
|
|
195
|
-
token_address: pool.address,
|
|
196
|
-
gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
|
|
197
|
-
deposit_address: basePoolZap.address,
|
|
198
|
-
implementation_address: pool.implementationAddress,
|
|
199
|
-
is_meta: true,
|
|
200
|
-
is_factory: true,
|
|
201
|
-
base_pool: basePoolId,
|
|
202
|
-
underlying_coins: [coinNames[0], ...basePoolCoinNames],
|
|
203
|
-
wrapped_coins: coinNames,
|
|
204
|
-
underlying_coin_addresses: [coinAddresses[0], ...basePoolCoinAddresses],
|
|
205
|
-
wrapped_coin_addresses: coinAddresses,
|
|
206
|
-
underlying_decimals: [coinDecimals[0], ...basePoolDecimals],
|
|
207
|
-
wrapped_decimals: coinDecimals,
|
|
208
|
-
swap_abi: implementationABIDict[pool.implementationAddress],
|
|
209
|
-
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
210
|
-
deposit_abi: basePoolZap.ABI,
|
|
211
|
-
in_api: true,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
216
|
-
FACTORY_POOLS_DATA[pool.id] = {
|
|
217
|
-
name: pool.name.split(": ")[1].trim(),
|
|
218
|
-
full_name: pool.name,
|
|
219
|
-
symbol: pool.symbol,
|
|
220
|
-
reference_asset: pool.assetTypeName.toUpperCase(),
|
|
221
|
-
swap_address: pool.address,
|
|
222
|
-
token_address: pool.address,
|
|
223
|
-
gauge_address: pool.gaugeAddress ? pool.gaugeAddress : curve.constants.ZERO_ADDRESS,
|
|
224
|
-
implementation_address: pool.implementationAddress,
|
|
225
|
-
is_plain: true,
|
|
226
|
-
is_factory: true,
|
|
227
|
-
underlying_coins: coinNames,
|
|
228
|
-
wrapped_coins: coinNames,
|
|
229
|
-
underlying_coin_addresses: coinAddresses,
|
|
230
|
-
wrapped_coin_addresses: coinAddresses,
|
|
231
|
-
underlying_decimals: coinDecimals,
|
|
232
|
-
wrapped_decimals: coinDecimals,
|
|
233
|
-
swap_abi: implementationABIDict[pool.implementationAddress],
|
|
234
|
-
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
235
|
-
in_api: true,
|
|
236
|
-
};
|
|
237
|
-
}
|
|
314
|
+
});
|
|
238
315
|
});
|
|
239
|
-
return FACTORY_POOLS_DATA;
|
|
240
316
|
}
|