@dhedge/v2-sdk 1.10.15 → 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/pendle/index.d.ts +4 -0
- 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 +2 -2
- package/dist/v2-sdk.cjs.development.js +388 -1254
- 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 +388 -1254
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/abi/pendle/ActionMiscV3.json +122 -0
- package/src/config.ts +28 -20
- package/src/entities/pool.ts +58 -52
- package/src/services/pendle/index.ts +141 -0
- 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/pendle.test.ts +132 -0
- package/src/test/wallet.ts +1 -1
- package/src/types.ts +2 -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": {
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"inputs": [
|
|
4
|
+
{
|
|
5
|
+
"internalType": "address",
|
|
6
|
+
"name": "receiver",
|
|
7
|
+
"type": "address"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"internalType": "address",
|
|
11
|
+
"name": "market",
|
|
12
|
+
"type": "address"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"internalType": "uint256",
|
|
16
|
+
"name": "netPtIn",
|
|
17
|
+
"type": "uint256"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"internalType": "uint256",
|
|
21
|
+
"name": "netLpIn",
|
|
22
|
+
"type": "uint256"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"components": [
|
|
26
|
+
{
|
|
27
|
+
"internalType": "address",
|
|
28
|
+
"name": "tokenOut",
|
|
29
|
+
"type": "address"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"internalType": "uint256",
|
|
33
|
+
"name": "minTokenOut",
|
|
34
|
+
"type": "uint256"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"internalType": "address",
|
|
38
|
+
"name": "tokenRedeemSy",
|
|
39
|
+
"type": "address"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"internalType": "address",
|
|
43
|
+
"name": "pendleSwap",
|
|
44
|
+
"type": "address"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"components": [
|
|
48
|
+
{
|
|
49
|
+
"internalType": "enum SwapType",
|
|
50
|
+
"name": "swapType",
|
|
51
|
+
"type": "uint8"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"internalType": "address",
|
|
55
|
+
"name": "extRouter",
|
|
56
|
+
"type": "address"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"internalType": "bytes",
|
|
60
|
+
"name": "extCalldata",
|
|
61
|
+
"type": "bytes"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"internalType": "bool",
|
|
65
|
+
"name": "needScale",
|
|
66
|
+
"type": "bool"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"internalType": "struct SwapData",
|
|
70
|
+
"name": "swapData",
|
|
71
|
+
"type": "tuple"
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"internalType": "struct TokenOutput",
|
|
75
|
+
"name": "output",
|
|
76
|
+
"type": "tuple"
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"name": "exitPostExpToToken",
|
|
80
|
+
"outputs": [
|
|
81
|
+
{
|
|
82
|
+
"internalType": "uint256",
|
|
83
|
+
"name": "totalTokenOut",
|
|
84
|
+
"type": "uint256"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"components": [
|
|
88
|
+
{
|
|
89
|
+
"internalType": "uint256",
|
|
90
|
+
"name": "netPtFromRemove",
|
|
91
|
+
"type": "uint256"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"internalType": "uint256",
|
|
95
|
+
"name": "netSyFromRemove",
|
|
96
|
+
"type": "uint256"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"internalType": "uint256",
|
|
100
|
+
"name": "netPtRedeem",
|
|
101
|
+
"type": "uint256"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"internalType": "uint256",
|
|
105
|
+
"name": "netSyFromRedeem",
|
|
106
|
+
"type": "uint256"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"internalType": "uint256",
|
|
110
|
+
"name": "totalSyOut",
|
|
111
|
+
"type": "uint256"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"internalType": "struct IPActionMiscV3.ExitPostExpReturnParams",
|
|
115
|
+
"name": "params",
|
|
116
|
+
"type": "tuple"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"stateMutability": "nonpayable",
|
|
120
|
+
"type": "function"
|
|
121
|
+
}
|
|
122
|
+
]
|
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 = {
|
|
@@ -44,7 +44,8 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
44
44
|
[Dapp.VELODROMEV2]: "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858",
|
|
45
45
|
[Dapp.LYRA]: "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B",
|
|
46
46
|
[Dapp.ARRAKIS]: "0x9ce88a56d120300061593eF7AD074A1B710094d5",
|
|
47
|
-
[Dapp.ODOS]: "0xca423977156bb05b13a2ba3b76bc5419e2fe9680"
|
|
47
|
+
[Dapp.ODOS]: "0xca423977156bb05b13a2ba3b76bc5419e2fe9680",
|
|
48
|
+
[Dapp.PENDLE]: "0x888888888889758F76e7103c6CbF23ABbF58F946"
|
|
48
49
|
},
|
|
49
50
|
[Network.ARBITRUM]: {
|
|
50
51
|
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65",
|
|
@@ -53,18 +54,22 @@ export const routerAddress: AddressDappNetworkMap = {
|
|
|
53
54
|
[Dapp.BALANCER]: "0xBA12222222228d8Ba445958a75a0704d566BF2C8",
|
|
54
55
|
[Dapp.RAMSES]: "0xaaa87963efeb6f7e0a2711f397663105acb1805e",
|
|
55
56
|
[Dapp.TOROS]: "0xA5679C4272A056Bb83f039961fae7D99C48529F5",
|
|
56
|
-
[Dapp.ODOS]: "0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13"
|
|
57
|
+
[Dapp.ODOS]: "0xa669e7A0d4b3e4Fa48af2dE86BD4CD7126Be4e13",
|
|
58
|
+
[Dapp.PENDLE]: "0x888888888889758F76e7103c6CbF23ABbF58F946"
|
|
57
59
|
},
|
|
58
60
|
[Network.BASE]: {
|
|
59
61
|
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65",
|
|
60
62
|
[Dapp.AERODROME]: "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43",
|
|
61
63
|
[Dapp.AAVEV3]: "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5",
|
|
62
64
|
[Dapp.TOROS]: "0xf067575Eb60c7587C11e867907AA7284833704d1",
|
|
63
|
-
[Dapp.ODOS]: "0x19cEeAd7105607Cd444F5ad10dd51356436095a1"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
[Dapp.
|
|
65
|
+
[Dapp.ODOS]: "0x19cEeAd7105607Cd444F5ad10dd51356436095a1",
|
|
66
|
+
[Dapp.PENDLE]: "0x888888888889758F76e7103c6CbF23ABbF58F946"
|
|
67
|
+
},
|
|
68
|
+
[Network.ETHEREUM]: {
|
|
69
|
+
[Dapp.AAVEV3]: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
|
|
70
|
+
[Dapp.ODOS]: "0xCf5540fFFCdC3d510B18bFcA6d2b9987b0772559",
|
|
71
|
+
[Dapp.PENDLE]: "0x888888888889758F76e7103c6CbF23ABbF58F946",
|
|
72
|
+
[Dapp.ONEINCH]: "0x111111125421ca6dc452d289314280a0f8842a65"
|
|
68
73
|
}
|
|
69
74
|
};
|
|
70
75
|
|
|
@@ -76,7 +81,7 @@ export const dappFactoryAddress: AddressDappNetworkMap = {
|
|
|
76
81
|
[Network.OPTIMISM]: {},
|
|
77
82
|
[Network.ARBITRUM]: {},
|
|
78
83
|
[Network.BASE]: {},
|
|
79
|
-
[Network.
|
|
84
|
+
[Network.ETHEREUM]: {}
|
|
80
85
|
};
|
|
81
86
|
|
|
82
87
|
export const stakingAddress: AddressDappNetworkMap = {
|
|
@@ -97,9 +102,7 @@ export const stakingAddress: AddressDappNetworkMap = {
|
|
|
97
102
|
[Network.BASE]: {
|
|
98
103
|
[Dapp.PANCAKECL]: "0xC6A2Db661D5a5690172d8eB0a7DEA2d3008665A3"
|
|
99
104
|
},
|
|
100
|
-
[Network.
|
|
101
|
-
[Dapp.SHADOWCL]: "0xe879d0E44e6873cf4ab71686055a4f6817685f02" //specific for wS/USDC CL
|
|
102
|
-
}
|
|
105
|
+
[Network.ETHEREUM]: {}
|
|
103
106
|
};
|
|
104
107
|
|
|
105
108
|
export const aaveAddressProvider: AddressDappNetworkMap = {
|
|
@@ -117,8 +120,8 @@ export const aaveAddressProvider: AddressDappNetworkMap = {
|
|
|
117
120
|
// https://docs.aave.com/developers/deployed-contracts/v3-mainnet/base
|
|
118
121
|
[Dapp.AAVEV3]: "0xe20fCBdBfFC4Dd138cE8b2E6FBb6CB49777ad64D"
|
|
119
122
|
},
|
|
120
|
-
[Network.
|
|
121
|
-
[Dapp.AAVEV3]: "
|
|
123
|
+
[Network.ETHEREUM]: {
|
|
124
|
+
[Dapp.AAVEV3]: "0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e"
|
|
122
125
|
}
|
|
123
126
|
};
|
|
124
127
|
export const nonfungiblePositionManagerAddress: AddressDappNetworkMap = {
|
|
@@ -139,9 +142,7 @@ export const nonfungiblePositionManagerAddress: AddressDappNetworkMap = {
|
|
|
139
142
|
[Dapp.AERODROMECL]: "0x827922686190790b37229fd06084350e74485b72",
|
|
140
143
|
[Dapp.PANCAKECL]: "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364"
|
|
141
144
|
},
|
|
142
|
-
[Network.
|
|
143
|
-
[Dapp.SHADOWCL]: "0x12e66c8f215ddd5d48d150c8f46ad0c6fb0f4406"
|
|
144
|
-
}
|
|
145
|
+
[Network.ETHEREUM]: {}
|
|
145
146
|
};
|
|
146
147
|
|
|
147
148
|
export const networkChainIdMap: NetworkChainIdMap = {
|
|
@@ -149,7 +150,7 @@ export const networkChainIdMap: NetworkChainIdMap = {
|
|
|
149
150
|
[Network.OPTIMISM]: 10,
|
|
150
151
|
[Network.ARBITRUM]: 42161,
|
|
151
152
|
[Network.BASE]: 8453,
|
|
152
|
-
[Network.
|
|
153
|
+
[Network.ETHEREUM]: 1
|
|
153
154
|
};
|
|
154
155
|
|
|
155
156
|
export const balancerSubgraph: AddressNetworkMap = {
|
|
@@ -158,7 +159,7 @@ export const balancerSubgraph: AddressNetworkMap = {
|
|
|
158
159
|
[Network.OPTIMISM]: "",
|
|
159
160
|
[Network.ARBITRUM]: "",
|
|
160
161
|
[Network.BASE]: "",
|
|
161
|
-
[Network.
|
|
162
|
+
[Network.ETHEREUM]: ""
|
|
162
163
|
};
|
|
163
164
|
|
|
164
165
|
export const multiCallAddress: AddressNetworkMap = {
|
|
@@ -166,7 +167,7 @@ export const multiCallAddress: AddressNetworkMap = {
|
|
|
166
167
|
[Network.OPTIMISM]: "",
|
|
167
168
|
[Network.ARBITRUM]: "",
|
|
168
169
|
[Network.BASE]: "",
|
|
169
|
-
[Network.
|
|
170
|
+
[Network.ETHEREUM]: ""
|
|
170
171
|
};
|
|
171
172
|
|
|
172
173
|
export const lyraNetworkMap: LyraNetworkMap = {
|
|
@@ -204,5 +205,12 @@ export const flatMoneyContractAddresses: Readonly<Partial<
|
|
|
204
205
|
FlatcoinVault: "0x86C7b9640302082B0dF78023F930d8612bFcaD3f",
|
|
205
206
|
COLLATERAL: "0x68f180fcCe6836688e9084f035309E29Bf0A2095", // WBTC
|
|
206
207
|
StableModule: "0x357CB23571EF7a3d6189b7FAcFC361eA71f7CAB5"
|
|
208
|
+
},
|
|
209
|
+
[Network.ARBITRUM]: {
|
|
210
|
+
OrderExecution: "0x7e50AD6E467D9FAFC3B4BFd003247cEaA2F17e5b",
|
|
211
|
+
DelayedOrder: "0x2326BB21B769D81E134C9b305ca156f989249fE7", // OrderAnnouncementModule
|
|
212
|
+
FlatcoinVault: "0x29fAD9d44C550e5D8081AB35763797B39d75b858",
|
|
213
|
+
COLLATERAL: "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f", // WBTC
|
|
214
|
+
StableModule: "0xcD3657cB0E851b6a734c4D1e7FC2640Bcd9f6B2d"
|
|
207
215
|
}
|
|
208
216
|
};
|
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,62 +30,63 @@ 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
|
+
import { getPendleSwapTxData } from "../services/pendle";
|
|
89
90
|
|
|
90
91
|
export class Pool {
|
|
91
92
|
public readonly poolLogic: Contract;
|
|
@@ -130,7 +131,7 @@ export class Pool {
|
|
|
130
131
|
asset: asset,
|
|
131
132
|
isDeposit: isDeposit,
|
|
132
133
|
balance: result[1][index],
|
|
133
|
-
rate: result[2][index]
|
|
134
|
+
rate: result[2][index]
|
|
134
135
|
};
|
|
135
136
|
}
|
|
136
137
|
);
|
|
@@ -225,7 +226,7 @@ export class Pool {
|
|
|
225
226
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
226
227
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
227
228
|
routerAddress[this.network][dapp],
|
|
228
|
-
amount
|
|
229
|
+
amount
|
|
229
230
|
]);
|
|
230
231
|
const tx = await getPoolTxOrGasEstimate(
|
|
231
232
|
this,
|
|
@@ -254,7 +255,7 @@ export class Pool {
|
|
|
254
255
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
255
256
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
256
257
|
stakingAddress[this.network][dapp],
|
|
257
|
-
amount
|
|
258
|
+
amount
|
|
258
259
|
]);
|
|
259
260
|
const tx = await getPoolTxOrGasEstimate(
|
|
260
261
|
this,
|
|
@@ -282,7 +283,7 @@ export class Pool {
|
|
|
282
283
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
283
284
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
284
285
|
nonfungiblePositionManagerAddress[this.network][Dapp.UNISWAPV3],
|
|
285
|
-
amount
|
|
286
|
+
amount
|
|
286
287
|
]);
|
|
287
288
|
const tx = await getPoolTxOrGasEstimate(
|
|
288
289
|
this,
|
|
@@ -311,7 +312,7 @@ export class Pool {
|
|
|
311
312
|
const iERC20 = new ethers.utils.Interface(IERC20.abi);
|
|
312
313
|
const approveTxData = iERC20.encodeFunctionData("approve", [
|
|
313
314
|
spender,
|
|
314
|
-
amount
|
|
315
|
+
amount
|
|
315
316
|
]);
|
|
316
317
|
const tx = await getPoolTxOrGasEstimate(
|
|
317
318
|
this,
|
|
@@ -340,7 +341,7 @@ export class Pool {
|
|
|
340
341
|
const iERC721 = new ethers.utils.Interface(IERC721.abi);
|
|
341
342
|
const approveTxData = iERC721.encodeFunctionData("approve", [
|
|
342
343
|
spender,
|
|
343
|
-
tokenId
|
|
344
|
+
tokenId
|
|
344
345
|
]);
|
|
345
346
|
const tx = await getPoolTxOrGasEstimate(
|
|
346
347
|
this,
|
|
@@ -392,7 +393,7 @@ export class Pool {
|
|
|
392
393
|
break;
|
|
393
394
|
case Dapp.SYNTHETIX:
|
|
394
395
|
const iSynthetix = new ethers.utils.Interface(ISynthetix.abi);
|
|
395
|
-
const assets = [assetFrom, assetTo].map(
|
|
396
|
+
const assets = [assetFrom, assetTo].map(asset =>
|
|
396
397
|
ethers.utils.formatBytes32String(asset)
|
|
397
398
|
);
|
|
398
399
|
const daoAddress = await this.factory.owner();
|
|
@@ -401,7 +402,7 @@ export class Pool {
|
|
|
401
402
|
amountIn,
|
|
402
403
|
assets[1],
|
|
403
404
|
daoAddress,
|
|
404
|
-
SYNTHETIX_TRACKING_CODE
|
|
405
|
+
SYNTHETIX_TRACKING_CODE
|
|
405
406
|
]);
|
|
406
407
|
break;
|
|
407
408
|
case Dapp.TOROS:
|
|
@@ -422,6 +423,15 @@ export class Pool {
|
|
|
422
423
|
slippage
|
|
423
424
|
);
|
|
424
425
|
break;
|
|
426
|
+
case Dapp.PENDLE:
|
|
427
|
+
swapTxData = await getPendleSwapTxData(
|
|
428
|
+
this,
|
|
429
|
+
assetFrom,
|
|
430
|
+
assetTo,
|
|
431
|
+
amountIn,
|
|
432
|
+
slippage
|
|
433
|
+
);
|
|
434
|
+
break;
|
|
425
435
|
default:
|
|
426
436
|
const iUniswapV2Router = new ethers.utils.Interface(
|
|
427
437
|
IUniswapV2Router.abi
|
|
@@ -438,7 +448,7 @@ export class Pool {
|
|
|
438
448
|
minAmountOut,
|
|
439
449
|
[assetFrom, assetTo],
|
|
440
450
|
this.address,
|
|
441
|
-
await getDeadline(this)
|
|
451
|
+
await getDeadline(this)
|
|
442
452
|
]);
|
|
443
453
|
}
|
|
444
454
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -480,7 +490,7 @@ export class Pool {
|
|
|
480
490
|
0,
|
|
481
491
|
0,
|
|
482
492
|
this.address,
|
|
483
|
-
await getDeadline(this)
|
|
493
|
+
await getDeadline(this)
|
|
484
494
|
]
|
|
485
495
|
);
|
|
486
496
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -543,7 +553,7 @@ export class Pool {
|
|
|
543
553
|
const stakeTxData = iMiniChefV2.encodeFunctionData(Transaction.DEPOSIT, [
|
|
544
554
|
poolId,
|
|
545
555
|
amount,
|
|
546
|
-
this.address
|
|
556
|
+
this.address
|
|
547
557
|
]);
|
|
548
558
|
const tx = await getPoolTxOrGasEstimate(
|
|
549
559
|
this,
|
|
@@ -576,7 +586,7 @@ export class Pool {
|
|
|
576
586
|
IBalancerRewardsGauge.abi
|
|
577
587
|
);
|
|
578
588
|
stakeTxData = rewardsGauge.encodeFunctionData("deposit(uint256)", [
|
|
579
|
-
amount
|
|
589
|
+
amount
|
|
580
590
|
]);
|
|
581
591
|
break;
|
|
582
592
|
case Dapp.VELODROME:
|
|
@@ -628,7 +638,7 @@ export class Pool {
|
|
|
628
638
|
const unStakeTxData = iMiniChefV2.encodeFunctionData(Transaction.WITHDRAW, [
|
|
629
639
|
poolId,
|
|
630
640
|
amount,
|
|
631
|
-
this.address
|
|
641
|
+
this.address
|
|
632
642
|
]);
|
|
633
643
|
const tx = await getPoolTxOrGasEstimate(
|
|
634
644
|
this,
|
|
@@ -661,7 +671,7 @@ export class Pool {
|
|
|
661
671
|
unstakeTxData = getPancakeUnStakeTxData(this, amount.toString());
|
|
662
672
|
} else {
|
|
663
673
|
unstakeTxData = rewardsGauge.encodeFunctionData("withdraw(uint256)", [
|
|
664
|
-
amount
|
|
674
|
+
amount
|
|
665
675
|
]);
|
|
666
676
|
}
|
|
667
677
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -695,7 +705,7 @@ export class Pool {
|
|
|
695
705
|
asset,
|
|
696
706
|
amount,
|
|
697
707
|
this.address,
|
|
698
|
-
referralCode
|
|
708
|
+
referralCode
|
|
699
709
|
]);
|
|
700
710
|
|
|
701
711
|
const tx = await getPoolTxOrGasEstimate(
|
|
@@ -812,7 +822,7 @@ export class Pool {
|
|
|
812
822
|
amount,
|
|
813
823
|
2,
|
|
814
824
|
referralCode,
|
|
815
|
-
this.address
|
|
825
|
+
this.address
|
|
816
826
|
]);
|
|
817
827
|
const tx = await getPoolTxOrGasEstimate(
|
|
818
828
|
this,
|
|
@@ -843,7 +853,7 @@ export class Pool {
|
|
|
843
853
|
asset,
|
|
844
854
|
amount,
|
|
845
855
|
2,
|
|
846
|
-
this.address
|
|
856
|
+
this.address
|
|
847
857
|
]);
|
|
848
858
|
const tx = await getPoolTxOrGasEstimate(
|
|
849
859
|
this,
|
|
@@ -871,7 +881,7 @@ export class Pool {
|
|
|
871
881
|
const poolId = await this.utils.getLpPoolId(dapp, asset);
|
|
872
882
|
const harvestTxData = iMiniChefV2.encodeFunctionData(Transaction.HARVEST, [
|
|
873
883
|
poolId,
|
|
874
|
-
this.address
|
|
884
|
+
this.address
|
|
875
885
|
]);
|
|
876
886
|
const tx = await getPoolTxOrGasEstimate(
|
|
877
887
|
this,
|
|
@@ -894,12 +904,12 @@ export class Pool {
|
|
|
894
904
|
estimateGas = false
|
|
895
905
|
): Promise<any> {
|
|
896
906
|
const currentAssetsEnabled = await this.getComposition();
|
|
897
|
-
const currentAssets = currentAssetsEnabled.map(
|
|
907
|
+
const currentAssets = currentAssetsEnabled.map(e =>
|
|
898
908
|
e.asset.toLocaleLowerCase()
|
|
899
909
|
);
|
|
900
|
-
const newAssets = assets.map(
|
|
901
|
-
const removedAssets = currentAssets.filter(
|
|
902
|
-
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]);
|
|
903
913
|
|
|
904
914
|
if (estimateGas) {
|
|
905
915
|
return await this.managerLogic.estimateGas.changeAssets(
|
|
@@ -1056,7 +1066,7 @@ export class Pool {
|
|
|
1056
1066
|
[
|
|
1057
1067
|
stakingAddress[this.network][Dapp.AAVEV3] as string,
|
|
1058
1068
|
claimTxData,
|
|
1059
|
-
options
|
|
1069
|
+
options
|
|
1060
1070
|
],
|
|
1061
1071
|
estimateGas
|
|
1062
1072
|
);
|
|
@@ -1081,7 +1091,7 @@ export class Pool {
|
|
|
1081
1091
|
[
|
|
1082
1092
|
stakingAddress[this.network][Dapp.COMPOUNDV3] as string,
|
|
1083
1093
|
claimTxData,
|
|
1084
|
-
options
|
|
1094
|
+
options
|
|
1085
1095
|
],
|
|
1086
1096
|
estimateGas
|
|
1087
1097
|
);
|
|
@@ -1110,8 +1120,7 @@ export class Pool {
|
|
|
1110
1120
|
| Dapp.VELODROMECL
|
|
1111
1121
|
| Dapp.AERODROMECL
|
|
1112
1122
|
| Dapp.RAMSESCL
|
|
1113
|
-
| Dapp.PANCAKECL
|
|
1114
|
-
| Dapp.SHADOWCL,
|
|
1123
|
+
| Dapp.PANCAKECL,
|
|
1115
1124
|
assetA: string,
|
|
1116
1125
|
assetB: string,
|
|
1117
1126
|
amountA: BigNumber | string,
|
|
@@ -1151,7 +1160,7 @@ export class Pool {
|
|
|
1151
1160
|
[
|
|
1152
1161
|
nonfungiblePositionManagerAddress[this.network][dapp],
|
|
1153
1162
|
mintTxData,
|
|
1154
|
-
options
|
|
1163
|
+
options
|
|
1155
1164
|
],
|
|
1156
1165
|
estimateGas
|
|
1157
1166
|
);
|
|
@@ -1180,7 +1189,6 @@ export class Pool {
|
|
|
1180
1189
|
switch (dapp) {
|
|
1181
1190
|
case Dapp.UNISWAPV3:
|
|
1182
1191
|
case Dapp.RAMSESCL:
|
|
1183
|
-
case Dapp.SHADOWCL:
|
|
1184
1192
|
dappAddress = nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1185
1193
|
break;
|
|
1186
1194
|
case Dapp.VELODROMECL:
|
|
@@ -1246,7 +1254,6 @@ export class Pool {
|
|
|
1246
1254
|
switch (dapp) {
|
|
1247
1255
|
case Dapp.UNISWAPV3:
|
|
1248
1256
|
case Dapp.RAMSESCL:
|
|
1249
|
-
case Dapp.SHADOWCL:
|
|
1250
1257
|
dappAddress = nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1251
1258
|
break;
|
|
1252
1259
|
case Dapp.VELODROMECL:
|
|
@@ -1311,7 +1318,6 @@ export class Pool {
|
|
|
1311
1318
|
switch (dapp) {
|
|
1312
1319
|
case Dapp.UNISWAPV3:
|
|
1313
1320
|
case Dapp.RAMSESCL:
|
|
1314
|
-
case Dapp.SHADOWCL:
|
|
1315
1321
|
contractAddress = nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1316
1322
|
txData = iNonfungiblePositionManager.encodeFunctionData(
|
|
1317
1323
|
Transaction.COLLECT,
|
|
@@ -1382,13 +1388,13 @@ export class Pool {
|
|
|
1382
1388
|
options: any = null,
|
|
1383
1389
|
estimateGas = false
|
|
1384
1390
|
): Promise<any> {
|
|
1385
|
-
const claimAddress =
|
|
1386
|
-
dapp === Dapp.SHADOWCL
|
|
1387
|
-
? stakingAddress[this.network][dapp] //specific for wS/USDC CL
|
|
1388
|
-
: nonfungiblePositionManagerAddress[this.network][dapp];
|
|
1389
1391
|
const tx = await getPoolTxOrGasEstimate(
|
|
1390
1392
|
this,
|
|
1391
|
-
[
|
|
1393
|
+
[
|
|
1394
|
+
nonfungiblePositionManagerAddress[this.network][dapp],
|
|
1395
|
+
getRewardsTxDta(tokenId, rewards),
|
|
1396
|
+
options
|
|
1397
|
+
],
|
|
1392
1398
|
estimateGas
|
|
1393
1399
|
);
|
|
1394
1400
|
return tx;
|
|
@@ -1463,7 +1469,7 @@ export class Pool {
|
|
|
1463
1469
|
amountB,
|
|
1464
1470
|
isStable
|
|
1465
1471
|
),
|
|
1466
|
-
options
|
|
1472
|
+
options
|
|
1467
1473
|
],
|
|
1468
1474
|
estimateGas
|
|
1469
1475
|
);
|
|
@@ -1499,7 +1505,7 @@ export class Pool {
|
|
|
1499
1505
|
amount,
|
|
1500
1506
|
isStable
|
|
1501
1507
|
),
|
|
1502
|
-
options
|
|
1508
|
+
options
|
|
1503
1509
|
],
|
|
1504
1510
|
estimateGas
|
|
1505
1511
|
);
|
|
@@ -1538,7 +1544,7 @@ export class Pool {
|
|
|
1538
1544
|
amountB,
|
|
1539
1545
|
isStable
|
|
1540
1546
|
),
|
|
1541
|
-
options
|
|
1547
|
+
options
|
|
1542
1548
|
],
|
|
1543
1549
|
estimateGas
|
|
1544
1550
|
);
|
|
@@ -1574,7 +1580,7 @@ export class Pool {
|
|
|
1574
1580
|
amount,
|
|
1575
1581
|
isStable
|
|
1576
1582
|
),
|
|
1577
|
-
options
|
|
1583
|
+
options
|
|
1578
1584
|
],
|
|
1579
1585
|
estimateGas
|
|
1580
1586
|
);
|
|
@@ -1615,7 +1621,7 @@ export class Pool {
|
|
|
1615
1621
|
amountB,
|
|
1616
1622
|
isStable
|
|
1617
1623
|
),
|
|
1618
|
-
options
|
|
1624
|
+
options
|
|
1619
1625
|
],
|
|
1620
1626
|
estimateGas
|
|
1621
1627
|
);
|
|
@@ -1653,7 +1659,7 @@ export class Pool {
|
|
|
1653
1659
|
amount,
|
|
1654
1660
|
isStable
|
|
1655
1661
|
),
|
|
1656
|
-
options
|
|
1662
|
+
options
|
|
1657
1663
|
],
|
|
1658
1664
|
estimateGas
|
|
1659
1665
|
);
|