@dhedge/v2-sdk 2.1.5 → 2.1.6

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.
Files changed (34) hide show
  1. package/README.md +180 -45
  2. package/dist/config.d.ts +2 -0
  3. package/dist/entities/pool.d.ts +110 -1
  4. package/dist/services/hyperliquid/constants.d.ts +16 -0
  5. package/dist/services/hyperliquid/index.d.ts +6 -0
  6. package/dist/services/hyperliquid/marketData.d.ts +12 -0
  7. package/dist/services/hyperliquid/positionData.d.ts +1 -0
  8. package/dist/services/toros/limitOrder.d.ts +8 -0
  9. package/dist/test/constants.d.ts +7 -1
  10. package/dist/test/wallet.d.ts +1 -0
  11. package/dist/types.d.ts +12 -2
  12. package/dist/v2-sdk.cjs.development.js +1470 -32
  13. package/dist/v2-sdk.cjs.development.js.map +1 -1
  14. package/dist/v2-sdk.cjs.production.min.js +1 -1
  15. package/dist/v2-sdk.cjs.production.min.js.map +1 -1
  16. package/dist/v2-sdk.esm.js +1449 -12
  17. package/dist/v2-sdk.esm.js.map +1 -1
  18. package/package.json +3 -2
  19. package/src/abi/hyperliquid/ICoreDepositWallet.json +130 -0
  20. package/src/abi/hyperliquid/ICoreWriter.json +1 -0
  21. package/src/abi/toros/IPoolLimitOrderManager.json +78 -0
  22. package/src/config.ts +31 -9
  23. package/src/entities/pool.ts +348 -4
  24. package/src/services/hyperliquid/constants.ts +23 -0
  25. package/src/services/hyperliquid/index.ts +176 -0
  26. package/src/services/hyperliquid/marketData.ts +157 -0
  27. package/src/services/hyperliquid/positionData.ts +33 -0
  28. package/src/services/toros/limitOrder.ts +86 -0
  29. package/src/test/constants.ts +11 -5
  30. package/src/test/hyperliquid.test.ts +107 -0
  31. package/src/test/pool.test.ts +37 -45
  32. package/src/test/torosLimitOrder.test.ts +130 -0
  33. package/src/test/wallet.ts +2 -1
  34. package/src/types.ts +13 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhedge/v2-sdk",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "license": "MIT",
5
5
  "description": "🛠 An SDK for building applications on top of dHEDGE V2",
6
6
  "main": "dist/index.js",
@@ -25,7 +25,8 @@
25
25
  "fork:arbitrum": "hardhat node --port 8540 --fork $(grep ARBITRUM_URL .env | cut -d '=' -f2)",
26
26
  "fork:base": "hardhat node --port 8546 --fork $(grep BASE_URL .env | cut -d '=' -f2)",
27
27
  "fork:ethereum": "hardhat node --port 8547 --fork $(grep ETHEREUM_URL .env | cut -d '=' -f2)",
28
- "fork:plasma": "hardhat node --port 8548 --fork $(grep PLASMA_URL .env | cut -d '=' -f2)"
28
+ "fork:plasma": "hardhat node --port 8548 --fork $(grep PLASMA_URL .env | cut -d '=' -f2)",
29
+ "fork:hyperliquid": "hardhat node --port 8549 --fork $(grep HYPERLIQUID_URL .env | cut -d '=' -f2)"
29
30
  },
