@dhedge/v2-sdk 2.1.8 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +400 -53
- package/dist/config.d.ts +13 -2
- package/dist/entities/pool.d.ts +25 -86
- package/dist/entities/utils.d.ts +15 -0
- package/dist/services/hyperliquid/index.d.ts +22 -0
- package/dist/services/kyberSwap/index.d.ts +1 -1
- package/dist/services/oneInch/index.d.ts +1 -1
- package/dist/services/toros/easySwapper.d.ts +14 -0
- package/dist/services/toros/swapData.d.ts +5 -5
- package/dist/services/uniswap/V3Liquidity.d.ts +2 -2
- package/dist/services/velodrome/liquidity.d.ts +3 -0
- package/dist/test/constants.d.ts +48 -3
- package/dist/test/utils/testingHelper.d.ts +4 -0
- package/dist/types.d.ts +19 -4
- package/dist/utils/contract.d.ts +20 -0
- package/dist/v2-sdk.cjs.development.js +4996 -6742
- package/dist/v2-sdk.cjs.development.js.map +1 -1
- package/dist/v2-sdk.cjs.production.min.js +1 -1
- package/dist/v2-sdk.cjs.production.min.js.map +1 -1
- package/dist/v2-sdk.esm.js +5001 -6742
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/PoolFactory.json +414 -204
- package/src/abi/PoolLogic.json +160 -134
- package/src/config.ts +13 -8
- package/src/entities/pool.ts +46 -253
- package/src/entities/utils.ts +15 -0
- package/src/services/hyperliquid/index.ts +22 -0
- package/src/services/kyberSwap/index.ts +5 -3
- package/src/services/oneInch/index.ts +5 -4
- package/src/services/toros/completeWithdrawal.ts +57 -40
- package/src/services/toros/easySwapper.ts +15 -1
- package/src/services/toros/initWithdrawal.ts +39 -31
- package/src/services/toros/swapData.ts +45 -131
- package/src/services/uniswap/V3Liquidity.ts +3 -24
- package/src/services/velodrome/liquidity.ts +3 -0
- package/src/test/aave.test.ts +99 -70
- package/src/test/aerodrome.test.ts +53 -24
- package/src/test/aerodromeCL.test.ts +64 -30
- package/src/test/arrakis.test.ts +23 -35
- package/src/test/balancer.test.ts +114 -106
- package/src/test/compoundV3.test.ts +45 -29
- package/src/test/constants.ts +56 -11
- package/src/test/cowswap.test.ts +33 -35
- package/src/test/dhedge.test.ts +45 -12
- package/src/test/flatmoney.test.ts +25 -39
- package/src/test/fluid.test.ts +33 -24
- package/src/test/hyperliquid.onchain.test.ts +131 -0
- package/src/test/kyberSwap.test.ts +37 -16
- package/src/test/lyra.test.ts +159 -150
- package/src/test/odos.test.ts +2 -2
- package/src/test/oneInch.test.ts +36 -22
- package/src/test/pancakeCL.test.ts +72 -31
- package/src/test/pendle.test.ts +94 -54
- package/src/test/{pendleMint.test.ts → pendleMint.onchain.test.ts} +22 -8
- package/src/test/pool.test.ts +152 -95
- package/src/test/toros.onchain.test.ts +92 -0
- package/src/test/toros.test.ts +74 -20
- package/src/test/torosLimitOrder.test.ts +87 -42
- package/src/test/uniswap.test.ts +77 -128
- package/src/test/utils/testingHelper.ts +120 -0
- package/src/test/velodrome.test.ts +126 -92
- package/src/test/velodromeCL.test.ts +43 -31
- package/src/test/velodromeV2.test.ts +153 -95
- package/src/types.ts +20 -5
- package/src/utils/contract.ts +20 -0
- package/dist/services/futures/constants.d.ts +0 -1
- package/dist/services/futures/index.d.ts +0 -2
- package/dist/services/futures/margin.d.ts +0 -2
- package/dist/services/futures/trade.d.ts +0 -3
- package/dist/services/ramses/vesting.d.ts +0 -4
- package/dist/services/uniswap/V3Trade.d.ts +0 -3
- package/dist/test/utils/futures.d.ts +0 -2
- package/src/abi/IRamsesNonfungiblePositionManager.json +0 -486
- package/src/abi/ISynthetiXFuturesMarketV2.json +0 -531
- package/src/abi/ISynthetix.json +0 -139
- package/src/abi/IUniswapV3Quoter.json +0 -195
- package/src/abi/IUniswapV3Router.json +0 -221
- package/src/abi/IXRam.json +0 -99
- package/src/services/futures/constants.ts +0 -1
- package/src/services/futures/index.ts +0 -2
- package/src/services/futures/margin.ts +0 -10
- package/src/services/futures/trade.ts +0 -32
- package/src/services/ramses/vesting.ts +0 -24
- package/src/services/uniswap/V3Trade.ts +0 -46
- package/src/test/futures.test.ts +0 -51
- package/src/test/hyperliquid.test.ts +0 -107
- package/src/test/ramses.test.ts +0 -190
- package/src/test/ramsesCL.test.ts +0 -155
- package/src/test/synthetix.test.ts +0 -36
- package/src/test/utils/futures.ts +0 -14
|
@@ -1,114 +1,172 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
import { ethers } from "ethers";
|
|
3
5
|
import { Dhedge, Pool } from "..";
|
|
4
6
|
import { routerAddress } from "../config";
|
|
5
7
|
import { Dapp, Network } from "../types";
|
|
6
8
|
import { CONTRACT_ADDRESS, MAX_AMOUNT, TEST_POOL } from "./constants";
|
|
7
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
TestingRunParams,
|
|
11
|
+
fixOracleAggregatorStaleness,
|
|
12
|
+
runWithImpersonateAccount,
|
|
13
|
+
setChainlinkTimeout,
|
|
14
|
+
setUSDCAmount,
|
|
15
|
+
setWETHAmount,
|
|
16
|
+
testingHelper
|
|
17
|
+
} from "./utils/testingHelper";
|
|
18
|
+
import { balanceDelta } from "./utils/token";
|
|
8
19
|
|
|
9
|
-
|
|
20
|
+
// Velodrome V2 VARIABLE USDC/WETH pool (native USDC)
|
|
21
|
+
const USDC_WETH_Lp = "0xF4F2657AE744354bAcA871E56775e5083F7276Ab";
|
|
22
|
+
const USDC_WETH_Gauge = "0xBde5E1592AEb3D8396b90c4B4ba274E5Ae31e552";
|
|
10
23
|
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const SUSD = CONTRACT_ADDRESS[network].SUSD;
|
|
15
|
-
const USDC = CONTRACT_ADDRESS[network].USDC;
|
|
24
|
+
const testVelodromeV2 = ({ wallet, network, provider }: TestingRunParams) => {
|
|
25
|
+
const USDC = CONTRACT_ADDRESS[network].USDC;
|
|
26
|
+
const WETH = CONTRACT_ADDRESS[network].WETH;
|
|
16
27
|
|
|
17
|
-
let dhedge: Dhedge;
|
|
18
|
-
let pool: Pool;
|
|
19
|
-
jest.setTimeout(100000);
|
|
28
|
+
let dhedge: Dhedge;
|
|
29
|
+
let pool: Pool;
|
|
30
|
+
jest.setTimeout(100000);
|
|
20
31
|
|
|
21
|
-
describe(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
describe(`pool on ${network}`, () => {
|
|
33
|
+
beforeAll(async () => {
|
|
34
|
+
await provider.send("hardhat_setBalance", [
|
|
35
|
+
wallet.address,
|
|
36
|
+
"0x10000000000000000"
|
|
37
|
+
]);
|
|
38
|
+
dhedge = new Dhedge(wallet, network);
|
|
39
|
+
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
await pool.approve(Dapp.VELODROMEV2, USDC, MAX_AMOUNT);
|
|
30
|
-
const UsdcAllowanceDelta = await allowanceDelta(
|
|
31
|
-
pool.address,
|
|
32
|
-
USDC,
|
|
33
|
-
routerAddress[network].velodromeV2!,
|
|
34
|
-
pool.signer
|
|
35
|
-
);
|
|
36
|
-
await expect(UsdcAllowanceDelta.gt(0));
|
|
37
|
-
});
|
|
41
|
+
await setChainlinkTimeout({ pool, provider }, 86400 * 365);
|
|
42
|
+
await fixOracleAggregatorStaleness({ pool, provider });
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
expect(lpTokenDelta.gt(0));
|
|
54
|
-
});
|
|
44
|
+
await runWithImpersonateAccount(
|
|
45
|
+
{ provider, account: await pool.managerLogic.manager() },
|
|
46
|
+
async ({ signer }) => {
|
|
47
|
+
await pool.managerLogic.connect(signer).setTrader(wallet.address);
|
|
48
|
+
await pool.managerLogic.connect(signer).changeAssets(
|
|
49
|
+
[
|
|
50
|
+
[USDC, true],
|
|
51
|
+
[WETH, true],
|
|
52
|
+
[USDC_WETH_Lp, false]
|
|
53
|
+
],
|
|
54
|
+
[]
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
await setUSDCAmount({
|
|
60
|
+
amount: new BigNumber(10000).times(1e6).toFixed(0),
|
|
61
|
+
userAddress: pool.address,
|
|
62
|
+
network,
|
|
63
|
+
provider
|
|
64
|
+
});
|
|
65
|
+
await setWETHAmount({
|
|
66
|
+
amount: new BigNumber(3).times(1e18).toFixed(0),
|
|
67
|
+
userAddress: pool.address,
|
|
68
|
+
network,
|
|
69
|
+
provider
|
|
70
|
+
});
|
|
71
|
+
});
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
it("approves unlimited WETH and USDC on for Velodrome", async () => {
|
|
74
|
+
await pool.approve(Dapp.VELODROMEV2, WETH, MAX_AMOUNT);
|
|
75
|
+
await pool.approve(Dapp.VELODROMEV2, USDC, MAX_AMOUNT);
|
|
76
|
+
const iERC20 = new ethers.Contract(
|
|
77
|
+
USDC,
|
|
78
|
+
["function allowance(address,address) view returns (uint256)"],
|
|
79
|
+
pool.signer
|
|
80
|
+
);
|
|
81
|
+
const usdcAllowance = await iERC20.allowance(
|
|
82
|
+
pool.address,
|
|
83
|
+
routerAddress[network].velodromeV2!
|
|
84
|
+
);
|
|
85
|
+
expect(usdcAllowance.gt(0)).toBe(true);
|
|
86
|
+
});
|
|
72
87
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
USDC_SUSD_Lp,
|
|
82
|
-
pool.signer
|
|
83
|
-
);
|
|
84
|
-
expect(lpTokenDelta.gt(0));
|
|
85
|
-
});
|
|
88
|
+
it("adds USDC and WETH to a Velodrome volatile pool", async () => {
|
|
89
|
+
await pool.addLiquidityVelodromeV2(
|
|
90
|
+
USDC,
|
|
91
|
+
WETH,
|
|
92
|
+
new BigNumber(100).times(1e6).toFixed(0),
|
|
93
|
+
new BigNumber(0.05).times(1e18).toFixed(0),
|
|
94
|
+
false
|
|
95
|
+
);
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
const lpTokenDelta = await balanceDelta(
|
|
98
|
+
pool.address,
|
|
99
|
+
USDC_WETH_Lp,
|
|
100
|
+
pool.signer
|
|
101
|
+
);
|
|
102
|
+
expect(lpTokenDelta.gt(0)).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("should stake USDC-WETH LP in a gauge", async () => {
|
|
106
|
+
const balance = await dhedge.utils.getBalance(USDC_WETH_Lp, pool.address);
|
|
107
|
+
await pool.approveSpender(USDC_WETH_Gauge, USDC_WETH_Lp, MAX_AMOUNT);
|
|
108
|
+
await pool.stakeInGauge(Dapp.VELODROMEV2, USDC_WETH_Gauge, balance);
|
|
109
|
+
const gaugeBalance = await balanceDelta(
|
|
110
|
+
pool.address,
|
|
111
|
+
USDC_WETH_Lp,
|
|
112
|
+
pool.signer
|
|
113
|
+
);
|
|
114
|
+
expect(gaugeBalance.lt(0)).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("should claim rewards from Gauge", async () => {
|
|
118
|
+
const tx = await pool.claimFees(Dapp.VELODROMEV2, USDC_WETH_Gauge);
|
|
119
|
+
expect(tx).not.toBe(null);
|
|
120
|
+
});
|
|
97
121
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
|
|
122
|
+
it("should unStake USDC-WETH LP from a gauge", async () => {
|
|
123
|
+
const gaugeBalance = await dhedge.utils.getBalance(
|
|
124
|
+
USDC_WETH_Gauge,
|
|
125
|
+
pool.address
|
|
126
|
+
);
|
|
127
|
+
await pool.unstakeFromGauge(USDC_WETH_Gauge, gaugeBalance);
|
|
128
|
+
const lpTokenDelta = await balanceDelta(
|
|
129
|
+
pool.address,
|
|
130
|
+
USDC_WETH_Lp,
|
|
131
|
+
pool.signer
|
|
132
|
+
);
|
|
133
|
+
expect(lpTokenDelta.gt(0)).toBe(true);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("approves unlimited USDC-WETH LP for Velodrome", async () => {
|
|
137
|
+
await pool.approve(Dapp.VELODROMEV2, USDC_WETH_Lp, MAX_AMOUNT);
|
|
138
|
+
const iERC20 = new ethers.Contract(
|
|
139
|
+
USDC_WETH_Lp,
|
|
140
|
+
["function allowance(address,address) view returns (uint256)"],
|
|
141
|
+
pool.signer
|
|
142
|
+
);
|
|
143
|
+
const lpAllowance = await iERC20.allowance(
|
|
144
|
+
pool.address,
|
|
145
|
+
routerAddress[network].velodromeV2!
|
|
146
|
+
);
|
|
147
|
+
expect(lpAllowance.gt(0)).toBe(true);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("should remove all liquidity from an existing pool ", async () => {
|
|
151
|
+
const balance = await dhedge.utils.getBalance(USDC_WETH_Lp, pool.address);
|
|
152
|
+
await pool.removeLiquidityVelodromeV2(USDC, WETH, balance, false);
|
|
153
|
+
const usdcBalanceDelta = await balanceDelta(
|
|
154
|
+
pool.address,
|
|
155
|
+
USDC,
|
|
156
|
+
pool.signer
|
|
157
|
+
);
|
|
158
|
+
const wethBalanceDelta = await balanceDelta(
|
|
159
|
+
pool.address,
|
|
160
|
+
WETH,
|
|
161
|
+
pool.signer
|
|
162
|
+
);
|
|
163
|
+
expect(usdcBalanceDelta.gt(0)).toBe(true);
|
|
164
|
+
expect(wethBalanceDelta.gt(0)).toBe(true);
|
|
165
|
+
});
|
|
113
166
|
});
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
testingHelper({
|
|
170
|
+
network: Network.OPTIMISM,
|
|
171
|
+
testingRun: testVelodromeV2
|
|
114
172
|
});
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Deployment } from "@lyrafinance/lyra-js";
|
|
2
2
|
import { BigNumber } from "ethers";
|
|
3
3
|
|
|
4
|
+
/** Networks supported by the SDK. The string value matches keys in `routerAddress`,
|
|
5
|
+
* `nonfungiblePositionManagerAddress`, etc. in `config.ts`. */
|
|
4
6
|
export enum Network {
|
|
5
7
|
POLYGON = "polygon",
|
|
6
8
|
OPTIMISM = "optimism",
|
|
@@ -11,6 +13,8 @@ export enum Network {
|
|
|
11
13
|
HYPERLIQUID = "hyperliquid"
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
/** Identifies a target protocol/integration for `pool.trade`, `pool.approve`, etc.
|
|
17
|
+
* Each entry maps to address registries (router, factory, gauge) in `config.ts`. */
|
|
14
18
|
export enum Dapp {
|
|
15
19
|
SUSHISWAP = "sushiswap",
|
|
16
20
|
AAVE = "aave",
|
|
@@ -18,7 +22,6 @@ export enum Dapp {
|
|
|
18
22
|
QUICKSWAP = "quickswap",
|
|
19
23
|
BALANCER = "balancer",
|
|
20
24
|
UNISWAPV3 = "uniswapV3",
|
|
21
|
-
SYNTHETIX = "synthetix",
|
|
22
25
|
AAVEV3 = "aavev3",
|
|
23
26
|
ARRAKIS = "arrakis",
|
|
24
27
|
TOROS = "toros",
|
|
@@ -26,10 +29,8 @@ export enum Dapp {
|
|
|
26
29
|
VELODROMEV2 = "velodromeV2",
|
|
27
30
|
VELODROMECL = "velodromeCL",
|
|
28
31
|
LYRA = "lyra",
|
|
29
|
-
RAMSES = "ramses",
|
|
30
32
|
AERODROME = "aerodrome",
|
|
31
33
|
AERODROMECL = "aerodromeCL",
|
|
32
|
-
RAMSESCL = "ramsesCL",
|
|
33
34
|
PANCAKECL = "pancakeCL",
|
|
34
35
|
COMPOUNDV3 = "compoundV3",
|
|
35
36
|
ODOS = "odos",
|
|
@@ -39,6 +40,8 @@ export enum Dapp {
|
|
|
39
40
|
COWSWAP = "cowswap"
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/** Function-name strings used when encoding ABI calls — keep in sync with the
|
|
44
|
+
* matching ABI files in `src/abi/`. */
|
|
42
45
|
export enum Transaction {
|
|
43
46
|
SWAP = "swapExactTokensForTokens",
|
|
44
47
|
ADD_LIQUIDITY = "addLiquidity",
|
|
@@ -56,7 +59,6 @@ export enum Transaction {
|
|
|
56
59
|
WITHDRAW = "withdraw",
|
|
57
60
|
MINT = "mint",
|
|
58
61
|
BURN = "burn",
|
|
59
|
-
SWAP_SYNTHS = "exchangeWithTracking",
|
|
60
62
|
ADD_LIQUIDITY_STAKE = "addLiquidityAndStake",
|
|
61
63
|
REMOVE_LIQUIDITY_UNSTAKE = "removeLiquidityAndUnstake"
|
|
62
64
|
}
|
|
@@ -69,13 +71,16 @@ export type AddressDappMap = {
|
|
|
69
71
|
|
|
70
72
|
export type AddressDappNetworkMap = Readonly<Record<Network, AddressDappMap>>;
|
|
71
73
|
|
|
74
|
+
/** Tuple form `[asset, isDeposit]` accepted by the factory's `createFund`. */
|
|
72
75
|
export type SupportedAsset = [string, boolean];
|
|
73
76
|
|
|
77
|
+
/** Object form of a supported asset entry; preferred over `SupportedAsset` in SDK methods. */
|
|
74
78
|
export type AssetEnabled = {
|
|
75
79
|
asset: string;
|
|
76
80
|
isDeposit: boolean;
|
|
77
81
|
};
|
|
78
82
|
|
|
83
|
+
/** A pool's holding of one asset returned by `pool.getComposition()`. */
|
|
79
84
|
export type FundComposition = {
|
|
80
85
|
asset: string;
|
|
81
86
|
isDeposit: boolean;
|
|
@@ -107,14 +112,24 @@ export type LyraPosition = {
|
|
|
107
112
|
state: number;
|
|
108
113
|
};
|
|
109
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Options that control how SDK methods dispatch a transaction:
|
|
117
|
+
* - `estimateGas`: simulate and return gas + minAmountOut without sending.
|
|
118
|
+
* - `onlyGetTxData`: return the encoded calldata without sending or simulating.
|
|
119
|
+
* - `useTraderAddressAsFrom`: send via the EOA wallet instead of the pool's
|
|
120
|
+
* `execTransaction` (used when the SDK is acting as a non-dHEDGE caller).
|
|
121
|
+
* - `boolean` shorthand: `true` is equivalent to `{ estimateGas: true }` (kept
|
|
122
|
+
* for backward compatibility).
|
|
123
|
+
*/
|
|
110
124
|
export type SDKOptions =
|
|
111
125
|
| {
|
|
112
126
|
estimateGas: boolean;
|
|
113
127
|
onlyGetTxData?: boolean;
|
|
114
128
|
useTraderAddressAsFrom?: boolean;
|
|
115
129
|
}
|
|
116
|
-
| boolean;
|
|
130
|
+
| boolean;
|
|
117
131
|
|
|
132
|
+
/** Parameters for a Toros limit order (stop-loss / take-profit) on a vault token. */
|
|
118
133
|
export type LimitOrderInfo = {
|
|
119
134
|
amount: BigNumber;
|
|
120
135
|
stopLossPriceD18: BigNumber;
|
package/src/utils/contract.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { multiCallAddress } from "../config";
|
|
|
6
6
|
import { ethers, Network, Pool, SDKOptions } from "..";
|
|
7
7
|
import { Signer } from "ethers";
|
|
8
8
|
|
|
9
|
+
/** Single contract read: `call = [address, methodName, params?]`. */
|
|
9
10
|
export async function call(
|
|
10
11
|
provider: ethers.Signer,
|
|
11
12
|
abi: any[],
|
|
@@ -21,6 +22,11 @@ export async function call(
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Batch multiple contract reads through Multicall's `tryAggregate`.
|
|
27
|
+
* Each call entry is `[address, methodName, params]`. When `requireSuccess` is false,
|
|
28
|
+
* failing calls return `null` instead of reverting the whole batch.
|
|
29
|
+
*/
|
|
24
30
|
export async function multicall<T>(
|
|
25
31
|
network: Network,
|
|
26
32
|
provider: ethers.Signer,
|
|
@@ -59,6 +65,11 @@ export async function multicall<T>(
|
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Fluent helper for building a multicall and dispatching results into a typed object.
|
|
70
|
+
* Use `.call(path, address, fn, params)` repeatedly, then `.execute()` returns the
|
|
71
|
+
* populated object with results placed at the given lodash paths.
|
|
72
|
+
*/
|
|
62
73
|
export class Multicaller {
|
|
63
74
|
public network: Network;
|
|
64
75
|
public provider: ethers.Signer;
|
|
@@ -135,6 +146,15 @@ export const isSdkOptionsBoolean = (
|
|
|
135
146
|
return typeof sdkOptions === "boolean";
|
|
136
147
|
};
|
|
137
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Central executor for SDK transactions. Routes a (`to`, `data`, `txOptions`) tuple
|
|
151
|
+
* through one of four paths depending on `pool.isDhedge` and `sdkOptions`:
|
|
152
|
+
* - dHEDGE pool: `pool.poolLogic.execTransaction(...)` (or its gas estimate)
|
|
153
|
+
* - non-dHEDGE/EOA: `pool.signer.sendTransaction(...)` (or its gas estimate)
|
|
154
|
+
* Honours `sdkOptions.onlyGetTxData` (returns the encoded tx without sending),
|
|
155
|
+
* `estimateGas` (returns gas + minAmountOut without sending), and
|
|
156
|
+
* `useTraderAddressAsFrom` (forces the EOA path even for dHEDGE pools).
|
|
157
|
+
*/
|
|
138
158
|
export const getPoolTxOrGasEstimate = async (
|
|
139
159
|
pool: Pool,
|
|
140
160
|
args: any[],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const FUTURES_TRACKING = "DHEDGE";
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
|
-
export declare function getCreateVestTxData(amount: BigNumber | string): string;
|
|
3
|
-
export declare function getExitVestTxData(vestId: number): string;
|
|
4
|
-
export declare function getRewardsTxDta(tokenId: string, rewards: string[]): string;
|