@dhedge/v2-sdk 2.1.7 → 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 +14 -2
- package/dist/entities/pool.d.ts +25 -86
- package/dist/entities/utils.d.ts +15 -0
- package/dist/services/cowSwap/index.d.ts +10 -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 +21 -5
- package/dist/utils/contract.d.ts +20 -0
- package/dist/v2-sdk.cjs.development.js +5193 -6711
- 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 +5198 -6711
- 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 +19 -9
- package/src/entities/pool.ts +103 -254
- package/src/entities/utils.ts +15 -0
- package/src/services/cowSwap/index.ts +281 -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 +57 -12
- package/src/test/cowswap.test.ts +79 -0
- 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 +22 -6
- 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,195 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"abi": [
|
|
3
|
-
{
|
|
4
|
-
"inputs": [
|
|
5
|
-
{
|
|
6
|
-
"internalType": "address",
|
|
7
|
-
"name": "_factory",
|
|
8
|
-
"type": "address"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"internalType": "address",
|
|
12
|
-
"name": "_WETH9",
|
|
13
|
-
"type": "address"
|
|
14
|
-
}
|
|
15
|
-
],
|
|
16
|
-
"stateMutability": "nonpayable",
|
|
17
|
-
"type": "constructor"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"inputs": [],
|
|
21
|
-
"name": "WETH9",
|
|
22
|
-
"outputs": [
|
|
23
|
-
{
|
|
24
|
-
"internalType": "address",
|
|
25
|
-
"name": "",
|
|
26
|
-
"type": "address"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"stateMutability": "view",
|
|
30
|
-
"type": "function"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"inputs": [],
|
|
34
|
-
"name": "factory",
|
|
35
|
-
"outputs": [
|
|
36
|
-
{
|
|
37
|
-
"internalType": "address",
|
|
38
|
-
"name": "",
|
|
39
|
-
"type": "address"
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
"stateMutability": "view",
|
|
43
|
-
"type": "function"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"inputs": [
|
|
47
|
-
{
|
|
48
|
-
"internalType": "bytes",
|
|
49
|
-
"name": "path",
|
|
50
|
-
"type": "bytes"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"internalType": "uint256",
|
|
54
|
-
"name": "amountIn",
|
|
55
|
-
"type": "uint256"
|
|
56
|
-
}
|
|
57
|
-
],
|
|
58
|
-
"name": "quoteExactInput",
|
|
59
|
-
"outputs": [
|
|
60
|
-
{
|
|
61
|
-
"internalType": "uint256",
|
|
62
|
-
"name": "amountOut",
|
|
63
|
-
"type": "uint256"
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
"stateMutability": "nonpayable",
|
|
67
|
-
"type": "function"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"inputs": [
|
|
71
|
-
{
|
|
72
|
-
"internalType": "address",
|
|
73
|
-
"name": "tokenIn",
|
|
74
|
-
"type": "address"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"internalType": "address",
|
|
78
|
-
"name": "tokenOut",
|
|
79
|
-
"type": "address"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
"internalType": "uint24",
|
|
83
|
-
"name": "fee",
|
|
84
|
-
"type": "uint24"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"internalType": "uint256",
|
|
88
|
-
"name": "amountIn",
|
|
89
|
-
"type": "uint256"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"internalType": "uint160",
|
|
93
|
-
"name": "sqrtPriceLimitX96",
|
|
94
|
-
"type": "uint160"
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
"name": "quoteExactInputSingle",
|
|
98
|
-
"outputs": [
|
|
99
|
-
{
|
|
100
|
-
"internalType": "uint256",
|
|
101
|
-
"name": "amountOut",
|
|
102
|
-
"type": "uint256"
|
|
103
|
-
}
|
|
104
|
-
],
|
|
105
|
-
"stateMutability": "nonpayable",
|
|
106
|
-
"type": "function"
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"inputs": [
|
|
110
|
-
{
|
|
111
|
-
"internalType": "bytes",
|
|
112
|
-
"name": "path",
|
|
113
|
-
"type": "bytes"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"internalType": "uint256",
|
|
117
|
-
"name": "amountOut",
|
|
118
|
-
"type": "uint256"
|
|
119
|
-
}
|
|
120
|
-
],
|
|
121
|
-
"name": "quoteExactOutput",
|
|
122
|
-
"outputs": [
|
|
123
|
-
{
|
|
124
|
-
"internalType": "uint256",
|
|
125
|
-
"name": "amountIn",
|
|
126
|
-
"type": "uint256"
|
|
127
|
-
}
|
|
128
|
-
],
|
|
129
|
-
"stateMutability": "nonpayable",
|
|
130
|
-
"type": "function"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"inputs": [
|
|
134
|
-
{
|
|
135
|
-
"internalType": "address",
|
|
136
|
-
"name": "tokenIn",
|
|
137
|
-
"type": "address"
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
"internalType": "address",
|
|
141
|
-
"name": "tokenOut",
|
|
142
|
-
"type": "address"
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"internalType": "uint24",
|
|
146
|
-
"name": "fee",
|
|
147
|
-
"type": "uint24"
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
"internalType": "uint256",
|
|
151
|
-
"name": "amountOut",
|
|
152
|
-
"type": "uint256"
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
"internalType": "uint160",
|
|
156
|
-
"name": "sqrtPriceLimitX96",
|
|
157
|
-
"type": "uint160"
|
|
158
|
-
}
|
|
159
|
-
],
|
|
160
|
-
"name": "quoteExactOutputSingle",
|
|
161
|
-
"outputs": [
|
|
162
|
-
{
|
|
163
|
-
"internalType": "uint256",
|
|
164
|
-
"name": "amountIn",
|
|
165
|
-
"type": "uint256"
|
|
166
|
-
}
|
|
167
|
-
],
|
|
168
|
-
"stateMutability": "nonpayable",
|
|
169
|
-
"type": "function"
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"inputs": [
|
|
173
|
-
{
|
|
174
|
-
"internalType": "int256",
|
|
175
|
-
"name": "amount0Delta",
|
|
176
|
-
"type": "int256"
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
"internalType": "int256",
|
|
180
|
-
"name": "amount1Delta",
|
|
181
|
-
"type": "int256"
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
"internalType": "bytes",
|
|
185
|
-
"name": "path",
|
|
186
|
-
"type": "bytes"
|
|
187
|
-
}
|
|
188
|
-
],
|
|
189
|
-
"name": "uniswapV3SwapCallback",
|
|
190
|
-
"outputs": [],
|
|
191
|
-
"stateMutability": "view",
|
|
192
|
-
"type": "function"
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"abi": [
|
|
3
|
-
{
|
|
4
|
-
"inputs": [
|
|
5
|
-
{
|
|
6
|
-
"components": [
|
|
7
|
-
{
|
|
8
|
-
"internalType": "bytes",
|
|
9
|
-
"name": "path",
|
|
10
|
-
"type": "bytes"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"internalType": "address",
|
|
14
|
-
"name": "recipient",
|
|
15
|
-
"type": "address"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"internalType": "uint256",
|
|
19
|
-
"name": "amountIn",
|
|
20
|
-
"type": "uint256"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"internalType": "uint256",
|
|
24
|
-
"name": "amountOutMinimum",
|
|
25
|
-
"type": "uint256"
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"internalType": "struct ISwapRouter.ExactInputParams",
|
|
29
|
-
"name": "params",
|
|
30
|
-
"type": "tuple"
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
"name": "exactInput",
|
|
34
|
-
"outputs": [
|
|
35
|
-
{
|
|
36
|
-
"internalType": "uint256",
|
|
37
|
-
"name": "amountOut",
|
|
38
|
-
"type": "uint256"
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
"stateMutability": "payable",
|
|
42
|
-
"type": "function"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"inputs": [
|
|
46
|
-
{
|
|
47
|
-
"components": [
|
|
48
|
-
{
|
|
49
|
-
"internalType": "address",
|
|
50
|
-
"name": "tokenIn",
|
|
51
|
-
"type": "address"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"internalType": "address",
|
|
55
|
-
"name": "tokenOut",
|
|
56
|
-
"type": "address"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"internalType": "uint24",
|
|
60
|
-
"name": "fee",
|
|
61
|
-
"type": "uint24"
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"internalType": "address",
|
|
65
|
-
"name": "recipient",
|
|
66
|
-
"type": "address"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"internalType": "uint256",
|
|
70
|
-
"name": "amountIn",
|
|
71
|
-
"type": "uint256"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"internalType": "uint256",
|
|
75
|
-
"name": "amountOutMinimum",
|
|
76
|
-
"type": "uint256"
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"internalType": "uint160",
|
|
80
|
-
"name": "sqrtPriceLimitX96",
|
|
81
|
-
"type": "uint160"
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
|
-
"internalType": "struct ISwapRouter.ExactInputSingleParams",
|
|
85
|
-
"name": "params",
|
|
86
|
-
"type": "tuple"
|
|
87
|
-
}
|
|
88
|
-
],
|
|
89
|
-
"name": "exactInputSingle",
|
|
90
|
-
"outputs": [
|
|
91
|
-
{
|
|
92
|
-
"internalType": "uint256",
|
|
93
|
-
"name": "amountOut",
|
|
94
|
-
"type": "uint256"
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
"stateMutability": "payable",
|
|
98
|
-
"type": "function"
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"inputs": [
|
|
102
|
-
{
|
|
103
|
-
"components": [
|
|
104
|
-
{
|
|
105
|
-
"internalType": "bytes",
|
|
106
|
-
"name": "path",
|
|
107
|
-
"type": "bytes"
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
"internalType": "address",
|
|
111
|
-
"name": "recipient",
|
|
112
|
-
"type": "address"
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
"internalType": "uint256",
|
|
116
|
-
"name": "amountOut",
|
|
117
|
-
"type": "uint256"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"internalType": "uint256",
|
|
121
|
-
"name": "amountInMaximum",
|
|
122
|
-
"type": "uint256"
|
|
123
|
-
}
|
|
124
|
-
],
|
|
125
|
-
"internalType": "struct ISwapRouter.ExactOutputParams",
|
|
126
|
-
"name": "params",
|
|
127
|
-
"type": "tuple"
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
"name": "exactOutput",
|
|
131
|
-
"outputs": [
|
|
132
|
-
{
|
|
133
|
-
"internalType": "uint256",
|
|
134
|
-
"name": "amountIn",
|
|
135
|
-
"type": "uint256"
|
|
136
|
-
}
|
|
137
|
-
],
|
|
138
|
-
"stateMutability": "payable",
|
|
139
|
-
"type": "function"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
"inputs": [
|
|
143
|
-
{
|
|
144
|
-
"components": [
|
|
145
|
-
{
|
|
146
|
-
"internalType": "address",
|
|
147
|
-
"name": "tokenIn",
|
|
148
|
-
"type": "address"
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
"internalType": "address",
|
|
152
|
-
"name": "tokenOut",
|
|
153
|
-
"type": "address"
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
"internalType": "uint24",
|
|
157
|
-
"name": "fee",
|
|
158
|
-
"type": "uint24"
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
"internalType": "address",
|
|
162
|
-
"name": "recipient",
|
|
163
|
-
"type": "address"
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
"internalType": "uint256",
|
|
167
|
-
"name": "amountOut",
|
|
168
|
-
"type": "uint256"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"internalType": "uint256",
|
|
172
|
-
"name": "amountInMaximum",
|
|
173
|
-
"type": "uint256"
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
"internalType": "uint160",
|
|
177
|
-
"name": "sqrtPriceLimitX96",
|
|
178
|
-
"type": "uint160"
|
|
179
|
-
}
|
|
180
|
-
],
|
|
181
|
-
"internalType": "struct ISwapRouter.ExactOutputSingleParams",
|
|
182
|
-
"name": "params",
|
|
183
|
-
"type": "tuple"
|
|
184
|
-
}
|
|
185
|
-
],
|
|
186
|
-
"name": "exactOutputSingle",
|
|
187
|
-
"outputs": [
|
|
188
|
-
{
|
|
189
|
-
"internalType": "uint256",
|
|
190
|
-
"name": "amountIn",
|
|
191
|
-
"type": "uint256"
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
"stateMutability": "payable",
|
|
195
|
-
"type": "function"
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
"inputs": [
|
|
199
|
-
{
|
|
200
|
-
"internalType": "int256",
|
|
201
|
-
"name": "amount0Delta",
|
|
202
|
-
"type": "int256"
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
"internalType": "int256",
|
|
206
|
-
"name": "amount1Delta",
|
|
207
|
-
"type": "int256"
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
"internalType": "bytes",
|
|
211
|
-
"name": "data",
|
|
212
|
-
"type": "bytes"
|
|
213
|
-
}
|
|
214
|
-
],
|
|
215
|
-
"name": "uniswapV3SwapCallback",
|
|
216
|
-
"outputs": [],
|
|
217
|
-
"stateMutability": "nonpayable",
|
|
218
|
-
"type": "function"
|
|
219
|
-
}
|
|
220
|
-
]
|
|
221
|
-
}
|
package/src/abi/IXRam.json
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
{ "abi": [
|
|
2
|
-
{
|
|
3
|
-
"inputs": [
|
|
4
|
-
{
|
|
5
|
-
"internalType": "uint256",
|
|
6
|
-
"name": "_amount",
|
|
7
|
-
"type": "uint256"
|
|
8
|
-
}
|
|
9
|
-
],
|
|
10
|
-
"name": "createVest",
|
|
11
|
-
"outputs": [],
|
|
12
|
-
"stateMutability": "nonpayable",
|
|
13
|
-
"type": "function"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"inputs": [
|
|
17
|
-
{
|
|
18
|
-
"internalType": "uint256",
|
|
19
|
-
"name": "_vestID",
|
|
20
|
-
"type": "uint256"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"internalType": "bool",
|
|
24
|
-
"name": "_ve",
|
|
25
|
-
"type": "bool"
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"name": "exitVest",
|
|
29
|
-
"outputs": [
|
|
30
|
-
{
|
|
31
|
-
"internalType": "bool",
|
|
32
|
-
"name": "",
|
|
33
|
-
"type": "bool"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
"stateMutability": "nonpayable",
|
|
37
|
-
"type": "function"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"inputs": [
|
|
41
|
-
{
|
|
42
|
-
"internalType": "address",
|
|
43
|
-
"name": "_user",
|
|
44
|
-
"type": "address"
|
|
45
|
-
}
|
|
46
|
-
],
|
|
47
|
-
"name": "usersTotalVests",
|
|
48
|
-
"outputs": [
|
|
49
|
-
{
|
|
50
|
-
"internalType": "uint256",
|
|
51
|
-
"name": "",
|
|
52
|
-
"type": "uint256"
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
"stateMutability": "view",
|
|
56
|
-
"type": "function"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"inputs": [
|
|
60
|
-
{
|
|
61
|
-
"internalType": "address",
|
|
62
|
-
"name": "user",
|
|
63
|
-
"type": "address"
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
"name": "vestInfo",
|
|
67
|
-
"outputs": [
|
|
68
|
-
{
|
|
69
|
-
"components": [
|
|
70
|
-
{
|
|
71
|
-
"internalType": "uint256",
|
|
72
|
-
"name": "amount",
|
|
73
|
-
"type": "uint256"
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"internalType": "uint256",
|
|
77
|
-
"name": "start",
|
|
78
|
-
"type": "uint256"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"internalType": "uint256",
|
|
82
|
-
"name": "maxEnd",
|
|
83
|
-
"type": "uint256"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
"internalType": "uint256",
|
|
87
|
-
"name": "vestID",
|
|
88
|
-
"type": "uint256"
|
|
89
|
-
}
|
|
90
|
-
],
|
|
91
|
-
"internalType": "struct IXRam.VestPosition[]",
|
|
92
|
-
"name": "",
|
|
93
|
-
"type": "tuple[]"
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
"stateMutability": "view",
|
|
97
|
-
"type": "function"
|
|
98
|
-
}
|
|
99
|
-
]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const FUTURES_TRACKING = "DHEDGE";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ethers } from "../..";
|
|
2
|
-
import ISynthetixFuturesMarketV2 from "../../abi/ISynthetixFuturesMarketV2.json";
|
|
3
|
-
|
|
4
|
-
export function getFuturesChangeMarginTxData(
|
|
5
|
-
amount: ethers.BigNumber | string
|
|
6
|
-
): string {
|
|
7
|
-
return new ethers.utils.Interface(
|
|
8
|
-
ISynthetixFuturesMarketV2.abi
|
|
9
|
-
).encodeFunctionData("transferMargin", [amount]);
|
|
10
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Pool, ethers } from "../..";
|
|
2
|
-
import { FUTURES_TRACKING } from "./constants";
|
|
3
|
-
import ISynthetixFuturesMarketV2 from "../../abi/ISynthetixFuturesMarketV2.json";
|
|
4
|
-
|
|
5
|
-
export async function getFuturesChangePositionTxData(
|
|
6
|
-
amount: ethers.BigNumber | string,
|
|
7
|
-
market: string,
|
|
8
|
-
pool: Pool
|
|
9
|
-
): Promise<string> {
|
|
10
|
-
const futuresMarket = new ethers.Contract(
|
|
11
|
-
market,
|
|
12
|
-
ISynthetixFuturesMarketV2.abi,
|
|
13
|
-
pool.signer
|
|
14
|
-
);
|
|
15
|
-
const fillPrice = await futuresMarket.fillPrice(amount);
|
|
16
|
-
//Allows for +-0.5% price movements on the desired fill price
|
|
17
|
-
const adjustmentFactor = ethers.BigNumber.from(amount).lt(0) ? 995 : 1005;
|
|
18
|
-
const desiredFillPrice = fillPrice.price.mul(adjustmentFactor).div(1000);
|
|
19
|
-
return new ethers.utils.Interface(
|
|
20
|
-
ISynthetixFuturesMarketV2.abi
|
|
21
|
-
).encodeFunctionData("submitOffchainDelayedOrderWithTracking", [
|
|
22
|
-
amount,
|
|
23
|
-
desiredFillPrice,
|
|
24
|
-
ethers.utils.formatBytes32String(FUTURES_TRACKING)
|
|
25
|
-
]);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function getFuturesCancelOrderTxData(pool: Pool): Promise<string> {
|
|
29
|
-
return new ethers.utils.Interface(
|
|
30
|
-
ISynthetixFuturesMarketV2.abi
|
|
31
|
-
).encodeFunctionData("cancelOffchainDelayedOrder", [pool.address]);
|
|
32
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { BigNumber, ethers } from "ethers";
|
|
3
|
-
import IXRam from "../../abi/IXRam.json";
|
|
4
|
-
import IRamsesNonfungiblePositionManager from "../../abi/IRamsesNonfungiblePositionManager.json";
|
|
5
|
-
|
|
6
|
-
const iXRam = new ethers.utils.Interface(IXRam.abi);
|
|
7
|
-
const iRamsesNonfungiblePositionManager = new ethers.utils.Interface(
|
|
8
|
-
IRamsesNonfungiblePositionManager
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
export function getCreateVestTxData(amount: BigNumber | string): string {
|
|
12
|
-
return iXRam.encodeFunctionData("createVest", [amount]);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getExitVestTxData(vestId: number): string {
|
|
16
|
-
return iXRam.encodeFunctionData("exitVest", [vestId, false]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getRewardsTxDta(tokenId: string, rewards: string[]): string {
|
|
20
|
-
return iRamsesNonfungiblePositionManager.encodeFunctionData("getReward", [
|
|
21
|
-
tokenId,
|
|
22
|
-
rewards
|
|
23
|
-
]);
|
|
24
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ethers } from "ethers";
|
|
2
|
-
import { Pool } from "../..";
|
|
3
|
-
|
|
4
|
-
import IUniswapV3Router from "../../abi/IUniswapV3Router.json";
|
|
5
|
-
import IUniswapV3Quoter from "../../abi/IUniswapV3Quoter.json";
|
|
6
|
-
import { UNISWAPV3_QUOTER_ADDRESS } from "../../config";
|
|
7
|
-
|
|
8
|
-
export async function getUniswapV3SwapTxData(
|
|
9
|
-
pool: Pool,
|
|
10
|
-
assetA: string,
|
|
11
|
-
assetB: string,
|
|
12
|
-
amountIn: string | ethers.BigNumber,
|
|
13
|
-
slippage: number,
|
|
14
|
-
feeAmount: number
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
-
): Promise<any> {
|
|
17
|
-
const quoterContract = new ethers.Contract(
|
|
18
|
-
UNISWAPV3_QUOTER_ADDRESS,
|
|
19
|
-
IUniswapV3Quoter.abi,
|
|
20
|
-
pool.signer
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const quotedAmountOut: ethers.BigNumber = await quoterContract.callStatic.quoteExactInputSingle(
|
|
24
|
-
assetA,
|
|
25
|
-
assetB,
|
|
26
|
-
feeAmount,
|
|
27
|
-
amountIn.toString(),
|
|
28
|
-
0
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const minAmountOut = quotedAmountOut.mul((100 - slippage) * 100).div(10000);
|
|
32
|
-
|
|
33
|
-
const iUniswapV3Router = new ethers.utils.Interface(IUniswapV3Router.abi);
|
|
34
|
-
const swapTx = iUniswapV3Router.encodeFunctionData("exactInputSingle", [
|
|
35
|
-
[
|
|
36
|
-
assetA,
|
|
37
|
-
assetB,
|
|
38
|
-
feeAmount,
|
|
39
|
-
pool.address,
|
|
40
|
-
amountIn.toString(),
|
|
41
|
-
minAmountOut.toString(),
|
|
42
|
-
0
|
|
43
|
-
]
|
|
44
|
-
]);
|
|
45
|
-
return swapTx;
|
|
46
|
-
}
|
package/src/test/futures.test.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Dhedge, Pool } from "..";
|
|
2
|
-
import { Network } from "../types";
|
|
3
|
-
import { CONTRACT_ADDRESS, TEST_POOL } from "./constants";
|
|
4
|
-
import { getDelayedOrders } from "./utils/futures";
|
|
5
|
-
import { balanceDelta } from "./utils/token";
|
|
6
|
-
import { wallet } from "./wallet";
|
|
7
|
-
|
|
8
|
-
jest.setTimeout(100000);
|
|
9
|
-
|
|
10
|
-
const network = Network.OPTIMISM;
|
|
11
|
-
const perp = CONTRACT_ADDRESS[network].KWENTA_ETH_PERP_V2;
|
|
12
|
-
|
|
13
|
-
describe("pool", () => {
|
|
14
|
-
let dhedge: Dhedge;
|
|
15
|
-
let pool: Pool;
|
|
16
|
-
beforeAll(async () => {
|
|
17
|
-
dhedge = new Dhedge(wallet, network);
|
|
18
|
-
pool = await dhedge.loadPool(TEST_POOL[network]);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("deposits 50 sUSD margin into ETH future market", async () => {
|
|
22
|
-
const depositAmount = (50 * 1e18).toString();
|
|
23
|
-
await pool.changeFuturesMargin(perp, depositAmount);
|
|
24
|
-
|
|
25
|
-
const sUSDBalanceDelta = await balanceDelta(
|
|
26
|
-
pool.address,
|
|
27
|
-
CONTRACT_ADDRESS[network].SUSD,
|
|
28
|
-
pool.signer
|
|
29
|
-
);
|
|
30
|
-
expect(sUSDBalanceDelta.abs().toString()).toBe(depositAmount);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("goes long ETH-PERP about 2x leverage", async () => {
|
|
34
|
-
//size 50*2/2000 (margin * leverage / price)
|
|
35
|
-
const size = (0.05 * 1e18).toString();
|
|
36
|
-
await pool.changeFuturesPosition(perp, size);
|
|
37
|
-
const orders = await getDelayedOrders(perp, pool);
|
|
38
|
-
expect(orders.length).toBeGreaterThan(0);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("removes 20 sUSD margin from ETH future market", async () => {
|
|
42
|
-
await getDelayedOrders(perp, pool);
|
|
43
|
-
await pool.changeFuturesMargin(perp, (-20 * 1e18).toString());
|
|
44
|
-
const sUSDBalanceDelta = await balanceDelta(
|
|
45
|
-
pool.address,
|
|
46
|
-
CONTRACT_ADDRESS[network].SUSD,
|
|
47
|
-
pool.signer
|
|
48
|
-
);
|
|
49
|
-
expect(sUSDBalanceDelta.gt(0));
|
|
50
|
-
});
|
|
51
|
-
});
|