@dhedge/v2-sdk 1.10.16 → 1.11.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/dist/entities/pool.d.ts +1 -1
- package/dist/services/uniswap/V3Liquidity.d.ts +1 -1
- package/dist/test/constants.d.ts +4 -4
- package/dist/test/wallet.d.ts +1 -1
- package/dist/types.d.ts +1 -2
- package/dist/v2-sdk.cjs.development.js +30 -1240
- 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 +30 -1240
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/config.ts +14 -17
- package/src/entities/pool.ts +48 -52
- package/src/services/uniswap/V3Liquidity.ts +5 -16
- package/src/test/constants.ts +6 -6
- package/src/test/oneInch.test.ts +16 -4
- package/src/test/wallet.ts +1 -1
- package/src/types.ts +1 -2
- package/src/abi/IShadowNonfungiblePositionManager.json +0 -697
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhedge/v2-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "🛠 An SDK for building applications on top of dHEDGE V2",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"fork:polygon": "hardhat node --port 8542 --fork $(grep POLYGON_URL .env | cut -d '=' -f2)",
|
|
24
24
|
"fork:optimism": "hardhat node --port 8544 --fork $(grep OPTIMISM_URL .env | cut -d '=' -f2)",
|
|
25
25
|
"fork:arbitrum": "hardhat node --port 8540 --fork $(grep ARBITRUM_URL .env | cut -d '=' -f2)",
|
|
26
|
-
"fork:base": "hardhat node --port 8546 --fork $(grep BASE_URL .env | cut -d '=' -f2)"
|
|
26
|
+
"fork:base": "hardhat node --port 8546 --fork $(grep BASE_URL .env | cut -d '=' -f2)",
|
|
27
|
+
"fork:ethereum": "hardhat node --port 8547 --fork $(grep ETHEREUM_URL .env | cut -d '=' -f2)"
|
|
27
28
|
},
|
|
28
29
|
"husky": {
|
|
29
30
|
"hooks": {
|
package/src/config.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const factoryAddress: AddressNetworkMap = {
|
|
|
18
18
|
[Network.OPTIMISM]: "0x5e61a079A178f0E5784107a4963baAe0c5a680c6",
|
|
19
19
|
[Network.ARBITRUM]: "0xfffb5fb14606eb3a548c113026355020ddf27535",
|
|
20
20
|
[Network.BASE]: "0x49Afe3abCf66CF09Fab86cb1139D8811C8afe56F",
|
|
21
|
-
[Network.
|
|
21
|
+
[Network.ETHEREUM]: "0x96D33bCF84DdE326014248E2896F79bbb9c13D6d"
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const routerAddress: AddressDappNetworkMap = {
|
|
@@ -65,10 +65,11 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
65
65
|
[Dapp.ODOS]: "0x19cEeAd7105607Cd444F5ad10dd51356436095a1",
|
|
66
66
|
[Dapp.PENDLE]: "0x888888888889758F76e7103c6CbF23ABbF58F946"
|
|
67
67
|
},
|
|
68
|
-
[Network.
|
|
69
|
-
[Dapp.AAVEV3]: "
|
|
70
|
-
[Dapp.ODOS]: "
|
|
71
|
-
[Dapp.PENDLE]: "0x888888888889758F76e7103c6CbF23ABbF58F946"
|
|
68
|
+
[Network.ETHEREUM]: {
|
|
69
|
+
[Dapp.AAVEV3]: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
|
|
70
|
+
[Dapp.ODOS]: "0xCf5540fFFCdC3d510B18bFcA6d2b9987b0772559",
|
|
71
|
+
[Dapp.PENDLE]: "0x888888888889758F76e7103c6CbF23ABbF58F946",
|
|
72
|
+
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65"
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
75
|
|
|
@@ -80,7 +81,7 @@ export const dappFactoryAddress: AddressDappNetworkMap = {
|
|
|
80
81
|
[Network.OPTIMISM]: {},
|
|
81
82
|
[Network.ARBITRUM]: {},
|
|
82
83
|
[Network.BASE]: {},
|
|
83
|
-
[Network.
|
|
84
|
+
[Network.ETHEREUM]: {}
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
export const stakingAddress: AddressDappNetworkMap = {
|
|
@@ -101,9 +102,7 @@ export const stakingAddress: AddressDappNetworkMap = {
|
|
|
101
102
|
[Network.BASE]: {
|
|
102
103
|
[Dapp.PANCAKECL]: "0xC6A2Db661D5a5690172d8eB0a7DEA2d3008665A3"
|
|
103
104
|
},
|
|
104
|
-
[Network.
|
|
105
|
-
[Dapp.SHADOWCL]: "0xe879d0E44e6873cf4ab71686055a4f6817685f02" //specific for wS/USDC CL
|
|
106
|
-
}
|
|
105
|
+
[Network.ETHEREUM]: {}
|
|
107
106
|
};
|
|
108
107
|
|
|
109
108
|
export const aaveAddressProvider: AddressDappNetworkMap = {
|
|
@@ -121,8 +120,8 @@ export const aaveAddressProvider: AddressDappNetworkMap = {
|
|
|
121
120
|
// https://docs.aave.com/developers/deployed-contracts/v3-mainnet/base
|
|
122
121
|
[Dapp.AAVEV3]: "0xe20fCBdBfFC4Dd138cE8b2E6FBb6CB49777ad64D"
|
|
123
122
|
},
|
|
124
|
-
[Network.
|
|
125
|
-
[Dapp.AAVEV3]: "
|
|
123
|
+
[Network.ETHEREUM]: {
|
|
124
|
+
[Dapp.AAVEV3]: "0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e"
|
|
126
125
|
}
|
|
127
126
|
};
|
|
128
127
|
export const nonfungiblePositionManagerAddress: AddressDappNetworkMap = {
|
|
@@ -143,9 +142,7 @@ export const nonfungiblePositionManagerAddress: AddressDappNetworkMap = {
|
|
|
143
142
|
[Dapp.AERODROMECL]: "0x827922686190790b37229fd06084350e74485b72",
|
|
144
143
|
[Dapp.PANCAKECL]: "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364"
|
|
145
144
|
},
|
|
146
|
-
[Network.
|
|
147
|
-
[Dapp.SHADOWCL]: "0x12e66c8f215ddd5d48d150c8f46ad0c6fb0f4406"
|
|
148
|
-
}
|
|
145
|
+
[Network.ETHEREUM]: {}
|
|
149
146
|
};
|
|
150
147
|
|
|
151
148
|
export const networkChainIdMap: NetworkChainIdMap = {
|
|
@@ -153,7 +150,7 @@ export const networkChainIdMap: NetworkChainIdMap = {
|
|
|
153
150
|
[Network.OPTIMISM]: 10,
|
|
154
151
|
[Network.ARBITRUM]: 42161,
|
|
155
152
|
[Network.BASE]: 8453,
|
|
156
|
-
[Network.
|
|
153
|
+
[Network.ETHEREUM]: 1
|
|
157
154
|
};
|
|
158
155
|
|
|
159
156
|
export const balancerSubgraph: AddressNetworkMap = {
|
|
@@ -162,7 +159,7 @@ export const balancerSubgraph: AddressNetworkMap = {
|
|
|
162
159
|
[Network.OPTIMISM]: "",
|
|
163
160
|
[Network.ARBITRUM]: "",
|
|
164
161
|
[Network.BASE]: "",
|
|
165
|
-
[Network.
|
|
162
|
+
[Network.ETHEREUM]: ""
|
|
166
163
|
};
|
|
167
164
|
|
|
168
165
|
export const multiCallAddress: AddressNetworkMap = {
|
|
@@ -170,7 +167,7 @@ export const multiCallAddress: AddressNetworkMap = {
|
|
|
170
167
|
[Network.OPTIMISM]: "",
|
|
171
168
|
[Network.ARBITRUM]: "",
|
|
172
169
|
[Network.BASE]: "",
|
|
173
|
-
[Network.
|
|
170
|
+
[Network.ETHEREUM]: ""
|
|
174
171
|
};
|
|
175
172
|
|
|
176
173
|
export const lyraNetworkMap: LyraNetworkMap = {
|
package/src/entities/pool.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
nonfungiblePositionManagerAddress,
|
|
20
20
|
routerAddress,
|
|
21
21
|
stakingAddress,
|
|
22
|
-
SYNTHETIX_TRACKING_CODE
|
|
22
|
+
SYNTHETIX_TRACKING_CODE
|
|
23
23
|
} from "../config";
|
|
24
24
|
import {
|
|
25
25
|
Dapp,
|
|
@@ -30,60 +30,60 @@ import {
|
|
|
30
30
|
LyraOptionMarket,
|
|
31
31
|
LyraOptionType,
|
|
32
32
|
LyraTradeType,
|
|
33
|
-
LyraPosition
|
|
33
|
+
LyraPosition
|
|
34
34
|
} from "../types";
|
|
35
35
|
|
|
36
36
|
import { Utils } from "./utils";
|
|
37
37
|
import {
|
|
38
38
|
getDecreaseLiquidityTxData,
|
|
39
39
|
getIncreaseLiquidityTxData,
|
|
40
|
-
getUniswapV3MintTxData
|
|
40
|
+
getUniswapV3MintTxData
|
|
41
41
|
} from "../services/uniswap/V3Liquidity";
|
|
42
42
|
import { getUniswapV3SwapTxData } from "../services/uniswap/V3Trade";
|
|
43
43
|
import {
|
|
44
44
|
getCompleteWithdrawalTxData,
|
|
45
|
-
getEasySwapperTxData
|
|
45
|
+
getEasySwapperTxData
|
|
46
46
|
} from "../services/toros/easySwapper";
|
|
47
47
|
import { getAaveV3ClaimTxData } from "../services/aave/incentives";
|
|
48
48
|
import {
|
|
49
49
|
getClOwner,
|
|
50
50
|
getVelodromeAddLiquidityTxData,
|
|
51
|
-
getVelodromeRemoveLiquidityTxData
|
|
51
|
+
getVelodromeRemoveLiquidityTxData
|
|
52
52
|
} from "../services/velodrome/liquidity";
|
|
53
53
|
import {
|
|
54
54
|
getVelodromeClaimTxData,
|
|
55
55
|
getVelodromeCLClaimTxData,
|
|
56
|
-
getVelodromeStakeTxData
|
|
56
|
+
getVelodromeStakeTxData
|
|
57
57
|
} from "../services/velodrome/staking";
|
|
58
58
|
import { getLyraOptionTxData } from "../services/lyra/trade";
|
|
59
59
|
import { getOptionPositions } from "../services/lyra/positions";
|
|
60
60
|
import { getDeadline } from "../utils/deadline";
|
|
61
61
|
import {
|
|
62
62
|
getFuturesChangePositionTxData,
|
|
63
|
-
getFuturesChangeMarginTxData
|
|
63
|
+
getFuturesChangeMarginTxData
|
|
64
64
|
} from "../services/futures";
|
|
65
65
|
import { getFuturesCancelOrderTxData } from "../services/futures/trade";
|
|
66
66
|
import { getOneInchSwapTxData } from "../services/oneInch";
|
|
67
67
|
import {
|
|
68
68
|
getCreateVestTxData,
|
|
69
69
|
getExitVestTxData,
|
|
70
|
-
getRewardsTxDta
|
|
70
|
+
getRewardsTxDta
|
|
71
71
|
} from "../services/ramses/vesting";
|
|
72
72
|
import { getPoolTxOrGasEstimate } from "../utils/contract";
|
|
73
73
|
import {
|
|
74
74
|
cancelOrderViaFlatMoney,
|
|
75
75
|
mintUnitViaFlatMoney,
|
|
76
|
-
redeemUnitViaFlatMoney
|
|
76
|
+
redeemUnitViaFlatMoney
|
|
77
77
|
} from "../services/flatmoney/stableLp";
|
|
78
78
|
import {
|
|
79
79
|
getCompoundV3LendTxData,
|
|
80
|
-
getCompoundV3WithdrawTxData
|
|
80
|
+
getCompoundV3WithdrawTxData
|
|
81
81
|
} from "../services/compound/lending";
|
|
82
82
|
import { getCompoundV3ClaimTxData } from "../services/compound/rewards";
|
|
83
83
|
import {
|
|
84
84
|
getPancakeHarvestClaimTxData,
|
|
85
85
|
getPancakeStakeTxData,
|
|
86
|
-
getPancakeUnStakeTxData
|
|
86
|
+
getPancakeUnStakeTxData
|
|
87
87
|
} from "../services/pancake/staking";
|
|
88
88
|
import { getOdosSwapTxData } from "../services/odos";
|
|
89
89
|
import { getPendleSwapTxData } from "../services/pendle";
|
|
@@ -131,7 +131,7 @@ export class Pool {
|
|
|
131
131
|
asset: asset,
|
|
132
132
|
isDeposit: isDeposit,
|
|
133
133
|
balance: result[1][index],
|
|
134
|
-
rate: result[2][index]
|
|
134
|
+
rate: result[2][index]
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
137
|
);
|
|
@@ -226,7 +226,7 @@ export class Pool {
|
|
|
226
226
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
227
227
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
228
228
|
routerAddress[this.network][dapp],
|
|
229
|
-
amount
|
|
229
|
+
amount
|
|
230
230
|
]);
|
|
231
231
|
const tx = await getPoolTxOrGasEstimate(
|
|
232
232
|
this,
|
|
@@ -255,7 +255,7 @@ export class Pool {
|
|
|
255
255
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
256
256
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
257
257
|
stakingAddress[this.network][dapp],
|
|
258
|
-
amount
|
|
258
|
+
amount
|
|
259
259
|
]);
|
|
260
260
|
const tx = await getPoolTxOrGasEstimate(
|
|
261
261
|
this,
|
|
@@ -283,7 +283,7 @@ export class Pool {
|
|
|
283
283
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
284
284
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
285
285
|
nonfungiblePositionManagerAddress[this.network][Dapp.UNISWAPV3],
|
|
286
|
-
amount
|
|
286
|
+
amount
|
|
287
287
|
]);
|
|
288
288
|
const tx = await getPoolTxOrGasEstimate(
|
|
289
289
|
this,
|
|
@@ -312,7 +312,7 @@ export class Pool {
|
|
|
312
312
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
313
313
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
314
314
|
spender,
|
|
315
|
-
amount
|
|
315
|
+
amount
|
|
316
316
|
]);
|
|
317
317
|
const tx = await getPoolTxOrGasEstimate(
|
|
318
318
|
this,
|
|
@@ -341,7 +341,7 @@ export class Pool {
|
|
|
341
341
|
const iERC721 = new ethers.utils.Interface(IERC721.abi);
|
|
342
342
|
const approveTxData = iERC721.encodeFunctionData("approve", [
|
|
343
343
|
spender,
|
|
344
|
-
tokenId
|
|
344
|
+
tokenId
|
|
345
345
|
]);
|
|
346
346
|
const tx = await getPoolTxOrGasEstimate(
|
|
347
347
|
this,
|
|
@@ -393,7 +393,7 @@ export class Pool {
|
|
|
393
393
|
break;
|
|
394
394
|
case Dapp.SYNTHETIX:
|
|
395
395
|
const iSynthetix = new ethers.utils.Interface(ISynthetix.abi);
|
|
396
|
-
const assets = [assetFrom, assetTo].map(
|
|
396
|
+
const assets = [assetFrom, assetTo].map(asset =>
|
|
397
397
|
ethers.utils.formatBytes32String(asset)
|
|
398
398
|
);
|
|
399
399
|
const daoAddress = await this.factory.owner();
|
|
@@ -402,7 +402,7 @@ export class Pool {
|
|
|
402
402
|
amountIn,
|
|
403
403
|
assets[1],
|
|
404
404
|
daoAddress,
|
|
405
|
-
SYNTHETIX_TRACKING_CODE
|
|
405
|
+
SYNTHETIX_TRACKING_CODE
|
|
406
406
|
]);
|
|
407
407
|
break;
|
|
408
408
|
case Dapp.TOROS:
|
|
@@ -448,7 +448,7 @@ export class Pool {
|
|
|
448
448
|
minAmountOut,
|
|
449
449
|
[assetFrom, assetTo],
|
|
450
450
|
this.address,
|
|
451
|
-
await getDeadline(this)
|
|
451
|
+
await getDeadline(this)
|
|
452
452
|
]);
|
|
453
453
|
}
|
|
454
454
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -490,7 +490,7 @@ export class Pool {
|
|
|
490
490
|
0,
|
|
491
491
|
0,
|
|
492
492
|
this.address,
|
|
493
|
-
await getDeadline(this)
|
|
493
|
+
await getDeadline(this)
|
|
494
494
|
]
|
|
495
495
|
);
|
|
496
496
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -553,7 +553,7 @@ export class Pool {
|
|
|
553
553
|
const stakeTxData = iMiniChefV2.encodeFunctionData(Transaction.DEPOSIT, [
|
|
554
554
|
poolId,
|
|
555
555
|
amount,
|
|
556
|
-
this.address
|
|
556
|
+
this.address
|
|
557
557
|
]);
|
|
558
558
|
const tx = await getPoolTxOrGasEstimate(
|
|
559
559
|
this,
|
|
@@ -586,7 +586,7 @@ export class Pool {
|
|
|
586
586
|
IBalancerRewardsGauge.abi
|
|
587
587
|
);
|
|
588
588
|
stakeTxData = rewardsGauge.encodeFunctionData("deposit(uint256)", [
|
|
589
|
-
amount
|
|
589
|
+
amount
|
|
590
590
|
]);
|
|
591
591
|
break;
|
|
592
592
|
case Dapp.VELODROME:
|
|
@@ -638,7 +638,7 @@ export class Pool {
|
|
|
638
638
|
const unStakeTxData = iMiniChefV2.encodeFunctionData(Transaction.WITHDRAW, [
|
|
639
639
|
poolId,
|
|
640
640
|
amount,
|
|
641
|
-
this.address
|
|
641
|
+
this.address
|
|
642
642
|
]);
|
|
643
643
|
const tx = await getPoolTxOrGasEstimate(
|
|
644
644
|
this,
|
|
@@ -671,7 +671,7 @@ export class Pool {
|
|
|
671
671
|
unstakeTxData = getPancakeUnStakeTxData(this, amount.toString());
|
|
672
672
|
} else {
|
|
673
673
|
unstakeTxData = rewardsGauge.encodeFunctionData("withdraw(uint256)", [
|
|
674
|
-
amount
|
|
674
|
+
amount
|
|
675
675
|
]);
|
|
676
676
|
}
|
|
677
677
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -705,7 +705,7 @@ export class Pool {
|
|
|
705
705
|
asset,
|
|
706
706
|
amount,
|
|
707
707
|
this.address,
|
|
708
|
-
referralCode
|
|
708
|
+
referralCode
|
|
709
709
|
]);
|
|
710
710
|
|
|
711
711
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -822,7 +822,7 @@ export class Pool {
|
|
|
822
822
|
amount,
|
|
823
823
|
2,
|
|
824
824
|
referralCode,
|
|
825
|
-
this.address
|
|
825
|
+
this.address
|
|
826
826
|
]);
|
|
827
827
|
const tx = await getPoolTxOrGasEstimate(
|
|
828
828
|
this,
|
|
@@ -853,7 +853,7 @@ export class Pool {
|
|
|
853
853
|
asset,
|
|
854
854
|
amount,
|
|
855
855
|
2,
|
|
856
|
-
this.address
|
|
856
|
+
this.address
|
|
857
857
|
]);
|
|
858
858
|
const tx = await getPoolTxOrGasEstimate(
|
|
859
859
|
this,
|
|
@@ -881,7 +881,7 @@ export class Pool {
|
|
|
881
881
|
const poolId = await this.utils.getLpPoolId(dapp, asset);
|
|
882
882
|
const harvestTxData = iMiniChefV2.encodeFunctionData(Transaction.HARVEST, [
|
|
883
883
|
poolId,
|
|
884
|
-
this.address
|
|
884
|
+
this.address
|
|
885
885
|
]);
|
|
886
886
|
const tx = await getPoolTxOrGasEstimate(
|
|
887
887
|
this,
|
|
@@ -904,12 +904,12 @@ export class Pool {
|
|
|
904
904
|
estimateGas = false
|
|
905
905
|
): Promise<any> {
|
|
906
906
|
const currentAssetsEnabled = await this.getComposition();
|
|
907
|
-
const currentAssets = currentAssetsEnabled.map(
|
|
907
|
+
const currentAssets = currentAssetsEnabled.map(e =>
|
|
908
908
|
e.asset.toLocaleLowerCase()
|
|
909
909
|
);
|
|
910
|
-
const newAssets = assets.map(
|
|
911
|
-
const removedAssets = currentAssets.filter(
|
|
912
|
-
const changedAssets = assets.map(
|
|
910
|
+
const newAssets = assets.map(e => e.asset.toLocaleLowerCase());
|
|
911
|
+
const removedAssets = currentAssets.filter(e => !newAssets.includes(e));
|
|
912
|
+
const changedAssets = assets.map(e => [e.asset, e.isDeposit]);
|
|
913
913
|
|
|
914
914
|
if (estimateGas) {
|
|
915
915
|
return await this.managerLogic.estimateGas.changeAssets(
|
|
@@ -1066,7 +1066,7 @@ export class Pool {
|
|
|
1066
1066
|
[
|
|
1067
1067
|
stakingAddress[this.network][Dapp.AAVEV3] as string,
|
|
1068
1068
|
claimTxData,
|
|
1069
|
-
options
|
|
1069
|
+
options
|
|
1070
1070
|
],
|
|
1071
1071
|
estimateGas
|
|
1072
1072
|
);
|
|
@@ -1091,7 +1091,7 @@ export class Pool {
|
|
|
1091
1091
|
[
|
|
1092
1092
|
stakingAddress[this.network][Dapp.COMPOUNDV3] as string,
|
|
1093
1093
|
claimTxData,
|
|
1094
|
-
options
|
|
1094
|
+
options
|
|
1095
1095
|
],
|
|
1096
1096
|
estimateGas
|
|
1097
1097
|
);
|
|
@@ -1120,8 +1120,7 @@ export class Pool {
|
|
|
1120
1120
|
| Dapp.VELODROMECL
|
|
1121
1121
|
| Dapp.AERODROMECL
|
|
1122
1122
|
| Dapp.RAMSESCL
|
|
1123
|
-
| Dapp.PANCAKECL
|
|
1124
|
-
| Dapp.SHADOWCL,
|
|
1123
|
+
| Dapp.PANCAKECL,
|
|
1125
1124
|
assetA: string,
|
|
1126
1125
|
assetB: string,
|
|
1127
1126
|
amountA: BigNumber | string,
|
|
@@ -1161,7 +1160,7 @@ export class Pool {
|
|
|
1161
1160
|
[
|
|
1162
1161
|
nonfungiblePositionManagerAddress[this.network][dapp],
|
|
1163
1162
|
mintTxData,
|
|
1164
|
-
options
|
|
1163
|
+
options
|
|
1165
1164
|
],
|
|
1166
1165
|
estimateGas
|
|
1167
1166
|
);
|
|
@@ -1190,7 +1189,6 @@ export class Pool {
|
|
|
1190
1189
|
switch (dapp) {
|
|
1191
1190
|
case Dapp.UNISWAPV3:
|
|
1192
1191
|
case Dapp.RAMSESCL:
|
|
1193
|
-
case Dapp.SHADOWCL:
|
|
1194
1192
|
dappAddress = nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1195
1193
|
break;
|
|
1196
1194
|
case Dapp.VELODROMECL:
|
|
@@ -1256,7 +1254,6 @@ export class Pool {
|
|
|
1256
1254
|
switch (dapp) {
|
|
1257
1255
|
case Dapp.UNISWAPV3:
|
|
1258
1256
|
case Dapp.RAMSESCL:
|
|
1259
|
-
case Dapp.SHADOWCL:
|
|
1260
1257
|
dappAddress = nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1261
1258
|
break;
|
|
1262
1259
|
case Dapp.VELODROMECL:
|
|
@@ -1321,7 +1318,6 @@ export class Pool {
|
|
|
1321
1318
|
switch (dapp) {
|
|
1322
1319
|
case Dapp.UNISWAPV3:
|
|
1323
1320
|
case Dapp.RAMSESCL:
|
|
1324
|
-
case Dapp.SHADOWCL:
|
|
1325
1321
|
contractAddress = nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1326
1322
|
txData = iNonfungiblePositionManager.encodeFunctionData(
|
|
1327
1323
|
Transaction.COLLECT,
|
|
@@ -1392,13 +1388,13 @@ export class Pool {
|
|
|
1392
1388
|
options: any = null,
|
|
1393
1389
|
estimateGas = false
|
|
1394
1390
|
): Promise<any> {
|
|
1395
|
-
const claimAddress =
|
|
1396
|
-
dapp === Dapp.SHADOWCL
|
|
1397
|
-
? stakingAddress[this.network][dapp] //specific for wS/USDC CL
|
|
1398
|
-
: nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1399
1391
|
const tx = await getPoolTxOrGasEstimate(
|
|
1400
1392
|
this,
|
|
1401
|
-
[
|
|
1393
|
+
[
|
|
1394
|
+
nonfungiblePositionManagerAddress[this.network][dapp],
|
|
1395
|
+
getRewardsTxDta(tokenId, rewards),
|
|
1396
|
+
options
|
|
1397
|
+
],
|
|
1402
1398
|
estimateGas
|
|
1403
1399
|
);
|
|
1404
1400
|
return tx;
|
|
@@ -1473,7 +1469,7 @@ export class Pool {
|
|
|
1473
1469
|
amountB,
|
|
1474
1470
|
isStable
|
|
1475
1471
|
),
|
|
1476
|
-
options
|
|
1472
|
+
options
|
|
1477
1473
|
],
|
|
1478
1474
|
estimateGas
|
|
1479
1475
|
);
|
|
@@ -1509,7 +1505,7 @@ export class Pool {
|
|
|
1509
1505
|
amount,
|
|
1510
1506
|
isStable
|
|
1511
1507
|
),
|
|
1512
|
-
options
|
|
1508
|
+
options
|
|
1513
1509
|
],
|
|
1514
1510
|
estimateGas
|
|
1515
1511
|
);
|
|
@@ -1548,7 +1544,7 @@ export class Pool {
|
|
|
1548
1544
|
amountB,
|
|
1549
1545
|
isStable
|
|
1550
1546
|
),
|
|
1551
|
-
options
|
|
1547
|
+
options
|
|
1552
1548
|
],
|
|
1553
1549
|
estimateGas
|
|
1554
1550
|
);
|
|
@@ -1584,7 +1580,7 @@ export class Pool {
|
|
|
1584
1580
|
amount,
|
|
1585
1581
|
isStable
|
|
1586
1582
|
),
|
|
1587
|
-
options
|
|
1583
|
+
options
|
|
1588
1584
|
],
|
|
1589
1585
|
estimateGas
|
|
1590
1586
|
);
|
|
@@ -1625,7 +1621,7 @@ export class Pool {
|
|
|
1625
1621
|
amountB,
|
|
1626
1622
|
isStable
|
|
1627
1623
|
),
|
|
1628
|
-
options
|
|
1624
|
+
options
|
|
1629
1625
|
],
|
|
1630
1626
|
estimateGas
|
|
1631
1627
|
);
|
|
@@ -1663,7 +1659,7 @@ export class Pool {
|
|
|
1663
1659
|
amount,
|
|
1664
1660
|
isStable
|
|
1665
1661
|
),
|
|
1666
|
-
options
|
|
1662
|
+
options
|
|
1667
1663
|
],
|
|
1668
1664
|
estimateGas
|
|
1669
1665
|
);
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
} from "../../config";
|
|
20
20
|
import INonfungiblePositionManager from "../../abi/INonfungiblePositionManager.json";
|
|
21
21
|
import IVeldodromePositionManager from "../../abi/IVelodromeNonfungiblePositionManager.json";
|
|
22
|
-
import IShadowNonfungiblePositionManager from "../../abi/IShadowNonfungiblePositionManager.json";
|
|
23
22
|
import IRamsesPositionManager from "../../abi/IRamsesNonfungiblePositionManager.json";
|
|
24
23
|
import IArrakisV1RouterStaking from "../../abi/IArrakisV1RouterStaking.json";
|
|
25
24
|
import IPancakeMasterChef from "../../abi/IPancakeMasterChefV3.json";
|
|
@@ -78,8 +77,8 @@ export async function getUniswapV3MintTxData(
|
|
|
78
77
|
| Dapp.VELODROMECL
|
|
79
78
|
| Dapp.AERODROMECL
|
|
80
79
|
| Dapp.RAMSESCL
|
|
81
|
-
| Dapp.PANCAKECL
|
|
82
|
-
|
|
80
|
+
| Dapp.PANCAKECL,
|
|
81
|
+
|
|
83
82
|
pool: Pool,
|
|
84
83
|
assetA: string,
|
|
85
84
|
assetB: string,
|
|
@@ -170,12 +169,6 @@ export async function getUniswapV3MintTxData(
|
|
|
170
169
|
mintParams.push(0);
|
|
171
170
|
}
|
|
172
171
|
|
|
173
|
-
if (dapp === Dapp.SHADOWCL) {
|
|
174
|
-
iNonfungiblePositionManager = new ethers.utils.Interface(
|
|
175
|
-
IShadowNonfungiblePositionManager
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
172
|
return iNonfungiblePositionManager.encodeFunctionData(Transaction.MINT, [
|
|
180
173
|
mintParams
|
|
181
174
|
]);
|
|
@@ -196,9 +189,7 @@ export async function getUniswapV3Liquidity(
|
|
|
196
189
|
const iNonfungiblePositionManager = new ethers.Contract(
|
|
197
190
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
198
191
|
nonfungiblePositionManagerAddress[pool.network][dapp]!,
|
|
199
|
-
|
|
200
|
-
? IShadowNonfungiblePositionManager
|
|
201
|
-
: INonfungiblePositionManager.abi,
|
|
192
|
+
INonfungiblePositionManager.abi,
|
|
202
193
|
pool.signer
|
|
203
194
|
);
|
|
204
195
|
const result = await iNonfungiblePositionManager.positions(tokenId);
|
|
@@ -218,8 +209,7 @@ export async function getIncreaseLiquidityTxData(
|
|
|
218
209
|
dapp === Dapp.VELODROMECL ||
|
|
219
210
|
dapp === Dapp.AERODROMECL ||
|
|
220
211
|
dapp === Dapp.RAMSESCL ||
|
|
221
|
-
dapp === Dapp.PANCAKECL
|
|
222
|
-
dapp === Dapp.SHADOWCL
|
|
212
|
+
dapp === Dapp.PANCAKECL
|
|
223
213
|
) {
|
|
224
214
|
const abi = new ethers.utils.Interface(INonfungiblePositionManager.abi);
|
|
225
215
|
txData = abi.encodeFunctionData(Transaction.INCREASE_LIQUIDITY, [
|
|
@@ -256,8 +246,7 @@ export async function getDecreaseLiquidityTxData(
|
|
|
256
246
|
dapp === Dapp.VELODROMECL ||
|
|
257
247
|
dapp === Dapp.AERODROMECL ||
|
|
258
248
|
dapp === Dapp.RAMSESCL ||
|
|
259
|
-
dapp === Dapp.PANCAKECL
|
|
260
|
-
dapp === Dapp.SHADOWCL
|
|
249
|
+
dapp === Dapp.PANCAKECL
|
|
261
250
|
) {
|
|
262
251
|
const abi = new ethers.utils.Interface(INonfungiblePositionManager.abi);
|
|
263
252
|
const liquidity = (await getUniswapV3Liquidity(dapp, tokenId, pool))
|
package/src/test/constants.ts
CHANGED
|
@@ -43,7 +43,7 @@ export const TEST_POOL = {
|
|
|
43
43
|
[Network.OPTIMISM]: "0x12573bfdf764ab9d52aca20e2827497a66829716",
|
|
44
44
|
[Network.ARBITRUM]: "0x0b5f6591c8eb23e5a68102d3d39ebbb464ee5c14",
|
|
45
45
|
[Network.BASE]: "0x4842b42F68524383F609aa46eAfc18c1459cE3cD",
|
|
46
|
-
[Network.
|
|
46
|
+
[Network.ETHEREUM]: "0xe8e74f664d2d6a919a18b911990db0979789b6f7"
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
export const CONTRACT_ADDRESS = {
|
|
@@ -135,11 +135,11 @@ export const CONTRACT_ADDRESS = {
|
|
|
135
135
|
COMPOUNDV3_WETH: "",
|
|
136
136
|
TOROS: ""
|
|
137
137
|
},
|
|
138
|
-
[Network.
|
|
139
|
-
USDC: "
|
|
138
|
+
[Network.ETHEREUM]: {
|
|
139
|
+
USDC: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
140
140
|
USDT: "",
|
|
141
141
|
SUSD: "",
|
|
142
|
-
WETH: "
|
|
142
|
+
WETH: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
143
143
|
WBTC: "",
|
|
144
144
|
SWETH: "",
|
|
145
145
|
uniswapV3: {
|
|
@@ -164,7 +164,7 @@ export const USDC_BALANCEOF_SLOT = {
|
|
|
164
164
|
[Network.ARBITRUM]: 9,
|
|
165
165
|
[Network.POLYGON]: 0,
|
|
166
166
|
[Network.BASE]: 9,
|
|
167
|
-
[Network.
|
|
167
|
+
[Network.ETHEREUM]: 9
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
export const WETH_BALANCEOF_SLOT = {
|
|
@@ -172,5 +172,5 @@ export const WETH_BALANCEOF_SLOT = {
|
|
|
172
172
|
[Network.ARBITRUM]: 51,
|
|
173
173
|
[Network.POLYGON]: 0,
|
|
174
174
|
[Network.BASE]: 0,
|
|
175
|
-
[Network.
|
|
175
|
+
[Network.ETHEREUM]: 3
|
|
176
176
|
};
|
package/src/test/oneInch.test.ts
CHANGED
|
@@ -34,6 +34,13 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
|
|
|
34
34
|
"0x10000000000000000"
|
|
35
35
|
]);
|
|
36
36
|
await provider.send("evm_mine", []);
|
|
37
|
+
|
|
38
|
+
const newAssets = [
|
|
39
|
+
{ asset: USDC, isDeposit: true },
|
|
40
|
+
{ asset: WETH, isDeposit: true }
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
await pool.managerLogic.changeAssets(newAssets, []);
|
|
37
44
|
// top up USDC
|
|
38
45
|
await setUSDCAmount({
|
|
39
46
|
amount: new BigNumber(2).times(1e6).toFixed(0),
|
|
@@ -104,10 +111,10 @@ const testOneInch = ({ wallet, network, provider }: TestingRunParams) => {
|
|
|
104
111
|
});
|
|
105
112
|
};
|
|
106
113
|
|
|
107
|
-
testingHelper({
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
114
|
+
// testingHelper({
|
|
115
|
+
// network: Network.OPTIMISM,
|
|
116
|
+
// testingRun: testOneInch
|
|
117
|
+
// });
|
|
111
118
|
|
|
112
119
|
// testingHelper({
|
|
113
120
|
// network: Network.POLYGON,
|
|
@@ -120,3 +127,8 @@ testingHelper({
|
|
|
120
127
|
// onFork: false,
|
|
121
128
|
// testingRun: testOneInch
|
|
122
129
|
// });
|
|
130
|
+
|
|
131
|
+
testingHelper({
|
|
132
|
+
network: Network.ETHEREUM,
|
|
133
|
+
testingRun: testOneInch
|
|
134
|
+
});
|
package/src/test/wallet.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -6,7 +6,7 @@ export enum Network {
|
|
|
6
6
|
OPTIMISM = "optimism",
|
|
7
7
|
ARBITRUM = "arbitrum",
|
|
8
8
|
BASE = "base",
|
|
9
|
-
|
|
9
|
+
ETHEREUM = "ethereum"
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export enum Dapp {
|
|
@@ -31,7 +31,6 @@ export enum Dapp {
|
|
|
31
31
|
PANCAKECL = "pancakeCL",
|
|
32
32
|
COMPOUNDV3 = "compoundV3",
|
|
33
33
|
ODOS = "odos",
|
|
34
|
-
SHADOWCL = "shadowCL",
|
|
35
34
|
PENDLE = "pendle"
|
|
36
35
|
}
|
|
37
36
|
|