30
31
  "husky": {
31
32
  "hooks": {
@@ -0,0 +1,130 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "address",
6
+ "name": "from",
7
+ "type": "address"
8
+ },
9
+ {
10
+ "internalType": "bytes32",
11
+ "name": "destinationRecipient",
12
+ "type": "bytes32"
13
+ },
14
+ {
15
+ "internalType": "uint32",
16
+ "name": "destinationChainId",
17
+ "type": "uint32"
18
+ },
19
+ {
20
+ "internalType": "uint256",
21
+ "name": "amount",
22
+ "type": "uint256"
23
+ },
24
+ {
25
+ "internalType": "uint64",
26
+ "name": "coreNonce",
27
+ "type": "uint64"
28
+ },
29
+ {
30
+ "internalType": "bytes",
31
+ "name": "data",
32
+ "type": "bytes"
33
+ }
34
+ ],
35
+ "name": "coreReceiveWithData",
36
+ "outputs": [],
37
+ "stateMutability": "nonpayable",
38
+ "type": "function"
39
+ },
40
+ {
41
+ "inputs": [
42
+ {
43
+ "internalType": "uint256",
44
+ "name": "amount",
45
+ "type": "uint256"
46
+ },
47
+ {
48
+ "internalType": "uint32",
49
+ "name": "destinationDex",
50
+ "type": "uint32"
51
+ }
52
+ ],
53
+ "name": "deposit",
54
+ "outputs": [],
55
+ "stateMutability": "nonpayable",
56
+ "type": "function"
57
+ },
58
+ {
59
+ "inputs": [
60
+ {
61
+ "internalType": "uint256",
62
+ "name": "amount",
63
+ "type": "uint256"
64
+ },
65
+ {
66
+ "internalType": "uint256",
67
+ "name": "authValidAfter",
68
+ "type": "uint256"
69
+ },
70
+ {
71
+ "internalType": "uint256",
72
+ "name": "authValidBefore",
73
+ "type": "uint256"
74
+ },
75
+ {
76
+ "internalType": "bytes32",
77
+ "name": "authNonce",
78
+ "type": "bytes32"
79
+ },
80
+ {
81
+ "internalType": "uint8",
82
+ "name": "v",
83
+ "type": "uint8"
84
+ },
85
+ {
86
+ "internalType": "bytes32",
87
+ "name": "r",
88
+ "type": "bytes32"
89
+ },
90
+ {
91
+ "internalType": "bytes32",
92
+ "name": "s",
93
+ "type": "bytes32"
94
+ },
95
+ {
96
+ "internalType": "uint32",
97
+ "name": "destinationDex",
98
+ "type": "uint32"
99
+ }
100
+ ],
101
+ "name": "depositWithAuth",
102
+ "outputs": [],
103
+ "stateMutability": "nonpayable",
104
+ "type": "function"
105
+ },
106
+ {
107
+ "inputs": [
108
+ {
109
+ "internalType": "address",
110
+ "name": "to",
111
+ "type": "address"
112
+ },
113
+ {
114
+ "internalType": "uint256",
115
+ "name": "amount",
116
+ "type": "uint256"
117
+ }
118
+ ],
119
+ "name": "transfer",
120
+ "outputs": [
121
+ {
122
+ "internalType": "bool",
123
+ "name": "success",
124
+ "type": "bool"
125
+ }
126
+ ],
127
+ "stateMutability": "nonpayable",
128
+ "type": "function"
129
+ }
130
+ ]
@@ -0,0 +1 @@
1
+ [{"anonymous": false,"inputs": [{"indexed": true,"internalType": "address","name": "user","type": "address"},{"indexed": false,"internalType": "bytes","name": "data","type": "bytes"}],"name": "RawAction","type": "event"},{"inputs": [{"internalType": "bytes","name": "data","type": "bytes"}],"name": "sendRawAction","outputs": [],"stateMutability": "nonpayable","type": "function"}]
@@ -0,0 +1,78 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "components": [
6
+ { "internalType": "uint256", "name": "amount", "type": "uint256" },
7
+ { "internalType": "uint256", "name": "stopLossPriceD18", "type": "uint256" },
8
+ { "internalType": "uint256", "name": "takeProfitPriceD18", "type": "uint256" },
9
+ { "internalType": "address", "name": "user", "type": "address" },
10
+ { "internalType": "address", "name": "pool", "type": "address" },
11
+ { "internalType": "address", "name": "pricingAsset", "type": "address" }
12
+ ],
13
+ "internalType": "struct IPoolLimitOrderManager.LimitOrderInfo",
14
+ "name": "limitOrderInfo",
15
+ "type": "tuple"
16
+ }
17
+ ],
18
+ "name": "createLimitOrder",
19
+ "outputs": [],
20
+ "stateMutability": "nonpayable",
21
+ "type": "function"
22
+ },
23
+ {
24
+ "inputs": [
25
+ {
26
+ "components": [
27
+ { "internalType": "uint256", "name": "amount", "type": "uint256" },
28
+ { "internalType": "uint256", "name": "stopLossPriceD18", "type": "uint256" },
29
+ { "internalType": "uint256", "name": "takeProfitPriceD18", "type": "uint256" },
30
+ { "internalType": "address", "name": "user", "type": "address" },
31
+ { "internalType": "address", "name": "pool", "type": "address" },
32
+ { "internalType": "address", "name": "pricingAsset", "type": "address" }
33
+ ],
34
+ "internalType": "struct IPoolLimitOrderManager.LimitOrderInfo",
35
+ "name": "limitOrderInfo",
36
+ "type": "tuple"
37
+ }
38
+ ],
39
+ "name": "modifyLimitOrder",
40
+ "outputs": [],
41
+ "stateMutability": "nonpayable",
42
+ "type": "function"
43
+ },
44
+ {
45
+ "inputs": [
46
+ { "internalType": "address", "name": "pool_", "type": "address" }
47
+ ],
48
+ "name": "deleteLimitOrder",
49
+ "outputs": [],
50
+ "stateMutability": "nonpayable",
51
+ "type": "function"
52
+ },
53
+ {
54
+ "inputs": [],
55
+ "name": "getAllLimitOrderIds",
56
+ "outputs": [
57
+ { "internalType": "bytes32[]", "name": "", "type": "bytes32[]" }
58
+ ],
59
+ "stateMutability": "view",
60
+ "type": "function"
61
+ },
62
+ {
63
+ "inputs": [
64
+ { "internalType": "bytes32", "name": "orderId", "type": "bytes32" }
65
+ ],
66
+ "name": "limitOrders",
67
+ "outputs": [
68
+ { "internalType": "uint256", "name": "amount", "type": "uint256" },
69
+ { "internalType": "uint256", "name": "stopLossPriceD18", "type": "uint256" },
70
+ { "internalType": "uint256", "name": "takeProfitPriceD18", "type": "uint256" },
71
+ { "internalType": "address", "name": "user", "type": "address" },
72
+ { "internalType": "address", "name": "pool", "type": "address" },
73
+ { "internalType": "address", "name": "pricingAsset", "type": "address" }
74
+ ],
75
+ "stateMutability": "view",
76
+ "type": "function"
77
+ }
78
+ ]
package/src/config.ts CHANGED
@@ -19,7 +19,8 @@ export const factoryAddress: AddressNetworkMap = {
19
19
  [Network.ARBITRUM]: "0xfffb5fb14606eb3a548c113026355020ddf27535",
20
20
  [Network.BASE]: "0x49Afe3abCf66CF09Fab86cb1139D8811C8afe56F",
21
21
  [Network.ETHEREUM]: "0x96D33bCF84DdE326014248E2896F79bbb9c13D6d",
22
- [Network.PLASMA]: "0xAec4975Fc8ad911464D2948D771488b30F6eEE87"
22
+ [Network.PLASMA]: "0xAec4975Fc8ad911464D2948D771488b30F6eEE87",
23
+ [Network.HYPERLIQUID]: "0xe91505e2ab653dd128c71e9690eeefd28cc5b333"
23
24
  };
