@curvefi/api 2.63.2 → 2.63.4
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/constants/aliases.js +3 -2
- package/lib/curve.js +3 -0
- package/lib/dao.js +12 -12
- package/lib/factory/factory-crypto.js +26 -17
- package/lib/factory/factory-tricrypto.js +29 -32
- package/lib/factory/factory-twocrypto.js +28 -29
- package/lib/factory/factory.js +27 -24
- package/lib/interfaces.d.ts +2 -1
- package/package.json +1 -1
package/lib/constants/aliases.js
CHANGED
|
@@ -129,7 +129,8 @@ export const ALIASES_OPTIMISM = lowerCaseValues({
|
|
|
129
129
|
});
|
|
130
130
|
export const ALIASES_XDAI = lowerCaseValues({
|
|
131
131
|
"crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
|
|
132
|
-
"gauge_factory": "
|
|
132
|
+
"gauge_factory": "0x7BE6BD57A319A7180f71552E58c9d32Da32b6f96",
|
|
133
|
+
"gauge_factory_old": "0xabC000d88f23Bb45525E447528DBF656A9D55bf5",
|
|
133
134
|
"voting_escrow": "0xefde221f306152971d8e9f181bfe998447975810",
|
|
134
135
|
"fee_distributor": "0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc",
|
|
135
136
|
"gauge_controller": "0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB",
|
|
@@ -143,7 +144,7 @@ export const ALIASES_XDAI = lowerCaseValues({
|
|
|
143
144
|
"eywa_factory": '0x37F22A0B028f2152e6CAcef210e0C4d3b875f367',
|
|
144
145
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
145
146
|
"twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
|
|
146
|
-
"tricrypto_factory": '
|
|
147
|
+
"tricrypto_factory": '0xb47988aD49DCE8D909c6f9Cf7B26caF04e1445c8',
|
|
147
148
|
"stable_ng_factory": '0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8',
|
|
148
149
|
"factory_admin": "",
|
|
149
150
|
});
|
package/lib/curve.js
CHANGED
|
@@ -787,6 +787,9 @@ class Curve {
|
|
|
787
787
|
this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
|
|
788
788
|
const _gaugeFactoryABI = this.chainId === 1 ? gaugeFactoryABI : gaugeFactorySidechainABI;
|
|
789
789
|
this.setContract(this.constants.ALIASES.gauge_factory, _gaugeFactoryABI);
|
|
790
|
+
if ("gauge_factory_old" in this.constants.ALIASES) {
|
|
791
|
+
this.setContract(this.constants.ALIASES.gauge_factory_old, _gaugeFactoryABI);
|
|
792
|
+
}
|
|
790
793
|
if (this.chainId === 1) {
|
|
791
794
|
this.setContract(this.constants.ALIASES.minter, minterMainnetABI);
|
|
792
795
|
this.setContract(this.constants.ALIASES.gauge_factory_fraxtal, gaugeFactoryForFraxtalABI);
|
package/lib/dao.js
CHANGED
|
@@ -193,7 +193,7 @@ const _extractNetworkFromPoolUrl = (poolUrl) => {
|
|
|
193
193
|
return poolUrl.split("/")[4];
|
|
194
194
|
};
|
|
195
195
|
export const getVotingGaugeList = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
|
-
var _a;
|
|
196
|
+
var _a, _b;
|
|
197
197
|
if (curve.chainId !== 1)
|
|
198
198
|
throw Error("Ethereum-only method");
|
|
199
199
|
const gaugeData = Object.values(yield _getAllGauges());
|
|
@@ -202,21 +202,21 @@ export const getVotingGaugeList = () => __awaiter(void 0, void 0, void 0, functi
|
|
|
202
202
|
if ((gaugeData[i].is_killed || gaugeData[i].hasNoCrv) && Number(gaugeData[i].gauge_controller.gauge_relative_weight) === 0)
|
|
203
203
|
continue;
|
|
204
204
|
res.push({
|
|
205
|
-
poolUrl: gaugeData[i].poolUrls.swap[0],
|
|
206
|
-
network:
|
|
205
|
+
poolUrl: ((_a = gaugeData[i].poolUrls) === null || _a === void 0 ? void 0 : _a.swap[0]) || '',
|
|
206
|
+
network: gaugeData[i].blockchainId,
|
|
207
207
|
gaugeAddress: gaugeData[i].gauge,
|
|
208
|
-
poolAddress: gaugeData[i].swap,
|
|
209
|
-
lpTokenAddress: gaugeData[i].swap_token,
|
|
208
|
+
poolAddress: gaugeData[i].swap || '',
|
|
209
|
+
lpTokenAddress: gaugeData[i].swap_token || '',
|
|
210
210
|
poolName: gaugeData[i].shortName,
|
|
211
211
|
totalVeCrv: curve.formatUnits(gaugeData[i].gauge_controller.get_gauge_weight, 18),
|
|
212
212
|
relativeWeight: curve.formatUnits(gaugeData[i].gauge_controller.gauge_relative_weight, 16),
|
|
213
|
-
isKilled: (
|
|
213
|
+
isKilled: (_b = gaugeData[i].is_killed) !== null && _b !== void 0 ? _b : false,
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
return res;
|
|
217
217
|
});
|
|
218
218
|
export const userGaugeVotes = (address = "") => __awaiter(void 0, void 0, void 0, function* () {
|
|
219
|
-
var
|
|
219
|
+
var _c, _d;
|
|
220
220
|
if (curve.chainId !== 1)
|
|
221
221
|
throw Error("Ethereum-only method");
|
|
222
222
|
address = _getAddress(address);
|
|
@@ -243,15 +243,15 @@ export const userGaugeVotes = (address = "") => __awaiter(void 0, void 0, void 0
|
|
|
243
243
|
userFutureVeCrv: curve.formatUnits(veCrvBalance * votes[i][1] / BigInt(10000), 18),
|
|
244
244
|
expired: dt === BigInt(0),
|
|
245
245
|
gaugeData: {
|
|
246
|
-
poolUrl: gaugeData[i].poolUrls.swap[0],
|
|
247
|
-
network:
|
|
246
|
+
poolUrl: ((_c = gaugeData[i].poolUrls) === null || _c === void 0 ? void 0 : _c.swap[0]) || '',
|
|
247
|
+
network: gaugeData[i].blockchainId,
|
|
248
248
|
gaugeAddress: gaugeData[i].gauge,
|
|
249
|
-
poolAddress: gaugeData[i].swap,
|
|
250
|
-
lpTokenAddress: gaugeData[i].swap_token,
|
|
249
|
+
poolAddress: gaugeData[i].swap || '',
|
|
250
|
+
lpTokenAddress: gaugeData[i].swap_token || '',
|
|
251
251
|
poolName: gaugeData[i].shortName,
|
|
252
252
|
totalVeCrv: curve.formatUnits(gaugeData[i].gauge_controller.get_gauge_weight, 18),
|
|
253
253
|
relativeWeight: curve.formatUnits(gaugeData[i].gauge_controller.gauge_relative_weight, 16),
|
|
254
|
-
isKilled: (
|
|
254
|
+
isKilled: (_d = gaugeData[i].is_killed) !== null && _d !== void 0 ? _d : false,
|
|
255
255
|
},
|
|
256
256
|
});
|
|
257
257
|
powerUsed += votes[i][1];
|
|
@@ -68,9 +68,11 @@ function _getLpTokenMap(factorySwapAddresses) {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
function getPoolsData(factorySwapAddresses) {
|
|
71
|
+
var _a;
|
|
71
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
73
|
const factoryMulticallContract = this.contracts[this.constants.ALIASES.crypto_factory].multicallContract;
|
|
73
|
-
const
|
|
74
|
+
const isGaugeFactoryNull = this.constants.ALIASES.gauge_factory === curve.constants.ZERO_ADDRESS;
|
|
75
|
+
const isGaugeFactoryOldNull = !("gauge_factory_old" in this.constants.ALIASES);
|
|
74
76
|
const calls = [];
|
|
75
77
|
if (this.chainId === 1) {
|
|
76
78
|
for (const addr of factorySwapAddresses) {
|
|
@@ -80,29 +82,32 @@ function getPoolsData(factorySwapAddresses) {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
else {
|
|
83
|
-
const
|
|
85
|
+
const gaugeFactoryMulticallContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
86
|
+
const gaugeFactoryOldMulticallContract = this.contracts[(_a = this.constants.ALIASES.gauge_factory_old) !== null && _a !== void 0 ? _a : curve.constants.ZERO_ADDRESS].multicallContract;
|
|
84
87
|
const LpTokenMap = yield _getLpTokenMap.call(this, factorySwapAddresses);
|
|
85
88
|
for (const addr of factorySwapAddresses) {
|
|
86
89
|
calls.push(factoryMulticallContract.get_token(addr));
|
|
87
|
-
if (!
|
|
88
|
-
calls.push(
|
|
89
|
-
|
|
90
|
+
if (!isGaugeFactoryNull)
|
|
91
|
+
calls.push(gaugeFactoryMulticallContract.get_gauge_from_lp_token(LpTokenMap[addr]));
|
|
92
|
+
if (!isGaugeFactoryOldNull)
|
|
93
|
+
calls.push(gaugeFactoryOldMulticallContract.get_gauge_from_lp_token(LpTokenMap[addr]));
|
|
90
94
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
const res = yield this.multicallProvider.all(calls);
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const tokenAddresses = res.filter((a, i) => i % 3 == 0).map((a) => a.toLowerCase());
|
|
102
|
-
const gaugeAddresses = res.filter((a, i) => i % 3 == 1).map((a) => a.toLowerCase());
|
|
103
|
-
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 3 == 2));
|
|
104
|
-
return [tokenAddresses, gaugeAddresses, coinAddresses];
|
|
98
|
+
if (isGaugeFactoryNull || isGaugeFactoryOldNull) {
|
|
99
|
+
for (let index = 0; index < res.length; index++) {
|
|
100
|
+
if (isGaugeFactoryNull && index % 4 == 1)
|
|
101
|
+
res.splice(index, 0, curve.constants.ZERO_ADDRESS);
|
|
102
|
+
if (isGaugeFactoryOldNull && index % 4 == 2)
|
|
103
|
+
res.splice(index, 0, curve.constants.ZERO_ADDRESS);
|
|
104
|
+
}
|
|
105
105
|
}
|
|
106
|
+
const tokenAddresses = res.filter((a, i) => i % 4 == 0).map((a) => a.toLowerCase());
|
|
107
|
+
const gaugeAddresses = res.filter((a, i) => i % 4 == 1).map((a) => a.toLowerCase());
|
|
108
|
+
const gaugeOldAddresses = res.filter((a, i) => i % 4 == 2).map((a) => a.toLowerCase());
|
|
109
|
+
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 4 == 3));
|
|
110
|
+
return [tokenAddresses, gaugeAddresses, gaugeOldAddresses, coinAddresses];
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
113
|
function setCryptoFactorySwapContracts(factorySwapAddresses) {
|
|
@@ -199,7 +204,11 @@ export function getCryptoFactoryPoolData(fromIdx = 0, swapAddress) {
|
|
|
199
204
|
: yield getCryptoFactoryIdsAndSwapAddresses.call(this, fromIdx);
|
|
200
205
|
if (poolIds.length === 0)
|
|
201
206
|
return {};
|
|
202
|
-
const [tokenAddresses,
|
|
207
|
+
const [tokenAddresses, rawGaugeAddresses, rawOldGaugeAddresses, coinAddresses] = yield getPoolsData.call(this, swapAddresses);
|
|
208
|
+
const gaugeAddresses = [];
|
|
209
|
+
for (let i = 0; i < rawGaugeAddresses.length; i++) {
|
|
210
|
+
gaugeAddresses.push(rawGaugeAddresses[i] !== curve.constants.ZERO_ADDRESS ? rawGaugeAddresses[i] : rawOldGaugeAddresses[i]);
|
|
211
|
+
}
|
|
203
212
|
setCryptoFactorySwapContracts.call(this, swapAddresses);
|
|
204
213
|
setCryptoFactoryTokenContracts.call(this, tokenAddresses);
|
|
205
214
|
setCryptoFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
@@ -47,47 +47,45 @@ function _handleCoinAddresses(coinAddresses) {
|
|
|
47
47
|
return coinAddresses.map((addresses) => addresses.map((addr) => this.chainId === 137 && addr === "0x0000000000000000000000000000000000001010" ? this.constants.NATIVE_TOKEN.wrappedAddress : addr.toLowerCase()));
|
|
48
48
|
}
|
|
49
49
|
function getPoolsData(factorySwapAddresses) {
|
|
50
|
+
var _a;
|
|
50
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
|
|
53
|
+
const isGaugeFactoryNull = this.constants.ALIASES.gauge_factory === curve.constants.ZERO_ADDRESS;
|
|
54
|
+
const isGaugeFactoryOldNull = !("gauge_factory_old" in this.constants.ALIASES);
|
|
55
|
+
const calls = [];
|
|
51
56
|
if (this.chainId === 1) {
|
|
52
|
-
const factoryMulticallContract = this.contracts[this.constants.ALIASES.tricrypto_factory].multicallContract;
|
|
53
|
-
const calls = [];
|
|
54
57
|
for (const addr of factorySwapAddresses) {
|
|
55
58
|
calls.push(factoryMulticallContract.get_gauge(addr));
|
|
56
59
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
57
60
|
calls.push(factoryMulticallContract.get_implementation_address(addr));
|
|
58
61
|
}
|
|
59
|
-
const res = yield this.multicallProvider.all(calls);
|
|
60
|
-
const gaugeAddresses = res.filter((a, i) => i % 3 == 0).map((a) => a.toLowerCase());
|
|
61
|
-
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 3 == 1));
|
|
62
|
-
const implementationAddresses = res.filter((a, i) => i % 3 == 2).map((a) => a.toLowerCase());
|
|
63
|
-
return [gaugeAddresses, coinAddresses, implementationAddresses];
|
|
64
62
|
}
|
|
65
63
|
else {
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const factoryMulticallGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
69
|
-
const calls = [];
|
|
64
|
+
const gaugeFactoryMulticallContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
65
|
+
const gaugeFactoryOldMulticallContract = this.contracts[(_a = this.constants.ALIASES.gauge_factory_old) !== null && _a !== void 0 ? _a : curve.constants.ZERO_ADDRESS].multicallContract;
|
|
70
66
|
for (const addr of factorySwapAddresses) {
|
|
71
|
-
if (!
|
|
72
|
-
calls.push(
|
|
73
|
-
|
|
67
|
+
if (!isGaugeFactoryNull)
|
|
68
|
+
calls.push(gaugeFactoryMulticallContract.get_gauge_from_lp_token(addr));
|
|
69
|
+
if (!isGaugeFactoryOldNull)
|
|
70
|
+
calls.push(gaugeFactoryOldMulticallContract.get_gauge_from_lp_token(addr));
|
|
74
71
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
75
72
|
calls.push(factoryMulticallContract.get_implementation_address(addr));
|
|
76
73
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 2 == 0));
|
|
86
|
-
const gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(() => '0x0000000000000000000000000000000000000000');
|
|
87
|
-
const implementationAddresses = res.filter((a, i) => i % 2 == 1).map((a) => a.toLowerCase());
|
|
88
|
-
return [gaugeAddresses, coinAddresses, implementationAddresses];
|
|
74
|
+
}
|
|
75
|
+
const res = yield this.multicallProvider.all(calls);
|
|
76
|
+
if (isGaugeFactoryNull || isGaugeFactoryOldNull) {
|
|
77
|
+
for (let index = 0; index < res.length; index++) {
|
|
78
|
+
if (isGaugeFactoryNull && index % 4 == 0)
|
|
79
|
+
res.splice(index, 0, curve.constants.ZERO_ADDRESS);
|
|
80
|
+
if (isGaugeFactoryOldNull && index % 4 == 1)
|
|
81
|
+
res.splice(index, 0, curve.constants.ZERO_ADDRESS);
|
|
89
82
|
}
|
|
90
83
|
}
|
|
84
|
+
const gaugeAddresses = res.filter((a, i) => i % 4 == 0).map((a) => a.toLowerCase());
|
|
85
|
+
const gaugeOldAddresses = res.filter((a, i) => i % 4 == 1).map((a) => a.toLowerCase());
|
|
86
|
+
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 4 == 2));
|
|
87
|
+
const implementationAddresses = res.filter((a, i) => i % 4 == 3).map((a) => a.toLowerCase());
|
|
88
|
+
return [gaugeAddresses, gaugeOldAddresses, coinAddresses, implementationAddresses];
|
|
91
89
|
});
|
|
92
90
|
}
|
|
93
91
|
function setCryptoFactorySwapContracts(factorySwapAddresses) {
|
|
@@ -95,11 +93,6 @@ function setCryptoFactorySwapContracts(factorySwapAddresses) {
|
|
|
95
93
|
this.setContract(addr, tricryptoFactorySwapABI);
|
|
96
94
|
});
|
|
97
95
|
}
|
|
98
|
-
function setCryptoFactoryTokenContracts(factoryTokenAddresses) {
|
|
99
|
-
factoryTokenAddresses.forEach((addr) => {
|
|
100
|
-
this.setContract(addr, ERC20ABI);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
96
|
function setCryptoFactoryGaugeContracts(factoryGaugeAddresses) {
|
|
104
97
|
factoryGaugeAddresses.filter((addr) => addr !== curve.constants.ZERO_ADDRESS).forEach((addr, i) => {
|
|
105
98
|
this.setContract(addr, this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
|
|
@@ -180,7 +173,11 @@ export function getTricryptoFactoryPoolData(fromIdx = 0, swapAddress) {
|
|
|
180
173
|
: yield getCryptoFactoryIdsAndSwapAddresses.call(this, fromIdx);
|
|
181
174
|
if (poolIds.length === 0)
|
|
182
175
|
return {};
|
|
183
|
-
const [
|
|
176
|
+
const [rawGaugeAddresses, rawOldGaugeAddresses, coinAddresses, implementationAddresses] = yield getPoolsData.call(this, swapAddresses);
|
|
177
|
+
const gaugeAddresses = [];
|
|
178
|
+
for (let i = 0; i < rawGaugeAddresses.length; i++) {
|
|
179
|
+
gaugeAddresses.push(rawGaugeAddresses[i] !== curve.constants.ZERO_ADDRESS ? rawGaugeAddresses[i] : rawOldGaugeAddresses[i]);
|
|
180
|
+
}
|
|
184
181
|
setCryptoFactorySwapContracts.call(this, swapAddresses);
|
|
185
182
|
setCryptoFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
186
183
|
setCryptoFactoryCoinsContracts.call(this, coinAddresses);
|
|
@@ -46,42 +46,42 @@ function _handleCoinAddresses(coinAddresses) {
|
|
|
46
46
|
return coinAddresses.map((addresses) => addresses.map((addr) => this.chainId === 137 && addr === "0x0000000000000000000000000000000000001010" ? this.constants.NATIVE_TOKEN.wrappedAddress : addr.toLowerCase()));
|
|
47
47
|
}
|
|
48
48
|
function getPoolsData(factorySwapAddresses) {
|
|
49
|
+
var _a;
|
|
49
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const factoryMulticallContract = this.contracts[this.constants.ALIASES.twocrypto_factory].multicallContract;
|
|
52
|
+
const isGaugeFactoryNull = this.constants.ALIASES.gauge_factory === curve.constants.ZERO_ADDRESS;
|
|
53
|
+
const isGaugeFactoryOldNull = !("gauge_factory_old" in this.constants.ALIASES);
|
|
54
|
+
const calls = [];
|
|
50
55
|
if (this.chainId === 1) {
|
|
51
|
-
const factoryMulticallContract = this.contracts[this.constants.ALIASES.twocrypto_factory].multicallContract;
|
|
52
|
-
const calls = [];
|
|
53
56
|
for (const addr of factorySwapAddresses) {
|
|
54
57
|
calls.push(factoryMulticallContract.get_gauge(addr));
|
|
55
58
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
56
59
|
}
|
|
57
|
-
const res = yield this.multicallProvider.all(calls);
|
|
58
|
-
const gaugeAddresses = res.filter((a, i) => i % 2 == 0).map((a) => a.toLowerCase());
|
|
59
|
-
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 2 == 1));
|
|
60
|
-
return [gaugeAddresses, coinAddresses];
|
|
61
60
|
}
|
|
62
61
|
else {
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const factoryMulticallGaugeContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
66
|
-
const calls = [];
|
|
62
|
+
const gaugeFactoryMulticallContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
63
|
+
const gaugeFactoryOldMulticallContract = this.contracts[(_a = this.constants.ALIASES.gauge_factory_old) !== null && _a !== void 0 ? _a : curve.constants.ZERO_ADDRESS].multicallContract;
|
|
67
64
|
for (const addr of factorySwapAddresses) {
|
|
68
|
-
if (!
|
|
69
|
-
calls.push(
|
|
70
|
-
|
|
65
|
+
if (!isGaugeFactoryNull)
|
|
66
|
+
calls.push(gaugeFactoryMulticallContract.get_gauge_from_lp_token(addr));
|
|
67
|
+
if (!isGaugeFactoryOldNull)
|
|
68
|
+
calls.push(gaugeFactoryOldMulticallContract.get_gauge_from_lp_token(addr));
|
|
71
69
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
72
70
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const gaugeAddresses = Array.from(Array(factorySwapAddresses.length)).map(() => '0x0000000000000000000000000000000000000000');
|
|
82
|
-
return [gaugeAddresses, coinAddresses];
|
|
71
|
+
}
|
|
72
|
+
const res = yield this.multicallProvider.all(calls);
|
|
73
|
+
if (isGaugeFactoryNull || isGaugeFactoryOldNull) {
|
|
74
|
+
for (let index = 0; index < res.length; index++) {
|
|
75
|
+
if (isGaugeFactoryNull && index % 3 == 0)
|
|
76
|
+
res.splice(index, 0, curve.constants.ZERO_ADDRESS);
|
|
77
|
+
if (isGaugeFactoryOldNull && index % 3 == 1)
|
|
78
|
+
res.splice(index, 0, curve.constants.ZERO_ADDRESS);
|
|
83
79
|
}
|
|
84
80
|
}
|
|
81
|
+
const gaugeAddresses = res.filter((a, i) => i % 3 == 0).map((a) => a.toLowerCase());
|
|
82
|
+
const gaugeOldAddresses = res.filter((a, i) => i % 3 == 1).map((a) => a.toLowerCase());
|
|
83
|
+
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 3 == 2));
|
|
84
|
+
return [gaugeAddresses, gaugeOldAddresses, coinAddresses];
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
function setTwocryptoFactorySwapContracts(factorySwapAddresses) {
|
|
@@ -89,11 +89,6 @@ function setTwocryptoFactorySwapContracts(factorySwapAddresses) {
|
|
|
89
89
|
this.setContract(addr, twocryptoFactorySwapABI);
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
function setTwocryptoFactoryTokenContracts(factoryTokenAddresses) {
|
|
93
|
-
factoryTokenAddresses.forEach((addr) => {
|
|
94
|
-
this.setContract(addr, ERC20ABI);
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
92
|
function setTwocryptoFactoryGaugeContracts(factoryGaugeAddresses) {
|
|
98
93
|
factoryGaugeAddresses.filter((addr) => addr !== curve.constants.ZERO_ADDRESS).forEach((addr, i) => {
|
|
99
94
|
this.setContract(addr, this.chainId === 1 ? factoryGaugeABI : gaugeChildABI);
|
|
@@ -177,7 +172,11 @@ export function getTwocryptoFactoryPoolData(fromIdx = 0, swapAddress) {
|
|
|
177
172
|
: yield getTwocryptoFactoryIdsAndSwapAddresses.call(this, fromIdx);
|
|
178
173
|
if (poolIds.length === 0)
|
|
179
174
|
return {};
|
|
180
|
-
const [
|
|
175
|
+
const [rawGaugeAddresses, rawOldGaugeAddresses, coinAddresses] = yield getPoolsData.call(this, swapAddresses);
|
|
176
|
+
const gaugeAddresses = [];
|
|
177
|
+
for (let i = 0; i < rawGaugeAddresses.length; i++) {
|
|
178
|
+
gaugeAddresses.push(rawGaugeAddresses[i] !== curve.constants.ZERO_ADDRESS ? rawGaugeAddresses[i] : rawOldGaugeAddresses[i]);
|
|
179
|
+
}
|
|
181
180
|
setTwocryptoFactorySwapContracts.call(this, swapAddresses);
|
|
182
181
|
setTwocryptoFactoryGaugeContracts.call(this, gaugeAddresses);
|
|
183
182
|
setTwocryptoFactoryCoinsContracts.call(this, coinAddresses);
|
package/lib/factory/factory.js
CHANGED
|
@@ -106,11 +106,14 @@ function _handleCoinAddresses(coinAddresses) {
|
|
|
106
106
|
.map((addr) => this.chainId === 137 && addr === "0x0000000000000000000000000000000000001010" ? this.constants.NATIVE_TOKEN.address : addr.toLowerCase()));
|
|
107
107
|
}
|
|
108
108
|
function getPoolsData(factorySwapAddresses, factoryAddress) {
|
|
109
|
+
var _a;
|
|
109
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
111
|
const factoryMulticallContract = this.contracts[factoryAddress].multicallContract;
|
|
111
|
-
const
|
|
112
|
+
const isGaugeFactoryNull = this.constants.ALIASES.gauge_factory === curve.constants.ZERO_ADDRESS;
|
|
113
|
+
const isGaugeFactoryOldNull = !("gauge_factory_old" in this.constants.ALIASES);
|
|
112
114
|
const isStableNgFactory = factoryAddress === this.constants.ALIASES['stable_ng_factory'];
|
|
113
|
-
const
|
|
115
|
+
const gaugeFactoryContract = this.contracts[this.constants.ALIASES.gauge_factory].multicallContract;
|
|
116
|
+
const gaugeFactoryOldContract = this.contracts[(_a = this.constants.ALIASES.gauge_factory_old) !== null && _a !== void 0 ? _a : curve.constants.ZERO_ADDRESS].multicallContract;
|
|
114
117
|
const calls = [];
|
|
115
118
|
for (const addr of factorySwapAddresses) {
|
|
116
119
|
const tempSwapContract = new MulticallContract(addr, ERC20ABI);
|
|
@@ -118,8 +121,11 @@ function getPoolsData(factorySwapAddresses, factoryAddress) {
|
|
|
118
121
|
if (this.chainId === 1) {
|
|
119
122
|
calls.push(factoryMulticallContract.get_gauge(addr));
|
|
120
123
|
}
|
|
121
|
-
else if (!
|
|
122
|
-
calls.push(
|
|
124
|
+
else if (!isGaugeFactoryNull) {
|
|
125
|
+
calls.push(gaugeFactoryContract.get_gauge_from_lp_token(addr));
|
|
126
|
+
}
|
|
127
|
+
if (!isGaugeFactoryOldNull) {
|
|
128
|
+
calls.push(gaugeFactoryOldContract.get_gauge_from_lp_token(addr));
|
|
123
129
|
}
|
|
124
130
|
if (!isStableNgFactory) {
|
|
125
131
|
calls.push(factoryMulticallContract.get_pool_asset_type(addr));
|
|
@@ -130,28 +136,25 @@ function getPoolsData(factorySwapAddresses, factoryAddress) {
|
|
|
130
136
|
calls.push(factoryMulticallContract.get_coins(addr));
|
|
131
137
|
}
|
|
132
138
|
const res = yield this.multicallProvider.all(calls);
|
|
133
|
-
if (
|
|
139
|
+
if (isGaugeFactoryNull || isGaugeFactoryOldNull || isStableNgFactory) {
|
|
134
140
|
for (let index = 0; index < res.length; index++) {
|
|
135
|
-
if (index %
|
|
136
|
-
res.splice(index, 0,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (isStableNgFactory) {
|
|
141
|
-
for (let index = 0; index < res.length; index++) {
|
|
142
|
-
if (index % 7 == 2) {
|
|
141
|
+
if (isGaugeFactoryNull && index % 8 == 1)
|
|
142
|
+
res.splice(index, 0, curve.constants.ZERO_ADDRESS);
|
|
143
|
+
if (isGaugeFactoryOldNull && index % 8 == 2)
|
|
144
|
+
res.splice(index, 0, curve.constants.ZERO_ADDRESS);
|
|
145
|
+
if (isStableNgFactory && index % 8 == 3)
|
|
143
146
|
res.splice(index, 0, -1);
|
|
144
|
-
}
|
|
145
147
|
}
|
|
146
148
|
}
|
|
147
|
-
const implememntationAddresses = res.filter((a, i) => i %
|
|
148
|
-
const gaugeAddresses = res.filter((a, i) => i %
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
|
|
149
|
+
const implememntationAddresses = res.filter((a, i) => i % 8 == 0).map((a) => a.toLowerCase());
|
|
150
|
+
const gaugeAddresses = res.filter((a, i) => i % 8 == 1).map((a) => a.toLowerCase());
|
|
151
|
+
const oldGaugeAddresses = res.filter((a, i) => i % 8 == 2).map((a) => a.toLowerCase());
|
|
152
|
+
const referenceAssets = _handleReferenceAssets(res.filter((a, i) => i % 8 == 3));
|
|
153
|
+
const symbols = res.filter((a, i) => i % 8 == 4);
|
|
154
|
+
const names = res.filter((a, i) => i % 8 == 5);
|
|
155
|
+
const isMeta = res.filter((a, i) => i % 8 == 6);
|
|
156
|
+
const coinAddresses = _handleCoinAddresses.call(this, res.filter((a, i) => i % 8 == 7));
|
|
157
|
+
return [implememntationAddresses, gaugeAddresses, oldGaugeAddresses, referenceAssets, symbols, names, isMeta, coinAddresses];
|
|
155
158
|
});
|
|
156
159
|
}
|
|
157
160
|
function setFactorySwapContracts(factorySwapAddresses, factorySwapABIs) {
|
|
@@ -226,7 +229,7 @@ export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = cu
|
|
|
226
229
|
: yield getFactoryIdsAndSwapAddresses.call(this, fromIdx, factoryAddress);
|
|
227
230
|
if (rawPoolIds.length === 0)
|
|
228
231
|
return {};
|
|
229
|
-
const [rawImplementations, rawGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses] = yield getPoolsData.call(this, rawSwapAddresses, factoryAddress);
|
|
232
|
+
const [rawImplementations, rawGauges, rawOldGauges, rawReferenceAssets, rawPoolSymbols, rawPoolNames, rawIsMeta, rawCoinAddresses] = yield getPoolsData.call(this, rawSwapAddresses, factoryAddress);
|
|
230
233
|
const poolIds = [];
|
|
231
234
|
const swapAddresses = [];
|
|
232
235
|
const implementations = [];
|
|
@@ -242,7 +245,7 @@ export function getFactoryPoolData(fromIdx = 0, swapAddress, factoryAddress = cu
|
|
|
242
245
|
poolIds.push(rawPoolIds[i]);
|
|
243
246
|
swapAddresses.push(rawSwapAddresses[i]);
|
|
244
247
|
implementations.push(rawImplementations[i]);
|
|
245
|
-
gaugeAddresses.push(rawGauges[i]);
|
|
248
|
+
gaugeAddresses.push(rawGauges[i] !== curve.constants.ZERO_ADDRESS ? rawGauges[i] : rawOldGauges[i]);
|
|
246
249
|
referenceAssets.push(rawReferenceAssets[i]);
|
|
247
250
|
poolSymbols.push(rawPoolSymbols[i]);
|
|
248
251
|
poolNames.push(rawPoolNames[i]);
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -178,6 +178,7 @@ export interface IProfit {
|
|
|
178
178
|
price: number;
|
|
179
179
|
}
|
|
180
180
|
export interface IGaugesDataFromApi {
|
|
181
|
+
blockchainId: string;
|
|
181
182
|
gauge: string;
|
|
182
183
|
swap: string;
|
|
183
184
|
swap_token: string;
|
|
@@ -186,7 +187,7 @@ export interface IGaugesDataFromApi {
|
|
|
186
187
|
gauge_relative_weight: string;
|
|
187
188
|
get_gauge_weight: string;
|
|
188
189
|
};
|
|
189
|
-
poolUrls
|
|
190
|
+
poolUrls?: {
|
|
190
191
|
swap: string[];
|
|
191
192
|
};
|
|
192
193
|
is_killed?: boolean;
|