@curvefi/api 2.65.28 → 2.65.29
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/eslint.config.mjs +88 -0
- package/lib/boosting.js +13 -13
- package/lib/constants/coins/avalanche.js +4 -4
- package/lib/constants/coins/base.js +1 -1
- package/lib/constants/coins/celo.js +1 -1
- package/lib/constants/coins/ethereum.js +88 -88
- package/lib/constants/coins/fantom.js +5 -5
- package/lib/constants/coins/kava.js +1 -1
- package/lib/constants/coins/polygon.js +18 -18
- package/lib/constants/coins/zksync.js +1 -1
- package/lib/constants/factory/crypto.js +32 -32
- package/lib/constants/factory/stable.js +57 -57
- package/lib/constants/network_constants.js +37 -37
- package/lib/constants/pools/arbitrum.js +8 -8
- package/lib/constants/pools/aurora.js +2 -2
- package/lib/constants/pools/avalanche.js +13 -13
- package/lib/constants/pools/ethereum.js +89 -89
- package/lib/constants/pools/fantom.js +13 -13
- package/lib/constants/pools/moonbeam.js +3 -3
- package/lib/constants/pools/optimism.js +3 -3
- package/lib/constants/pools/polygon.js +21 -21
- package/lib/constants/pools/xdai.js +13 -13
- package/lib/curve.d.ts +1 -1
- package/lib/curve.js +38 -38
- package/lib/dao.js +12 -12
- package/lib/external-api.d.ts +0 -9
- package/lib/external-api.js +75 -104
- package/lib/factory/deploy.js +12 -12
- package/lib/factory/factory-api.js +13 -13
- package/lib/factory/factory-crypto.js +10 -10
- package/lib/factory/factory-tricrypto.js +11 -11
- package/lib/factory/factory-twocrypto.js +9 -9
- package/lib/factory/factory.js +13 -13
- package/lib/index.d.ts +59 -59
- package/lib/index.js +3 -3
- package/lib/pools/PoolTemplate.js +59 -59
- package/lib/pools/mixins/depositMixins.js +14 -14
- package/lib/pools/mixins/depositWrappedMixins.js +8 -8
- package/lib/pools/mixins/swapMixins.js +12 -12
- package/lib/pools/mixins/swapWrappedMixins.js +8 -8
- package/lib/pools/mixins/withdrawImbalanceMixins.js +12 -12
- package/lib/pools/mixins/withdrawImbalanceWrappedMixins.js +6 -6
- package/lib/pools/mixins/withdrawMixins.js +14 -14
- package/lib/pools/mixins/withdrawOneCoinMixins.js +14 -14
- package/lib/pools/mixins/withdrawOneCoinWrappedMixins.js +6 -6
- package/lib/pools/mixins/withdrawWrappedMixins.js +6 -6
- package/lib/pools/subClasses/gaugePool.js +4 -4
- package/lib/pools/subClasses/statsPool.js +3 -3
- package/lib/pools/utils.js +11 -11
- package/lib/route-graph.worker.js +3 -3
- package/lib/router.js +4 -5
- package/lib/utils.js +22 -24
- package/package.json +21 -18
|
@@ -21,8 +21,8 @@ function _withdrawImbalanceWrappedCheck(amounts) {
|
|
|
21
21
|
return amounts.map((amount, i) => parseUnits(amount, this.wrappedDecimals[i]));
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
function _withdrawImbalanceWrappedMaxBurnAmount(
|
|
25
|
-
return __awaiter(this,
|
|
24
|
+
function _withdrawImbalanceWrappedMaxBurnAmount(_amounts_1) {
|
|
25
|
+
return __awaiter(this, arguments, void 0, function* (_amounts, slippage = 0.5) {
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
const _expectedLpTokenAmount = yield this._calcLpTokenAmount(_amounts, false, false);
|
|
28
28
|
const maxBurnAmountBN = toBN(_expectedLpTokenAmount).times(100 + slippage).div(100);
|
|
@@ -32,8 +32,8 @@ function _withdrawImbalanceWrappedMaxBurnAmount(_amounts, slippage = 0.5) {
|
|
|
32
32
|
// @ts-ignore
|
|
33
33
|
export const withdrawImbalanceWrapped2argsMixin = {
|
|
34
34
|
// @ts-ignore
|
|
35
|
-
_withdrawImbalanceWrapped(
|
|
36
|
-
return __awaiter(this,
|
|
35
|
+
_withdrawImbalanceWrapped(_amounts_1, slippage_1) {
|
|
36
|
+
return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
|
|
37
37
|
const _maxBurnAmount = yield _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage);
|
|
38
38
|
const contract = curve.contracts[this.address].contract;
|
|
39
39
|
const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, curve.constantOptions);
|
|
@@ -63,8 +63,8 @@ export const withdrawImbalanceWrapped2argsMixin = {
|
|
|
63
63
|
// @ts-ignore
|
|
64
64
|
export const withdrawImbalanceWrapped3argsMixin = {
|
|
65
65
|
// @ts-ignore
|
|
66
|
-
_withdrawImbalanceWrapped(
|
|
67
|
-
return __awaiter(this,
|
|
66
|
+
_withdrawImbalanceWrapped(_amounts_1, slippage_1) {
|
|
67
|
+
return __awaiter(this, arguments, void 0, function* (_amounts, slippage, estimateGas = false) {
|
|
68
68
|
const _maxBurnAmount = yield _withdrawImbalanceWrappedMaxBurnAmount.call(this, _amounts, slippage);
|
|
69
69
|
const contract = curve.contracts[this.address].contract;
|
|
70
70
|
const gas = yield contract.remove_liquidity_imbalance.estimateGas(_amounts, _maxBurnAmount, false, curve.constantOptions);
|
|
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { curve } from "../../curve.js";
|
|
11
11
|
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
12
12
|
// @ts-ignore
|
|
13
|
-
function _withdrawCheck(
|
|
14
|
-
return __awaiter(this,
|
|
13
|
+
function _withdrawCheck(lpTokenAmount_1) {
|
|
14
|
+
return __awaiter(this, arguments, void 0, function* (lpTokenAmount, estimateGas = false) {
|
|
15
15
|
const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
|
|
16
16
|
if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
|
|
17
17
|
throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
|
|
@@ -24,8 +24,8 @@ function _withdrawCheck(lpTokenAmount, estimateGas = false) {
|
|
|
24
24
|
return parseUnits(lpTokenAmount);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
function _withdrawMinAmounts(
|
|
28
|
-
return __awaiter(this,
|
|
27
|
+
function _withdrawMinAmounts(_lpTokenAmount_1) {
|
|
28
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage = 0.5) {
|
|
29
29
|
const expectedAmounts = yield this.withdrawExpected(curve.formatUnits(_lpTokenAmount));
|
|
30
30
|
const _expectedAmounts = expectedAmounts.map((a, i) => curve.parseUnits(a, this.underlyingDecimals[i]));
|
|
31
31
|
const minRecvAmountsBN = _expectedAmounts.map((_a, i) => toBN(_a, this.underlyingDecimals[i]).times(100 - slippage).div(100));
|
|
@@ -35,8 +35,8 @@ function _withdrawMinAmounts(_lpTokenAmount, slippage = 0.5) {
|
|
|
35
35
|
// @ts-ignore
|
|
36
36
|
export const withdrawMetaFactoryMixin = {
|
|
37
37
|
// @ts-ignore
|
|
38
|
-
_withdraw(
|
|
39
|
-
return __awaiter(this,
|
|
38
|
+
_withdraw(_lpTokenAmount_1, slippage_1) {
|
|
39
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
|
|
40
40
|
if (!estimateGas)
|
|
41
41
|
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
42
42
|
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
@@ -68,8 +68,8 @@ export const withdrawMetaFactoryMixin = {
|
|
|
68
68
|
// @ts-ignore
|
|
69
69
|
export const withdrawCryptoMetaFactoryMixin = {
|
|
70
70
|
// @ts-ignore
|
|
71
|
-
_withdraw(
|
|
72
|
-
return __awaiter(this,
|
|
71
|
+
_withdraw(_lpTokenAmount_1, slippage_1) {
|
|
72
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
|
|
73
73
|
if (!estimateGas)
|
|
74
74
|
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
75
75
|
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
@@ -101,8 +101,8 @@ export const withdrawCryptoMetaFactoryMixin = {
|
|
|
101
101
|
// @ts-ignore
|
|
102
102
|
export const withdrawZapMixin = {
|
|
103
103
|
// @ts-ignore
|
|
104
|
-
_withdraw(
|
|
105
|
-
return __awaiter(this,
|
|
104
|
+
_withdraw(_lpTokenAmount_1, slippage_1) {
|
|
105
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
|
|
106
106
|
if (!estimateGas)
|
|
107
107
|
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
108
108
|
// @ts-ignore
|
|
@@ -138,8 +138,8 @@ export const withdrawZapMixin = {
|
|
|
138
138
|
// @ts-ignore
|
|
139
139
|
export const withdrawLendingOrCryptoMixin = {
|
|
140
140
|
// @ts-ignore
|
|
141
|
-
_withdraw(
|
|
142
|
-
return __awaiter(this,
|
|
141
|
+
_withdraw(_lpTokenAmount_1, slippage_1) {
|
|
142
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
|
|
143
143
|
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
144
144
|
const contract = curve.contracts[this.address].contract;
|
|
145
145
|
const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, true, curve.constantOptions);
|
|
@@ -169,8 +169,8 @@ export const withdrawLendingOrCryptoMixin = {
|
|
|
169
169
|
// @ts-ignore
|
|
170
170
|
export const withdrawPlainMixin = {
|
|
171
171
|
// @ts-ignore
|
|
172
|
-
_withdraw(
|
|
173
|
-
return __awaiter(this,
|
|
172
|
+
_withdraw(_lpTokenAmount_1, slippage_1) {
|
|
173
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
|
|
174
174
|
// @ts-ignore
|
|
175
175
|
const _minAmounts = yield _withdrawMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
176
176
|
const contract = curve.contracts[this.address].contract;
|
|
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { curve } from "../../curve.js";
|
|
11
11
|
import { _ensureAllowance, fromBN, hasAllowance, toBN, parseUnits, mulBy1_3, smartNumber, DIGas } from '../../utils.js';
|
|
12
12
|
// @ts-ignore
|
|
13
|
-
function _withdrawOneCoinCheck(
|
|
14
|
-
return __awaiter(this,
|
|
13
|
+
function _withdrawOneCoinCheck(lpTokenAmount_1, coin_1) {
|
|
14
|
+
return __awaiter(this, arguments, void 0, function* (lpTokenAmount, coin, estimateGas = false) {
|
|
15
15
|
const lpTokenBalance = (yield this.wallet.lpTokenBalances())['lpToken'];
|
|
16
16
|
if (Number(lpTokenBalance) < Number(lpTokenAmount)) {
|
|
17
17
|
throw Error(`Not enough LP tokens. Actual: ${lpTokenBalance}, required: ${lpTokenAmount}`);
|
|
@@ -27,8 +27,8 @@ function _withdrawOneCoinCheck(lpTokenAmount, coin, estimateGas = false) {
|
|
|
27
27
|
return [_lpTokenAmount, i];
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
function _withdrawOneCoinMinAmount(
|
|
31
|
-
return __awaiter(this,
|
|
30
|
+
function _withdrawOneCoinMinAmount(_lpTokenAmount_1, i_1) {
|
|
31
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage = 0.5) {
|
|
32
32
|
// @ts-ignore
|
|
33
33
|
const _expectedLpTokenAmount = yield this._withdrawOneCoinExpected(_lpTokenAmount, i);
|
|
34
34
|
const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
|
|
@@ -38,8 +38,8 @@ function _withdrawOneCoinMinAmount(_lpTokenAmount, i, slippage = 0.5) {
|
|
|
38
38
|
// @ts-ignore
|
|
39
39
|
export const withdrawOneCoinMetaFactoryMixin = {
|
|
40
40
|
// @ts-ignore
|
|
41
|
-
_withdrawOneCoin(
|
|
42
|
-
return __awaiter(this,
|
|
41
|
+
_withdrawOneCoin(_lpTokenAmount_1, i_1, slippage_1) {
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false) {
|
|
43
43
|
if (!estimateGas)
|
|
44
44
|
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
45
45
|
const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
|
|
@@ -71,8 +71,8 @@ export const withdrawOneCoinMetaFactoryMixin = {
|
|
|
71
71
|
// @ts-ignore
|
|
72
72
|
export const withdrawOneCoinCryptoMetaFactoryMixin = {
|
|
73
73
|
// @ts-ignore
|
|
74
|
-
_withdrawOneCoin(
|
|
75
|
-
return __awaiter(this,
|
|
74
|
+
_withdrawOneCoin(_lpTokenAmount_1, i_1, slippage_1) {
|
|
75
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false) {
|
|
76
76
|
if (!estimateGas)
|
|
77
77
|
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
78
78
|
const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
|
|
@@ -104,8 +104,8 @@ export const withdrawOneCoinCryptoMetaFactoryMixin = {
|
|
|
104
104
|
// @ts-ignore
|
|
105
105
|
export const withdrawOneCoinZapMixin = {
|
|
106
106
|
// @ts-ignore
|
|
107
|
-
_withdrawOneCoin(
|
|
108
|
-
return __awaiter(this,
|
|
107
|
+
_withdrawOneCoin(_lpTokenAmount_1, i_1, slippage_1) {
|
|
108
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false) {
|
|
109
109
|
if (!estimateGas)
|
|
110
110
|
yield _ensureAllowance([this.lpToken], [_lpTokenAmount], this.zap);
|
|
111
111
|
const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
|
|
@@ -140,8 +140,8 @@ export const withdrawOneCoinZapMixin = {
|
|
|
140
140
|
// @ts-ignore
|
|
141
141
|
export const withdrawOneCoinLendingOrCryptoMixin = {
|
|
142
142
|
// @ts-ignore
|
|
143
|
-
_withdrawOneCoin(
|
|
144
|
-
return __awaiter(this,
|
|
143
|
+
_withdrawOneCoin(_lpTokenAmount_1, i_1, slippage_1) {
|
|
144
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false) {
|
|
145
145
|
const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
|
|
146
146
|
const contract = curve.contracts[this.address].contract;
|
|
147
147
|
const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, true, curve.constantOptions);
|
|
@@ -171,8 +171,8 @@ export const withdrawOneCoinLendingOrCryptoMixin = {
|
|
|
171
171
|
// @ts-ignore
|
|
172
172
|
export const withdrawOneCoinPlainMixin = {
|
|
173
173
|
// @ts-ignore
|
|
174
|
-
_withdrawOneCoin(
|
|
175
|
-
return __awaiter(this,
|
|
174
|
+
_withdrawOneCoin(_lpTokenAmount_1, i_1, slippage_1) {
|
|
175
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false) {
|
|
176
176
|
const _minAmount = yield _withdrawOneCoinMinAmount.call(this, _lpTokenAmount, i, slippage);
|
|
177
177
|
const contract = curve.contracts[this.address].contract;
|
|
178
178
|
const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, curve.constantOptions);
|
|
@@ -23,8 +23,8 @@ function _withdrawOneCoinWrappedCheck(lpTokenAmount, coin) {
|
|
|
23
23
|
return [_lpTokenAmount, i];
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function _withdrawOneCoinWrappedMinAmount(
|
|
27
|
-
return __awaiter(this,
|
|
26
|
+
function _withdrawOneCoinWrappedMinAmount(_lpTokenAmount_1, i_1) {
|
|
27
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage = 0.5) {
|
|
28
28
|
// @ts-ignore
|
|
29
29
|
const _expectedLpTokenAmount = yield this._withdrawOneCoinWrappedExpected(_lpTokenAmount, i);
|
|
30
30
|
const minAmountBN = toBN(_expectedLpTokenAmount).times(100 - slippage).div(100);
|
|
@@ -34,8 +34,8 @@ function _withdrawOneCoinWrappedMinAmount(_lpTokenAmount, i, slippage = 0.5) {
|
|
|
34
34
|
// @ts-ignore
|
|
35
35
|
export const withdrawOneCoinWrappedLendingOrCryptoMixin = {
|
|
36
36
|
// @ts-ignore
|
|
37
|
-
_withdrawOneCoinWrapped(
|
|
38
|
-
return __awaiter(this,
|
|
37
|
+
_withdrawOneCoinWrapped(_lpTokenAmount_1, i_1, slippage_1) {
|
|
38
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false) {
|
|
39
39
|
const _minAmount = yield _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage);
|
|
40
40
|
const contract = curve.contracts[this.address].contract;
|
|
41
41
|
const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, false, curve.constantOptions);
|
|
@@ -65,8 +65,8 @@ export const withdrawOneCoinWrappedLendingOrCryptoMixin = {
|
|
|
65
65
|
// @ts-ignore
|
|
66
66
|
export const withdrawOneCoinWrappedMixin = {
|
|
67
67
|
// @ts-ignore
|
|
68
|
-
_withdrawOneCoinWrapped(
|
|
69
|
-
return __awaiter(this,
|
|
68
|
+
_withdrawOneCoinWrapped(_lpTokenAmount_1, i_1, slippage_1) {
|
|
69
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, i, slippage, estimateGas = false) {
|
|
70
70
|
const _minAmount = yield _withdrawOneCoinWrappedMinAmount.call(this, _lpTokenAmount, i, slippage);
|
|
71
71
|
const contract = curve.contracts[this.address].contract;
|
|
72
72
|
const gas = yield contract.remove_liquidity_one_coin.estimateGas(_lpTokenAmount, i, _minAmount, curve.constantOptions);
|
|
@@ -20,8 +20,8 @@ function _withdrawWrappedCheck(lpTokenAmount) {
|
|
|
20
20
|
return parseUnits(lpTokenAmount);
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
function _withdrawWrappedMinAmounts(
|
|
24
|
-
return __awaiter(this,
|
|
23
|
+
function _withdrawWrappedMinAmounts(_lpTokenAmount_1) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage = 0.5) {
|
|
25
25
|
const expectedAmounts = yield this.withdrawWrappedExpected(curve.formatUnits(_lpTokenAmount));
|
|
26
26
|
const _expectedAmounts = expectedAmounts.map((a, i) => curve.parseUnits(a, this.wrappedDecimals[i]));
|
|
27
27
|
const minRecvAmountsBN = _expectedAmounts.map((_a, i) => toBN(_a, this.wrappedDecimals[i]).times(100 - slippage).div(100));
|
|
@@ -31,8 +31,8 @@ function _withdrawWrappedMinAmounts(_lpTokenAmount, slippage = 0.5) {
|
|
|
31
31
|
// @ts-ignore
|
|
32
32
|
export const withdrawWrapped2argsMixin = {
|
|
33
33
|
// @ts-ignore
|
|
34
|
-
_withdrawWrapped(
|
|
35
|
-
return __awaiter(this,
|
|
34
|
+
_withdrawWrapped(_lpTokenAmount_1, slippage_1) {
|
|
35
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
|
|
36
36
|
const _minAmounts = yield _withdrawWrappedMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
37
37
|
const contract = curve.contracts[this.address].contract;
|
|
38
38
|
const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, curve.constantOptions);
|
|
@@ -62,8 +62,8 @@ export const withdrawWrapped2argsMixin = {
|
|
|
62
62
|
// @ts-ignore
|
|
63
63
|
export const withdrawWrapped3argsMixin = {
|
|
64
64
|
// @ts-ignore
|
|
65
|
-
_withdrawWrapped(
|
|
66
|
-
return __awaiter(this,
|
|
65
|
+
_withdrawWrapped(_lpTokenAmount_1, slippage_1) {
|
|
66
|
+
return __awaiter(this, arguments, void 0, function* (_lpTokenAmount, slippage, estimateGas = false) {
|
|
67
67
|
const _minAmounts = yield _withdrawWrappedMinAmounts.call(this, _lpTokenAmount, slippage);
|
|
68
68
|
const contract = curve.contracts[this.address].contract;
|
|
69
69
|
const gas = yield contract.remove_liquidity.estimateGas(_lpTokenAmount, _minAmounts, false, curve.constantOptions);
|
|
@@ -71,8 +71,8 @@ export class GaugePool {
|
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
_addReward(
|
|
75
|
-
return __awaiter(this,
|
|
74
|
+
_addReward(_reward_token_1, _distributor_1) {
|
|
75
|
+
return __awaiter(this, arguments, void 0, function* (_reward_token, _distributor, estimateGas = false) {
|
|
76
76
|
if (this.address !== curve.constants.ZERO_ADDRESS && this.address) {
|
|
77
77
|
const gas = yield curve.contracts[this.address].contract.add_reward.estimateGas(_reward_token, _distributor, Object.assign({}, curve.constantOptions));
|
|
78
78
|
if (estimateGas)
|
|
@@ -117,8 +117,8 @@ export class GaugePool {
|
|
|
117
117
|
return yield ensureAllowance([rewardToken], [amount], this.address);
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
_depositReward(
|
|
121
|
-
return __awaiter(this,
|
|
120
|
+
_depositReward(rewardToken_1, amount_1, epoch_1) {
|
|
121
|
+
return __awaiter(this, arguments, void 0, function* (rewardToken, amount, epoch, estimateGas = false) {
|
|
122
122
|
if (!estimateGas)
|
|
123
123
|
yield ensureAllowance([rewardToken], [amount], this.address);
|
|
124
124
|
const contract = curve.contracts[this.address].contract;
|
|
@@ -83,7 +83,7 @@ export class StatsPool {
|
|
|
83
83
|
];
|
|
84
84
|
return { lpTokenSupply, virtualPrice, fee, adminFee, A, future_A, initial_A, future_A_time, initial_A_time, gamma, priceOracle, priceScale };
|
|
85
85
|
});
|
|
86
|
-
this.totalLiquidity = (
|
|
86
|
+
this.totalLiquidity = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
87
87
|
if (curve.chainId === 1 && this.pool.id === "crveth")
|
|
88
88
|
return "0";
|
|
89
89
|
if (this.pool.isLlamma) {
|
|
@@ -153,7 +153,7 @@ export class StatsPool {
|
|
|
153
153
|
}
|
|
154
154
|
throw Error(`Can't get base APY for ${this.pool.name} (id: ${this.pool.id})`);
|
|
155
155
|
});
|
|
156
|
-
this.tokenApy = (
|
|
156
|
+
this.tokenApy = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
157
157
|
var _a;
|
|
158
158
|
if (curve.isLiteChain) {
|
|
159
159
|
throw Error('tokenApy is not supported for the lite version');
|
|
@@ -168,7 +168,7 @@ export class StatsPool {
|
|
|
168
168
|
}
|
|
169
169
|
return yield this.pool._calcTokenApy();
|
|
170
170
|
});
|
|
171
|
-
this.rewardsApy = (
|
|
171
|
+
this.rewardsApy = (...args_1) => __awaiter(this, [...args_1], void 0, function* (useApi = true) {
|
|
172
172
|
if (this.pool.gauge.address === curve.constants.ZERO_ADDRESS)
|
|
173
173
|
return [];
|
|
174
174
|
const isDisabledChain = [1313161554].includes(curve.chainId); // Disable Aurora
|
package/lib/pools/utils.js
CHANGED
|
@@ -11,7 +11,7 @@ import { getPool } from "./poolConstructor.js";
|
|
|
11
11
|
import { curve } from "../curve.js";
|
|
12
12
|
import { _getRewardsFromApi, _getUsdRate, _setContracts, toBN } from "../utils.js";
|
|
13
13
|
import { _getAllPoolsFromApi } from "../external-api.js";
|
|
14
|
-
import ERC20Abi from "../constants/abis/ERC20.json"
|
|
14
|
+
import ERC20Abi from "../constants/abis/ERC20.json" with { type: 'json' };
|
|
15
15
|
// _userLpBalance: { address: { poolId: { _lpBalance: 0, time: 0 } } }
|
|
16
16
|
const _userLpBalanceCache = {};
|
|
17
17
|
const _isUserLpBalanceCacheExpired = (address, poolId) => { var _a, _b; return (((_b = (_a = _userLpBalanceCache[address]) === null || _a === void 0 ? void 0 : _a[poolId]) === null || _b === void 0 ? void 0 : _b.time) || 0) + 600000 < Date.now(); };
|
|
@@ -43,7 +43,7 @@ const _getUserLpBalances = (pools, address, useCache) => __awaiter(void 0, void
|
|
|
43
43
|
}
|
|
44
44
|
return _lpBalances;
|
|
45
45
|
});
|
|
46
|
-
export const getUserPoolListByLiquidity = (
|
|
46
|
+
export const getUserPoolListByLiquidity = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = curve.signerAddress) {
|
|
47
47
|
const pools = curve.getPoolList();
|
|
48
48
|
const _lpBalances = yield _getUserLpBalances(pools, address, false);
|
|
49
49
|
const userPoolList = [];
|
|
@@ -54,7 +54,7 @@ export const getUserPoolListByLiquidity = (address = curve.signerAddress) => __a
|
|
|
54
54
|
}
|
|
55
55
|
return userPoolList;
|
|
56
56
|
});
|
|
57
|
-
export const getUserLiquidityUSD = (
|
|
57
|
+
export const getUserLiquidityUSD = (pools_1, ...args_1) => __awaiter(void 0, [pools_1, ...args_1], void 0, function* (pools, address = curve.signerAddress) {
|
|
58
58
|
const _lpBalances = yield _getUserLpBalances(pools, address, true);
|
|
59
59
|
const userLiquidityUSD = [];
|
|
60
60
|
for (let i = 0; i < pools.length; i++) {
|
|
@@ -68,7 +68,7 @@ export const getUserLiquidityUSD = (pools, address = curve.signerAddress) => __a
|
|
|
68
68
|
const _userClaimableCache = {};
|
|
69
69
|
const _isUserClaimableCacheExpired = (address, poolId) => { var _a, _b; return (((_b = (_a = _userClaimableCache[address]) === null || _a === void 0 ? void 0 : _a[poolId]) === null || _b === void 0 ? void 0 : _b.time) || 0) + 600000 < Date.now(); };
|
|
70
70
|
const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
var
|
|
71
|
+
var _a;
|
|
72
72
|
const poolsToFetch = useCache ? pools.filter((poolId) => _isUserClaimableCacheExpired(address, poolId)) : pools;
|
|
73
73
|
if (poolsToFetch.length > 0) {
|
|
74
74
|
// --- 1. CRV ---
|
|
@@ -194,12 +194,12 @@ const _getUserClaimable = (pools, address, useCache) => __awaiter(void 0, void 0
|
|
|
194
194
|
}
|
|
195
195
|
const _claimable = [];
|
|
196
196
|
for (const poolId of pools) {
|
|
197
|
-
_claimable.push((
|
|
197
|
+
_claimable.push((_a = _userClaimableCache[address]) === null || _a === void 0 ? void 0 : _a[poolId].rewards);
|
|
198
198
|
}
|
|
199
199
|
return _claimable;
|
|
200
200
|
});
|
|
201
201
|
const _getUserClaimableUseApi = (pools, address, useCache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
202
|
-
var
|
|
202
|
+
var _a, _b;
|
|
203
203
|
const poolsToFetch = useCache ? pools.filter((poolId) => _isUserClaimableCacheExpired(address, poolId)) : pools;
|
|
204
204
|
if (poolsToFetch.length > 0) {
|
|
205
205
|
// --- 1. CRV ---
|
|
@@ -218,7 +218,7 @@ const _getUserClaimableUseApi = (pools, address, useCache) => __awaiter(void 0,
|
|
|
218
218
|
for (let i = 0; i < poolsToFetch.length; i++) {
|
|
219
219
|
const pool = getPool(poolsToFetch[i]);
|
|
220
220
|
const rewards = yield _getRewardsFromApi();
|
|
221
|
-
rewardTokens[poolsToFetch[i]] = ((
|
|
221
|
+
rewardTokens[poolsToFetch[i]] = ((_a = rewards[pool.gauge.address]) !== null && _a !== void 0 ? _a : [])
|
|
222
222
|
.map((r) => ({ token: r.tokenAddress, symbol: r.symbol, decimals: Number(r.decimals) }));
|
|
223
223
|
}
|
|
224
224
|
// --- 3. Reward info ---
|
|
@@ -276,11 +276,11 @@ const _getUserClaimableUseApi = (pools, address, useCache) => __awaiter(void 0,
|
|
|
276
276
|
}
|
|
277
277
|
const _claimable = [];
|
|
278
278
|
for (const poolId of pools) {
|
|
279
|
-
_claimable.push((
|
|
279
|
+
_claimable.push((_b = _userClaimableCache[address]) === null || _b === void 0 ? void 0 : _b[poolId].rewards);
|
|
280
280
|
}
|
|
281
281
|
return _claimable;
|
|
282
282
|
});
|
|
283
|
-
export const getUserPoolListByClaimable = (
|
|
283
|
+
export const getUserPoolListByClaimable = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = curve.signerAddress) {
|
|
284
284
|
const pools = curve.getPoolList();
|
|
285
285
|
const _claimable = yield _getUserClaimable(pools, address, false);
|
|
286
286
|
const userPoolList = [];
|
|
@@ -291,7 +291,7 @@ export const getUserPoolListByClaimable = (address = curve.signerAddress) => __a
|
|
|
291
291
|
}
|
|
292
292
|
return userPoolList;
|
|
293
293
|
});
|
|
294
|
-
export const getUserClaimable = (
|
|
294
|
+
export const getUserClaimable = (pools_1, ...args_1) => __awaiter(void 0, [pools_1, ...args_1], void 0, function* (pools, address = curve.signerAddress) {
|
|
295
295
|
const _claimable = yield _getUserClaimable(pools, address, true);
|
|
296
296
|
const claimableWithPrice = [];
|
|
297
297
|
for (let i = 0; i < pools.length; i++) {
|
|
@@ -303,7 +303,7 @@ export const getUserClaimable = (pools, address = curve.signerAddress) => __awai
|
|
|
303
303
|
}
|
|
304
304
|
return claimableWithPrice;
|
|
305
305
|
});
|
|
306
|
-
export const getUserPoolList = (
|
|
306
|
+
export const getUserPoolList = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (address = curve.signerAddress, useApi = true) {
|
|
307
307
|
const pools = curve.getPoolList();
|
|
308
308
|
const [_lpBalances, _claimable] = yield Promise.all([
|
|
309
309
|
_getUserLpBalances(pools, address, false),
|
|
@@ -4,9 +4,9 @@ export function routeGraphWorker() {
|
|
|
4
4
|
10: {
|
|
5
5
|
swap: "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4".toLowerCase(),
|
|
6
6
|
coins: [
|
|
7
|
-
"0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9",
|
|
8
|
-
"0xFBc4198702E81aE77c06D58f81b629BDf36f0a71",
|
|
9
|
-
"0xe405de8f52ba7559f9df3c368500b6e6ae6cee49",
|
|
7
|
+
"0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9", // sUSD
|
|
8
|
+
"0xFBc4198702E81aE77c06D58f81b629BDf36f0a71", // sEUR
|
|
9
|
+
"0xe405de8f52ba7559f9df3c368500b6e6ae6cee49", // sETH
|
|
10
10
|
"0x298b9b95708152ff6968aafd889c6586e9169f1d", // sBTC
|
|
11
11
|
].map((a) => a.toLowerCase()),
|
|
12
12
|
},
|
package/lib/router.js
CHANGED
|
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import axios from "axios";
|
|
11
10
|
import memoize from "memoizee";
|
|
12
11
|
import { ethers } from "ethers";
|
|
13
12
|
import { curve, OLD_CHAINS } from "./curve.js";
|
|
@@ -26,7 +25,7 @@ const _getTVL = memoize((poolId) => __awaiter(void 0, void 0, void 0, function*
|
|
|
26
25
|
function entriesToDictAsync(entries, mapper) {
|
|
27
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
27
|
const result = {};
|
|
29
|
-
yield Promise.all(entries.map((
|
|
28
|
+
yield Promise.all(entries.map((_a) => __awaiter(this, [_a], void 0, function* ([key, value]) { return result[key] = yield mapper(key, value); })));
|
|
30
29
|
return result;
|
|
31
30
|
});
|
|
32
31
|
}
|
|
@@ -217,10 +216,10 @@ const _getBestRoute = memoize((inputCoinAddress, outputCoinAddress, amount) => _
|
|
|
217
216
|
const [gasAmounts, outputCoinUsdRate, gasData, ethUsdRate] = yield Promise.all([
|
|
218
217
|
_estimateGasForDifferentRoutes(routes.map((r) => r.route), inputCoinAddress, outputCoinAddress, _amount),
|
|
219
218
|
_getUsdRate(outputCoinAddress),
|
|
220
|
-
|
|
219
|
+
fetch("https://api.curve.fi/api/getGas").then((res) => res.json()),
|
|
221
220
|
_getUsdRate(ETH_ADDRESS),
|
|
222
221
|
]);
|
|
223
|
-
const gasPrice = gasData.data.
|
|
222
|
+
const gasPrice = gasData.data.gas.standard;
|
|
224
223
|
const expectedAmounts = (routes).map((route) => Number(curve.formatUnits(route._output, outputCoinDecimals)));
|
|
225
224
|
const expectedAmountsUsd = expectedAmounts.map((a) => a * outputCoinUsdRate);
|
|
226
225
|
const L1GasPrice = L2Networks.includes(curve.chainId) ? yield getGasPriceFromL1() : 0;
|
|
@@ -353,7 +352,7 @@ export const swapEstimateGas = (inputCoin, outputCoin, amount) => __awaiter(void
|
|
|
353
352
|
const [gas] = yield _estimateGasForDifferentRoutes([route], inputCoinAddress, outputCoinAddress, _amount);
|
|
354
353
|
return gas;
|
|
355
354
|
});
|
|
356
|
-
export const swap = (
|
|
355
|
+
export const swap = (inputCoin_1, outputCoin_1, amount_1, ...args_1) => __awaiter(void 0, [inputCoin_1, outputCoin_1, amount_1, ...args_1], void 0, function* (inputCoin, outputCoin, amount, slippage = 0.5) {
|
|
357
356
|
const [inputCoinAddress, outputCoinAddress] = _getCoinAddresses(inputCoin, outputCoin);
|
|
358
357
|
const [inputCoinDecimals, outputCoinDecimals] = _getCoinDecimals(inputCoinAddress, outputCoinAddress);
|
|
359
358
|
yield swapApprove(inputCoin, amount);
|
package/lib/utils.js
CHANGED
|
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import axios from 'axios';
|
|
11
10
|
import { Contract } from 'ethers';
|
|
12
11
|
import { Contract as MulticallContract } from "@curvefi/ethcall";
|
|
13
12
|
import BigNumber from 'bignumber.js';
|
|
@@ -192,7 +191,7 @@ export const hasAllowance = (coins, amounts, address, spender) => __awaiter(void
|
|
|
192
191
|
const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
|
|
193
192
|
return _allowance.map((a, i) => a >= _amounts[i]).reduce((a, b) => a && b);
|
|
194
193
|
});
|
|
195
|
-
export const _ensureAllowance = (
|
|
194
|
+
export const _ensureAllowance = (coins_1, amounts_1, spender_1, ...args_1) => __awaiter(void 0, [coins_1, amounts_1, spender_1, ...args_1], void 0, function* (coins, amounts, spender, isMax = true) {
|
|
196
195
|
const address = curve.signerAddress;
|
|
197
196
|
const allowance = yield _getAllowance(coins, address, spender);
|
|
198
197
|
const txHashes = [];
|
|
@@ -216,7 +215,7 @@ export const _ensureAllowance = (coins, amounts, spender, isMax = true) => __awa
|
|
|
216
215
|
return txHashes;
|
|
217
216
|
});
|
|
218
217
|
// coins can be either addresses or symbols
|
|
219
|
-
export const ensureAllowanceEstimateGas = (
|
|
218
|
+
export const ensureAllowanceEstimateGas = (coins_1, amounts_1, spender_1, ...args_1) => __awaiter(void 0, [coins_1, amounts_1, spender_1, ...args_1], void 0, function* (coins, amounts, spender, isMax = true) {
|
|
220
219
|
const coinAddresses = _getCoinAddresses(coins);
|
|
221
220
|
const decimals = _getCoinDecimals(coinAddresses);
|
|
222
221
|
const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
|
|
@@ -247,7 +246,7 @@ export const ensureAllowanceEstimateGas = (coins, amounts, spender, isMax = true
|
|
|
247
246
|
return getGasFromArray(gas);
|
|
248
247
|
});
|
|
249
248
|
// coins can be either addresses or symbols
|
|
250
|
-
export const ensureAllowance = (
|
|
249
|
+
export const ensureAllowance = (coins_1, amounts_1, spender_1, ...args_1) => __awaiter(void 0, [coins_1, amounts_1, spender_1, ...args_1], void 0, function* (coins, amounts, spender, isMax = true) {
|
|
251
250
|
const coinAddresses = _getCoinAddresses(coins);
|
|
252
251
|
const decimals = _getCoinDecimals(coinAddresses);
|
|
253
252
|
const _amounts = amounts.map((a, i) => parseUnits(a, decimals[i]));
|
|
@@ -331,7 +330,7 @@ export const _getUsdPricesFromApi = () => __awaiter(void 0, void 0, void 0, func
|
|
|
331
330
|
return priceDictByMaxTvl;
|
|
332
331
|
});
|
|
333
332
|
export const _getCrvApyFromApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
334
|
-
var
|
|
333
|
+
var _a, _b;
|
|
335
334
|
const network = curve.constants.NETWORK_NAME;
|
|
336
335
|
const allTypesExtendedPoolData = yield _getAllPoolsFromApi(network, curve.isLiteChain);
|
|
337
336
|
const apyDict = {};
|
|
@@ -342,7 +341,7 @@ export const _getCrvApyFromApi = () => __awaiter(void 0, void 0, void 0, functio
|
|
|
342
341
|
apyDict[pool.gaugeAddress.toLowerCase()] = [0, 0];
|
|
343
342
|
}
|
|
344
343
|
else {
|
|
345
|
-
apyDict[pool.gaugeAddress.toLowerCase()] = [(
|
|
344
|
+
apyDict[pool.gaugeAddress.toLowerCase()] = [(_a = pool.gaugeCrvApy[0]) !== null && _a !== void 0 ? _a : 0, (_b = pool.gaugeCrvApy[1]) !== null && _b !== void 0 ? _b : 0];
|
|
346
345
|
}
|
|
347
346
|
}
|
|
348
347
|
}
|
|
@@ -350,14 +349,14 @@ export const _getCrvApyFromApi = () => __awaiter(void 0, void 0, void 0, functio
|
|
|
350
349
|
return apyDict;
|
|
351
350
|
});
|
|
352
351
|
export const _getRewardsFromApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
353
|
-
var
|
|
352
|
+
var _a, _b;
|
|
354
353
|
const network = curve.constants.NETWORK_NAME;
|
|
355
354
|
const allTypesExtendedPoolData = yield _getAllPoolsFromApi(network, curve.isLiteChain);
|
|
356
355
|
const rewardsDict = {};
|
|
357
356
|
for (const extendedPoolData of allTypesExtendedPoolData) {
|
|
358
357
|
for (const pool of extendedPoolData.poolData) {
|
|
359
358
|
if (pool.gaugeAddress) {
|
|
360
|
-
rewardsDict[pool.gaugeAddress.toLowerCase()] = ((
|
|
359
|
+
rewardsDict[pool.gaugeAddress.toLowerCase()] = ((_b = (_a = pool.gaugeRewards) !== null && _a !== void 0 ? _a : pool.gaugeExtraRewards) !== null && _b !== void 0 ? _b : [])
|
|
361
360
|
.filter((r) => curve.chainId === 1 || r.tokenAddress.toLowerCase() !== curve.constants.COINS.crv);
|
|
362
361
|
}
|
|
363
362
|
}
|
|
@@ -366,7 +365,7 @@ export const _getRewardsFromApi = () => __awaiter(void 0, void 0, void 0, functi
|
|
|
366
365
|
});
|
|
367
366
|
const _usdRatesCache = {};
|
|
368
367
|
export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
369
|
-
var
|
|
368
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
370
369
|
if (curve.chainId === 1 && assetId.toLowerCase() === '0x8762db106b2c2a0bccb3a80d1ed41273552616e8')
|
|
371
370
|
return 0; // RSR
|
|
372
371
|
const pricesFromApi = yield _getUsdPricesFromApi();
|
|
@@ -393,7 +392,7 @@ export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, functi
|
|
|
393
392
|
42161: 'arbitrum-one',
|
|
394
393
|
1313161554: 'aurora',
|
|
395
394
|
}[curve.chainId];
|
|
396
|
-
const nativeTokenName = curve.isLiteChain ? (
|
|
395
|
+
const nativeTokenName = curve.isLiteChain ? (_b = (_a = curve.constants) === null || _a === void 0 ? void 0 : _a.API_CONSTANTS) === null || _b === void 0 ? void 0 : _b.nativeTokenName : {
|
|
397
396
|
1: 'ethereum',
|
|
398
397
|
10: 'ethereum',
|
|
399
398
|
56: 'binancecoin',
|
|
@@ -416,8 +415,8 @@ export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, functi
|
|
|
416
415
|
throw Error('curve object is not initialized');
|
|
417
416
|
}
|
|
418
417
|
if (nativeTokenName === undefined) {
|
|
419
|
-
if (curve.isLiteChain && ((
|
|
420
|
-
return pricesFromApi[(
|
|
418
|
+
if (curve.isLiteChain && ((_c = curve.constants.API_CONSTANTS) === null || _c === void 0 ? void 0 : _c.wrappedNativeTokenAddress.toLowerCase()) && ((_d = curve.constants.API_CONSTANTS) === null || _d === void 0 ? void 0 : _d.wrappedNativeTokenAddress.toLowerCase()) in pricesFromApi) {
|
|
419
|
+
return pricesFromApi[(_e = curve.constants.API_CONSTANTS) === null || _e === void 0 ? void 0 : _e.wrappedNativeTokenAddress.toLowerCase()];
|
|
421
420
|
}
|
|
422
421
|
else {
|
|
423
422
|
throw Error('nativeTokenName not found');
|
|
@@ -440,26 +439,25 @@ export const _getUsdRate = (assetId) => __awaiter(void 0, void 0, void 0, functi
|
|
|
440
439
|
if (assetId.toLowerCase() === curve.constants.ALIASES.crv) {
|
|
441
440
|
assetId = 'curve-dao-token';
|
|
442
441
|
}
|
|
443
|
-
if (curve.isLiteChain && assetId.toLowerCase() === ((
|
|
442
|
+
if (curve.isLiteChain && assetId.toLowerCase() === ((_f = curve.constants.API_CONSTANTS) === null || _f === void 0 ? void 0 : _f.wrappedNativeTokenAddress.toLowerCase())) {
|
|
444
443
|
assetId = nativeTokenName;
|
|
445
444
|
}
|
|
446
|
-
if ((((
|
|
445
|
+
if ((((_g = _usdRatesCache[assetId]) === null || _g === void 0 ? void 0 : _g.time) || 0) + 600000 < Date.now()) {
|
|
447
446
|
const url = [nativeTokenName, 'ethereum', 'bitcoin', 'link', 'curve-dao-token', 'stasis-eurs'].includes(assetId.toLowerCase()) ?
|
|
448
447
|
`https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd` :
|
|
449
448
|
`https://api.coingecko.com/api/v3/simple/token_price/${chainName}?contract_addresses=${assetId}&vs_currencies=usd`;
|
|
450
449
|
try {
|
|
451
|
-
const response = yield
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
if (response.status === 200 && ((_p = response.data[assetId]) === null || _p === void 0 ? void 0 : _p.usd) !== undefined) {
|
|
450
|
+
const response = yield fetch(url);
|
|
451
|
+
const data = (_h = yield response.json()) !== null && _h !== void 0 ? _h : {};
|
|
452
|
+
if (response.status === 200 && ((_j = data[assetId]) === null || _j === void 0 ? void 0 : _j.usd) !== undefined) {
|
|
455
453
|
_usdRatesCache[assetId] = {
|
|
456
|
-
'rate':
|
|
454
|
+
'rate': data[assetId].usd,
|
|
457
455
|
'time': Date.now(),
|
|
458
456
|
};
|
|
459
457
|
}
|
|
460
458
|
else {
|
|
461
459
|
if (!curve.isLiteChain) {
|
|
462
|
-
console.warn(`Non-200 response for ${assetId}:`, response.status,
|
|
460
|
+
console.warn(`Non-200 response for ${assetId}:`, response.status, data);
|
|
463
461
|
}
|
|
464
462
|
_usdRatesCache[assetId] = {
|
|
465
463
|
'rate': 0,
|
|
@@ -586,7 +584,7 @@ export const getNetworkConstants = (chainId) => __awaiter(void 0, void 0, void 0
|
|
|
586
584
|
return Object.assign(Object.assign({}, yield _getLiteNetworksData(NAME)), { NAME, IS_LITE_CHAIN: true });
|
|
587
585
|
}
|
|
588
586
|
});
|
|
589
|
-
export const getTVL = (
|
|
587
|
+
export const getTVL = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (chainId = curve.chainId) {
|
|
590
588
|
const networkConstants = yield getNetworkConstants(chainId);
|
|
591
589
|
const allTypesExtendedPoolData = yield _getAllPoolsFromApi(networkConstants.NAME, networkConstants.IS_LITE_CHAIN);
|
|
592
590
|
return allTypesExtendedPoolData.reduce((sum, data) => { var _a, _b; return sum + ((_b = (_a = data.tvl) !== null && _a !== void 0 ? _a : data.tvlAll) !== null && _b !== void 0 ? _b : 0); }, 0);
|
|
@@ -606,7 +604,7 @@ export const getVolumeApiController = (network) => __awaiter(void 0, void 0, voi
|
|
|
606
604
|
}
|
|
607
605
|
throw Error(`Can't get volume for network: ${network}`);
|
|
608
606
|
});
|
|
609
|
-
export const getVolume = (
|
|
607
|
+
export const getVolume = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (chainId = curve.chainId) {
|
|
610
608
|
if (curve.isLiteChain) {
|
|
611
609
|
throw Error('This method is not supported for the lite version');
|
|
612
610
|
}
|
|
@@ -752,7 +750,7 @@ export function runWorker(code, syncFn, inputData, timeout = 30000) {
|
|
|
752
750
|
}
|
|
753
751
|
export const PERIODS = {
|
|
754
752
|
DAY: 86400,
|
|
755
|
-
WEEK: 604800,
|
|
756
|
-
MONTH: 2592000,
|
|
753
|
+
WEEK: 604800, // 7 * 86400
|
|
754
|
+
MONTH: 2592000, // 30 * 86400
|
|
757
755
|
YEAR: 31536000, // 365 * 86400
|
|
758
756
|
};
|