24
25
 
25
26
  export const routerAddress: AddressDappNetworkMap = {
@@ -81,6 +82,9 @@ export const routerAddress: AddressDappNetworkMap = {
81
82
  [Dapp.AAVEV3]: "0x925a2A7214Ed92428B5b1B090F80b25700095e12",
82
83
  [Dapp.PENDLE]: "0x888888888889758F76e7103c6CbF23ABbF58F946",
83
84
  [Dapp.KYBERSWAP]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5"
85
+ },
86
+ [Network.HYPERLIQUID]: {
87
+ [Dapp.HYPERLIQUID]: "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24"
84
88
  }
85
89
  };
86
90
 
@@ -93,7 +97,8 @@ export const dappFactoryAddress: AddressDappNetworkMap = {
93
97
  [Network.ARBITRUM]: {},
94
98
  [Network.BASE]: {},
95
99
  [Network.ETHEREUM]: {},
96
- [Network.PLASMA]: {}
100
+ [Network.PLASMA]: {},
101
+ [Network.HYPERLIQUID]: {}
97
102
  };
98
103
 
99
104
  export const stakingAddress: AddressDappNetworkMap = {
@@ -115,7 +120,8 @@ export const stakingAddress: AddressDappNetworkMap = {
115
120
  [Dapp.PANCAKECL]: "0xC6A2Db661D5a5690172d8eB0a7DEA2d3008665A3"
116
121
  },
117
122
  [Network.ETHEREUM]: {},
118
- [Network.PLASMA]: {}
123
+ [Network.PLASMA]: {},
124
+ [Network.HYPERLIQUID]: {}
119
125
  };
120
126
 
