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