@curvefi/api 2.63.0 → 2.63.1
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 +247 -645
- package/lib/constants/L2Networks.js +1 -1
- package/lib/constants/aliases.js +19 -19
- 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/base.js +5 -5
- package/lib/constants/coins/bsc.js +5 -5
- package/lib/constants/coins/celo.js +5 -5
- package/lib/constants/coins/ethereum.js +9 -9
- package/lib/constants/coins/fantom.js +7 -7
- package/lib/constants/coins/fraxtal.js +5 -5
- package/lib/constants/coins/kava.js +5 -5
- package/lib/constants/coins/mantle.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/coins/xlayer.js +5 -5
- package/lib/constants/coins/zksync.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/base.js +1 -1
- package/lib/constants/pools/bsc.js +1 -1
- package/lib/constants/pools/celo.js +1 -1
- package/lib/constants/pools/ethereum.js +2 -2
- package/lib/constants/pools/fantom.js +1 -1
- package/lib/constants/pools/fraxtal.js +1 -1
- package/lib/constants/pools/kava.js +1 -1
- package/lib/constants/pools/mantle.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/pools/xlayer.js +1 -1
- package/lib/constants/pools/zksync.js +1 -1
- package/lib/constants/tricryptoDeployImplementations.js +1 -1
- package/lib/constants/utils.js +18 -19
- package/lib/constants/volumeNetworks.js +1 -1
- package/lib/curve.d.ts +3 -1
- package/lib/curve.js +534 -909
- package/lib/dao.js +351 -705
- package/lib/external-api.js +127 -256
- package/lib/factory/common.js +4 -4
- package/lib/factory/constants-crypto.js +33 -33
- package/lib/factory/constants.js +34 -34
- package/lib/factory/deploy.js +542 -907
- package/lib/factory/factory-api.js +205 -269
- package/lib/factory/factory-crypto.js +202 -342
- package/lib/factory/factory-tricrypto.js +164 -286
- package/lib/factory/factory-twocrypto.js +151 -269
- package/lib/factory/factory.js +245 -385
- package/lib/index.js +109 -198
- package/lib/interfaces.d.ts +1 -6
- package/lib/pools/PoolTemplate.js +1773 -3025
- package/lib/pools/gaugePool.js +112 -251
- package/lib/pools/mixins/common.js +22 -93
- package/lib/pools/mixins/depositBalancedAmountsMixins.js +52 -118
- package/lib/pools/mixins/depositMixins.js +160 -386
- package/lib/pools/mixins/depositWrappedMixins.js +79 -205
- package/lib/pools/mixins/poolBalancesMixin.js +24 -87
- package/lib/pools/mixins/swapMixins.js +139 -324
- package/lib/pools/mixins/swapWrappedMixins.js +111 -265
- package/lib/pools/mixins/withdrawExpectedMixins.js +27 -91
- package/lib/pools/mixins/withdrawImbalanceMixins.js +111 -293
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +58 -169
- package/lib/pools/mixins/withdrawMixins.js +139 -359
- package/lib/pools/mixins/withdrawOneCoinExpectedMixins.js +20 -75
- package/lib/pools/mixins/withdrawOneCoinMixins.js +140 -360
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +10 -51
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +60 -167
- package/lib/pools/mixins/withdrawWrappedMixins.js +57 -167
- package/lib/pools/poolConstructor.js +5 -25
- package/lib/pools/utils.js +301 -469
- package/lib/route-finder.worker.d.ts +9 -0
- package/lib/route-finder.worker.js +112 -0
- package/lib/route-graph.worker.d.ts +11 -0
- package/lib/route-graph.worker.js +334 -0
- package/lib/router.js +323 -912
- package/lib/utils.d.ts +5 -4
- package/lib/utils.js +539 -918
- package/package.json +1 -1
package/lib/factory/factory.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
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
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -18,42 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
8
|
});
|
|
20
9
|
};
|
|
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
|
-
};
|
|
57
10
|
import { Contract as MulticallContract } from "@curvefi/ethcall";
|
|
58
11
|
import { curve } from "../curve.js";
|
|
59
12
|
import ERC20ABI from "../constants/abis/ERC20.json" assert { type: 'json' };
|
|
@@ -62,7 +15,7 @@ import gaugeChildABI from "../constants/abis/gauge_child.json" assert { type: 'j
|
|
|
62
15
|
import { getPoolIdByAddress, setFactoryZapContracts } from "./common.js";
|
|
63
16
|
import { FACTORY_CONSTANTS } from "./constants.js";
|
|
64
17
|
import { getPoolName, isStableNgPool } from "../utils.js";
|
|
65
|
-
export
|
|
18
|
+
export const BLACK_LIST = {
|
|
66
19
|
1: [
|
|
67
20
|
"0x066b6e1e93fa7dcd3f0eb7f8bac7d5a747ce0bf9",
|
|
68
21
|
"0xc61557c5d177bd7dc889a3b621eec333e168f68a",
|
|
@@ -76,110 +29,70 @@ export var BLACK_LIST = {
|
|
|
76
29
|
"0xd7bb79aee866672419999a0496d99c54741d67b5",
|
|
77
30
|
],
|
|
78
31
|
};
|
|
79
|
-
|
|
32
|
+
const deepFlatten = (arr) => [].concat(...arr.map((v) => (Array.isArray(v) ? deepFlatten(v) : v)));
|
|
80
33
|
export function getBasePools(factoryAddress, rawSwapAddresses, tmpPools) {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (item !== '0x0000000000000000000000000000000000000000') {
|
|
99
|
-
basePoolIds.push(getPoolIdByAddress(tmpPools, item));
|
|
100
|
-
basePoolAddresses.push(item);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
basePoolIds.push('');
|
|
104
|
-
basePoolAddresses.push(item);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
return [2 /*return*/, {
|
|
108
|
-
ids: basePoolIds,
|
|
109
|
-
addresses: basePoolAddresses,
|
|
110
|
-
}];
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const factoryMulticallContract = this.contracts[factoryAddress].multicallContract;
|
|
36
|
+
const calls = [];
|
|
37
|
+
for (const addr of rawSwapAddresses) {
|
|
38
|
+
calls.push(factoryMulticallContract.get_base_pool(addr));
|
|
39
|
+
}
|
|
40
|
+
const result = yield this.multicallProvider.all(calls);
|
|
41
|
+
const basePoolIds = [];
|
|
42
|
+
const basePoolAddresses = [];
|
|
43
|
+
result.forEach((item) => {
|
|
44
|
+
if (item !== '0x0000000000000000000000000000000000000000') {
|
|
45
|
+
basePoolIds.push(getPoolIdByAddress(tmpPools, item));
|
|
46
|
+
basePoolAddresses.push(item);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
basePoolIds.push('');
|
|
50
|
+
basePoolAddresses.push(item);
|
|
111
51
|
}
|
|
112
52
|
});
|
|
53
|
+
return {
|
|
54
|
+
ids: basePoolIds,
|
|
55
|
+
addresses: basePoolAddresses,
|
|
56
|
+
};
|
|
113
57
|
});
|
|
114
58
|
}
|
|
115
59
|
function getRecentlyCreatedPoolId(swapAddress, factoryAddress) {
|
|
116
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
case 1:
|
|
127
|
-
poolCount = _a.apply(void 0, [_c.apply(_b, [_e.sent(), 0])]);
|
|
128
|
-
i = 1;
|
|
129
|
-
_e.label = 2;
|
|
130
|
-
case 2:
|
|
131
|
-
if (!(i <= poolCount)) return [3 /*break*/, 5];
|
|
132
|
-
return [4 /*yield*/, factoryContract.pool_list(poolCount - i)];
|
|
133
|
-
case 3:
|
|
134
|
-
address = _e.sent();
|
|
135
|
-
if (address.toLowerCase() === swapAddress.toLowerCase())
|
|
136
|
-
return [2 /*return*/, "".concat(prefix, "-").concat(poolCount - i)];
|
|
137
|
-
_e.label = 4;
|
|
138
|
-
case 4:
|
|
139
|
-
i++;
|
|
140
|
-
return [3 /*break*/, 2];
|
|
141
|
-
case 5: throw Error("Unknown pool");
|
|
142
|
-
}
|
|
143
|
-
});
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const factoryContract = this.contracts[factoryAddress].contract;
|
|
62
|
+
const prefix = factoryAddress === this.constants.ALIASES.factory ? 'factory-v2' : 'factory-stable-ng';
|
|
63
|
+
const poolCount = Number(curve.formatUnits(yield factoryContract.pool_count(this.constantOptions), 0));
|
|
64
|
+
for (let i = 1; i <= poolCount; i++) {
|
|
65
|
+
const address = yield factoryContract.pool_list(poolCount - i);
|
|
66
|
+
if (address.toLowerCase() === swapAddress.toLowerCase())
|
|
67
|
+
return `${prefix}-${poolCount - i}`;
|
|
68
|
+
}
|
|
69
|
+
throw Error("Unknown pool");
|
|
144
70
|
});
|
|
145
71
|
}
|
|
146
|
-
function getFactoryIdsAndSwapAddresses(fromIdx, factoryAddress) {
|
|
72
|
+
function getFactoryIdsAndSwapAddresses(fromIdx = 0, factoryAddress) {
|
|
147
73
|
var _a;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return [2 /*return*/, [[], []]];
|
|
167
|
-
prefix = factoryAddress === this.constants.ALIASES.factory ? "factory-v2-" :
|
|
168
|
-
factoryAddress === this.constants.ALIASES.crvusd_factory ? "factory-crvusd-" :
|
|
169
|
-
factoryAddress === this.constants.ALIASES.stable_ng_factory ? "factory-stable-ng-" : "factory-eywa-";
|
|
170
|
-
return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
171
|
-
case 2:
|
|
172
|
-
factories = (_f.sent()).map(function (addr, i) { return ({ id: prefix + (fromIdx + i), address: addr.toLowerCase() }); });
|
|
173
|
-
swapAddresses = Object.values(this.constants.POOLS_DATA).map(function (pool) { return pool.swap_address.toLowerCase(); });
|
|
174
|
-
blacklist = (_a = BLACK_LIST[this.chainId]) !== null && _a !== void 0 ? _a : [];
|
|
175
|
-
factories = factories.filter(function (f) { return !swapAddresses.includes(f.address) && !blacklist.includes(f.address); });
|
|
176
|
-
return [2 /*return*/, [factories.map(function (f) { return f.id; }), factories.map(function (f) { return f.address; })]];
|
|
177
|
-
}
|
|
178
|
-
});
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const factoryContract = this.contracts[factoryAddress].contract;
|
|
76
|
+
const factoryMulticallContract = this.contracts[factoryAddress].multicallContract;
|
|
77
|
+
const poolCount = Number(curve.formatUnits(yield factoryContract.pool_count(this.constantOptions), 0));
|
|
78
|
+
const calls = [];
|
|
79
|
+
for (let i = fromIdx; i < poolCount; i++) {
|
|
80
|
+
calls.push(factoryMulticallContract.pool_list(i));
|
|
81
|
+
}
|
|
82
|
+
if (calls.length === 0)
|
|
83
|
+
return [[], []];
|
|
84
|
+
const prefix = factoryAddress === this.constants.ALIASES.factory ? "factory-v2-" :
|
|
85
|
+
factoryAddress === this.constants.ALIASES.crvusd_factory ? "factory-crvusd-" :
|
|
86
|
+
factoryAddress === this.constants.ALIASES.stable_ng_factory ? "factory-stable-ng-" : "factory-eywa-";
|
|
87
|
+
let factories = (yield this.multicallProvider.all(calls)).map((addr, i) => ({ id: prefix + (fromIdx + i), address: addr.toLowerCase() }));
|
|
88
|
+
const swapAddresses = Object.values(this.constants.POOLS_DATA).map((pool) => pool.swap_address.toLowerCase());
|
|
89
|
+
const blacklist = (_a = BLACK_LIST[this.chainId]) !== null && _a !== void 0 ? _a : [];
|
|
90
|
+
factories = factories.filter((f) => !swapAddresses.includes(f.address) && !blacklist.includes(f.address));
|
|
91
|
+
return [factories.map((f) => f.id), factories.map((f) => f.address)];
|
|
179
92
|
});
|
|
180
93
|
}
|
|
181
94
|
function _handleReferenceAssets(referenceAssets) {
|
|
182
|
-
return referenceAssets.map(
|
|
95
|
+
return referenceAssets.map((t) => {
|
|
183
96
|
return {
|
|
184
97
|
0: "USD",
|
|
185
98
|
1: "ETH",
|
|
@@ -188,287 +101,234 @@ function _handleReferenceAssets(referenceAssets) {
|
|
|
188
101
|
});
|
|
189
102
|
}
|
|
190
103
|
function _handleCoinAddresses(coinAddresses) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
.
|
|
194
|
-
.map(function (addr) { return _this.chainId === 137 && addr === "0x0000000000000000000000000000000000001010" ? _this.constants.NATIVE_TOKEN.address : addr.toLowerCase(); }); });
|
|
104
|
+
return coinAddresses.map((addresses) => addresses
|
|
105
|
+
.filter((addr) => addr !== curve.constants.ZERO_ADDRESS)
|
|
106
|
+
.map((addr) => this.chainId === 137 && addr === "0x0000000000000000000000000000000000001010" ? this.constants.NATIVE_TOKEN.address : addr.toLowerCase()));
|
|
195
107
|
}
|
|
196
108
|
function getPoolsData(factorySwapAddresses, factoryAddress) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
addr = factorySwapAddresses_1[_i];
|
|
209
|
-
tempSwapContract = new MulticallContract(addr, ERC20ABI);
|
|
210
|
-
calls.push(factoryMulticallContract.get_implementation_address(addr));
|
|
211
|
-
if (this.chainId === 1) {
|
|
212
|
-
calls.push(factoryMulticallContract.get_gauge(addr));
|
|
213
|
-
}
|
|
214
|
-
else if (!isFactoryGaugeNull) {
|
|
215
|
-
calls.push(factoryGaugeContract.get_gauge_from_lp_token(addr));
|
|
216
|
-
}
|
|
217
|
-
if (!isStableNgFactory) {
|
|
218
|
-
calls.push(factoryMulticallContract.get_pool_asset_type(addr));
|
|
219
|
-
}
|
|
220
|
-
calls.push(tempSwapContract.symbol());
|
|
221
|
-
calls.push(tempSwapContract.name());
|
|
222
|
-
calls.push(factoryMulticallContract.is_meta(addr));
|
|
223
|
-
calls.push(factoryMulticallContract.get_coins(addr));
|
|
224
|
-
}
|
|
225
|
-
return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
226
|
-
case 1:
|
|
227
|
-
res = _a.sent();
|
|
228
|
-
if (isFactoryGaugeNull) {
|
|
229
|
-
for (index = 0; index < res.length; index++) {
|
|
230
|
-
if (index % 7 == 1) {
|
|
231
|
-
res.splice(index, 0, '0x0000000000000000000000000000000000000000');
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
if (isStableNgFactory) {
|
|
236
|
-
for (index = 0; index < res.length; index++) {
|
|
237
|
-
if (index % 7 == 2) {
|
|
238
|
-
res.splice(index, 0, -1);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
implememntationAddresses = res.filter(function (a, i) { return i % 7 == 0; }).map(function (a) { return a.toLowerCase(); });
|
|
243
|
-
gaugeAddresses = res.filter(function (a, i) { return i % 7 == 1; }).map(function (a) { return a.toLowerCase(); });
|
|
244
|
-
referenceAssets = _handleReferenceAssets(res.filter(function (a, i) { return i % 7 == 2; }));
|
|
245
|
-
symbols = res.filter(function (a, i) { return i % 7 == 3; });
|
|
246
|
-
names = res.filter(function (a, i) { return i % 7 == 4; });
|
|
247
|
-
isMeta = res.filter(function (a, i) { return i % 7 == 5; });
|
|
248
|
-
coinAddresses = _handleCoinAddresses.call(this, res.filter(function (a, i) { return i % 7 == 6; }));
|
|
249
|
-
return [2 /*return*/, [implememntationAddresses, gaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses]];
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const factoryMulticallContract = this.contracts[factoryAddress].multicallContract;
|
|
111
|
+
const isFactoryGaugeNull = this.constants.ALIASES.gauge_factory === '0x0000000000000000000000000000000000000000';
|
|
112
|
+
const isStableNgFactory = factoryAddress === this.constants.ALIASES['stable_ng_factory'];
|
|
113
|
+
const factoryGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
114
|
+
const calls = [];
|
|
115
|
+
for (const addr of factorySwapAddresses) {
|
|
116
|
+
const tempSwapContract = new MulticallContract(addr, ERC20ABI);
|
|
117
|
+
calls.push(factoryMulticallContract.get_implementation_address(addr));
|
|
118
|
+
if (this.chainId === 1) {
|
|
119
|
+
calls.push(factoryMulticallContract.get_gauge(addr));
|
|
250
120
|
}
|
|
251
|
-
|
|
121
|
+
else if (!isFactoryGaugeNull) {
|
|
122
|
+
calls.push(factoryGaugeContract.get_gauge_from_lp_token(addr));
|
|
123
|
+
}
|
|
124
|
+
if (!isStableNgFactory) {
|
|
125
|
+
calls.push(factoryMulticallContract.get_pool_asset_type(addr));
|
|
126
|
+
}
|
|
127
|
+
calls.push(tempSwapContract.symbol());
|
|
128
|
+
calls.push(tempSwapContract.name());
|
|
129
|
+
calls.push(factoryMulticallContract.is_meta(addr));
|
|
130
|
+
calls.push(factoryMulticallContract.get_coins(addr));
|
|
131
|
+
}
|
|
132
|
+
const res = yield this.multicallProvider.all(calls);
|
|
133
|
+
if (isFactoryGaugeNull) {
|
|
134
|
+
for (let index = 0; index < res.length; index++) {
|
|
135
|
+
if (index % 7 == 1) {
|
|
136
|
+
res.splice(index, 0, '0x0000000000000000000000000000000000000000');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (isStableNgFactory) {
|
|
141
|
+
for (let index = 0; index < res.length; index++) {
|
|
142
|
+
if (index % 7 == 2) {
|
|
143
|
+
res.splice(index, 0, -1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const implememntationAddresses = res.filter((a, i) => i % 7 == 0).map((a) => a.toLowerCase());
|
|
148
|
+
const gaugeAddresses = res.filter((a, i) => i % 7 == 1).map((a) => a.toLowerCase());
|
|
149
|
+
const referenceAssets = _handleReferenceAssets(res.filter((a, i) => i % 7 == 2));
|
|
150
|
+
const symbols = res.filter((a, i) => i % 7 == 3);
|
|
151
|
+
const names = res.filter((a, i) => i % 7 == 4);
|
|
152
|
+
const isMeta = res.filter((a, i) => i % 7 == 5);
|
|
153
|
+
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 7 == 6));
|
|
154
|
+
return [implememntationAddresses, gaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses];
|
|
252
155
|
});
|
|
253
156
|
}
|
|
254
157
|
function setFactorySwapContracts(factorySwapAddresses, factorySwapABIs) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
_this.setContract(addr, factorySwapABIs[i]);
|
|
158
|
+
factorySwapAddresses.forEach((addr, i) => {
|
|
159
|
+
this.setContract(addr, factorySwapABIs[i]);
|
|
258
160
|
});
|
|
259
161
|
}
|
|
260
162
|
function setFactoryGaugeContracts(factoryGaugeAddresses) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
_this.setContract(addr, _this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
|
|
163
|
+
factoryGaugeAddresses.filter((addr) => addr !== curve.constants.ZERO_ADDRESS).forEach((addr, i) => {
|
|
164
|
+
this.setContract(addr, this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
|
|
264
165
|
});
|
|
265
166
|
}
|
|
266
167
|
function setFactoryCoinsContracts(coinAddresses) {
|
|
267
|
-
|
|
268
|
-
for (
|
|
269
|
-
var addr = flattenedCoinAddresses_1[_i];
|
|
168
|
+
const flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses)));
|
|
169
|
+
for (const addr of flattenedCoinAddresses) {
|
|
270
170
|
if (addr in this.contracts)
|
|
271
171
|
continue;
|
|
272
172
|
this.setContract(addr, ERC20ABI);
|
|
273
173
|
}
|
|
274
174
|
}
|
|
275
175
|
function getExistingCoinAddressNameDict() {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
poolData.wrapped_coin_addresses.forEach(
|
|
176
|
+
const dict = {};
|
|
177
|
+
for (const poolData of Object.values(this.constants.POOLS_DATA)) {
|
|
178
|
+
poolData.wrapped_coin_addresses.forEach((addr, i) => {
|
|
279
179
|
if (!(addr.toLowerCase() in dict)) {
|
|
280
180
|
dict[addr.toLowerCase()] = poolData.wrapped_coins[i];
|
|
281
181
|
}
|
|
282
182
|
});
|
|
283
|
-
poolData.underlying_coin_addresses.forEach(
|
|
183
|
+
poolData.underlying_coin_addresses.forEach((addr, i) => {
|
|
284
184
|
if (!(addr.toLowerCase() in dict)) {
|
|
285
185
|
dict[addr.toLowerCase()] = poolData.underlying_coins[i];
|
|
286
186
|
}
|
|
287
187
|
});
|
|
288
|
-
};
|
|
289
|
-
for (var _i = 0, _a = Object.values(this.constants.POOLS_DATA); _i < _a.length; _i++) {
|
|
290
|
-
var poolData = _a[_i];
|
|
291
|
-
_loop_1(poolData);
|
|
292
188
|
}
|
|
293
189
|
dict[this.constants.NATIVE_TOKEN.address] = this.constants.NATIVE_TOKEN.symbol;
|
|
294
190
|
return dict;
|
|
295
191
|
}
|
|
296
192
|
function getCoinsData(coinAddresses, existingCoinAddrNameDict, existingCoinAddrDecimalsDict) {
|
|
297
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
coinAddrNamesDict[addr] = existingCoinAddrNameDict[addr];
|
|
310
|
-
coinAddrDecimalsDict[addr] = existingCoinAddrDecimalsDict[addr];
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
newCoinAddresses.push(addr);
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
calls = [];
|
|
317
|
-
for (_a = 0, newCoinAddresses_1 = newCoinAddresses; _a < newCoinAddresses_1.length; _a++) {
|
|
318
|
-
addr = newCoinAddresses_1[_a];
|
|
319
|
-
calls.push(this.contracts[addr].multicallContract.symbol());
|
|
320
|
-
calls.push(this.contracts[addr].multicallContract.decimals());
|
|
321
|
-
}
|
|
322
|
-
return [4 /*yield*/, this.multicallProvider.all(calls)];
|
|
323
|
-
case 1:
|
|
324
|
-
res = _b.sent();
|
|
325
|
-
symbols = res.filter(function (a, i) { return i % 2 == 0; });
|
|
326
|
-
decimals = res.filter(function (a, i) { return i % 2 == 1; }).map(function (_d) { return Number(curve.formatUnits(_d, 0)); });
|
|
327
|
-
newCoinAddresses.forEach(function (addr, i) {
|
|
328
|
-
coinAddrNamesDict[addr] = symbols[i];
|
|
329
|
-
coinAddrDecimalsDict[addr] = decimals[i];
|
|
330
|
-
});
|
|
331
|
-
return [2 /*return*/, [coinAddrNamesDict, coinAddrDecimalsDict]];
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
const flattenedCoinAddresses = Array.from(new Set(deepFlatten(coinAddresses)));
|
|
195
|
+
const newCoinAddresses = [];
|
|
196
|
+
const coinAddrNamesDict = {};
|
|
197
|
+
const coinAddrDecimalsDict = {};
|
|
198
|
+
for (const addr of flattenedCoinAddresses) {
|
|
199
|
+
if (addr in existingCoinAddrNameDict) {
|
|
200
|
+
coinAddrNamesDict[addr] = existingCoinAddrNameDict[addr];
|
|
201
|
+
coinAddrDecimalsDict[addr] = existingCoinAddrDecimalsDict[addr];
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
newCoinAddresses.push(addr);
|
|
332
205
|
}
|
|
206
|
+
}
|
|
207
|
+
const calls = [];
|
|
208
|
+
for (const addr of newCoinAddresses) {
|
|
209
|
+
calls.push(this.contracts[addr].multicallContract.symbol());
|
|
210
|
+
calls.push(this.contracts[addr].multicallContract.decimals());
|
|
211
|
+
}
|
|
212
|
+
const res = yield this.multicallProvider.all(calls);
|
|
213
|
+
const symbols = res.filter((a, i) => i % 2 == 0);
|
|
214
|
+
const decimals = res.filter((a, i) => i % 2 == 1).map((_d) => Number(curve.formatUnits(_d, 0)));
|
|
215
|
+
newCoinAddresses.forEach((addr, i) => {
|
|
216
|
+
coinAddrNamesDict[addr] = symbols[i];
|
|
217
|
+
coinAddrDecimalsDict[addr] = decimals[i];
|
|
333
218
|
});
|
|
219
|
+
return [coinAddrNamesDict, coinAddrDecimalsDict];
|
|
334
220
|
});
|
|
335
221
|
}
|
|
336
|
-
export function getFactoryPoolData(fromIdx, swapAddress, factoryAddress) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
poolSymbols = [];
|
|
366
|
-
poolNames = [];
|
|
367
|
-
isMeta = [];
|
|
368
|
-
coinAddresses = [];
|
|
369
|
-
implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
370
|
-
for (i = 0; i < rawPoolIds.length; i++) {
|
|
371
|
-
if (rawImplementations[i] in implementationABIDict) {
|
|
372
|
-
poolIds.push(rawPoolIds[i]);
|
|
373
|
-
swapAddresses.push(rawSwapAddresses[i]);
|
|
374
|
-
implementations.push(rawImplementations[i]);
|
|
375
|
-
gaugeAddresses.push(rawGauges[i]);
|
|
376
|
-
referenceAssets.push(rawReferenceAssets[i]);
|
|
377
|
-
poolSymbols.push(rawPoolSymbols[i]);
|
|
378
|
-
poolNames.push(rawPoolNames[i]);
|
|
379
|
-
isMeta.push(rawIsMeta[i]);
|
|
380
|
-
coinAddresses.push(rawCoinAddresses[i]);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
swapABIs = implementations.map(function (addr) { return implementationABIDict[addr]; });
|
|
384
|
-
setFactorySwapContracts.call(this, swapAddresses, swapABIs);
|
|
385
|
-
setFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
386
|
-
setFactoryCoinsContracts.call(this, coinAddresses);
|
|
387
|
-
setFactoryZapContracts.call(this, false);
|
|
388
|
-
return [4 /*yield*/, getCoinsData.call(this, coinAddresses, getExistingCoinAddressNameDict.call(this), this.constants.DECIMALS)];
|
|
389
|
-
case 6:
|
|
390
|
-
_e = _f.sent(), coinAddressNameDict = _e[0], coinAddressDecimalsDict = _e[1];
|
|
391
|
-
tmpPools = [];
|
|
392
|
-
poolIds.forEach(function (item, index) {
|
|
393
|
-
tmpPools.push({
|
|
394
|
-
id: item,
|
|
395
|
-
address: swapAddresses[index],
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
return [4 /*yield*/, getBasePools.call(this, factoryAddress, swapAddresses, tmpPools)];
|
|
399
|
-
case 7:
|
|
400
|
-
basePools = _f.sent();
|
|
401
|
-
FACTORY_POOLS_DATA = {};
|
|
402
|
-
_loop_2 = function (i) {
|
|
403
|
-
if (!isMeta[i]) {
|
|
404
|
-
FACTORY_POOLS_DATA[poolIds[i]] = {
|
|
405
|
-
name: getPoolName(poolNames[i]),
|
|
406
|
-
full_name: poolNames[i],
|
|
407
|
-
symbol: poolSymbols[i],
|
|
408
|
-
reference_asset: referenceAssets[i],
|
|
409
|
-
swap_address: swapAddresses[i],
|
|
410
|
-
token_address: swapAddresses[i],
|
|
411
|
-
gauge_address: gaugeAddresses[i],
|
|
412
|
-
implementation_address: implementations[i],
|
|
413
|
-
is_plain: true,
|
|
414
|
-
is_factory: true,
|
|
415
|
-
underlying_coins: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }), true),
|
|
416
|
-
wrapped_coins: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }), true),
|
|
417
|
-
underlying_coin_addresses: coinAddresses[i],
|
|
418
|
-
wrapped_coin_addresses: coinAddresses[i],
|
|
419
|
-
underlying_decimals: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }), true),
|
|
420
|
-
wrapped_decimals: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }), true),
|
|
421
|
-
swap_abi: swapABIs[i],
|
|
422
|
-
gauge_abi: this_1.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
423
|
-
is_ng: factoryAddress === curve.constants.ALIASES.stable_ng_factory,
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
var allPoolsData_1 = __assign(__assign(__assign({}, this_1.constants.POOLS_DATA), this_1.constants.FACTORY_POOLS_DATA), FACTORY_POOLS_DATA);
|
|
428
|
-
// @ts-ignore
|
|
429
|
-
var basePoolIdCoinsDict = Object.fromEntries(basePools.ids.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins]; }));
|
|
430
|
-
// @ts-ignore
|
|
431
|
-
var basePoolIdCoinAddressesDict = Object.fromEntries(basePools.ids.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coin_addresses]; }));
|
|
432
|
-
// @ts-ignore
|
|
433
|
-
var basePoolIdDecimalsDict = Object.fromEntries(basePools.ids.map(function (poolId) { var _a; return [poolId, (_a = allPoolsData_1[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_decimals]; }));
|
|
434
|
-
var basePoolIdZapDict = FACTORY_CONSTANTS[this_1.chainId].basePoolIdZapDict;
|
|
435
|
-
this_1.constants.BASE_POOLS[basePools.ids[i]] = this_1.constants.BASE_POOLS[basePools.ids[i]] ? this_1.constants.BASE_POOLS[basePools.ids[i]] + 1 : 1;
|
|
436
|
-
var basePoolZap = isStableNgPool(basePools.ids[i]) ? FACTORY_CONSTANTS[this_1.chainId].stableNgBasePoolZap : basePoolIdZapDict[basePools.ids[i]];
|
|
437
|
-
if (isStableNgPool(basePools.ids[i])) {
|
|
438
|
-
this_1.setContract(FACTORY_CONSTANTS[this_1.chainId].stableNgBasePoolZap.address, FACTORY_CONSTANTS[this_1.chainId].stableNgBasePoolZap.ABI);
|
|
439
|
-
}
|
|
440
|
-
FACTORY_POOLS_DATA[poolIds[i]] = {
|
|
441
|
-
name: getPoolName(poolNames[i]),
|
|
442
|
-
full_name: poolNames[i],
|
|
443
|
-
symbol: poolSymbols[i],
|
|
444
|
-
reference_asset: referenceAssets[i],
|
|
445
|
-
swap_address: swapAddresses[i],
|
|
446
|
-
token_address: swapAddresses[i],
|
|
447
|
-
gauge_address: gaugeAddresses[i],
|
|
448
|
-
deposit_address: basePoolZap.address,
|
|
449
|
-
implementation_address: implementations[i],
|
|
450
|
-
is_meta: true,
|
|
451
|
-
is_factory: true,
|
|
452
|
-
base_pool: basePools.ids[i],
|
|
453
|
-
underlying_coins: __spreadArray([coinAddressNameDict[coinAddresses[i][0]]], basePoolIdCoinsDict[basePools.ids[i]], true),
|
|
454
|
-
wrapped_coins: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressNameDict[addr]; }), true),
|
|
455
|
-
underlying_coin_addresses: __spreadArray([coinAddresses[i][0]], basePoolIdCoinAddressesDict[basePools.ids[i]], true),
|
|
456
|
-
wrapped_coin_addresses: coinAddresses[i],
|
|
457
|
-
underlying_decimals: __spreadArray([coinAddressDecimalsDict[coinAddresses[i][0]]], basePoolIdDecimalsDict[basePools.ids[i]], true),
|
|
458
|
-
wrapped_decimals: __spreadArray([], coinAddresses[i].map(function (addr) { return coinAddressDecimalsDict[addr]; }), true),
|
|
459
|
-
swap_abi: swapABIs[i],
|
|
460
|
-
gauge_abi: this_1.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
461
|
-
deposit_abi: basePoolZap.ABI,
|
|
462
|
-
is_ng: factoryAddress === curve.constants.ALIASES.stable_ng_factory,
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
this_1 = this;
|
|
467
|
-
for (i = 0; i < poolIds.length; i++) {
|
|
468
|
-
_loop_2(i);
|
|
469
|
-
}
|
|
470
|
-
return [2 /*return*/, FACTORY_POOLS_DATA];
|
|
222
|
+
export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = curve.constants.ALIASES.factory) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
+
const [rawPoolIds, rawSwapAddresses] = swapAddress ?
|
|
225
|
+
[[yield getRecentlyCreatedPoolId.call(this, swapAddress, factoryAddress)], [swapAddress.toLowerCase()]]
|
|
226
|
+
: yield getFactoryIdsAndSwapAddresses.call(this, fromIdx, factoryAddress);
|
|
227
|
+
if (rawPoolIds.length === 0)
|
|
228
|
+
return {};
|
|
229
|
+
const [rawImplementations, rawGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses] = yield getPoolsData.call(this, rawSwapAddresses, factoryAddress);
|
|
230
|
+
const poolIds = [];
|
|
231
|
+
const swapAddresses = [];
|
|
232
|
+
const implementations = [];
|
|
233
|
+
const gaugeAddresses = [];
|
|
234
|
+
const referenceAssets = [];
|
|
235
|
+
const poolSymbols = [];
|
|
236
|
+
const poolNames = [];
|
|
237
|
+
const isMeta = [];
|
|
238
|
+
const coinAddresses = [];
|
|
239
|
+
const implementationABIDict = FACTORY_CONSTANTS[this.chainId].implementationABIDict;
|
|
240
|
+
for (let i = 0; i < rawPoolIds.length; i++) {
|
|
241
|
+
if (rawImplementations[i] in implementationABIDict) {
|
|
242
|
+
poolIds.push(rawPoolIds[i]);
|
|
243
|
+
swapAddresses.push(rawSwapAddresses[i]);
|
|
244
|
+
implementations.push(rawImplementations[i]);
|
|
245
|
+
gaugeAddresses.push(rawGauges[i]);
|
|
246
|
+
referenceAssets.push(rawReferenceAssets[i]);
|
|
247
|
+
poolSymbols.push(rawPoolSymbols[i]);
|
|
248
|
+
poolNames.push(rawPoolNames[i]);
|
|
249
|
+
isMeta.push(rawIsMeta[i]);
|
|
250
|
+
coinAddresses.push(rawCoinAddresses[i]);
|
|
471
251
|
}
|
|
252
|
+
}
|
|
253
|
+
const swapABIs = implementations.map((addr) => implementationABIDict[addr]);
|
|
254
|
+
setFactorySwapContracts.call(this, swapAddresses, swapABIs);
|
|
255
|
+
setFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
256
|
+
setFactoryCoinsContracts.call(this, coinAddresses);
|
|
257
|
+
setFactoryZapContracts.call(this, false);
|
|
258
|
+
const [coinAddressNameDict, coinAddressDecimalsDict] = yield getCoinsData.call(this, coinAddresses, getExistingCoinAddressNameDict.call(this), this.constants.DECIMALS);
|
|
259
|
+
const tmpPools = [];
|
|
260
|
+
poolIds.forEach((item, index) => {
|
|
261
|
+
tmpPools.push({
|
|
262
|
+
id: item,
|
|
263
|
+
address: swapAddresses[index],
|
|
264
|
+
});
|
|
472
265
|
});
|
|
266
|
+
const basePools = yield getBasePools.call(this, factoryAddress, swapAddresses, tmpPools);
|
|
267
|
+
const FACTORY_POOLS_DATA = {};
|
|
268
|
+
for (let i = 0; i < poolIds.length; i++) {
|
|
269
|
+
if (!isMeta[i]) {
|
|
270
|
+
FACTORY_POOLS_DATA[poolIds[i]] = {
|
|
271
|
+
name: getPoolName(poolNames[i]),
|
|
272
|
+
full_name: poolNames[i],
|
|
273
|
+
symbol: poolSymbols[i],
|
|
274
|
+
reference_asset: referenceAssets[i],
|
|
275
|
+
swap_address: swapAddresses[i],
|
|
276
|
+
token_address: swapAddresses[i],
|
|
277
|
+
gauge_address: gaugeAddresses[i],
|
|
278
|
+
implementation_address: implementations[i],
|
|
279
|
+
is_plain: true,
|
|
280
|
+
is_factory: true,
|
|
281
|
+
underlying_coins: [...coinAddresses[i].map((addr) => coinAddressNameDict[addr])],
|
|
282
|
+
wrapped_coins: [...coinAddresses[i].map((addr) => coinAddressNameDict[addr])],
|
|
283
|
+
underlying_coin_addresses: coinAddresses[i],
|
|
284
|
+
wrapped_coin_addresses: coinAddresses[i],
|
|
285
|
+
underlying_decimals: [...coinAddresses[i].map((addr) => coinAddressDecimalsDict[addr])],
|
|
286
|
+
wrapped_decimals: [...coinAddresses[i].map((addr) => coinAddressDecimalsDict[addr])],
|
|
287
|
+
swap_abi: swapABIs[i],
|
|
288
|
+
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
289
|
+
is_ng: factoryAddress === curve.constants.ALIASES.stable_ng_factory,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
const allPoolsData = Object.assign(Object.assign(Object.assign({}, this.constants.POOLS_DATA), this.constants.FACTORY_POOLS_DATA), FACTORY_POOLS_DATA);
|
|
294
|
+
// @ts-ignore
|
|
295
|
+
const basePoolIdCoinsDict = Object.fromEntries(basePools.ids.map((poolId) => { var _a; return [poolId, (_a = allPoolsData[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coins]; }));
|
|
296
|
+
// @ts-ignore
|
|
297
|
+
const basePoolIdCoinAddressesDict = Object.fromEntries(basePools.ids.map((poolId) => { var _a; return [poolId, (_a = allPoolsData[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_coin_addresses]; }));
|
|
298
|
+
// @ts-ignore
|
|
299
|
+
const basePoolIdDecimalsDict = Object.fromEntries(basePools.ids.map((poolId) => { var _a; return [poolId, (_a = allPoolsData[poolId]) === null || _a === void 0 ? void 0 : _a.underlying_decimals]; }));
|
|
300
|
+
const basePoolIdZapDict = FACTORY_CONSTANTS[this.chainId].basePoolIdZapDict;
|
|
301
|
+
this.constants.BASE_POOLS[basePools.ids[i]] = this.constants.BASE_POOLS[basePools.ids[i]] ? this.constants.BASE_POOLS[basePools.ids[i]] + 1 : 1;
|
|
302
|
+
const basePoolZap = isStableNgPool(basePools.ids[i]) ? FACTORY_CONSTANTS[this.chainId].stableNgBasePoolZap : basePoolIdZapDict[basePools.ids[i]];
|
|
303
|
+
if (isStableNgPool(basePools.ids[i])) {
|
|
304
|
+
this.setContract(FACTORY_CONSTANTS[this.chainId].stableNgBasePoolZap.address, FACTORY_CONSTANTS[this.chainId].stableNgBasePoolZap.ABI);
|
|
305
|
+
}
|
|
306
|
+
FACTORY_POOLS_DATA[poolIds[i]] = {
|
|
307
|
+
name: getPoolName(poolNames[i]),
|
|
308
|
+
full_name: poolNames[i],
|
|
309
|
+
symbol: poolSymbols[i],
|
|
310
|
+
reference_asset: referenceAssets[i],
|
|
311
|
+
swap_address: swapAddresses[i],
|
|
312
|
+
token_address: swapAddresses[i],
|
|
313
|
+
gauge_address: gaugeAddresses[i],
|
|
314
|
+
deposit_address: basePoolZap.address,
|
|
315
|
+
implementation_address: implementations[i],
|
|
316
|
+
is_meta: true,
|
|
317
|
+
is_factory: true,
|
|
318
|
+
base_pool: basePools.ids[i],
|
|
319
|
+
underlying_coins: [coinAddressNameDict[coinAddresses[i][0]], ...basePoolIdCoinsDict[basePools.ids[i]]],
|
|
320
|
+
wrapped_coins: [...coinAddresses[i].map((addr) => coinAddressNameDict[addr])],
|
|
321
|
+
underlying_coin_addresses: [coinAddresses[i][0], ...basePoolIdCoinAddressesDict[basePools.ids[i]]],
|
|
322
|
+
wrapped_coin_addresses: coinAddresses[i],
|
|
323
|
+
underlying_decimals: [coinAddressDecimalsDict[coinAddresses[i][0]], ...basePoolIdDecimalsDict[basePools.ids[i]]],
|
|
324
|
+
wrapped_decimals: [...coinAddresses[i].map((addr) => coinAddressDecimalsDict[addr])],
|
|
325
|
+
swap_abi: swapABIs[i],
|
|
326
|
+
gauge_abi: this.chainId === 1 ? factoryGaugeABI : gaugeChildABI,
|
|
327
|
+
deposit_abi: basePoolZap.ABI,
|
|
328
|
+
is_ng: factoryAddress === curve.constants.ALIASES.stable_ng_factory,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return FACTORY_POOLS_DATA;
|
|
473
333
|
});
|
|
474
334
|
}
|