121
127
  export const aaveAddressProvider: AddressDappNetworkMap = {
@@ -138,7 +144,8 @@ export const aaveAddressProvider: AddressDappNetworkMap = {
138
144
  },
139
145
  [Network.PLASMA]: {
140
146
  [Dapp.AAVEV3]: "0x061D8e131F26512348ee5FA42e2DF1bA9d6505E9"
141
- }
147
+ },
148
+ [Network.HYPERLIQUID]: {}
142
149
  };
143
150
  export const nonfungiblePositionManagerAddress: AddressDappNetworkMap = {
144
151
  [Network.POLYGON]: {
@@ -159,7 +166,8 @@ export const nonfungiblePositionManagerAddress: AddressDappNetworkMap = {
159
166
  [Dapp.PANCAKECL]: "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364"
160
167
  },
161
168
  [Network.ETHEREUM]: {},
162
- [Network.PLASMA]: {}
169
+ [Network.PLASMA]: {},
170
+ [Network.HYPERLIQUID]: {}
163
171
  };
164
172
 
165
173
  export const networkChainIdMap: NetworkChainIdMap = {
@@ -168,7 +176,8 @@ export const networkChainIdMap: NetworkChainIdMap = {
168
176
  [Network.ARBITRUM]: 42161,
169
177
  [Network.BASE]: 8453,
170
178
  [Network.ETHEREUM]: 1,
171
- [Network.PLASMA]: 9745
179
+ [Network.PLASMA]: 9745,
180
+ [Network.HYPERLIQUID]: 999
172
181
  };
173
182
 
174
183
  export const balancerSubgraph: AddressNetworkMap = {
@@ -178,7 +187,8 @@ export const balancerSubgraph: AddressNetworkMap = {
178
187
  [Network.ARBITRUM]: "",
179
188
  [Network.BASE]: "",
180
189
  [Network.ETHEREUM]: "",
181
- [Network.PLASMA]: ""
190
+ [Network.PLASMA]: "",
191
+ [Network.HYPERLIQUID]: ""
182
192
  };
183
193
 
184
194
  export const multiCallAddress: AddressNetworkMap = {
@@ -187,7 +197,8 @@ export const multiCallAddress: AddressNetworkMap = {
187
197
  [Network.ARBITRUM]: "",
188
198
  [Network.BASE]: "",
189
199
  [Network.ETHEREUM]: "",
190
- [Network.PLASMA]: ""
200
+ [Network.PLASMA]: "",
201
+ [Network.HYPERLIQUID]: ""
191
202
  };
192
203
 
193
204
  export const lyraNetworkMap: LyraNetworkMap = {
@@ -235,11 +246,22 @@ export const flatMoneyContractAddresses: Readonly<Partial<
235
246
  }
236
247
  };
237
248
 
249
+ export const limitOrderAddress: AddressNetworkMap = {
250
+ [Network.POLYGON]: "0xB71410736d2C8F2DAf30dA9D332dA10534d2624d",
251
+ [Network.OPTIMISM]: "0x3bFE2a472d2964Ea4070725b7Fb0A868b3f08b63",
252
+ [Network.ARBITRUM]: "0x26a687e8244f1866E9Aa2D400c8b9957Aa8e6Ad4",
253
+ [Network.BASE]: "0xFcBEc28c43E356693971a24bf3F2Fd7D965E2ebA",
254
+ [Network.ETHEREUM]: "0x95B19De479bc693721cab39Da98FfECE062f5Ea4",
255
+ [Network.PLASMA]: "",
256
+ [Network.HYPERLIQUID]: ""
257
+ };
258
+
238
259
  export const OdosSwapFeeRecipient = {
239
260
  [Network.POLYGON]: "0x090e7fbD87A673eE3D0B6ccACf0e1d94fB90DA59",
240
261
  [Network.OPTIMISM]: "0x813123A13d01d3F07d434673Fdc89cBBA523f14d",
241
262
  [Network.ARBITRUM]: "0xfbD2B4216f422DC1eEe1Cff4Fb64B726F099dEF5",
242
263
  [Network.BASE]: "0x5619AD05b0253a7e647Bd2E4C01c7f40CEaB0879",
243
264
  [Network.ETHEREUM]: "0xfbD2B4216f422DC1eEe1Cff4Fb64B726F099dEF5",
244
- [Network.PLASMA]: ""
265
+ [Network.PLASMA]: "",
266
+ [Network.HYPERLIQUID]: ""
245
267
  };