@curvefi/api 2.31.1 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/constants/abis/stable_calc.json +151 -0
- package/lib/constants/abis/wbeth/swap.json +1086 -0
- package/lib/constants/aliases.js +11 -0
- package/lib/constants/pools/ethereum.js +25 -0
- package/lib/constants/utils.d.ts +1 -1
- package/lib/curve.js +2 -0
- package/lib/interfaces.d.ts +1 -6
- package/lib/pools/PoolTemplate.js +18 -58
- package/lib/pools/mixins/swapMixins.js +4 -4
- package/lib/pools/utils.js +2 -1
- package/lib/router.js +13 -218
- package/package.json +2 -1
package/lib/constants/aliases.js
CHANGED
|
@@ -8,6 +8,7 @@ export const ALIASES_ETHEREUM = lowerCaseValues({
|
|
|
8
8
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
9
9
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
10
10
|
"deposit_and_stake": "0x271fbE8aB7f1fB262f81C77Ea5303F03DA9d3d6A",
|
|
11
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
11
12
|
"factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
|
|
12
13
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
13
14
|
"registry_exchange": "",
|
|
@@ -21,6 +22,7 @@ export const ALIASES_POLYGON = lowerCaseValues({
|
|
|
21
22
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
22
23
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
23
24
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
25
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
24
26
|
"factory": '0x722272d36ef0da72ff51c5a65db7b870e2e8d4ee',
|
|
25
27
|
"crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
|
|
26
28
|
"registry_exchange": "",
|
|
@@ -34,6 +36,7 @@ export const ALIASES_FANTOM = lowerCaseValues({
|
|
|
34
36
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
35
37
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
36
38
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
39
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
37
40
|
"factory": "0x686d67265703d1f124c45e33d47d794c566889ba",
|
|
38
41
|
"crypto_factory": "0xE5De15A9C9bBedb4F5EC13B131E61245f2983A69",
|
|
39
42
|
"registry_exchange": "",
|
|
@@ -47,6 +50,7 @@ export const ALIASES_AVALANCHE = lowerCaseValues({
|
|
|
47
50
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
48
51
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
49
52
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
53
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
50
54
|
"factory": '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
|
|
51
55
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
52
56
|
"registry_exchange": "",
|
|
@@ -60,6 +64,7 @@ export const ALIASES_ARBITRUM = lowerCaseValues({
|
|
|
60
64
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
61
65
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
62
66
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
67
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
63
68
|
"factory": '0xb17b674D9c5CB2e441F8e196a2f048A81355d031',
|
|
64
69
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
65
70
|
"registry_exchange": "",
|
|
@@ -73,6 +78,7 @@ export const ALIASES_OPTIMISM = lowerCaseValues({
|
|
|
73
78
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
74
79
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
75
80
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
81
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
76
82
|
"factory": '0x2db0E83599a91b508Ac268a6197b8B14F5e72840',
|
|
77
83
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
78
84
|
"registry_exchange": "",
|
|
@@ -86,6 +92,7 @@ export const ALIASES_XDAI = lowerCaseValues({
|
|
|
86
92
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
87
93
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
88
94
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
95
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
89
96
|
"factory": '0xD19Baeadc667Cf2015e395f2B08668Ef120f41F5',
|
|
90
97
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
91
98
|
"registry_exchange": "",
|
|
@@ -99,6 +106,7 @@ export const ALIASES_MOONBEAM = lowerCaseValues({
|
|
|
99
106
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
100
107
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
101
108
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
109
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
102
110
|
"factory": '0x4244eB811D6e0Ef302326675207A95113dB4E1F8',
|
|
103
111
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
104
112
|
"registry_exchange": "",
|
|
@@ -112,6 +120,7 @@ export const ALIASES_AURORA = lowerCaseValues({
|
|
|
112
120
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
113
121
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
114
122
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
123
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
115
124
|
"factory": '0xb9fc157394af804a3578134a6585c0dc9cc990d4',
|
|
116
125
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
117
126
|
"registry_exchange": "",
|
|
@@ -125,6 +134,7 @@ export const ALIASES_KAVA = lowerCaseValues({
|
|
|
125
134
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
126
135
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
127
136
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
137
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
128
138
|
"factory": '0x40bc62805471eF53DdD5C5cF99ed3d9e5aa81b48',
|
|
129
139
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
130
140
|
"registry_exchange": "",
|
|
@@ -138,6 +148,7 @@ export const ALIASES_CELO = lowerCaseValues({
|
|
|
138
148
|
"address_provider": "0x0000000022d53366457f9d5e68ec105046fc4383",
|
|
139
149
|
"router": "0xfA9a30350048B2BF66865ee20363067c66f67e58",
|
|
140
150
|
"deposit_and_stake": "0xB7De33440B7171159a9718CBE748086cecDd9685",
|
|
151
|
+
"stable_calc": "0x5552b631e2aD801fAa129Aacf4B701071cC9D1f7",
|
|
141
152
|
"factory": '0x5277A0226d10392295E8D383E9724D6E416d6e6C',
|
|
142
153
|
"crypto_factory": '0xF18056Bbd320E96A48e3Fbf8bC061322531aac99',
|
|
143
154
|
"registry_exchange": "",
|
|
@@ -86,6 +86,7 @@ import fourpoolSwapABI from '../abis/4pool/swap.json' assert { type: 'json' };
|
|
|
86
86
|
import fraxusdcSwapABI from '../abis/fraxusdc/swap.json' assert { type: 'json' };
|
|
87
87
|
import frxethSwapABI from '../abis/frxeth/swap.json' assert { type: 'json' };
|
|
88
88
|
import sbtc2SwapABI from '../abis/sbtc2/swap.json' assert { type: 'json' };
|
|
89
|
+
import wbethSwapABI from '../abis/wbeth/swap.json' assert { type: 'json' };
|
|
89
90
|
export const POOLS_DATA_ETHEREUM = lowerCasePoolDataAddresses({
|
|
90
91
|
compound: {
|
|
91
92
|
name: "compound",
|
|
@@ -1617,4 +1618,28 @@ export const POOLS_DATA_ETHEREUM = lowerCasePoolDataAddresses({
|
|
|
1617
1618
|
swap_abi: fraxusdcSwapABI,
|
|
1618
1619
|
gauge_abi: gaugeV5ABI,
|
|
1619
1620
|
},
|
|
1621
|
+
wbeth: {
|
|
1622
|
+
name: "wbeth",
|
|
1623
|
+
full_name: "wbeth",
|
|
1624
|
+
symbol: "wbeth",
|
|
1625
|
+
reference_asset: 'ETH',
|
|
1626
|
+
swap_address: '0xBfAb6FA95E0091ed66058ad493189D2cB29385E6',
|
|
1627
|
+
token_address: '0xBfAb6FA95E0091ed66058ad493189D2cB29385E6',
|
|
1628
|
+
gauge_address: '0x0000000000000000000000000000000000000000',
|
|
1629
|
+
is_plain: true,
|
|
1630
|
+
underlying_coins: ['ETH', 'wBETH'],
|
|
1631
|
+
wrapped_coins: ['ETH', 'wBETH'],
|
|
1632
|
+
underlying_coin_addresses: [
|
|
1633
|
+
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
1634
|
+
"0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
|
1635
|
+
],
|
|
1636
|
+
wrapped_coin_addresses: [
|
|
1637
|
+
"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
1638
|
+
"0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
|
1639
|
+
],
|
|
1640
|
+
underlying_decimals: [18, 18],
|
|
1641
|
+
wrapped_decimals: [18, 18],
|
|
1642
|
+
swap_abi: wbethSwapABI,
|
|
1643
|
+
gauge_abi: gaugeV5ABI,
|
|
1644
|
+
},
|
|
1620
1645
|
});
|
package/lib/constants/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDict, IPoolData } from "../interfaces";
|
|
1
|
+
import { IDict, IPoolData } from "../interfaces.js";
|
|
2
2
|
export declare const lowerCasePoolDataAddresses: (poolsData: IDict<IPoolData>) => IDict<IPoolData>;
|
|
3
3
|
export declare const extractDecimals: (poolsData: IDict<IPoolData>) => IDict<number>;
|
|
4
4
|
export declare const extractGauges: (poolsData: IDict<IPoolData>) => string[];
|
package/lib/curve.js
CHANGED
|
@@ -15,6 +15,7 @@ import gaugeControllerABI from './constants/abis/gaugecontroller.json' assert {
|
|
|
15
15
|
import routerABI from './constants/abis/router.json' assert { type: 'json' };
|
|
16
16
|
import depositAndStakeABI from './constants/abis/deposit_and_stake.json' assert { type: 'json' };
|
|
17
17
|
import depositAndStake6CoinsABI from './constants/abis/deposit_and_stake_6coins.json' assert { type: 'json' };
|
|
18
|
+
import StableCalcZapABI from './constants/abis/stable_calc.json' assert { type: 'json' };
|
|
18
19
|
import registryExchangeABI from './constants/abis/registry_exchange.json' assert { type: 'json' };
|
|
19
20
|
import streamerABI from './constants/abis/streamer.json' assert { type: 'json' };
|
|
20
21
|
import factoryABI from './constants/abis/factory.json' assert { type: 'json' };
|
|
@@ -481,6 +482,7 @@ class Curve {
|
|
|
481
482
|
else {
|
|
482
483
|
this.setContract(this.constants.ALIASES.deposit_and_stake, depositAndStakeABI);
|
|
483
484
|
}
|
|
485
|
+
this.setContract(this.constants.ALIASES.stable_calc, StableCalcZapABI);
|
|
484
486
|
this.setContract(this.constants.ALIASES.factory, factoryABI);
|
|
485
487
|
this.setContract(this.constants.ALIASES.crypto_factory, cryptoFactoryABI);
|
|
486
488
|
}
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export interface IRewardFromApi {
|
|
|
100
100
|
tokenPrice: number;
|
|
101
101
|
name: string;
|
|
102
102
|
symbol: string;
|
|
103
|
-
decimals: number;
|
|
103
|
+
decimals: number | string;
|
|
104
104
|
apy: number;
|
|
105
105
|
}
|
|
106
106
|
export interface IPoolDataFromApi {
|
|
@@ -142,11 +142,6 @@ export interface IRouteStep {
|
|
|
142
142
|
swapAddress: string;
|
|
143
143
|
}
|
|
144
144
|
export type IRoute = IRouteStep[];
|
|
145
|
-
export interface IRouteTvl {
|
|
146
|
-
route: IRoute;
|
|
147
|
-
minTvl: number;
|
|
148
|
-
totalTvl: number;
|
|
149
|
-
}
|
|
150
145
|
export interface IRouteOutputAndCost {
|
|
151
146
|
route: IRoute;
|
|
152
147
|
_output: bigint;
|
|
@@ -245,17 +245,11 @@ export class PoolTemplate {
|
|
|
245
245
|
return apy;
|
|
246
246
|
};
|
|
247
247
|
this._calcLpTokenAmount = memoize(async (_amounts, isDeposit = true, useUnderlying = true) => {
|
|
248
|
-
let _rates = [];
|
|
249
|
-
if (!this.isMeta && useUnderlying) {
|
|
250
|
-
// For lending pools. For others rate = 1
|
|
251
|
-
_rates = await this._getRates();
|
|
252
|
-
_amounts = _amounts.map((_amount, i) => _amount * (10n ** 18n) / _rates[i]);
|
|
253
|
-
}
|
|
254
248
|
if (this.isCrypto) {
|
|
255
249
|
try {
|
|
256
250
|
return await this._pureCalcLpTokenAmount(_amounts, isDeposit, useUnderlying);
|
|
257
251
|
}
|
|
258
|
-
catch (e) {
|
|
252
|
+
catch (e) { // Seeding
|
|
259
253
|
const lpContract = curve.contracts[this.lpToken].contract;
|
|
260
254
|
const _lpTotalSupply = await lpContract.totalSupply(curve.constantOptions);
|
|
261
255
|
if (_lpTotalSupply > 0n)
|
|
@@ -273,50 +267,14 @@ export class PoolTemplate {
|
|
|
273
267
|
}
|
|
274
268
|
}
|
|
275
269
|
try {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const calcContract = curve.contracts[calcContractAddress].multicallContract;
|
|
281
|
-
const poolContract = curve.contracts[this.address].multicallContract;
|
|
282
|
-
const lpContract = curve.contracts[this.lpToken].multicallContract;
|
|
283
|
-
// totalSupply and fee
|
|
284
|
-
const calls = [lpContract.totalSupply(), poolContract.fee()];
|
|
285
|
-
// lpAmount before fees
|
|
286
|
-
if (this.isMetaFactory && useUnderlying) {
|
|
287
|
-
calls.push(calcContract.calc_token_amount(this.address, _amounts, isDeposit));
|
|
288
|
-
}
|
|
289
|
-
else if (calcContract[`calc_token_amount(uint256[${N_coins}],bool)`]) {
|
|
290
|
-
calls.push(calcContract.calc_token_amount(_amounts, isDeposit, curve.constantOptions));
|
|
270
|
+
const contract = curve.contracts[curve.constants.ALIASES.stable_calc].contract;
|
|
271
|
+
if (this.isMeta) {
|
|
272
|
+
const basePool = new PoolTemplate(this.basePool);
|
|
273
|
+
return await contract.calc_token_amount_meta(this.address, this.lpToken, _amounts.concat(Array(5 - _amounts.length).fill(0n)), _amounts.length, basePool.address, basePool.lpToken, isDeposit, useUnderlying);
|
|
291
274
|
}
|
|
292
275
|
else {
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
const res = await Promise.all([
|
|
296
|
-
curve.multicallProvider.all(calls),
|
|
297
|
-
this.isMeta && useUnderlying ? this.stats.underlyingBalances() : this.stats.wrappedBalances(),
|
|
298
|
-
]);
|
|
299
|
-
const [_totalSupply, _fee, _lpTokenAmount] = res[0];
|
|
300
|
-
const balances = res[1];
|
|
301
|
-
const [totalSupplyBN, feeBN, lpTokenAmountBN] = [toBN(_totalSupply), toBN(_fee, 10).times(N_coins).div(4 * (N_coins - 1)), toBN(_lpTokenAmount)];
|
|
302
|
-
const balancesBN = balances.map((b) => BN(b));
|
|
303
|
-
const amountsBN = _amounts.map((_a, i) => toBN(_a, decimals[i]));
|
|
304
|
-
// --- Calculating new amounts (old amounts minus fees) ---
|
|
305
|
-
// fees[i] = | expected1/total_supply * balances[i] - amounts[i] | * fee
|
|
306
|
-
const feesBN = Array(N_coins).fill(BN(0));
|
|
307
|
-
if (totalSupplyBN.gt(0)) {
|
|
308
|
-
for (let i = 0; i < N_coins; i++) {
|
|
309
|
-
feesBN[i] = balancesBN[i].times(lpTokenAmountBN).div(totalSupplyBN).minus(amountsBN[i]).times(feeBN);
|
|
310
|
-
if (feesBN[i].lt(0))
|
|
311
|
-
feesBN[i] = feesBN[i].times(-1);
|
|
312
|
-
}
|
|
276
|
+
return await contract.calc_token_amount(this.address, this.lpToken, _amounts.concat(Array(5 - _amounts.length).fill(0n)), _amounts.length, isDeposit, useUnderlying && this.isLending);
|
|
313
277
|
}
|
|
314
|
-
const _fees = feesBN.map((fBN, i) => fromBN(fBN, decimals[i]));
|
|
315
|
-
// --- Getting final lpAmount ---
|
|
316
|
-
let _lpTokenFee = await this._pureCalcLpTokenAmount(_fees, !isDeposit, this.isMeta && useUnderlying);
|
|
317
|
-
if (isDeposit)
|
|
318
|
-
_lpTokenFee = _lpTokenFee * (-1n);
|
|
319
|
-
return _lpTokenAmount + _lpTokenFee;
|
|
320
278
|
}
|
|
321
279
|
catch (e) { // Seeding
|
|
322
280
|
if (!isDeposit)
|
|
@@ -336,7 +294,7 @@ export class PoolTemplate {
|
|
|
336
294
|
}
|
|
337
295
|
else {
|
|
338
296
|
if (_amounts[0] <= 0n)
|
|
339
|
-
throw Error("Initial deposit amounts must be >0");
|
|
297
|
+
throw Error("Initial deposit amounts must be > 0");
|
|
340
298
|
amounts.forEach((a) => {
|
|
341
299
|
if (a !== amounts[0])
|
|
342
300
|
throw Error("Initial deposit amounts must be equal");
|
|
@@ -348,7 +306,8 @@ export class PoolTemplate {
|
|
|
348
306
|
}, {
|
|
349
307
|
primitive: true,
|
|
350
308
|
promise: true,
|
|
351
|
-
maxAge:
|
|
309
|
+
maxAge: 30 * 1000,
|
|
310
|
+
length: 3,
|
|
352
311
|
});
|
|
353
312
|
// ---------------- CRV PROFIT, CLAIM, BOOSTING ----------------
|
|
354
313
|
this.crvProfit = async (address = "") => {
|
|
@@ -477,7 +436,7 @@ export class PoolTemplate {
|
|
|
477
436
|
if (!rewards[this.gauge])
|
|
478
437
|
return [];
|
|
479
438
|
rewards[this.gauge].forEach((r) => _setContracts(r.tokenAddress, ERC20Abi));
|
|
480
|
-
return rewards[this.gauge].map((r) => ({ token: r.tokenAddress, symbol: r.symbol, decimals: r.decimals }));
|
|
439
|
+
return rewards[this.gauge].map((r) => ({ token: r.tokenAddress, symbol: r.symbol, decimals: Number(r.decimals) }));
|
|
481
440
|
}
|
|
482
441
|
const gaugeContract = curve.contracts[this.gauge].contract;
|
|
483
442
|
const gaugeMulticallContract = curve.contracts[this.gauge].multicallContract;
|
|
@@ -674,6 +633,7 @@ export class PoolTemplate {
|
|
|
674
633
|
}
|
|
675
634
|
return idx;
|
|
676
635
|
};
|
|
636
|
+
// Used by mixins
|
|
677
637
|
this._getRates = async () => {
|
|
678
638
|
const _rates = [];
|
|
679
639
|
for (let i = 0; i < this.wrappedCoinAddresses.length; i++) {
|
|
@@ -1130,7 +1090,7 @@ export class PoolTemplate {
|
|
|
1130
1090
|
}
|
|
1131
1091
|
const coinsAllowance = await hasAllowance(this.underlyingCoinAddresses, amounts, curve.signerAddress, curve.constants.ALIASES.deposit_and_stake);
|
|
1132
1092
|
const gaugeContract = curve.contracts[this.gauge].contract;
|
|
1133
|
-
if (
|
|
1093
|
+
if ('approved_to_deposit' in gaugeContract) {
|
|
1134
1094
|
const gaugeAllowance = await gaugeContract.approved_to_deposit(curve.constants.ALIASES.deposit_and_stake, curve.signerAddress, curve.constantOptions);
|
|
1135
1095
|
return coinsAllowance && gaugeAllowance;
|
|
1136
1096
|
}
|
|
@@ -1142,7 +1102,7 @@ export class PoolTemplate {
|
|
|
1142
1102
|
}
|
|
1143
1103
|
const approveCoinsGas = await ensureAllowanceEstimateGas(this.underlyingCoinAddresses, amounts, curve.constants.ALIASES.deposit_and_stake);
|
|
1144
1104
|
const gaugeContract = curve.contracts[this.gauge].contract;
|
|
1145
|
-
if (
|
|
1105
|
+
if ('approved_to_deposit' in gaugeContract) {
|
|
1146
1106
|
const gaugeAllowance = await gaugeContract.approved_to_deposit(curve.constants.ALIASES.deposit_and_stake, curve.signerAddress, curve.constantOptions);
|
|
1147
1107
|
if (!gaugeAllowance) {
|
|
1148
1108
|
const approveGaugeGas = Number(await gaugeContract.set_approve_deposit.estimateGas(curve.constants.ALIASES.deposit_and_stake, true, curve.constantOptions));
|
|
@@ -1157,7 +1117,7 @@ export class PoolTemplate {
|
|
|
1157
1117
|
}
|
|
1158
1118
|
const approveCoinsTx = await ensureAllowance(this.underlyingCoinAddresses, amounts, curve.constants.ALIASES.deposit_and_stake);
|
|
1159
1119
|
const gaugeContract = curve.contracts[this.gauge].contract;
|
|
1160
|
-
if (
|
|
1120
|
+
if ('approved_to_deposit' in gaugeContract) {
|
|
1161
1121
|
const gaugeAllowance = await gaugeContract.approved_to_deposit(curve.constants.ALIASES.deposit_and_stake, curve.signerAddress, curve.constantOptions);
|
|
1162
1122
|
if (!gaugeAllowance) {
|
|
1163
1123
|
const gasLimit = mulBy1_3(await gaugeContract.set_approve_deposit.estimateGas(curve.constants.ALIASES.deposit_and_stake, true, curve.constantOptions));
|
|
@@ -1204,7 +1164,7 @@ export class PoolTemplate {
|
|
|
1204
1164
|
throw Error(`depositAndStakeWrappedIsApproved method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1205
1165
|
const coinsAllowance = await hasAllowance(this.wrappedCoinAddresses, amounts, curve.signerAddress, curve.constants.ALIASES.deposit_and_stake);
|
|
1206
1166
|
const gaugeContract = curve.contracts[this.gauge].contract;
|
|
1207
|
-
if (
|
|
1167
|
+
if ('approved_to_deposit' in gaugeContract) {
|
|
1208
1168
|
const gaugeAllowance = await gaugeContract.approved_to_deposit(curve.constants.ALIASES.deposit_and_stake, curve.signerAddress, curve.constantOptions);
|
|
1209
1169
|
return coinsAllowance && gaugeAllowance;
|
|
1210
1170
|
}
|
|
@@ -1218,7 +1178,7 @@ export class PoolTemplate {
|
|
|
1218
1178
|
throw Error(`depositAndStakeWrappedApprove method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1219
1179
|
const approveCoinsGas = await ensureAllowanceEstimateGas(this.wrappedCoinAddresses, amounts, curve.constants.ALIASES.deposit_and_stake);
|
|
1220
1180
|
const gaugeContract = curve.contracts[this.gauge].contract;
|
|
1221
|
-
if (
|
|
1181
|
+
if ('approved_to_deposit' in gaugeContract) {
|
|
1222
1182
|
const gaugeAllowance = await gaugeContract.approved_to_deposit(curve.constants.ALIASES.deposit_and_stake, curve.signerAddress, curve.constantOptions);
|
|
1223
1183
|
if (!gaugeAllowance) {
|
|
1224
1184
|
const approveGaugeGas = Number(await gaugeContract.set_approve_deposit.estimateGas(curve.constants.ALIASES.deposit_and_stake, true, curve.constantOptions));
|
|
@@ -1235,7 +1195,7 @@ export class PoolTemplate {
|
|
|
1235
1195
|
throw Error(`depositAndStakeWrappedApprove method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1236
1196
|
const approveCoinsTx = await ensureAllowance(this.wrappedCoinAddresses, amounts, curve.constants.ALIASES.deposit_and_stake);
|
|
1237
1197
|
const gaugeContract = curve.contracts[this.gauge].contract;
|
|
1238
|
-
if (
|
|
1198
|
+
if ('approved_to_deposit' in gaugeContract) {
|
|
1239
1199
|
const gaugeAllowance = await gaugeContract.approved_to_deposit(curve.constants.ALIASES.deposit_and_stake, curve.signerAddress, curve.constantOptions);
|
|
1240
1200
|
if (!gaugeAllowance) {
|
|
1241
1201
|
const gasLimit = mulBy1_3(await gaugeContract.set_approve_deposit.estimateGas(curve.constants.ALIASES.deposit_and_stake, true, curve.constantOptions));
|
|
@@ -1601,7 +1561,7 @@ export class PoolTemplate {
|
|
|
1601
1561
|
async _swapExpected(i, j, _amount) {
|
|
1602
1562
|
const contractAddress = this.isCrypto && this.isMeta ? this.zap : this.address;
|
|
1603
1563
|
const contract = curve.contracts[contractAddress].contract;
|
|
1604
|
-
if (
|
|
1564
|
+
if ('get_dy_underlying' in contract) {
|
|
1605
1565
|
return await contract.get_dy_underlying(i, j, _amount, curve.constantOptions);
|
|
1606
1566
|
}
|
|
1607
1567
|
else {
|
|
@@ -37,7 +37,7 @@ export const swapTricrypto2Mixin = {
|
|
|
37
37
|
await _ensureAllowance([this.underlyingCoinAddresses[i]], [_amount], contractAddress);
|
|
38
38
|
const _minRecvAmount = await _swapMinAmount.call(this, i, j, _amount, slippage);
|
|
39
39
|
const contract = curve.contracts[contractAddress].contract;
|
|
40
|
-
const exchangeMethod =
|
|
40
|
+
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
41
41
|
const value = isEth(this.underlyingCoinAddresses[i]) ? _amount : 0n;
|
|
42
42
|
const gas = await contract[exchangeMethod].estimateGas(i, j, _amount, _minRecvAmount, true, { ...curve.constantOptions, value });
|
|
43
43
|
if (estimateGas)
|
|
@@ -68,7 +68,7 @@ export const swapMetaFactoryMixin = {
|
|
|
68
68
|
await _ensureAllowance([this.underlyingCoinAddresses[i]], [_amount], contractAddress);
|
|
69
69
|
const _minRecvAmount = await _swapMinAmount.call(this, i, j, _amount, slippage);
|
|
70
70
|
const contract = curve.contracts[contractAddress].contract;
|
|
71
|
-
const exchangeMethod =
|
|
71
|
+
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
72
72
|
const value = isEth(this.underlyingCoinAddresses[i]) ? _amount : 0n;
|
|
73
73
|
const gas = await contract[exchangeMethod].estimateGas(this.address, i, j, _amount, _minRecvAmount, { ...curve.constantOptions, value });
|
|
74
74
|
if (estimateGas)
|
|
@@ -99,7 +99,7 @@ export const swapCryptoMetaFactoryMixin = {
|
|
|
99
99
|
await _ensureAllowance([this.underlyingCoinAddresses[i]], [_amount], contractAddress);
|
|
100
100
|
const _minRecvAmount = await _swapMinAmount.call(this, i, j, _amount, slippage);
|
|
101
101
|
const contract = curve.contracts[contractAddress].contract;
|
|
102
|
-
const exchangeMethod =
|
|
102
|
+
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
103
103
|
const value = isEth(this.underlyingCoinAddresses[i]) ? _amount : 0n;
|
|
104
104
|
const gas = await contract[exchangeMethod].estimateGas(this.address, i, j, _amount, _minRecvAmount, true, { ...curve.constantOptions, value });
|
|
105
105
|
if (estimateGas)
|
|
@@ -130,7 +130,7 @@ export const swapMixin = {
|
|
|
130
130
|
await _ensureAllowance([this.underlyingCoinAddresses[i]], [_amount], contractAddress);
|
|
131
131
|
const _minRecvAmount = await _swapMinAmount.call(this, i, j, _amount, slippage);
|
|
132
132
|
const contract = curve.contracts[contractAddress].contract;
|
|
133
|
-
const exchangeMethod =
|
|
133
|
+
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
134
134
|
const value = isEth(this.underlyingCoinAddresses[i]) ? _amount : 0n;
|
|
135
135
|
const gas = await contract[exchangeMethod].estimateGas(i, j, _amount, _minRecvAmount, { ...curve.constantOptions, value });
|
|
136
136
|
if (estimateGas)
|
package/lib/pools/utils.js
CHANGED
|
@@ -204,7 +204,8 @@ const _getUserClaimableUseApi = async (pools, address, useCache) => {
|
|
|
204
204
|
for (let i = 0; i < poolsToFetch.length; i++) {
|
|
205
205
|
const pool = getPool(poolsToFetch[i]);
|
|
206
206
|
const rewards = await _getRewardsFromApi();
|
|
207
|
-
rewardTokens[poolsToFetch[i]] = (rewards[pool.gauge] ?? [])
|
|
207
|
+
rewardTokens[poolsToFetch[i]] = (rewards[pool.gauge] ?? [])
|
|
208
|
+
.map((r) => ({ token: r.tokenAddress, symbol: r.symbol, decimals: Number(r.decimals) }));
|
|
208
209
|
}
|
|
209
210
|
// --- 3. Reward info ---
|
|
210
211
|
const rewardInfoCalls = [];
|