@curvefi/api 2.68.32 → 2.68.33
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/README.md +11 -0
- package/lib/pools/PoolTemplate.d.ts +8 -0
- package/lib/pools/PoolTemplate.js +56 -0
- package/lib/pools/mixins/withdrawExpectedMixins.d.ts +4 -0
- package/lib/pools/mixins/withdrawExpectedMixins.js +22 -0
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.d.ts +2 -0
- package/lib/pools/mixins/withdrawOneCoinWrappedExpectedMixins.js +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -983,6 +983,17 @@ import curve from "@curvefi/api";
|
|
|
983
983
|
})()
|
|
984
984
|
```
|
|
985
985
|
|
|
986
|
+
### BigInt methods
|
|
987
|
+
|
|
988
|
+
- `pool.swapExpectedBigInt(inputCoin, outputCoin, amount: bigint): Promise<bigint>`
|
|
989
|
+
- `pool.swapWrappedExpectedBigInt(inputCoin, outputCoin, amount: bigint): Promise<bigint>`
|
|
990
|
+
- `pool.depositExpectedBigInt(amounts: bigint[]): Promise<bigint>`
|
|
991
|
+
- `pool.depositWrappedExpectedBigInt(amounts: bigint[]): Promise<bigint>`
|
|
992
|
+
- `pool.withdrawExpectedBigInt(lpTokenAmount: bigint): Promise<bigint[]>`
|
|
993
|
+
- `pool.withdrawWrappedExpectedBigInt(lpTokenAmount: bigint): Promise<bigint[]>`
|
|
994
|
+
- `pool.withdrawOneCoinExpectedBigInt(lpTokenAmount: bigint, coin: string | number): Promise<bigint>`
|
|
995
|
+
- `pool.withdrawOneCoinWrappedExpectedBigInt(lpTokenAmount: bigint, coin: string | number): Promise<bigint>`
|
|
996
|
+
|
|
986
997
|
### Getting swap ABI metadata
|
|
987
998
|
```ts
|
|
988
999
|
(async () => {
|
|
@@ -49,10 +49,13 @@ export declare class PoolTemplate extends CorePool {
|
|
|
49
49
|
private _pureCalcLpTokenAmount;
|
|
50
50
|
_calcLpTokenAmount: ((_amounts: bigint[], isDeposit?: any, useUnderlying?: any) => Promise<bigint>) & memoize.Memoized<(_amounts: bigint[], isDeposit?: any, useUnderlying?: any) => Promise<bigint>>;
|
|
51
51
|
private calcLpTokenAmount;
|
|
52
|
+
private calcLpTokenAmountBigInt;
|
|
52
53
|
private calcLpTokenAmountWrapped;
|
|
54
|
+
private calcLpTokenAmountWrappedBigInt;
|
|
53
55
|
getSeedAmounts(amount1: number | string, useUnderlying?: boolean): Promise<string[]>;
|
|
54
56
|
depositBalancedAmounts(): Promise<string[]>;
|
|
55
57
|
depositExpected(amounts: (number | string)[]): Promise<string>;
|
|
58
|
+
depositExpectedBigInt(amounts: bigint[]): Promise<bigint>;
|
|
56
59
|
private _balancedAmountsWithSameValue;
|
|
57
60
|
depositBonus(amounts: (number | string)[]): Promise<string>;
|
|
58
61
|
depositIsApproved(amounts: (number | string)[]): Promise<boolean>;
|
|
@@ -62,6 +65,7 @@ export declare class PoolTemplate extends CorePool {
|
|
|
62
65
|
deposit(amounts: (number | string)[], slippage?: number): Promise<string>;
|
|
63
66
|
depositWrappedBalancedAmounts(): Promise<string[]>;
|
|
64
67
|
depositWrappedExpected(amounts: (number | string)[]): Promise<string>;
|
|
68
|
+
depositWrappedExpectedBigInt(amounts: bigint[]): Promise<bigint>;
|
|
65
69
|
depositWrappedBonus(amounts: (number | string)[]): Promise<string>;
|
|
66
70
|
depositWrappedIsApproved(amounts: (number | string)[]): Promise<boolean>;
|
|
67
71
|
private depositWrappedApproveEstimateGas;
|
|
@@ -118,12 +122,14 @@ export declare class PoolTemplate extends CorePool {
|
|
|
118
122
|
depositAndStakeWrapped(amounts: (number | string)[], slippage?: number): Promise<string>;
|
|
119
123
|
private _depositAndStake;
|
|
120
124
|
withdrawExpected(lpTokenAmount: number | string): Promise<string[]>;
|
|
125
|
+
withdrawExpectedBigInt(lpTokenAmount: bigint): Promise<bigint[]>;
|
|
121
126
|
withdrawIsApproved(lpTokenAmount: number | string): Promise<boolean>;
|
|
122
127
|
private withdrawApproveEstimateGas;
|
|
123
128
|
withdrawApprove(lpTokenAmount: number | string): Promise<string[]>;
|
|
124
129
|
private withdrawEstimateGas;
|
|
125
130
|
withdraw(lpTokenAmount: number | string, slippage?: number): Promise<string>;
|
|
126
131
|
withdrawWrappedExpected(lpTokenAmount: number | string): Promise<string[]>;
|
|
132
|
+
withdrawWrappedExpectedBigInt(lpTokenAmount: bigint): Promise<bigint[]>;
|
|
127
133
|
private withdrawWrappedEstimateGas;
|
|
128
134
|
withdrawWrapped(lpTokenAmount: number | string, slippage?: number): Promise<string>;
|
|
129
135
|
withdrawImbalanceExpected(amounts: (number | string)[]): Promise<string>;
|
|
@@ -139,6 +145,7 @@ export declare class PoolTemplate extends CorePool {
|
|
|
139
145
|
withdrawImbalanceWrapped(amounts: (number | string)[], slippage?: number): Promise<string>;
|
|
140
146
|
_withdrawOneCoinExpected(_lpTokenAmount: bigint, i: number): Promise<bigint>;
|
|
141
147
|
withdrawOneCoinExpected(lpTokenAmount: number | string, coin: string | number): Promise<string>;
|
|
148
|
+
withdrawOneCoinExpectedBigInt(lpTokenAmount: bigint, coin: string | number): Promise<bigint>;
|
|
142
149
|
withdrawOneCoinBonus(lpTokenAmount: number | string, coin: string | number): Promise<string>;
|
|
143
150
|
withdrawOneCoinIsApproved(lpTokenAmount: number | string): Promise<boolean>;
|
|
144
151
|
private withdrawOneCoinApproveEstimateGas;
|
|
@@ -147,6 +154,7 @@ export declare class PoolTemplate extends CorePool {
|
|
|
147
154
|
withdrawOneCoin(lpTokenAmount: number | string, coin: string | number, slippage?: number): Promise<string>;
|
|
148
155
|
_withdrawOneCoinWrappedExpected(_lpTokenAmount: bigint, i: number): Promise<bigint>;
|
|
149
156
|
withdrawOneCoinWrappedExpected(lpTokenAmount: number | string, coin: string | number): Promise<string>;
|
|
157
|
+
withdrawOneCoinWrappedExpectedBigInt(lpTokenAmount: bigint, coin: string | number): Promise<bigint>;
|
|
150
158
|
withdrawOneCoinWrappedBonus(lpTokenAmount: number | string, coin: string | number): Promise<string>;
|
|
151
159
|
private withdrawOneCoinWrappedEstimateGas;
|
|
152
160
|
withdrawOneCoinWrapped(lpTokenAmount: number | string, coin: string | number, slippage?: number): Promise<string>;
|
|
@@ -617,6 +617,14 @@ export class PoolTemplate extends CorePool {
|
|
|
617
617
|
return this.curve.formatUnits(_expected);
|
|
618
618
|
});
|
|
619
619
|
}
|
|
620
|
+
calcLpTokenAmountBigInt(amounts_1) {
|
|
621
|
+
return __awaiter(this, arguments, void 0, function* (amounts, isDeposit = true) {
|
|
622
|
+
if (amounts.length !== this.underlyingCoinAddresses.length) {
|
|
623
|
+
throw Error(`${this.name} pool has ${this.underlyingCoinAddresses.length} coins (amounts provided for ${amounts.length})`);
|
|
624
|
+
}
|
|
625
|
+
return yield this._calcLpTokenAmount(amounts, isDeposit, true);
|
|
626
|
+
});
|
|
627
|
+
}
|
|
620
628
|
calcLpTokenAmountWrapped(amounts_1) {
|
|
621
629
|
return __awaiter(this, arguments, void 0, function* (amounts, isDeposit = true) {
|
|
622
630
|
if (amounts.length !== this.wrappedCoinAddresses.length) {
|
|
@@ -630,6 +638,17 @@ export class PoolTemplate extends CorePool {
|
|
|
630
638
|
return this.curve.formatUnits(_expected);
|
|
631
639
|
});
|
|
632
640
|
}
|
|
641
|
+
calcLpTokenAmountWrappedBigInt(amounts_1) {
|
|
642
|
+
return __awaiter(this, arguments, void 0, function* (amounts, isDeposit = true) {
|
|
643
|
+
if (amounts.length !== this.wrappedCoinAddresses.length) {
|
|
644
|
+
throw Error(`${this.name} pool has ${this.wrappedCoinAddresses.length} coins (amounts provided for ${amounts.length})`);
|
|
645
|
+
}
|
|
646
|
+
if (this.isFake) {
|
|
647
|
+
throw Error(`${this.name} pool doesn't have this method`);
|
|
648
|
+
}
|
|
649
|
+
return yield this._calcLpTokenAmount(amounts, isDeposit, false);
|
|
650
|
+
});
|
|
651
|
+
}
|
|
633
652
|
// ---------------- DEPOSIT ----------------
|
|
634
653
|
getSeedAmounts(amount1_1) {
|
|
635
654
|
return __awaiter(this, arguments, void 0, function* (amount1, useUnderlying = false) {
|
|
@@ -685,6 +704,11 @@ export class PoolTemplate extends CorePool {
|
|
|
685
704
|
return yield this.calcLpTokenAmount(amounts);
|
|
686
705
|
});
|
|
687
706
|
}
|
|
707
|
+
depositExpectedBigInt(amounts) {
|
|
708
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
709
|
+
return yield this.calcLpTokenAmountBigInt(amounts);
|
|
710
|
+
});
|
|
711
|
+
}
|
|
688
712
|
// | balanced[i] / sum(balanced[j]) = balance[i] / sum(balance[j]) |
|
|
689
713
|
// | sum(pj * balanced[j]) = sum(aj * pj) |
|
|
690
714
|
//
|
|
@@ -784,6 +808,14 @@ export class PoolTemplate extends CorePool {
|
|
|
784
808
|
return yield this.calcLpTokenAmountWrapped(amounts);
|
|
785
809
|
});
|
|
786
810
|
}
|
|
811
|
+
depositWrappedExpectedBigInt(amounts) {
|
|
812
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
813
|
+
if (this.isFake) {
|
|
814
|
+
throw Error(`depositWrappedExpectedBigInt method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
815
|
+
}
|
|
816
|
+
return yield this.calcLpTokenAmountWrappedBigInt(amounts);
|
|
817
|
+
});
|
|
818
|
+
}
|
|
787
819
|
depositWrappedBonus(amounts) {
|
|
788
820
|
return __awaiter(this, void 0, void 0, function* () {
|
|
789
821
|
const amountsBN = amounts.map(BN);
|
|
@@ -1275,6 +1307,12 @@ export class PoolTemplate extends CorePool {
|
|
|
1275
1307
|
throw Error(`withdrawExpected method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1276
1308
|
});
|
|
1277
1309
|
}
|
|
1310
|
+
// OVERRIDE
|
|
1311
|
+
withdrawExpectedBigInt(lpTokenAmount) {
|
|
1312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1313
|
+
throw Error(`withdrawExpectedBigInt method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1278
1316
|
withdrawIsApproved(lpTokenAmount) {
|
|
1279
1317
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1280
1318
|
if (!this.zap)
|
|
@@ -1316,6 +1354,12 @@ export class PoolTemplate extends CorePool {
|
|
|
1316
1354
|
});
|
|
1317
1355
|
}
|
|
1318
1356
|
// OVERRIDE
|
|
1357
|
+
withdrawWrappedExpectedBigInt(lpTokenAmount) {
|
|
1358
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1359
|
+
throw Error(`withdrawWrappedExpectedBigInt method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
// OVERRIDE
|
|
1319
1363
|
withdrawWrappedEstimateGas(lpTokenAmount) {
|
|
1320
1364
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1321
1365
|
throw Error(`withdrawWrapped method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
@@ -1462,6 +1506,12 @@ export class PoolTemplate extends CorePool {
|
|
|
1462
1506
|
return this.curve.formatUnits(_expected, this.underlyingDecimals[i]);
|
|
1463
1507
|
});
|
|
1464
1508
|
}
|
|
1509
|
+
withdrawOneCoinExpectedBigInt(lpTokenAmount, coin) {
|
|
1510
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1511
|
+
const i = this._getCoinIdx(coin);
|
|
1512
|
+
return yield this._withdrawOneCoinExpected(lpTokenAmount, i);
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1465
1515
|
withdrawOneCoinBonus(lpTokenAmount, coin) {
|
|
1466
1516
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1467
1517
|
let pricesBN = [];
|
|
@@ -1545,6 +1595,12 @@ export class PoolTemplate extends CorePool {
|
|
|
1545
1595
|
return this.curve.formatUnits(_expected, this.wrappedDecimals[i]);
|
|
1546
1596
|
});
|
|
1547
1597
|
}
|
|
1598
|
+
// OVERRIDE
|
|
1599
|
+
withdrawOneCoinWrappedExpectedBigInt(lpTokenAmount, coin) {
|
|
1600
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1601
|
+
throw Error(`withdrawOneCoinWrappedExpectedBigInt method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1548
1604
|
withdrawOneCoinWrappedBonus(lpTokenAmount, coin) {
|
|
1549
1605
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1550
1606
|
const prices = yield this._wrappedPrices();
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
2
|
export declare const withdrawExpectedMixin: {
|
|
3
3
|
withdrawExpected(this: PoolTemplate, lpTokenAmount: number | string): Promise<string[]>;
|
|
4
|
+
withdrawExpectedBigInt(this: PoolTemplate, lpTokenAmount: bigint): Promise<bigint[]>;
|
|
4
5
|
};
|
|
5
6
|
export declare const withdrawExpectedLendingOrCryptoMixin: {
|
|
6
7
|
withdrawExpected(this: PoolTemplate, lpTokenAmount: number | string): Promise<string[]>;
|
|
8
|
+
withdrawExpectedBigInt(this: PoolTemplate, lpTokenAmount: bigint): Promise<bigint[]>;
|
|
7
9
|
};
|
|
8
10
|
export declare const withdrawExpectedMetaMixin: {
|
|
9
11
|
withdrawExpected(this: PoolTemplate, lpTokenAmount: number | string): Promise<string[]>;
|
|
12
|
+
withdrawExpectedBigInt(this: PoolTemplate, lpTokenAmount: bigint): Promise<bigint[]>;
|
|
10
13
|
};
|
|
11
14
|
export declare const withdrawWrappedExpectedMixin: {
|
|
12
15
|
withdrawWrappedExpected(this: PoolTemplate, lpTokenAmount: number | string): Promise<string[]>;
|
|
16
|
+
withdrawWrappedExpectedBigInt(this: PoolTemplate, lpTokenAmount: bigint): Promise<bigint[]>;
|
|
13
17
|
};
|
|
@@ -18,6 +18,11 @@ export const withdrawExpectedMixin = {
|
|
|
18
18
|
return _expected.map((amount, i) => formatUnits(amount, this.underlyingDecimals[i]));
|
|
19
19
|
});
|
|
20
20
|
},
|
|
21
|
+
withdrawExpectedBigInt(lpTokenAmount) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
return yield _calcExpectedAmounts.call(this, lpTokenAmount);
|
|
24
|
+
});
|
|
25
|
+
},
|
|
21
26
|
};
|
|
22
27
|
export const withdrawExpectedLendingOrCryptoMixin = {
|
|
23
28
|
withdrawExpected(lpTokenAmount) {
|
|
@@ -29,6 +34,13 @@ export const withdrawExpectedLendingOrCryptoMixin = {
|
|
|
29
34
|
return _expected.map((amount, i) => formatUnits(amount, this.underlyingDecimals[i]));
|
|
30
35
|
});
|
|
31
36
|
},
|
|
37
|
+
withdrawExpectedBigInt(lpTokenAmount) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const _expectedAmounts = yield _calcExpectedAmounts.call(this, lpTokenAmount);
|
|
40
|
+
const _rates = yield this._getRates();
|
|
41
|
+
return _expectedAmounts.map((_amount, i) => _amount * _rates[i] / parseUnits(String(Math.pow(10, 18)), 0));
|
|
42
|
+
});
|
|
43
|
+
},
|
|
32
44
|
};
|
|
33
45
|
export const withdrawExpectedMetaMixin = {
|
|
34
46
|
withdrawExpected(lpTokenAmount) {
|
|
@@ -38,6 +50,11 @@ export const withdrawExpectedMetaMixin = {
|
|
|
38
50
|
return _expected.map((amount, i) => formatUnits(amount, this.underlyingDecimals[i]));
|
|
39
51
|
});
|
|
40
52
|
},
|
|
53
|
+
withdrawExpectedBigInt(lpTokenAmount) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return yield _calcExpectedUnderlyingAmountsMeta.call(this, lpTokenAmount);
|
|
56
|
+
});
|
|
57
|
+
},
|
|
41
58
|
};
|
|
42
59
|
export const withdrawWrappedExpectedMixin = {
|
|
43
60
|
withdrawWrappedExpected(lpTokenAmount) {
|
|
@@ -47,4 +64,9 @@ export const withdrawWrappedExpectedMixin = {
|
|
|
47
64
|
return _expected.map((amount, i) => formatUnits(amount, this.wrappedDecimals[i]));
|
|
48
65
|
});
|
|
49
66
|
},
|
|
67
|
+
withdrawWrappedExpectedBigInt(lpTokenAmount) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return yield _calcExpectedAmounts.call(this, lpTokenAmount);
|
|
70
|
+
});
|
|
71
|
+
},
|
|
50
72
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
2
|
export declare const withdrawOneCoinWrappedExpected2argsMixin: {
|
|
3
3
|
_withdrawOneCoinWrappedExpected(this: PoolTemplate, _lpTokenAmount: bigint, i: number): Promise<bigint>;
|
|
4
|
+
withdrawOneCoinWrappedExpectedBigInt(this: PoolTemplate, lpTokenAmount: bigint, coin: string | number): Promise<bigint>;
|
|
4
5
|
};
|
|
5
6
|
export declare const withdrawOneCoinWrappedExpected3argsMixin: {
|
|
6
7
|
_withdrawOneCoinWrappedExpected(this: PoolTemplate, _lpTokenAmount: bigint, i: number): Promise<bigint>;
|
|
8
|
+
withdrawOneCoinWrappedExpectedBigInt(this: PoolTemplate, lpTokenAmount: bigint, coin: string | number): Promise<bigint>;
|
|
7
9
|
};
|
|
@@ -14,6 +14,12 @@ export const withdrawOneCoinWrappedExpected2argsMixin = {
|
|
|
14
14
|
return yield contract.calc_withdraw_one_coin(_lpTokenAmount, i, this.curve.constantOptions);
|
|
15
15
|
});
|
|
16
16
|
},
|
|
17
|
+
withdrawOneCoinWrappedExpectedBigInt(lpTokenAmount, coin) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const i = this._getCoinIdx(coin, false);
|
|
20
|
+
return yield this._withdrawOneCoinWrappedExpected(lpTokenAmount, i);
|
|
21
|
+
});
|
|
22
|
+
},
|
|
17
23
|
};
|
|
18
24
|
export const withdrawOneCoinWrappedExpected3argsMixin = {
|
|
19
25
|
_withdrawOneCoinWrappedExpected(_lpTokenAmount, i) {
|
|
@@ -22,4 +28,10 @@ export const withdrawOneCoinWrappedExpected3argsMixin = {
|
|
|
22
28
|
return yield contract.calc_withdraw_one_coin(_lpTokenAmount, i, false, this.curve.constantOptions);
|
|
23
29
|
});
|
|
24
30
|
},
|
|
31
|
+
withdrawOneCoinWrappedExpectedBigInt(lpTokenAmount, coin) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const i = this._getCoinIdx(coin, false);
|
|
34
|
+
return yield this._withdrawOneCoinWrappedExpected(lpTokenAmount, i);
|
|
35
|
+
});
|
|
36
|
+
},
|
|
25
37
|
};
|