@curvefi/api 2.68.24 → 2.68.25
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 +49 -0
- package/lib/interfaces.d.ts +5 -0
- package/lib/pools/PoolTemplate.d.ts +7 -1
- package/lib/pools/PoolTemplate.js +16 -0
- package/lib/pools/mixins/swapMixins.d.ts +9 -4
- package/lib/pools/mixins/swapMixins.js +60 -12
- package/lib/pools/mixins/swapWrappedMixins.d.ts +5 -2
- package/lib/pools/mixins/swapWrappedMixins.js +28 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -983,6 +983,55 @@ import curve from "@curvefi/api";
|
|
|
983
983
|
})()
|
|
984
984
|
```
|
|
985
985
|
|
|
986
|
+
### Getting swap ABI metadata
|
|
987
|
+
```ts
|
|
988
|
+
(async () => {
|
|
989
|
+
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0 });
|
|
990
|
+
|
|
991
|
+
const pool = curve.getPool('mim');
|
|
992
|
+
|
|
993
|
+
// Get exact ABI information for swap (underlying) without executing the transaction
|
|
994
|
+
const swapInfo = await pool.abi.swap();
|
|
995
|
+
console.log(swapInfo);
|
|
996
|
+
// {
|
|
997
|
+
// address: '0x5a6a4d54456819380173272a5e8e9b9904bdf41b', // Contract address
|
|
998
|
+
// method: 'exchange_underlying', // Method name (exchange or exchange_underlying)
|
|
999
|
+
// abi: {
|
|
1000
|
+
// type: 'function',
|
|
1001
|
+
// name: 'exchange_underlying',
|
|
1002
|
+
// inputs: [
|
|
1003
|
+
// { name: 'i', type: 'int128' },
|
|
1004
|
+
// { name: 'j', type: 'int128' },
|
|
1005
|
+
// { name: 'dx', type: 'uint256' },
|
|
1006
|
+
// { name: 'min_dy', type: 'uint256' }
|
|
1007
|
+
// ],
|
|
1008
|
+
// outputs: [ { name: '', type: 'uint256' } ],
|
|
1009
|
+
// stateMutability: 'nonpayable'
|
|
1010
|
+
// }
|
|
1011
|
+
// }
|
|
1012
|
+
|
|
1013
|
+
// Get exact ABI information for swap wrapped without executing the transaction
|
|
1014
|
+
const swapWrappedInfo = await pool.abi.swapWrapped();
|
|
1015
|
+
console.log(swapWrappedInfo);
|
|
1016
|
+
// {
|
|
1017
|
+
// address: '0x5a6a4d54456819380173272a5e8e9b9904bdf41b', // Contract address
|
|
1018
|
+
// method: 'exchange', // Method name (always exchange for wrapped)
|
|
1019
|
+
// abi: {
|
|
1020
|
+
// type: 'function',
|
|
1021
|
+
// name: 'exchange',
|
|
1022
|
+
// inputs: [
|
|
1023
|
+
// { name: 'i', type: 'int128' },
|
|
1024
|
+
// { name: 'j', type: 'int128' },
|
|
1025
|
+
// { name: 'dx', type: 'uint256' },
|
|
1026
|
+
// { name: 'min_dy', type: 'uint256' }
|
|
1027
|
+
// ],
|
|
1028
|
+
// outputs: [ { name: '', type: 'uint256' } ],
|
|
1029
|
+
// stateMutability: 'nonpayable'
|
|
1030
|
+
// }
|
|
1031
|
+
// }
|
|
1032
|
+
})()
|
|
1033
|
+
```
|
|
1034
|
+
|
|
986
1035
|
### Deposit & Stake
|
|
987
1036
|
```ts
|
|
988
1037
|
(async () => {
|
package/lib/interfaces.d.ts
CHANGED
|
@@ -349,4 +349,9 @@ export type AbiError = {
|
|
|
349
349
|
name: string;
|
|
350
350
|
};
|
|
351
351
|
export type Abi = (AbiConstructor | AbiError | AbiEvent | AbiFallback | AbiFunction | AbiReceive)[];
|
|
352
|
+
export interface ISwapMethodInfo {
|
|
353
|
+
address: string;
|
|
354
|
+
method: string;
|
|
355
|
+
abi: any;
|
|
356
|
+
}
|
|
352
357
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import memoize from "memoizee";
|
|
3
|
-
import { IDict, IProfit } from '../interfaces';
|
|
3
|
+
import { IDict, IProfit, ISwapMethodInfo } from '../interfaces';
|
|
4
4
|
import { Curve } from "../curve.js";
|
|
5
5
|
import { CorePool } from "./subClasses/corePool.js";
|
|
6
6
|
import { StatsPool } from "./subClasses/statsPool.js";
|
|
@@ -36,6 +36,10 @@ export declare class PoolTemplate extends CorePool {
|
|
|
36
36
|
swapWrappedApprove: (inputCoin: string | number, amount: number | string) => Promise<number | number[]>;
|
|
37
37
|
swapWrapped: (inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage: number) => Promise<number | number[]>;
|
|
38
38
|
};
|
|
39
|
+
abi: {
|
|
40
|
+
swap: () => Promise<ISwapMethodInfo>;
|
|
41
|
+
swapWrapped: () => Promise<ISwapMethodInfo>;
|
|
42
|
+
};
|
|
39
43
|
stats: StatsPool;
|
|
40
44
|
wallet: WalletPool;
|
|
41
45
|
constructor(id: string, curve: Curve, poolData?: import("../interfaces").IPoolData);
|
|
@@ -176,6 +180,7 @@ export declare class PoolTemplate extends CorePool {
|
|
|
176
180
|
swapApprove(inputCoin: string | number, amount: number | string): Promise<string[]>;
|
|
177
181
|
private swapEstimateGas;
|
|
178
182
|
swap(inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
|
|
183
|
+
getSwapInfo(): Promise<ISwapMethodInfo>;
|
|
179
184
|
_swapWrappedExpected(i: number, j: number, _amount: bigint): Promise<bigint>;
|
|
180
185
|
swapWrappedExpected(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
|
|
181
186
|
swapWrappedPriceImpact(inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
|
|
@@ -184,6 +189,7 @@ export declare class PoolTemplate extends CorePool {
|
|
|
184
189
|
swapWrappedApprove(inputCoin: string | number, amount: number | string): Promise<string[]>;
|
|
185
190
|
private swapWrappedEstimateGas;
|
|
186
191
|
swapWrapped(inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
|
|
192
|
+
getSwapWrappedInfo(): Promise<ISwapMethodInfo>;
|
|
187
193
|
gaugeOptimalDeposits: (...accounts: string[]) => Promise<IDict<string>>;
|
|
188
194
|
_getCoinIdx: (coin: string | number, useUnderlying?: boolean) => number;
|
|
189
195
|
_getRates: () => Promise<bigint[]>;
|
|
@@ -574,6 +574,10 @@ export class PoolTemplate extends CorePool {
|
|
|
574
574
|
swapWrappedApprove: this.swapWrappedApproveEstimateGas.bind(this),
|
|
575
575
|
swapWrapped: this.swapWrappedEstimateGas.bind(this),
|
|
576
576
|
};
|
|
577
|
+
this.abi = {
|
|
578
|
+
swap: this.getSwapInfo.bind(this),
|
|
579
|
+
swapWrapped: this.getSwapWrappedInfo.bind(this),
|
|
580
|
+
};
|
|
577
581
|
}
|
|
578
582
|
hasVyperVulnerability() {
|
|
579
583
|
return checkVyperVulnerability(this.curve.chainId, this.id, this.implementation);
|
|
@@ -1802,6 +1806,12 @@ export class PoolTemplate extends CorePool {
|
|
|
1802
1806
|
throw Error(`swap method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1803
1807
|
});
|
|
1804
1808
|
}
|
|
1809
|
+
// OVERRIDE
|
|
1810
|
+
getSwapInfo() {
|
|
1811
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1812
|
+
throw Error(`getSwapInfo method doesn't exist for pool ${this.name} (id: ${this.id})`);
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1805
1815
|
// ---------------- SWAP WRAPPED ----------------
|
|
1806
1816
|
_swapWrappedExpected(i, j, _amount) {
|
|
1807
1817
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1864,6 +1874,12 @@ export class PoolTemplate extends CorePool {
|
|
|
1864
1874
|
throw Error(`swapWrapped method doesn't exist for pool ${this.name} (id: ${this.name})`);
|
|
1865
1875
|
});
|
|
1866
1876
|
}
|
|
1877
|
+
// OVERRIDE
|
|
1878
|
+
getSwapWrappedInfo() {
|
|
1879
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1880
|
+
throw Error(`getSwapWrappedInfo method doesn't exist for pool ${this.name} (id: ${this.id})`);
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1867
1883
|
getStoredRates() {
|
|
1868
1884
|
return __awaiter(this, arguments, void 0, function* (useUnderlying = false) {
|
|
1869
1885
|
try {
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
|
+
import { ISwapMethodInfo } from "../../interfaces.js";
|
|
2
3
|
export declare const swapTricrypto2Mixin: {
|
|
3
|
-
_swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
|
|
4
|
+
_swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean, getInfo?: boolean): Promise<string | number | number[] | ISwapMethodInfo>;
|
|
4
5
|
swapEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
|
|
5
6
|
swap(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
|
|
7
|
+
getSwapInfo(this: PoolTemplate): Promise<ISwapMethodInfo>;
|
|
6
8
|
};
|
|
7
9
|
export declare const swapMetaFactoryMixin: {
|
|
8
|
-
_swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
|
|
10
|
+
_swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean, getInfo?: boolean): Promise<string | number | number[] | ISwapMethodInfo>;
|
|
9
11
|
swapEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
|
|
10
12
|
swap(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
|
|
13
|
+
getSwapInfo(this: PoolTemplate): Promise<ISwapMethodInfo>;
|
|
11
14
|
};
|
|
12
15
|
export declare const swapCryptoMetaFactoryMixin: {
|
|
13
|
-
_swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
|
|
16
|
+
_swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean, getInfo?: boolean): Promise<string | number | number[] | ISwapMethodInfo>;
|
|
14
17
|
swapEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
|
|
15
18
|
swap(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
|
|
19
|
+
getSwapInfo(this: PoolTemplate): Promise<ISwapMethodInfo>;
|
|
16
20
|
};
|
|
17
21
|
export declare const swapMixin: {
|
|
18
|
-
_swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
|
|
22
|
+
_swap(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean, getInfo?: boolean): Promise<string | number | number[] | ISwapMethodInfo>;
|
|
19
23
|
swapEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
|
|
20
24
|
swap(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
|
|
25
|
+
getSwapInfo(this: PoolTemplate): Promise<ISwapMethodInfo>;
|
|
21
26
|
};
|
|
@@ -36,13 +36,20 @@ function _swapMinAmount(i_1, j_1, _amount_1) {
|
|
|
36
36
|
}
|
|
37
37
|
export const swapTricrypto2Mixin = {
|
|
38
38
|
_swap(i_1, j_1, _amount_1, slippage_1) {
|
|
39
|
-
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false) {
|
|
39
|
+
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false, getInfo = false) {
|
|
40
40
|
const contractAddress = this._swapContractAddress();
|
|
41
|
+
const contract = this.curve.contracts[contractAddress].contract;
|
|
42
|
+
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
43
|
+
if (getInfo) {
|
|
44
|
+
return {
|
|
45
|
+
address: contractAddress,
|
|
46
|
+
method: exchangeMethod,
|
|
47
|
+
abi: contract[exchangeMethod].fragment,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
41
50
|
if (!estimateGas)
|
|
42
51
|
yield _ensureAllowance.call(this.curve, [this.underlyingCoinAddresses[i]], [_amount], contractAddress);
|
|
43
52
|
const _minRecvAmount = yield _swapMinAmount.call(this, i, j, _amount, slippage);
|
|
44
|
-
const contract = this.curve.contracts[contractAddress].contract;
|
|
45
|
-
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
46
53
|
const value = this.curve.isEth(this.underlyingCoinAddresses[i]) ? _amount : this.curve.parseUnits("0");
|
|
47
54
|
const gas = yield contract[exchangeMethod].estimateGas(i, j, _amount, _minRecvAmount, true, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
|
|
48
55
|
if (estimateGas)
|
|
@@ -63,16 +70,28 @@ export const swapTricrypto2Mixin = {
|
|
|
63
70
|
return yield swapTricrypto2Mixin._swap.call(this, i, j, _amount, slippage);
|
|
64
71
|
});
|
|
65
72
|
},
|
|
73
|
+
getSwapInfo() {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
return yield swapTricrypto2Mixin._swap.call(this, 0, 0, BigInt(0), 0, false, true);
|
|
76
|
+
});
|
|
77
|
+
},
|
|
66
78
|
};
|
|
67
79
|
export const swapMetaFactoryMixin = {
|
|
68
80
|
_swap(i_1, j_1, _amount_1, slippage_1) {
|
|
69
|
-
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false) {
|
|
81
|
+
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false, getInfo = false) {
|
|
70
82
|
const contractAddress = this._swapContractAddress();
|
|
83
|
+
const contract = this.curve.contracts[contractAddress].contract;
|
|
84
|
+
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
85
|
+
if (getInfo) {
|
|
86
|
+
return {
|
|
87
|
+
address: contractAddress,
|
|
88
|
+
method: exchangeMethod,
|
|
89
|
+
abi: contract[exchangeMethod].fragment,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
71
92
|
if (!estimateGas)
|
|
72
93
|
yield _ensureAllowance.call(this.curve, [this.underlyingCoinAddresses[i]], [_amount], contractAddress);
|
|
73
94
|
const _minRecvAmount = yield _swapMinAmount.call(this, i, j, _amount, slippage);
|
|
74
|
-
const contract = this.curve.contracts[contractAddress].contract;
|
|
75
|
-
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
76
95
|
const value = this.curve.isEth(this.underlyingCoinAddresses[i]) ? _amount : this.curve.parseUnits("0");
|
|
77
96
|
const gas = yield contract[exchangeMethod].estimateGas(this.address, i, j, _amount, _minRecvAmount, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
|
|
78
97
|
if (estimateGas)
|
|
@@ -93,16 +112,28 @@ export const swapMetaFactoryMixin = {
|
|
|
93
112
|
return yield swapMetaFactoryMixin._swap.call(this, i, j, _amount, slippage);
|
|
94
113
|
});
|
|
95
114
|
},
|
|
115
|
+
getSwapInfo() {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
return yield swapMetaFactoryMixin._swap.call(this, 0, 0, BigInt(0), 0, false, true);
|
|
118
|
+
});
|
|
119
|
+
},
|
|
96
120
|
};
|
|
97
121
|
export const swapCryptoMetaFactoryMixin = {
|
|
98
122
|
_swap(i_1, j_1, _amount_1, slippage_1) {
|
|
99
|
-
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false) {
|
|
123
|
+
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false, getInfo = false) {
|
|
100
124
|
const contractAddress = this._swapContractAddress();
|
|
125
|
+
const contract = this.curve.contracts[contractAddress].contract;
|
|
126
|
+
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
127
|
+
if (getInfo) {
|
|
128
|
+
return {
|
|
129
|
+
address: contractAddress,
|
|
130
|
+
method: exchangeMethod,
|
|
131
|
+
abi: contract[exchangeMethod].fragment,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
101
134
|
if (!estimateGas)
|
|
102
135
|
yield _ensureAllowance.call(this.curve, [this.underlyingCoinAddresses[i]], [_amount], contractAddress);
|
|
103
136
|
const _minRecvAmount = yield _swapMinAmount.call(this, i, j, _amount, slippage);
|
|
104
|
-
const contract = this.curve.contracts[contractAddress].contract;
|
|
105
|
-
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
106
137
|
const value = this.curve.isEth(this.underlyingCoinAddresses[i]) ? _amount : this.curve.parseUnits("0");
|
|
107
138
|
const gas = yield contract[exchangeMethod].estimateGas(this.address, i, j, _amount, _minRecvAmount, true, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
|
|
108
139
|
if (estimateGas)
|
|
@@ -123,16 +154,28 @@ export const swapCryptoMetaFactoryMixin = {
|
|
|
123
154
|
return yield swapCryptoMetaFactoryMixin._swap.call(this, i, j, _amount, slippage);
|
|
124
155
|
});
|
|
125
156
|
},
|
|
157
|
+
getSwapInfo() {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
return yield swapCryptoMetaFactoryMixin._swap.call(this, 0, 0, BigInt(0), 0, false, true);
|
|
160
|
+
});
|
|
161
|
+
},
|
|
126
162
|
};
|
|
127
163
|
export const swapMixin = {
|
|
128
164
|
_swap(i_1, j_1, _amount_1, slippage_1) {
|
|
129
|
-
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false) {
|
|
165
|
+
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false, getInfo = false) {
|
|
130
166
|
const contractAddress = this._swapContractAddress();
|
|
167
|
+
const contract = this.curve.contracts[contractAddress].contract;
|
|
168
|
+
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
169
|
+
if (getInfo) {
|
|
170
|
+
return {
|
|
171
|
+
address: contractAddress,
|
|
172
|
+
method: exchangeMethod,
|
|
173
|
+
abi: contract[exchangeMethod].fragment,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
131
176
|
if (!estimateGas)
|
|
132
177
|
yield _ensureAllowance.call(this.curve, [this.underlyingCoinAddresses[i]], [_amount], contractAddress);
|
|
133
178
|
const _minRecvAmount = yield _swapMinAmount.call(this, i, j, _amount, slippage);
|
|
134
|
-
const contract = this.curve.contracts[contractAddress].contract;
|
|
135
|
-
const exchangeMethod = 'exchange_underlying' in contract ? 'exchange_underlying' : 'exchange';
|
|
136
179
|
const value = this.curve.isEth(this.underlyingCoinAddresses[i]) ? _amount : this.curve.parseUnits("0");
|
|
137
180
|
const gas = yield contract[exchangeMethod].estimateGas(i, j, _amount, _minRecvAmount, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
|
|
138
181
|
if (estimateGas)
|
|
@@ -154,4 +197,9 @@ export const swapMixin = {
|
|
|
154
197
|
return yield swapMixin._swap.call(this, i, j, _amount, slippage);
|
|
155
198
|
});
|
|
156
199
|
},
|
|
200
|
+
getSwapInfo() {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
return yield swapMixin._swap.call(this, 0, 0, BigInt(0), 0, false, true);
|
|
203
|
+
});
|
|
204
|
+
},
|
|
157
205
|
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { PoolTemplate } from "../PoolTemplate.js";
|
|
2
|
+
import { ISwapMethodInfo } from "../../interfaces.js";
|
|
2
3
|
export declare const swapWrappedTricrypto2Mixin: {
|
|
3
|
-
_swapWrapped(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
|
|
4
|
+
_swapWrapped(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean, getInfo?: boolean): Promise<string | number | number[] | ISwapMethodInfo>;
|
|
4
5
|
swapWrappedEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
|
|
5
6
|
swapWrapped(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
|
|
7
|
+
getSwapWrappedInfo(this: PoolTemplate): Promise<ISwapMethodInfo>;
|
|
6
8
|
};
|
|
7
9
|
export declare const swapWrappedMixin: {
|
|
8
|
-
_swapWrapped(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean): Promise<string | number | number[]>;
|
|
10
|
+
_swapWrapped(this: PoolTemplate, i: number, j: number, _amount: bigint, slippage?: number, estimateGas?: boolean, getInfo?: boolean): Promise<string | number | number[] | ISwapMethodInfo>;
|
|
9
11
|
swapWrappedEstimateGas(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<number>;
|
|
10
12
|
swapWrapped(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string, slippage?: number): Promise<string>;
|
|
13
|
+
getSwapWrappedInfo(this: PoolTemplate): Promise<ISwapMethodInfo>;
|
|
11
14
|
};
|
|
12
15
|
export declare const swapWrappedExpectedAndApproveMixin: {
|
|
13
16
|
swapWrappedExpected(this: PoolTemplate, inputCoin: string | number, outputCoin: string | number, amount: number | string): Promise<string>;
|
|
@@ -35,11 +35,18 @@ function _swapWrappedMinAmount(i_1, j_1, _amount_1) {
|
|
|
35
35
|
}
|
|
36
36
|
export const swapWrappedTricrypto2Mixin = {
|
|
37
37
|
_swapWrapped(i_1, j_1, _amount_1, slippage_1) {
|
|
38
|
-
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false) {
|
|
38
|
+
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false, getInfo = false) {
|
|
39
|
+
const contract = this.curve.contracts[this.address].contract;
|
|
40
|
+
if (getInfo) {
|
|
41
|
+
return {
|
|
42
|
+
address: this.address,
|
|
43
|
+
method: 'exchange',
|
|
44
|
+
abi: contract.exchange.fragment,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
39
47
|
if (!estimateGas)
|
|
40
48
|
yield _ensureAllowance.call(this.curve, [this.wrappedCoinAddresses[i]], [_amount], this.address);
|
|
41
49
|
const _minRecvAmount = yield _swapWrappedMinAmount.call(this, i, j, _amount, slippage);
|
|
42
|
-
const contract = this.curve.contracts[this.address].contract;
|
|
43
50
|
const value = this.curve.isEth(this.wrappedCoinAddresses[i]) ? _amount : this.curve.parseUnits("0");
|
|
44
51
|
const gas = yield contract.exchange.estimateGas(i, j, _amount, _minRecvAmount, false, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
|
|
45
52
|
if (estimateGas)
|
|
@@ -60,14 +67,26 @@ export const swapWrappedTricrypto2Mixin = {
|
|
|
60
67
|
return yield swapWrappedTricrypto2Mixin._swapWrapped.call(this, i, j, _amount, slippage);
|
|
61
68
|
});
|
|
62
69
|
},
|
|
70
|
+
getSwapWrappedInfo() {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return yield swapWrappedTricrypto2Mixin._swapWrapped.call(this, 0, 0, BigInt(0), 0, false, true);
|
|
73
|
+
});
|
|
74
|
+
},
|
|
63
75
|
};
|
|
64
76
|
export const swapWrappedMixin = {
|
|
65
77
|
_swapWrapped(i_1, j_1, _amount_1, slippage_1) {
|
|
66
|
-
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false) {
|
|
78
|
+
return __awaiter(this, arguments, void 0, function* (i, j, _amount, slippage, estimateGas = false, getInfo = false) {
|
|
79
|
+
const contract = this.curve.contracts[this.address].contract;
|
|
80
|
+
if (getInfo) {
|
|
81
|
+
return {
|
|
82
|
+
address: this.address,
|
|
83
|
+
method: 'exchange',
|
|
84
|
+
abi: contract.exchange.fragment,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
67
87
|
if (!estimateGas)
|
|
68
88
|
yield _ensureAllowance.call(this.curve, [this.wrappedCoinAddresses[i]], [_amount], this.address);
|
|
69
89
|
const _minRecvAmount = yield _swapWrappedMinAmount.call(this, i, j, _amount, slippage);
|
|
70
|
-
const contract = this.curve.contracts[this.address].contract;
|
|
71
90
|
const value = this.curve.isEth(this.wrappedCoinAddresses[i]) ? _amount : this.curve.parseUnits("0");
|
|
72
91
|
const gas = yield contract.exchange.estimateGas(i, j, _amount, _minRecvAmount, Object.assign(Object.assign({}, this.curve.constantOptions), { value }));
|
|
73
92
|
if (estimateGas)
|
|
@@ -88,6 +107,11 @@ export const swapWrappedMixin = {
|
|
|
88
107
|
return yield swapWrappedMixin._swapWrapped.call(this, i, j, _amount, slippage);
|
|
89
108
|
});
|
|
90
109
|
},
|
|
110
|
+
getSwapWrappedInfo() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
return yield swapWrappedMixin._swapWrapped.call(this, 0, 0, BigInt(0), 0, false, true);
|
|
113
|
+
});
|
|
114
|
+
},
|
|
91
115
|
};
|
|
92
116
|
export const swapWrappedExpectedAndApproveMixin = {
|
|
93
117
|
swapWrappedExpected(inputCoin, outputCoin, amount) {
|