@curvefi/api 2.68.31 → 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 +103 -0
- package/lib/bridge.d.ts +21 -0
- package/lib/bridge.js +128 -0
- package/lib/constants/abis/fastBridge.json +400 -0
- package/lib/constants/network_constants.js +6 -0
- package/lib/curve.js +8 -0
- package/lib/index.d.ts +35 -0
- package/lib/index.js +15 -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 () => {
|
|
@@ -1380,6 +1391,98 @@ import curve from "@curvefi/api";
|
|
|
1380
1391
|
})()
|
|
1381
1392
|
```
|
|
1382
1393
|
|
|
1394
|
+
## FastBridge
|
|
1395
|
+
|
|
1396
|
+
FastBridge allows bridging crvUSD from L2 networks (Arbitrum, Optimism, Fraxtal) to Ethereum mainnet.
|
|
1397
|
+
|
|
1398
|
+
```ts
|
|
1399
|
+
import curve from "@curvefi/api";
|
|
1400
|
+
|
|
1401
|
+
(async () => {
|
|
1402
|
+
// Initialize on L2 network (Arbitrum, Optimism, or Fraxtal)
|
|
1403
|
+
await curve.init('JsonRpc', {}, { gasPrice: 0, maxFeePerGas: 0, maxPriorityFeePerGas: 0, chainId: 42161 }); // Arbitrum
|
|
1404
|
+
|
|
1405
|
+
// Check if FastBridge is supported on current network
|
|
1406
|
+
curve.fastBridge.isSupported();
|
|
1407
|
+
// true (on Arbitrum, Optimism, Fraxtal)
|
|
1408
|
+
// false (on other networks)
|
|
1409
|
+
|
|
1410
|
+
// Assert that FastBridge is supported (throws error if not)
|
|
1411
|
+
curve.fastBridge.assertIsSupported();
|
|
1412
|
+
// No error on supported networks
|
|
1413
|
+
// Throws "FastBridge is not available on this network" on unsupported networks
|
|
1414
|
+
|
|
1415
|
+
// Get list of supported networks
|
|
1416
|
+
const supportedNetworks = curve.fastBridge.getSupportedNetworks();
|
|
1417
|
+
console.log(supportedNetworks);
|
|
1418
|
+
// [
|
|
1419
|
+
// {
|
|
1420
|
+
// chainId: 42161,
|
|
1421
|
+
// name: 'Arbitrum',
|
|
1422
|
+
// fastBridgeAddress: '0x1F2aF270029d028400265Ce1dd0919BA8780dAe1',
|
|
1423
|
+
// crvUsdAddress: '0x498Bf2B1e120FeD3ad3D42EA2165E9b73f99C1e5'
|
|
1424
|
+
// },
|
|
1425
|
+
// {
|
|
1426
|
+
// chainId: 10,
|
|
1427
|
+
// name: 'Optimism',
|
|
1428
|
+
// fastBridgeAddress: '0xD16d5eC345Dd86Fb63C6a9C43c517210F1027914',
|
|
1429
|
+
// crvUsdAddress: '0x417Ac0e078398C154EdFadD9Ef675d30Be60Af93'
|
|
1430
|
+
// },
|
|
1431
|
+
// {
|
|
1432
|
+
// chainId: 252,
|
|
1433
|
+
// name: 'Fraxtal',
|
|
1434
|
+
// fastBridgeAddress: '0x3fE593E651Cd0B383AD36b75F4159f30BB0631A6',
|
|
1435
|
+
// crvUsdAddress: '0x67bCae3700C0fd13FB1951C7801050349F8C5caa'
|
|
1436
|
+
// }
|
|
1437
|
+
// ]
|
|
1438
|
+
|
|
1439
|
+
// Check allowed bridge amounts (min/max)
|
|
1440
|
+
const { min, max } = await curve.fastBridge.allowedToBridge();
|
|
1441
|
+
console.log(min, max);
|
|
1442
|
+
// 10.0 49990.0
|
|
1443
|
+
|
|
1444
|
+
// Get bridge cost (must be called before bridging to cache the value)
|
|
1445
|
+
const cost = await curve.fastBridge.bridgeCost();
|
|
1446
|
+
console.log(cost);
|
|
1447
|
+
// 0.001234567890123456 (in ETH)
|
|
1448
|
+
|
|
1449
|
+
// Check if crvUSD is approved for the amount you want to bridge
|
|
1450
|
+
await curve.fastBridge.isApproved(1000);
|
|
1451
|
+
// false
|
|
1452
|
+
|
|
1453
|
+
// Approve crvUSD for bridging
|
|
1454
|
+
await curve.fastBridge.approve(1000);
|
|
1455
|
+
// [
|
|
1456
|
+
// '0xc111e471715ae6f5437e12d3b94868a5b6542cd7304efca18b5782d315760ae5'
|
|
1457
|
+
// ]
|
|
1458
|
+
|
|
1459
|
+
// Bridge crvUSD to Ethereum mainnet
|
|
1460
|
+
// Note: You must call bridgeCost() first to cache the cost value
|
|
1461
|
+
const bridgeTx = await curve.fastBridge.bridge(1000);
|
|
1462
|
+
// OR bridge to specific address:
|
|
1463
|
+
// const bridgeTx = await curve.fastBridge.bridge(1000, '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb');
|
|
1464
|
+
console.log(bridgeTx.hash);
|
|
1465
|
+
// 0xc7ba1d60871c0295ac5471bb602c37ec0f00a71543b3a041308ebd91833f26ba
|
|
1466
|
+
|
|
1467
|
+
// Estimate gas for approve
|
|
1468
|
+
await curve.fastBridge.estimateGas.approve(1000);
|
|
1469
|
+
// 46000
|
|
1470
|
+
|
|
1471
|
+
// Estimate gas for bridge
|
|
1472
|
+
await curve.fastBridge.estimateGas.bridge(1000);
|
|
1473
|
+
// 150000
|
|
1474
|
+
})()
|
|
1475
|
+
```
|
|
1476
|
+
|
|
1477
|
+
**Important Notes:**
|
|
1478
|
+
1. FastBridge is only available on L2 networks (Arbitrum, Optimism, Fraxtal)
|
|
1479
|
+
- Use `isSupported()` to check if current network supports FastBridge
|
|
1480
|
+
- Use `assertIsSupported()` to throw an error if not supported
|
|
1481
|
+
2. You must call `bridgeCost()` before calling `bridge()` to cache the cost value
|
|
1482
|
+
3. The bridge method is payable - it will send the cost amount in ETH/native currency
|
|
1483
|
+
4. Bridge amount must be within the allowed range (min/max from `allowedToBridge()`)
|
|
1484
|
+
5. `_min_amount` is automatically set equal to `_amount` for slippage protection
|
|
1485
|
+
|
|
1383
1486
|
## Boosting
|
|
1384
1487
|
|
|
1385
1488
|
### Lock
|
package/lib/bridge.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { type Curve } from "./curve.js";
|
|
3
|
+
export interface IFastBridgeNetwork {
|
|
4
|
+
chainId: number;
|
|
5
|
+
name: string;
|
|
6
|
+
fastBridgeAddress: string;
|
|
7
|
+
crvUsdAddress: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function isSupported(this: Curve): boolean;
|
|
10
|
+
export declare function assertIsSupported(this: Curve): void;
|
|
11
|
+
export declare function allowedToBridge(this: Curve): Promise<{
|
|
12
|
+
min: number;
|
|
13
|
+
max: number;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function bridgeCost(this: Curve): Promise<number>;
|
|
16
|
+
export declare function bridgeIsApproved(this: Curve, amount: number | string): Promise<boolean>;
|
|
17
|
+
export declare function bridgeApproveEstimateGas(this: Curve, amount: number | string): Promise<number | number[]>;
|
|
18
|
+
export declare function bridgeApprove(this: Curve, amount: number | string): Promise<string[]>;
|
|
19
|
+
export declare function bridgeEstimateGas(this: Curve, amount: number | string, address?: string): Promise<number | number[]>;
|
|
20
|
+
export declare function bridge(this: Curve, amount: number | string, address?: string): Promise<ethers.ContractTransactionResponse>;
|
|
21
|
+
export declare function getSupportedNetworks(): IFastBridgeNetwork[];
|
package/lib/bridge.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { ensureAllowance, ensureAllowanceEstimateGas, hasAllowance, parseUnits, DIGas, smartNumber, } from "./utils.js";
|
|
11
|
+
import { NETWORK_CONSTANTS } from "./constants/network_constants.js";
|
|
12
|
+
const CRVUSD_DECIMALS = 18;
|
|
13
|
+
const _bridgeCostCache = {};
|
|
14
|
+
export function isSupported() {
|
|
15
|
+
return !!(this.constants.ALIASES.fast_bridge && this.constants.ALIASES.crvusd);
|
|
16
|
+
}
|
|
17
|
+
export function assertIsSupported() {
|
|
18
|
+
if (!this.constants.ALIASES.fast_bridge) {
|
|
19
|
+
throw new Error("FastBridge is not available on this network");
|
|
20
|
+
}
|
|
21
|
+
if (!this.constants.ALIASES.crvusd) {
|
|
22
|
+
throw new Error("crvUSD is not available on this network");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function _allowedToBridge() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
assertIsSupported.call(this);
|
|
28
|
+
const contract = this.contracts[this.constants.ALIASES.fast_bridge].contract;
|
|
29
|
+
const result = yield contract.allowed_to_bridge(this.constantOptions);
|
|
30
|
+
return {
|
|
31
|
+
_min: result[0],
|
|
32
|
+
_max: result[1],
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function allowedToBridge() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const { _min, _max } = yield _allowedToBridge.call(this);
|
|
39
|
+
return {
|
|
40
|
+
min: Number(this.formatUnits(_min, CRVUSD_DECIMALS)),
|
|
41
|
+
max: Number(this.formatUnits(_max, CRVUSD_DECIMALS)),
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function _bridgeCost() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
assertIsSupported.call(this);
|
|
48
|
+
const contract = this.contracts[this.constants.ALIASES.fast_bridge].contract;
|
|
49
|
+
return yield contract.cost(this.constantOptions);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function bridgeCost() {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const _cost = yield _bridgeCost.call(this);
|
|
55
|
+
const key = `${this.chainId}`;
|
|
56
|
+
_bridgeCostCache[key] = _cost;
|
|
57
|
+
return Number(this.formatUnits(_cost, 18));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export function bridgeIsApproved(amount) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
assertIsSupported.call(this);
|
|
63
|
+
return yield hasAllowance.call(this, [this.constants.ALIASES.crvusd], [amount], this.signerAddress, this.constants.ALIASES.fast_bridge);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function bridgeApproveEstimateGas(amount) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
assertIsSupported.call(this);
|
|
69
|
+
return yield ensureAllowanceEstimateGas.call(this, [this.constants.ALIASES.crvusd], [amount], this.constants.ALIASES.fast_bridge);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function bridgeApprove(amount) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
assertIsSupported.call(this);
|
|
75
|
+
return yield ensureAllowance.call(this, [this.constants.ALIASES.crvusd], [amount], this.constants.ALIASES.fast_bridge);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function _bridge(amount_1, address_1) {
|
|
79
|
+
return __awaiter(this, arguments, void 0, function* (amount, address, estimateGas = false) {
|
|
80
|
+
assertIsSupported.call(this);
|
|
81
|
+
const _amount = parseUnits(amount, CRVUSD_DECIMALS);
|
|
82
|
+
const { _min, _max } = yield _allowedToBridge.call(this);
|
|
83
|
+
if (_amount < _min || _amount > _max) {
|
|
84
|
+
throw new Error(`Amount must be between ${this.formatUnits(_min, CRVUSD_DECIMALS)} and ${this.formatUnits(_max, CRVUSD_DECIMALS)}`);
|
|
85
|
+
}
|
|
86
|
+
const key = `${this.chainId}`;
|
|
87
|
+
const _cost = _bridgeCostCache[key];
|
|
88
|
+
if (_cost === undefined) {
|
|
89
|
+
throw new Error("You must call bridgeCost() first to get the bridge cost");
|
|
90
|
+
}
|
|
91
|
+
const to = address || this.signerAddress;
|
|
92
|
+
const contract = this.contracts[this.constants.ALIASES.fast_bridge].contract;
|
|
93
|
+
if (!estimateGas)
|
|
94
|
+
yield bridgeApprove.call(this, amount);
|
|
95
|
+
const gas = yield contract.bridge.estimateGas(this.constants.ALIASES.crvusd, to, _amount, _amount, Object.assign(Object.assign({}, this.constantOptions), { value: _cost }));
|
|
96
|
+
if (estimateGas)
|
|
97
|
+
return smartNumber(gas);
|
|
98
|
+
yield this.updateFeeData();
|
|
99
|
+
const gasLimit = DIGas(gas) * this.parseUnits("160", 0) / this.parseUnits("100", 0);
|
|
100
|
+
return yield contract.bridge(this.constants.ALIASES.crvusd, to, _amount, _amount, Object.assign(Object.assign({}, this.options), { value: _cost, gasLimit }));
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export function bridgeEstimateGas(amount, address) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
return yield _bridge.call(this, amount, address, true);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
export function bridge(amount, address) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
return yield _bridge.call(this, amount, address, false);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export function getSupportedNetworks() {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
const networks = [];
|
|
116
|
+
for (const [chainIdStr, config] of Object.entries(NETWORK_CONSTANTS)) {
|
|
117
|
+
const chainId = Number(chainIdStr);
|
|
118
|
+
if (((_a = config.ALIASES) === null || _a === void 0 ? void 0 : _a.fast_bridge) && ((_b = config.ALIASES) === null || _b === void 0 ? void 0 : _b.crvusd)) {
|
|
119
|
+
networks.push({
|
|
120
|
+
chainId,
|
|
121
|
+
name: config.NAME,
|
|
122
|
+
fastBridgeAddress: config.ALIASES.fast_bridge,
|
|
123
|
+
crvUsdAddress: config.ALIASES.crvusd,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return networks;
|
|
128
|
+
}
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"anonymous": false,
|
|
4
|
+
"inputs": [
|
|
5
|
+
{
|
|
6
|
+
"indexed": false,
|
|
7
|
+
"name": "min_amount",
|
|
8
|
+
"type": "uint256"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"name": "SetMinAmount",
|
|
12
|
+
"type": "event"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"anonymous": false,
|
|
16
|
+
"inputs": [
|
|
17
|
+
{
|
|
18
|
+
"indexed": false,
|
|
19
|
+
"name": "limit",
|
|
20
|
+
"type": "uint256"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"name": "SetLimit",
|
|
24
|
+
"type": "event"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"anonymous": false,
|
|
28
|
+
"inputs": [
|
|
29
|
+
{
|
|
30
|
+
"indexed": false,
|
|
31
|
+
"name": "bridger",
|
|
32
|
+
"type": "address"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"name": "SetBridger",
|
|
36
|
+
"type": "event"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"anonymous": false,
|
|
40
|
+
"inputs": [
|
|
41
|
+
{
|
|
42
|
+
"indexed": false,
|
|
43
|
+
"name": "messenger",
|
|
44
|
+
"type": "address"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"name": "SetMessenger",
|
|
48
|
+
"type": "event"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"anonymous": false,
|
|
52
|
+
"inputs": [
|
|
53
|
+
{
|
|
54
|
+
"indexed": true,
|
|
55
|
+
"name": "previous_owner",
|
|
56
|
+
"type": "address"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"indexed": true,
|
|
60
|
+
"name": "new_owner",
|
|
61
|
+
"type": "address"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"name": "OwnershipTransferred",
|
|
65
|
+
"type": "event"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"anonymous": false,
|
|
69
|
+
"inputs": [
|
|
70
|
+
{
|
|
71
|
+
"indexed": true,
|
|
72
|
+
"name": "token",
|
|
73
|
+
"type": "address"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"indexed": true,
|
|
77
|
+
"name": "sender",
|
|
78
|
+
"type": "address"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"indexed": true,
|
|
82
|
+
"name": "receiver",
|
|
83
|
+
"type": "address"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"indexed": false,
|
|
87
|
+
"name": "amount",
|
|
88
|
+
"type": "uint256"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"name": "Bridge",
|
|
92
|
+
"type": "event"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"inputs": [],
|
|
96
|
+
"name": "owner",
|
|
97
|
+
"outputs": [
|
|
98
|
+
{
|
|
99
|
+
"name": "",
|
|
100
|
+
"type": "address"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"stateMutability": "view",
|
|
104
|
+
"type": "function"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"inputs": [
|
|
108
|
+
{
|
|
109
|
+
"name": "new_owner",
|
|
110
|
+
"type": "address"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"name": "transfer_ownership",
|
|
114
|
+
"outputs": [],
|
|
115
|
+
"stateMutability": "nonpayable",
|
|
116
|
+
"type": "function"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"inputs": [],
|
|
120
|
+
"name": "renounce_ownership",
|
|
121
|
+
"outputs": [],
|
|
122
|
+
"stateMutability": "nonpayable",
|
|
123
|
+
"type": "function"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"inputs": [],
|
|
127
|
+
"name": "cost",
|
|
128
|
+
"outputs": [
|
|
129
|
+
{
|
|
130
|
+
"name": "",
|
|
131
|
+
"type": "uint256"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"stateMutability": "view",
|
|
135
|
+
"type": "function"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"inputs": [
|
|
139
|
+
{
|
|
140
|
+
"name": "_token",
|
|
141
|
+
"type": "address"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "_to",
|
|
145
|
+
"type": "address"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"name": "_amount",
|
|
149
|
+
"type": "uint256"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"name": "bridge",
|
|
153
|
+
"outputs": [
|
|
154
|
+
{
|
|
155
|
+
"name": "",
|
|
156
|
+
"type": "uint256"
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"stateMutability": "payable",
|
|
160
|
+
"type": "function"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"inputs": [
|
|
164
|
+
{
|
|
165
|
+
"name": "_token",
|
|
166
|
+
"type": "address"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "_to",
|
|
170
|
+
"type": "address"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"name": "_amount",
|
|
174
|
+
"type": "uint256"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "_min_amount",
|
|
178
|
+
"type": "uint256"
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"name": "bridge",
|
|
182
|
+
"outputs": [
|
|
183
|
+
{
|
|
184
|
+
"name": "",
|
|
185
|
+
"type": "uint256"
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"stateMutability": "payable",
|
|
189
|
+
"type": "function"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"inputs": [],
|
|
193
|
+
"name": "allowed_to_bridge",
|
|
194
|
+
"outputs": [
|
|
195
|
+
{
|
|
196
|
+
"name": "",
|
|
197
|
+
"type": "uint256"
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"name": "",
|
|
201
|
+
"type": "uint256"
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
"stateMutability": "view",
|
|
205
|
+
"type": "function"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"inputs": [
|
|
209
|
+
{
|
|
210
|
+
"name": "_ts",
|
|
211
|
+
"type": "uint256"
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
"name": "allowed_to_bridge",
|
|
215
|
+
"outputs": [
|
|
216
|
+
{
|
|
217
|
+
"name": "",
|
|
218
|
+
"type": "uint256"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "",
|
|
222
|
+
"type": "uint256"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"stateMutability": "view",
|
|
226
|
+
"type": "function"
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"inputs": [
|
|
230
|
+
{
|
|
231
|
+
"name": "_min_amount",
|
|
232
|
+
"type": "uint256"
|
|
233
|
+
}
|
|
234
|
+
],
|
|
235
|
+
"name": "set_min_amount",
|
|
236
|
+
"outputs": [],
|
|
237
|
+
"stateMutability": "nonpayable",
|
|
238
|
+
"type": "function"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"inputs": [
|
|
242
|
+
{
|
|
243
|
+
"name": "_limit",
|
|
244
|
+
"type": "uint256"
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
"name": "set_limit",
|
|
248
|
+
"outputs": [],
|
|
249
|
+
"stateMutability": "nonpayable",
|
|
250
|
+
"type": "function"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"inputs": [
|
|
254
|
+
{
|
|
255
|
+
"name": "_bridger",
|
|
256
|
+
"type": "address"
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
"name": "set_bridger",
|
|
260
|
+
"outputs": [],
|
|
261
|
+
"stateMutability": "nonpayable",
|
|
262
|
+
"type": "function"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"inputs": [
|
|
266
|
+
{
|
|
267
|
+
"name": "_messenger",
|
|
268
|
+
"type": "address"
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
"name": "set_messenger",
|
|
272
|
+
"outputs": [],
|
|
273
|
+
"stateMutability": "nonpayable",
|
|
274
|
+
"type": "function"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"inputs": [],
|
|
278
|
+
"name": "version",
|
|
279
|
+
"outputs": [
|
|
280
|
+
{
|
|
281
|
+
"name": "",
|
|
282
|
+
"type": "string"
|
|
283
|
+
}
|
|
284
|
+
],
|
|
285
|
+
"stateMutability": "view",
|
|
286
|
+
"type": "function"
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"inputs": [],
|
|
290
|
+
"name": "CRVUSD",
|
|
291
|
+
"outputs": [
|
|
292
|
+
{
|
|
293
|
+
"name": "",
|
|
294
|
+
"type": "address"
|
|
295
|
+
}
|
|
296
|
+
],
|
|
297
|
+
"stateMutability": "view",
|
|
298
|
+
"type": "function"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
"inputs": [],
|
|
302
|
+
"name": "VAULT",
|
|
303
|
+
"outputs": [
|
|
304
|
+
{
|
|
305
|
+
"name": "",
|
|
306
|
+
"type": "address"
|
|
307
|
+
}
|
|
308
|
+
],
|
|
309
|
+
"stateMutability": "view",
|
|
310
|
+
"type": "function"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"inputs": [],
|
|
314
|
+
"name": "min_amount",
|
|
315
|
+
"outputs": [
|
|
316
|
+
{
|
|
317
|
+
"name": "",
|
|
318
|
+
"type": "uint256"
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
"stateMutability": "view",
|
|
322
|
+
"type": "function"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"inputs": [],
|
|
326
|
+
"name": "limit",
|
|
327
|
+
"outputs": [
|
|
328
|
+
{
|
|
329
|
+
"name": "",
|
|
330
|
+
"type": "uint256"
|
|
331
|
+
}
|
|
332
|
+
],
|
|
333
|
+
"stateMutability": "view",
|
|
334
|
+
"type": "function"
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
"inputs": [
|
|
338
|
+
{
|
|
339
|
+
"name": "arg0",
|
|
340
|
+
"type": "uint256"
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
"name": "bridged",
|
|
344
|
+
"outputs": [
|
|
345
|
+
{
|
|
346
|
+
"name": "",
|
|
347
|
+
"type": "uint256"
|
|
348
|
+
}
|
|
349
|
+
],
|
|
350
|
+
"stateMutability": "view",
|
|
351
|
+
"type": "function"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"inputs": [],
|
|
355
|
+
"name": "bridger",
|
|
356
|
+
"outputs": [
|
|
357
|
+
{
|
|
358
|
+
"name": "",
|
|
359
|
+
"type": "address"
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
"stateMutability": "view",
|
|
363
|
+
"type": "function"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"inputs": [],
|
|
367
|
+
"name": "messenger",
|
|
368
|
+
"outputs": [
|
|
369
|
+
{
|
|
370
|
+
"name": "",
|
|
371
|
+
"type": "address"
|
|
372
|
+
}
|
|
373
|
+
],
|
|
374
|
+
"stateMutability": "view",
|
|
375
|
+
"type": "function"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
"inputs": [
|
|
379
|
+
{
|
|
380
|
+
"name": "_crvusd",
|
|
381
|
+
"type": "address"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"name": "_vault",
|
|
385
|
+
"type": "address"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"name": "_bridger",
|
|
389
|
+
"type": "address"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"name": "_messenger",
|
|
393
|
+
"type": "address"
|
|
394
|
+
}
|
|
395
|
+
],
|
|
396
|
+
"outputs": [],
|
|
397
|
+
"stateMutability": "nonpayable",
|
|
398
|
+
"type": "constructor"
|
|
399
|
+
}
|
|
400
|
+
]
|
|
@@ -100,6 +100,8 @@ const ALIASES_ARBITRUM = lowerCaseValues({
|
|
|
100
100
|
"twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
|
|
101
101
|
"tricrypto_factory": '0xbC0797015fcFc47d9C1856639CaE50D0e69FbEE8',
|
|
102
102
|
"factory_admin": "",
|
|
103
|
+
"fast_bridge": "0x1F2aF270029d028400265Ce1dd0919BA8780dAe1",
|
|
104
|
+
"crvusd": "0x498Bf2B1e120FeD3ad3D42EA2165E9b73f99C1e5",
|
|
103
105
|
});
|
|
104
106
|
const ALIASES_OPTIMISM = lowerCaseValues({
|
|
105
107
|
"crv": "0x0994206dfE8De6Ec6920FF4D779B0d950605Fb53",
|
|
@@ -120,6 +122,8 @@ const ALIASES_OPTIMISM = lowerCaseValues({
|
|
|
120
122
|
"factory_admin": "",
|
|
121
123
|
"gas_oracle": '0xc0d3C0d3C0d3c0D3C0D3C0d3C0d3C0D3C0D3000f',
|
|
122
124
|
"gas_oracle_blob": '0x420000000000000000000000000000000000000f',
|
|
125
|
+
"fast_bridge": "0xD16d5eC345Dd86Fb63C6a9C43c517210F1027914",
|
|
126
|
+
"crvusd": "0xC52D7F23a2e460248Db6eE192Cb23dD12bDDCbf6",
|
|
123
127
|
});
|
|
124
128
|
const ALIASES_XDAI = lowerCaseValues({
|
|
125
129
|
"crv": "0x712b3d230f3c1c19db860d80619288b1f0bdd0bd",
|
|
@@ -274,6 +278,8 @@ const ALIASES_FRAXTAL = lowerCaseValues({
|
|
|
274
278
|
"twocrypto_factory": '0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F',
|
|
275
279
|
"tricrypto_factory": '0xc9Fe0C63Af9A39402e8a5514f9c43Af0322b665F',
|
|
276
280
|
"factory_admin": '0x0000000000000000000000000000000000000000',
|
|
281
|
+
"fast_bridge": "0x3fE593E651Cd0B383AD36b75F4159f30BB0631A6",
|
|
282
|
+
"crvusd": "0xB102f7Efa0d5dE071A8D37B3548e1C7CB148Caf3",
|
|
277
283
|
});
|
|
278
284
|
const ALIASES_XLAYER = lowerCaseValues({
|
|
279
285
|
"crv": "0x0000000000000000000000000000000000000000",
|
package/lib/curve.js
CHANGED
|
@@ -48,6 +48,7 @@ import gasOracleBlobABI from './constants/abis/gas_oracle_optimism_blob.json' wi
|
|
|
48
48
|
import votingProposalABI from './constants/abis/voting_proposal.json' with { type: 'json' };
|
|
49
49
|
import circulatingSupplyABI from './constants/abis/circulating_supply.json' with { type: 'json' };
|
|
50
50
|
import rootGaugeFactoryABI from "./constants/abis/gauge_factory/root_gauge_factory.json" with { type: "json" };
|
|
51
|
+
import fastBridgeABI from './constants/abis/fastBridge.json' with { type: 'json' };
|
|
51
52
|
import { extractDecimals, extractGauges, formatUnits, lowerCasePoolDataAddresses, parseUnits, } from "./constants/utils.js";
|
|
52
53
|
import { _getHiddenPools } from "./external-api.js";
|
|
53
54
|
import { L2Networks } from "./constants/L2Networks.js";
|
|
@@ -561,6 +562,13 @@ export class Curve {
|
|
|
561
562
|
this.constants.DECIMALS[this.constants.ALIASES.crv] = 18;
|
|
562
563
|
this.setContract(this.constants.COINS.scrvusd, ERC20Abi);
|
|
563
564
|
this.constants.DECIMALS[this.constants.COINS.scrvusd] = 18;
|
|
565
|
+
if (this.constants.ALIASES.fast_bridge) {
|
|
566
|
+
this.setContract(this.constants.ALIASES.fast_bridge, fastBridgeABI);
|
|
567
|
+
}
|
|
568
|
+
if (this.constants.ALIASES.crvusd) {
|
|
569
|
+
this.setContract(this.constants.ALIASES.crvusd, ERC20Abi);
|
|
570
|
+
this.constants.DECIMALS[this.constants.ALIASES.crvusd] = 18;
|
|
571
|
+
}
|
|
564
572
|
if (this.chainId === 1) {
|
|
565
573
|
this.setContract(this.constants.ALIASES.minter, minterMainnetABI);
|
|
566
574
|
this.setContract(this.constants.ALIASES.fee_distributor_crvusd, feeDistributorCrvUSDABI);
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from "ethers";
|
|
2
2
|
import { PoolTemplate } from "./pools/index.js";
|
|
3
|
+
import { getSupportedNetworks } from "./bridge.js";
|
|
3
4
|
import { deployCryptoPoolEstimateGas, deployTwocryptoPoolEstimateGas } from './factory/deploy.js';
|
|
4
5
|
import { getTwoCryptoImplementations } from './constants/twoCryptoImplementations.js';
|
|
5
6
|
export declare const createCurve: () => {
|
|
@@ -268,6 +269,23 @@ export declare const createCurve: () => {
|
|
|
268
269
|
swapFromCalldata: (tx: ethers.TransactionRequest) => Promise<number | number[]>;
|
|
269
270
|
};
|
|
270
271
|
};
|
|
272
|
+
fastBridge: {
|
|
273
|
+
assertIsSupported: () => void;
|
|
274
|
+
isSupported: () => boolean;
|
|
275
|
+
getSupportedNetworks: typeof getSupportedNetworks;
|
|
276
|
+
allowedToBridge: () => Promise<{
|
|
277
|
+
min: number;
|
|
278
|
+
max: number;
|
|
279
|
+
}>;
|
|
280
|
+
bridgeCost: () => Promise<number>;
|
|
281
|
+
isApproved: (amount: string | number) => Promise<boolean>;
|
|
282
|
+
approve: (amount: string | number) => Promise<string[]>;
|
|
283
|
+
bridge: (amount: string | number, address?: string | undefined) => Promise<ethers.ContractTransactionResponse>;
|
|
284
|
+
estimateGas: {
|
|
285
|
+
approve: (amount: string | number) => Promise<number | number[]>;
|
|
286
|
+
bridge: (amount: string | number, address?: string | undefined) => Promise<number | number[]>;
|
|
287
|
+
};
|
|
288
|
+
};
|
|
271
289
|
dao: {
|
|
272
290
|
crvSupplyStats: () => Promise<{
|
|
273
291
|
circulating: string;
|
|
@@ -585,6 +603,23 @@ declare const _default: {
|
|
|
585
603
|
swapFromCalldata: (tx: ethers.TransactionRequest) => Promise<number | number[]>;
|
|
586
604
|
};
|
|
587
605
|
};
|
|
606
|
+
fastBridge: {
|
|
607
|
+
assertIsSupported: () => void;
|
|
608
|
+
isSupported: () => boolean;
|
|
609
|
+
getSupportedNetworks: typeof getSupportedNetworks;
|
|
610
|
+
allowedToBridge: () => Promise<{
|
|
611
|
+
min: number;
|
|
612
|
+
max: number;
|
|
613
|
+
}>;
|
|
614
|
+
bridgeCost: () => Promise<number>;
|
|
615
|
+
isApproved: (amount: string | number) => Promise<boolean>;
|
|
616
|
+
approve: (amount: string | number) => Promise<string[]>;
|
|
617
|
+
bridge: (amount: string | number, address?: string | undefined) => Promise<ethers.ContractTransactionResponse>;
|
|
618
|
+
estimateGas: {
|
|
619
|
+
approve: (amount: string | number) => Promise<number | number[]>;
|
|
620
|
+
bridge: (amount: string | number, address?: string | undefined) => Promise<number | number[]>;
|
|
621
|
+
};
|
|
622
|
+
};
|
|
588
623
|
dao: {
|
|
589
624
|
crvSupplyStats: () => Promise<{
|
|
590
625
|
circulating: string;
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { PoolTemplate, getPool } from "./pools/index.js";
|
|
11
11
|
import { getUserPoolListByLiquidity, getUserPoolListByClaimable, getUserPoolList, getUserLiquidityUSD, getUserClaimable, } from "./pools/utils.js";
|
|
12
12
|
import { getBestRouteAndOutput, getArgs, swapExpected, swapRequired, swapPriceImpact, swapIsApproved, swapApproveEstimateGas, swapApprove, swapPopulateApprove, swapEstimateGas, swap, populateSwap, getSwappedAmount, approveFromCalldata, approveFromCalldataEstimateGas, swapFromCalldata, swapFromCalldataEstimateGas, } from "./router.js";
|
|
13
|
+
import { isSupported, assertIsSupported, allowedToBridge, bridgeCost, bridgeIsApproved, bridgeApproveEstimateGas, bridgeApprove, bridgeEstimateGas, bridge, getSupportedNetworks, } from "./bridge.js";
|
|
13
14
|
import { Curve } from "./curve.js";
|
|
14
15
|
import { getCrv, getLockedAmountAndUnlockTime, getVeCrv, getVeCrvPct, calcUnlockTime, createLockEstimateGas, createLock, isApproved, approveEstimateGas, approve, increaseAmountEstimateGas, increaseAmount, increaseUnlockTimeEstimateGas, increaseUnlockTime, withdrawLockedCrvEstimateGas, withdrawLockedCrv, claimableFees, claimFeesEstimateGas, claimFees, lastEthBlock, getAnycallBalance, topUpAnycall, topUpAnycallEstimateGas, lastBlockSent, blockToSend, sendBlockhash, sendBlockhashEstimateGas, submitProof, submitProofEstimateGas, claimFeesCrvUSDEstimateGas, claimableFeesCrvUSD, claimFeesCrvUSD, calculateVeCrv, } from "./boosting.js";
|
|
15
16
|
import { getBalances, getAllowance, hasAllowance, ensureAllowanceEstimateGas, ensureAllowance, populateApprove, getUsdRate, getGasPriceFromL1, getGasPriceFromL2, getGasInfoForL2, getTVL, getCoinsData, getVolume, hasDepositAndStake, hasRouter, getBasePools, getGasPrice, getCurveLiteNetworks, } from "./utils.js";
|
|
@@ -242,6 +243,20 @@ export const createCurve = () => {
|
|
|
242
243
|
swapFromCalldata: swapFromCalldataEstimateGas.bind(_curve),
|
|
243
244
|
},
|
|
244
245
|
},
|
|
246
|
+
fastBridge: {
|
|
247
|
+
assertIsSupported: assertIsSupported.bind(_curve),
|
|
248
|
+
isSupported: isSupported.bind(_curve),
|
|
249
|
+
getSupportedNetworks: getSupportedNetworks.bind(_curve),
|
|
250
|
+
allowedToBridge: allowedToBridge.bind(_curve),
|
|
251
|
+
bridgeCost: bridgeCost.bind(_curve),
|
|
252
|
+
isApproved: bridgeIsApproved.bind(_curve),
|
|
253
|
+
approve: bridgeApprove.bind(_curve),
|
|
254
|
+
bridge: bridge.bind(_curve),
|
|
255
|
+
estimateGas: {
|
|
256
|
+
approve: bridgeApproveEstimateGas.bind(_curve),
|
|
257
|
+
bridge: bridgeEstimateGas.bind(_curve),
|
|
258
|
+
},
|
|
259
|
+
},
|
|
245
260
|
dao: {
|
|
246
261
|
// --- CRV lock ---
|
|
247
262
|
// View methods
|
|
@@ -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
|
};
|