@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
@@ -10,7 +10,8 @@ var Lyra__default = _interopDefault(Lyra);
10
10
  var sdkCore = require('@uniswap/sdk-core');
11
11
  var v3Sdk = require('@uniswap/v3-sdk');
12
12
  var JSBI = _interopDefault(require('jsbi'));
13
- var BigNumber = _interopDefault(require('bignumber.js'));
13
+ var BigNumber = require('bignumber.js');
14
+ var BigNumber__default = _interopDefault(BigNumber);
14
15
  var axios = _interopDefault(require('axios'));
15
16
  require('lodash/set');
16
17
  require('@ethersproject/abi');
@@ -4313,6 +4314,7 @@ var ManagerLogic = {
4313
4314
  Network["BASE"] = "base";
4314
4315
  Network["ETHEREUM"] = "ethereum";
4315
4316
  Network["PLASMA"] = "plasma";
4317
+ Network["HYPERLIQUID"] = "hyperliquid";
4316
4318
  })(exports.Network || (exports.Network = {}));
4317
4319
 
4318
4320
  (function (Dapp) {
@@ -4339,6 +4341,7 @@ var ManagerLogic = {
4339
4341
  Dapp["ODOS"] = "odos";
4340
4342
  Dapp["PENDLE"] = "pendle";
4341
4343
  Dapp["KYBERSWAP"] = "kyberswap";
4344
+ Dapp["HYPERLIQUID"] = "hyperliquid";
4342
4345
  })(exports.Dapp || (exports.Dapp = {}));
4343
4346
 
4344
4347
  (function (Transaction) {
@@ -4363,19 +4366,19 @@ var ManagerLogic = {
4363
4366
  Transaction["REMOVE_LIQUIDITY_UNSTAKE"] = "removeLiquidityAndUnstake";
4364
4367
  })(exports.Transaction || (exports.Transaction = {}));
4365
4368
 
4366
- var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _Network$ARBITRUM, _Network$BASE, _Network$ETHEREUM, _Network$PLASMA, _routerAddress, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _Network$OPTIMISM2, _Network$ARBITRUM2, _Network$BASE2, _stakingAddress, _Network$POLYGON4, _Network$OPTIMISM3, _Network$ARBITRUM3, _Network$BASE3, _Network$ETHEREUM2, _Network$PLASMA2, _aaveAddressProvider, _Network$POLYGON5, _Network$OPTIMISM4, _Network$ARBITRUM4, _Network$BASE4, _nonfungiblePositionM, _networkChainIdMap, _balancerSubgraph, _multiCallAddress, _lyraNetworkMap, _flatMoneyContractAdd, _OdosSwapFeeRecipient;
4369
+ var _factoryAddress, _Network$POLYGON, _Network$OPTIMISM, _Network$ARBITRUM, _Network$BASE, _Network$ETHEREUM, _Network$PLASMA, _Network$HYPERLIQUID, _routerAddress, _Network$POLYGON2, _dappFactoryAddress, _Network$POLYGON3, _Network$OPTIMISM2, _Network$ARBITRUM2, _Network$BASE2, _stakingAddress, _Network$POLYGON4, _Network$OPTIMISM3, _Network$ARBITRUM3, _Network$BASE3, _Network$ETHEREUM2, _Network$PLASMA2, _aaveAddressProvider, _Network$POLYGON5, _Network$OPTIMISM4, _Network$ARBITRUM4, _Network$BASE4, _nonfungiblePositionM, _networkChainIdMap, _balancerSubgraph, _multiCallAddress, _lyraNetworkMap, _flatMoneyContractAdd, _limitOrderAddress, _OdosSwapFeeRecipient;
4367
4370
 
4368
4371
  require("dotenv").config();
4369
4372
 
4370
- var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[exports.Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress[exports.Network.ARBITRUM] = "0xfffb5fb14606eb3a548c113026355020ddf27535", _factoryAddress[exports.Network.BASE] = "0x49Afe3abCf66CF09Fab86cb1139D8811C8afe56F", _factoryAddress[exports.Network.ETHEREUM] = "0x96D33bCF84DdE326014248E2896F79bbb9c13D6d", _factoryAddress[exports.Network.PLASMA] = "0xAec4975Fc8ad911464D2948D771488b30F6eEE87", _factoryAddress);
4371
- var routerAddress = (_routerAddress = {}, _routerAddress[exports.Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[exports.Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[exports.Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[exports.Dapp.TOROS] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$POLYGON[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$POLYGON), _routerAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[exports.Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[exports.Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[exports.Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[exports.Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[exports.Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[exports.Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$OPTIMISM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$OPTIMISM), _routerAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[exports.Dapp.RAMSES] = "0xaaa87963efeb6f7e0a2711f397663105acb1805e", _Network$ARBITRUM[exports.Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ARBITRUM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ARBITRUM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ARBITRUM), _routerAddress[exports.Network.BASE] = (_Network$BASE = {}, _Network$BASE[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[exports.Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[exports.Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[exports.Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$BASE[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$BASE), _routerAddress[exports.Network.ETHEREUM] = (_Network$ETHEREUM = {}, _Network$ETHEREUM[exports.Dapp.AAVEV3] = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", _Network$ETHEREUM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ETHEREUM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ETHEREUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ETHEREUM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ETHEREUM), _routerAddress[exports.Network.PLASMA] = (_Network$PLASMA = {}, _Network$PLASMA[exports.Dapp.AAVEV3] = "0x925a2A7214Ed92428B5b1B090F80b25700095e12", _Network$PLASMA[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$PLASMA[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$PLASMA), _routerAddress);
4372
- var dappFactoryAddress = (_dappFactoryAddress = {}, _dappFactoryAddress[exports.Network.POLYGON] = (_Network$POLYGON2 = {}, _Network$POLYGON2[exports.Dapp.SUSHISWAP] = "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", _Network$POLYGON2[exports.Dapp.QUICKSWAP] = "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", _Network$POLYGON2), _dappFactoryAddress[exports.Network.OPTIMISM] = {}, _dappFactoryAddress[exports.Network.ARBITRUM] = {}, _dappFactoryAddress[exports.Network.BASE] = {}, _dappFactoryAddress[exports.Network.ETHEREUM] = {}, _dappFactoryAddress[exports.Network.PLASMA] = {}, _dappFactoryAddress);
4373
- var stakingAddress = (_stakingAddress = {}, _stakingAddress[exports.Network.POLYGON] = (_Network$POLYGON3 = {}, _Network$POLYGON3[exports.Dapp.SUSHISWAP] = "0x0769fd68dFb93167989C6f7254cd0D766Fb2841F", _Network$POLYGON3[exports.Dapp.BALANCER] = "0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e", _Network$POLYGON3[exports.Dapp.AAVE] = "0x357D51124f59836DeD84c8a1730D72B749d8BC23", _Network$POLYGON3[exports.Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$POLYGON3), _stakingAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM2 = {}, _Network$OPTIMISM2[exports.Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$OPTIMISM2[exports.Dapp.COMPOUNDV3] = "0x443ea0340cb75a160f31a440722dec7b5bc3c2e9", _Network$OPTIMISM2), _stakingAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM2 = {}, _Network$ARBITRUM2[exports.Dapp.COMPOUNDV3] = "0x88730d254a2f7e6ac8388c3198afd694ba9f7fae", _Network$ARBITRUM2[exports.Dapp.PANCAKECL] = "0x5e09ACf80C0296740eC5d6F643005a4ef8DaA694", _Network$ARBITRUM2), _stakingAddress[exports.Network.BASE] = (_Network$BASE2 = {}, _Network$BASE2[exports.Dapp.PANCAKECL] = "0xC6A2Db661D5a5690172d8eB0a7DEA2d3008665A3", _Network$BASE2), _stakingAddress[exports.Network.ETHEREUM] = {}, _stakingAddress[exports.Network.PLASMA] = {}, _stakingAddress);
4374
- var aaveAddressProvider = (_aaveAddressProvider = {}, _aaveAddressProvider[exports.Network.POLYGON] = (_Network$POLYGON4 = {}, _Network$POLYGON4[exports.Dapp.AAVE] = "0xd05e3E715d945B59290df0ae8eF85c1BdB684744", _Network$POLYGON4[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$POLYGON4), _aaveAddressProvider[exports.Network.OPTIMISM] = (_Network$OPTIMISM3 = {}, _Network$OPTIMISM3[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$OPTIMISM3), _aaveAddressProvider[exports.Network.ARBITRUM] = (_Network$ARBITRUM3 = {}, _Network$ARBITRUM3[exports.Dapp.AAVEV3] = "0xa97684ead0e402dc232d5a977953df7ecbab3cdb", _Network$ARBITRUM3), _aaveAddressProvider[exports.Network.BASE] = (_Network$BASE3 = {}, _Network$BASE3[exports.Dapp.AAVEV3] = "0xe20fCBdBfFC4Dd138cE8b2E6FBb6CB49777ad64D", _Network$BASE3), _aaveAddressProvider[exports.Network.ETHEREUM] = (_Network$ETHEREUM2 = {}, _Network$ETHEREUM2[exports.Dapp.AAVEV3] = "0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e", _Network$ETHEREUM2), _aaveAddressProvider[exports.Network.PLASMA] = (_Network$PLASMA2 = {}, _Network$PLASMA2[exports.Dapp.AAVEV3] = "0x061D8e131F26512348ee5FA42e2DF1bA9d6505E9", _Network$PLASMA2), _aaveAddressProvider);
4375
- var nonfungiblePositionManagerAddress = (_nonfungiblePositionM = {}, _nonfungiblePositionM[exports.Network.POLYGON] = (_Network$POLYGON5 = {}, _Network$POLYGON5[exports.Dapp.UNISWAPV3] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _Network$POLYGON5), _nonfungiblePositionM[exports.Network.OPTIMISM] = (_Network$OPTIMISM4 = {}, _Network$OPTIMISM4[exports.Dapp.UNISWAPV3] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _Network$OPTIMISM4[exports.Dapp.VELODROMECL] = "0x416b433906b1B72FA758e166e239c43d68dC6F29", _Network$OPTIMISM4), _nonfungiblePositionM[exports.Network.ARBITRUM] = (_Network$ARBITRUM4 = {}, _Network$ARBITRUM4[exports.Dapp.UNISWAPV3] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _Network$ARBITRUM4[exports.Dapp.RAMSESCL] = "0xAA277CB7914b7e5514946Da92cb9De332Ce610EF", _Network$ARBITRUM4[exports.Dapp.PANCAKECL] = "0x46a15b0b27311cedf172ab29e4f4766fbe7f4364", _Network$ARBITRUM4), _nonfungiblePositionM[exports.Network.BASE] = (_Network$BASE4 = {}, _Network$BASE4[exports.Dapp.UNISWAPV3] = "0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1", _Network$BASE4[exports.Dapp.AERODROMECL] = "0x827922686190790b37229fd06084350e74485b72", _Network$BASE4[exports.Dapp.PANCAKECL] = "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364", _Network$BASE4), _nonfungiblePositionM[exports.Network.ETHEREUM] = {}, _nonfungiblePositionM[exports.Network.PLASMA] = {}, _nonfungiblePositionM);
4376
- var networkChainIdMap = (_networkChainIdMap = {}, _networkChainIdMap[exports.Network.POLYGON] = 137, _networkChainIdMap[exports.Network.OPTIMISM] = 10, _networkChainIdMap[exports.Network.ARBITRUM] = 42161, _networkChainIdMap[exports.Network.BASE] = 8453, _networkChainIdMap[exports.Network.ETHEREUM] = 1, _networkChainIdMap[exports.Network.PLASMA] = 9745, _networkChainIdMap);
4377
- var balancerSubgraph = (_balancerSubgraph = {}, _balancerSubgraph[exports.Network.POLYGON] = "https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2", _balancerSubgraph[exports.Network.OPTIMISM] = "", _balancerSubgraph[exports.Network.ARBITRUM] = "", _balancerSubgraph[exports.Network.BASE] = "", _balancerSubgraph[exports.Network.ETHEREUM] = "", _balancerSubgraph[exports.Network.PLASMA] = "", _balancerSubgraph);
4378
- var multiCallAddress = (_multiCallAddress = {}, _multiCallAddress[exports.Network.POLYGON] = "0x275617327c958bD06b5D6b871E7f491D76113dd8", _multiCallAddress[exports.Network.OPTIMISM] = "", _multiCallAddress[exports.Network.ARBITRUM] = "", _multiCallAddress[exports.Network.BASE] = "", _multiCallAddress[exports.Network.ETHEREUM] = "", _multiCallAddress[exports.Network.PLASMA] = "", _multiCallAddress);
4373
+ var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[exports.Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress[exports.Network.ARBITRUM] = "0xfffb5fb14606eb3a548c113026355020ddf27535", _factoryAddress[exports.Network.BASE] = "0x49Afe3abCf66CF09Fab86cb1139D8811C8afe56F", _factoryAddress[exports.Network.ETHEREUM] = "0x96D33bCF84DdE326014248E2896F79bbb9c13D6d", _factoryAddress[exports.Network.PLASMA] = "0xAec4975Fc8ad911464D2948D771488b30F6eEE87", _factoryAddress[exports.Network.HYPERLIQUID] = "0xe91505e2ab653dd128c71e9690eeefd28cc5b333", _factoryAddress);
4374
+ var routerAddress = (_routerAddress = {}, _routerAddress[exports.Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[exports.Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[exports.Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[exports.Dapp.TOROS] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$POLYGON[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$POLYGON), _routerAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[exports.Dapp.SYNTHETIX] = "0x8700dAec35aF8Ff88c16BdF0418774CB3D7599B4", _Network$OPTIMISM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[exports.Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[exports.Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[exports.Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[exports.Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[exports.Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$OPTIMISM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$OPTIMISM), _routerAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[exports.Dapp.RAMSES] = "0xaaa87963efeb6f7e0a2711f397663105acb1805e", _Network$ARBITRUM[exports.Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ARBITRUM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ARBITRUM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ARBITRUM), _routerAddress[exports.Network.BASE] = (_Network$BASE = {}, _Network$BASE[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[exports.Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[exports.Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[exports.Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$BASE[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$BASE), _routerAddress[exports.Network.ETHEREUM] = (_Network$ETHEREUM = {}, _Network$ETHEREUM[exports.Dapp.AAVEV3] = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", _Network$ETHEREUM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ETHEREUM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ETHEREUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ETHEREUM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ETHEREUM), _routerAddress[exports.Network.PLASMA] = (_Network$PLASMA = {}, _Network$PLASMA[exports.Dapp.AAVEV3] = "0x925a2A7214Ed92428B5b1B090F80b25700095e12", _Network$PLASMA[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$PLASMA[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$PLASMA), _routerAddress[exports.Network.HYPERLIQUID] = (_Network$HYPERLIQUID = {}, _Network$HYPERLIQUID[exports.Dapp.HYPERLIQUID] = "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24", _Network$HYPERLIQUID), _routerAddress);
4375
+ var dappFactoryAddress = (_dappFactoryAddress = {}, _dappFactoryAddress[exports.Network.POLYGON] = (_Network$POLYGON2 = {}, _Network$POLYGON2[exports.Dapp.SUSHISWAP] = "0xc35DADB65012eC5796536bD9864eD8773aBc74C4", _Network$POLYGON2[exports.Dapp.QUICKSWAP] = "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", _Network$POLYGON2), _dappFactoryAddress[exports.Network.OPTIMISM] = {}, _dappFactoryAddress[exports.Network.ARBITRUM] = {}, _dappFactoryAddress[exports.Network.BASE] = {}, _dappFactoryAddress[exports.Network.ETHEREUM] = {}, _dappFactoryAddress[exports.Network.PLASMA] = {}, _dappFactoryAddress[exports.Network.HYPERLIQUID] = {}, _dappFactoryAddress);
4376
+ var stakingAddress = (_stakingAddress = {}, _stakingAddress[exports.Network.POLYGON] = (_Network$POLYGON3 = {}, _Network$POLYGON3[exports.Dapp.SUSHISWAP] = "0x0769fd68dFb93167989C6f7254cd0D766Fb2841F", _Network$POLYGON3[exports.Dapp.BALANCER] = "0x0F3e0c4218b7b0108a3643cFe9D3ec0d4F57c54e", _Network$POLYGON3[exports.Dapp.AAVE] = "0x357D51124f59836DeD84c8a1730D72B749d8BC23", _Network$POLYGON3[exports.Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$POLYGON3), _stakingAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM2 = {}, _Network$OPTIMISM2[exports.Dapp.AAVEV3] = "0x929EC64c34a17401F460460D4B9390518E5B473e", _Network$OPTIMISM2[exports.Dapp.COMPOUNDV3] = "0x443ea0340cb75a160f31a440722dec7b5bc3c2e9", _Network$OPTIMISM2), _stakingAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM2 = {}, _Network$ARBITRUM2[exports.Dapp.COMPOUNDV3] = "0x88730d254a2f7e6ac8388c3198afd694ba9f7fae", _Network$ARBITRUM2[exports.Dapp.PANCAKECL] = "0x5e09ACf80C0296740eC5d6F643005a4ef8DaA694", _Network$ARBITRUM2), _stakingAddress[exports.Network.BASE] = (_Network$BASE2 = {}, _Network$BASE2[exports.Dapp.PANCAKECL] = "0xC6A2Db661D5a5690172d8eB0a7DEA2d3008665A3", _Network$BASE2), _stakingAddress[exports.Network.ETHEREUM] = {}, _stakingAddress[exports.Network.PLASMA] = {}, _stakingAddress[exports.Network.HYPERLIQUID] = {}, _stakingAddress);
4377
+ var aaveAddressProvider = (_aaveAddressProvider = {}, _aaveAddressProvider[exports.Network.POLYGON] = (_Network$POLYGON4 = {}, _Network$POLYGON4[exports.Dapp.AAVE] = "0xd05e3E715d945B59290df0ae8eF85c1BdB684744", _Network$POLYGON4[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$POLYGON4), _aaveAddressProvider[exports.Network.OPTIMISM] = (_Network$OPTIMISM3 = {}, _Network$OPTIMISM3[exports.Dapp.AAVEV3] = "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", _Network$OPTIMISM3), _aaveAddressProvider[exports.Network.ARBITRUM] = (_Network$ARBITRUM3 = {}, _Network$ARBITRUM3[exports.Dapp.AAVEV3] = "0xa97684ead0e402dc232d5a977953df7ecbab3cdb", _Network$ARBITRUM3), _aaveAddressProvider[exports.Network.BASE] = (_Network$BASE3 = {}, _Network$BASE3[exports.Dapp.AAVEV3] = "0xe20fCBdBfFC4Dd138cE8b2E6FBb6CB49777ad64D", _Network$BASE3), _aaveAddressProvider[exports.Network.ETHEREUM] = (_Network$ETHEREUM2 = {}, _Network$ETHEREUM2[exports.Dapp.AAVEV3] = "0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e", _Network$ETHEREUM2), _aaveAddressProvider[exports.Network.PLASMA] = (_Network$PLASMA2 = {}, _Network$PLASMA2[exports.Dapp.AAVEV3] = "0x061D8e131F26512348ee5FA42e2DF1bA9d6505E9", _Network$PLASMA2), _aaveAddressProvider[exports.Network.HYPERLIQUID] = {}, _aaveAddressProvider);
4378
+ var nonfungiblePositionManagerAddress = (_nonfungiblePositionM = {}, _nonfungiblePositionM[exports.Network.POLYGON] = (_Network$POLYGON5 = {}, _Network$POLYGON5[exports.Dapp.UNISWAPV3] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _Network$POLYGON5), _nonfungiblePositionM[exports.Network.OPTIMISM] = (_Network$OPTIMISM4 = {}, _Network$OPTIMISM4[exports.Dapp.UNISWAPV3] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _Network$OPTIMISM4[exports.Dapp.VELODROMECL] = "0x416b433906b1B72FA758e166e239c43d68dC6F29", _Network$OPTIMISM4), _nonfungiblePositionM[exports.Network.ARBITRUM] = (_Network$ARBITRUM4 = {}, _Network$ARBITRUM4[exports.Dapp.UNISWAPV3] = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", _Network$ARBITRUM4[exports.Dapp.RAMSESCL] = "0xAA277CB7914b7e5514946Da92cb9De332Ce610EF", _Network$ARBITRUM4[exports.Dapp.PANCAKECL] = "0x46a15b0b27311cedf172ab29e4f4766fbe7f4364", _Network$ARBITRUM4), _nonfungiblePositionM[exports.Network.BASE] = (_Network$BASE4 = {}, _Network$BASE4[exports.Dapp.UNISWAPV3] = "0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1", _Network$BASE4[exports.Dapp.AERODROMECL] = "0x827922686190790b37229fd06084350e74485b72", _Network$BASE4[exports.Dapp.PANCAKECL] = "0x46A15B0b27311cedF172AB29E4f4766fbE7F4364", _Network$BASE4), _nonfungiblePositionM[exports.Network.ETHEREUM] = {}, _nonfungiblePositionM[exports.Network.PLASMA] = {}, _nonfungiblePositionM[exports.Network.HYPERLIQUID] = {}, _nonfungiblePositionM);
4379
+ var networkChainIdMap = (_networkChainIdMap = {}, _networkChainIdMap[exports.Network.POLYGON] = 137, _networkChainIdMap[exports.Network.OPTIMISM] = 10, _networkChainIdMap[exports.Network.ARBITRUM] = 42161, _networkChainIdMap[exports.Network.BASE] = 8453, _networkChainIdMap[exports.Network.ETHEREUM] = 1, _networkChainIdMap[exports.Network.PLASMA] = 9745, _networkChainIdMap[exports.Network.HYPERLIQUID] = 999, _networkChainIdMap);
4380
+ var balancerSubgraph = (_balancerSubgraph = {}, _balancerSubgraph[exports.Network.POLYGON] = "https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-polygon-v2", _balancerSubgraph[exports.Network.OPTIMISM] = "", _balancerSubgraph[exports.Network.ARBITRUM] = "", _balancerSubgraph[exports.Network.BASE] = "", _balancerSubgraph[exports.Network.ETHEREUM] = "", _balancerSubgraph[exports.Network.PLASMA] = "", _balancerSubgraph[exports.Network.HYPERLIQUID] = "", _balancerSubgraph);
4381
+ var multiCallAddress = (_multiCallAddress = {}, _multiCallAddress[exports.Network.POLYGON] = "0x275617327c958bD06b5D6b871E7f491D76113dd8", _multiCallAddress[exports.Network.OPTIMISM] = "", _multiCallAddress[exports.Network.ARBITRUM] = "", _multiCallAddress[exports.Network.BASE] = "", _multiCallAddress[exports.Network.ETHEREUM] = "", _multiCallAddress[exports.Network.PLASMA] = "", _multiCallAddress[exports.Network.HYPERLIQUID] = "", _multiCallAddress);
4379
4382
  var lyraNetworkMap = (_lyraNetworkMap = {}, _lyraNetworkMap[exports.Network.OPTIMISM] = Lyra.Deployment.Mainnet, _lyraNetworkMap);
4380
4383
  var MaxUint128 = "0xffffffffffffffffffffffffffffffff";
4381
4384
  var UNISWAPV3_QUOTER_ADDRESS = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6";
@@ -4399,7 +4402,8 @@ var flatMoneyContractAddresses = (_flatMoneyContractAdd = {}, _flatMoneyContract
4399
4402
  COLLATERAL: "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
4400
4403
  StableModule: "0xcD3657cB0E851b6a734c4D1e7FC2640Bcd9f6B2d"
4401
4404
  }, _flatMoneyContractAdd);
4402
- var OdosSwapFeeRecipient = (_OdosSwapFeeRecipient = {}, _OdosSwapFeeRecipient[exports.Network.POLYGON] = "0x090e7fbD87A673eE3D0B6ccACf0e1d94fB90DA59", _OdosSwapFeeRecipient[exports.Network.OPTIMISM] = "0x813123A13d01d3F07d434673Fdc89cBBA523f14d", _OdosSwapFeeRecipient[exports.Network.ARBITRUM] = "0xfbD2B4216f422DC1eEe1Cff4Fb64B726F099dEF5", _OdosSwapFeeRecipient[exports.Network.BASE] = "0x5619AD05b0253a7e647Bd2E4C01c7f40CEaB0879", _OdosSwapFeeRecipient[exports.Network.ETHEREUM] = "0xfbD2B4216f422DC1eEe1Cff4Fb64B726F099dEF5", _OdosSwapFeeRecipient[exports.Network.PLASMA] = "", _OdosSwapFeeRecipient);
4405
+ var limitOrderAddress = (_limitOrderAddress = {}, _limitOrderAddress[exports.Network.POLYGON] = "0xB71410736d2C8F2DAf30dA9D332dA10534d2624d", _limitOrderAddress[exports.Network.OPTIMISM] = "0x3bFE2a472d2964Ea4070725b7Fb0A868b3f08b63", _limitOrderAddress[exports.Network.ARBITRUM] = "0x26a687e8244f1866E9Aa2D400c8b9957Aa8e6Ad4", _limitOrderAddress[exports.Network.BASE] = "0xFcBEc28c43E356693971a24bf3F2Fd7D965E2ebA", _limitOrderAddress[exports.Network.ETHEREUM] = "0x95B19De479bc693721cab39Da98FfECE062f5Ea4", _limitOrderAddress[exports.Network.PLASMA] = "", _limitOrderAddress[exports.Network.HYPERLIQUID] = "", _limitOrderAddress);
4406
+ var OdosSwapFeeRecipient = (_OdosSwapFeeRecipient = {}, _OdosSwapFeeRecipient[exports.Network.POLYGON] = "0x090e7fbD87A673eE3D0B6ccACf0e1d94fB90DA59", _OdosSwapFeeRecipient[exports.Network.OPTIMISM] = "0x813123A13d01d3F07d434673Fdc89cBBA523f14d", _OdosSwapFeeRecipient[exports.Network.ARBITRUM] = "0xfbD2B4216f422DC1eEe1Cff4Fb64B726F099dEF5", _OdosSwapFeeRecipient[exports.Network.BASE] = "0x5619AD05b0253a7e647Bd2E4C01c7f40CEaB0879", _OdosSwapFeeRecipient[exports.Network.ETHEREUM] = "0xfbD2B4216f422DC1eEe1Cff4Fb64B726F099dEF5", _OdosSwapFeeRecipient[exports.Network.PLASMA] = "", _OdosSwapFeeRecipient[exports.Network.HYPERLIQUID] = "", _OdosSwapFeeRecipient);
4403
4407
 
4404
4408
  var abi$3 = [
4405
4409
  {
@@ -9616,7 +9620,7 @@ function _getUniswapV3Liquidity() {
9616
9620
 
9617
9621
  case 3:
9618
9622
  result = _context2.sent;
9619
- return _context2.abrupt("return", new BigNumber(result.liquidity.toString()));
9623
+ return _context2.abrupt("return", new BigNumber__default(result.liquidity.toString()));
9620
9624
 
9621
9625
  case 5:
9622
9626
  case "end":
@@ -9753,7 +9757,7 @@ function _getDecreaseLiquidityTxData() {
9753
9757
  }
9754
9758
 
9755
9759
  _abi3 = new ethers.ethers.utils.Interface(IArrakisV1RouterStaking.abi);
9756
- _context4.t7 = BigNumber;
9760
+ _context4.t7 = BigNumber__default;
9757
9761
  _context4.next = 28;
9758
9762
  return pool.utils.getBalance(tokenId, pool.address);
9759
9763
 
@@ -14000,10 +14004,10 @@ function _getOdosSwapTxData() {
14000
14004
  });
14001
14005
 
14002
14006
  case 22:
14003
- FEE_DENOM = new BigNumber(1e18);
14004
- correctedFee = new BigNumber(referralFeeBips * 1e18 / 10000);
14007
+ FEE_DENOM = new BigNumber__default(1e18);
14008
+ correctedFee = new BigNumber__default(referralFeeBips * 1e18 / 10000);
14005
14009
  factor = 1.1;
14006
- correctedOutputQuote = new BigNumber(tokenInfo.outputQuote.toString()).times(FEE_DENOM.minus(correctedFee).div(FEE_DENOM.minus(referralInfo.fee.toString()))).times(factor); // example referralInfo.fee could be 0.0005 * 1e18 = 500000000000000, which is 0.05%
14010
+ correctedOutputQuote = new BigNumber__default(tokenInfo.outputQuote.toString()).times(FEE_DENOM.minus(correctedFee).div(FEE_DENOM.minus(referralInfo.fee.toString()))).times(factor); // example referralInfo.fee could be 0.0005 * 1e18 = 500000000000000, which is 0.05%
14007
14011
  // Create corrected referral info
14008
14012
 
14009
14013
  correctedTxData = iface.encodeFunctionData(decodedData.name, [_extends({}, tokenInfo, {
@@ -14077,7 +14081,7 @@ var getSwapDataViaOdos = /*#__PURE__*/function () {
14077
14081
  tokenAddress: dstAsset,
14078
14082
  proportion: 1
14079
14083
  }],
14080
- slippageLimitPercent: new BigNumber(slippage).div(100).toString(),
14084
+ slippageLimitPercent: new BigNumber__default(slippage).div(100).toString(),
14081
14085
  userAddr: from,
14082
14086
  referralFee: referralFeeBips,
14083
14087
  referralFeeRecipient: OdosSwapFeeRecipient[network],
@@ -14127,10 +14131,10 @@ var getSwapDataViaOdos = /*#__PURE__*/function () {
14127
14131
  return _context.abrupt("return", txData);
14128
14132
 
14129
14133
  case 26:
14130
- FEE_DENOM = new BigNumber(1e18);
14131
- correctedFee = new BigNumber(referralFeeBips * 1e18 / 10000);
14134
+ FEE_DENOM = new BigNumber__default(1e18);
14135
+ correctedFee = new BigNumber__default(referralFeeBips * 1e18 / 10000);
14132
14136
  factor = 1.1;
14133
- correctedOutputQuote = new BigNumber(tokenInfo.outputQuote.toString()).times(FEE_DENOM.minus(correctedFee).div(FEE_DENOM.minus(referralInfo.fee.toString()))).times(factor); // example referralInfo.fee could be 0.0005 * 1e18 = 500000000000000, which is 0.05%
14137
+ correctedOutputQuote = new BigNumber__default(tokenInfo.outputQuote.toString()).times(FEE_DENOM.minus(correctedFee).div(FEE_DENOM.minus(referralInfo.fee.toString()))).times(factor); // example referralInfo.fee could be 0.0005 * 1e18 = 500000000000000, which is 0.05%
14134
14138
  // Create corrected referral info
14135
14139
 
14136
14140
  correctedTxData = iface.encodeFunctionData(decodedData.name, [_extends({}, tokenInfo, {
@@ -27418,7 +27422,7 @@ var getKeeperFee = /*#__PURE__*/function () {
27418
27422
  }
27419
27423
 
27420
27424
  _context2.next = 10;
27421
- return keeperFeeContract["getKeeperFee(uint256)"](new BigNumber(gasPrice.toString()).times(1.5).toFixed(0));
27425
+ return keeperFeeContract["getKeeperFee(uint256)"](new BigNumber__default(gasPrice.toString()).times(1.5).toFixed(0));
27422
27426
 
27423
27427
  case 10:
27424
27428
  keeperfee = _context2.sent;
@@ -27495,7 +27499,7 @@ var getKeeperFeeInUsd = /*#__PURE__*/function () {
27495
27499
  throw new Error("getKeeperFeeInUsd: required asset not enabled yet");
27496
27500
 
27497
27501
  case 9:
27498
- rateD1 = new BigNumber(filteredFc[0].rate.toString()).div(1e18);
27502
+ rateD1 = new BigNumber__default(filteredFc[0].rate.toString()).div(1e18);
27499
27503
  _context3.next = 12;
27500
27504
  return pool.utils.getDecimals(flatMoneyContracts.COLLATERAL);
27501
27505
 
@@ -27566,14 +27570,14 @@ function _mintUnitViaFlatMoney() {
27566
27570
  case 7:
27567
27571
  keeperfee = _context.sent;
27568
27572
  // in COLLATERAL
27569
- adjustedDepositAmount = new BigNumber(depositAmount.toString()).minus(keeperfee.toString() // keeper fee deducted from amountIn
27573
+ adjustedDepositAmount = new BigNumber__default(depositAmount.toString()).minus(keeperfee.toString() // keeper fee deducted from amountIn
27570
27574
  );
27571
27575
  _context.next = 11;
27572
27576
  return getStableDepositQuote(pool, adjustedDepositAmount.toFixed(0));
27573
27577
 
27574
27578
  case 11:
27575
27579
  amountOut = _context.sent;
27576
- minAmountOut = new BigNumber(amountOut.toString()).times(1 - slippage / 100).toFixed(0);
27580
+ minAmountOut = new BigNumber__default(amountOut.toString()).times(1 - slippage / 100).toFixed(0);
27577
27581
  _context.next = 15;
27578
27582
  return getAnnounceStableDepositTxData(adjustedDepositAmount.toFixed(0), minAmountOut, keeperfee);
27579
27583
 
@@ -27638,7 +27642,7 @@ function _redeemUnitViaFlatMoney() {
27638
27642
 
27639
27643
  case 10:
27640
27644
  amountOut = _context2.sent;
27641
- minAmountOut = new BigNumber(amountOut.toString()).times(1 - slippage / 100).minus(keeperfee.toString()) // keeper fee deducted from amountOut
27645
+ minAmountOut = new BigNumber__default(amountOut.toString()).times(1 - slippage / 100).minus(keeperfee.toString()) // keeper fee deducted from amountOut
27642
27646
  .toFixed(0);
27643
27647
  _context2.next = 14;
27644
27648
  return getAnnounceStableWithdrawTxData(withdrawAmount, minAmountOut, keeperfee);
@@ -28862,7 +28866,7 @@ var getExitExpPTTxData = /*#__PURE__*/function () {
28862
28866
 
28863
28867
  case 12:
28864
28868
  exchangeRate = _context2.sent;
28865
- minAmountOut = new BigNumber(amountIn.toString()).times(1e18).div(exchangeRate.toString()).decimalPlaces(0, BigNumber.ROUND_DOWN).toFixed(0);
28869
+ minAmountOut = new BigNumber__default(amountIn.toString()).times(1e18).div(exchangeRate.toString()).decimalPlaces(0, BigNumber__default.ROUND_DOWN).toFixed(0);
28866
28870
  return _context2.abrupt("return", {
28867
28871
  txData: txData,
28868
28872
  minAmountOut: minAmountOut
@@ -29327,7 +29331,7 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
29327
29331
  case 9:
29328
29332
  assetHandlerAddress = _context4.sent;
29329
29333
  assetHandler = new ethers.ethers.Contract(assetHandlerAddress, AssetHandlerAbi.abi, pool.signer);
29330
- _context4.t0 = BigNumber;
29334
+ _context4.t0 = BigNumber__default;
29331
29335
  _context4.next = 14;
29332
29336
  return assetHandler.getUSDPrice(receiveToken);
29333
29337
 
@@ -29352,7 +29356,7 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
29352
29356
  while (1) {
29353
29357
  switch (_context3.prev = _context3.next) {
29354
29358
  case 0:
29355
- _context3.t0 = BigNumber;
29359
+ _context3.t0 = BigNumber__default;
29356
29360
  _context3.next = 3;
29357
29361
  return assetHandler.getUSDPrice(swapTAsset.token);
29358
29362
 
@@ -29369,7 +29373,7 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
29369
29373
 
29370
29374
  case 10:
29371
29375
  swapTAssetDecimals = _context3.sent;
29372
- tokenBalanceBN = new BigNumber(swapTAsset.balance.toString());
29376
+ tokenBalanceBN = new BigNumber__default(swapTAsset.balance.toString());
29373
29377
  estimatedValueToSwapD0 = tokenBalanceBN.times(swapTAssetPriceD18).div(Math.pow(10, 18)).div(Math.pow(10, Number(swapTAssetDecimals.toString()))); // --- caution: if the estimated value to swap is less than the low USD value for withdrawal, use a higher slippage
29374
29378
 
29375
29379
  // --- caution: if the estimated value to swap is less than the low USD value for withdrawal, use a higher slippage
@@ -29377,7 +29381,7 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
29377
29381
 
29378
29382
  // -----
29379
29383
  estimatedMinReceiveAmount = tokenBalanceBN.times(swapTAssetPriceD18).div(receiveTokenPriceD18).div(Math.pow(10, Number(swapTAssetDecimals.toString()))).times(Math.pow(10, Number(receiveTokenDecimals.toString()))).times(1 - adjustedSlippage / 10000) // slippage is in basis points, so divide by 10000
29380
- .decimalPlaces(0, BigNumber.ROUND_DOWN);
29384
+ .decimalPlaces(0, BigNumber__default.ROUND_DOWN);
29381
29385
  return _context3.abrupt("return", {
29382
29386
  token: swapTAsset.token,
29383
29387
  balance: swapTAsset.balance,
@@ -29402,7 +29406,7 @@ var createCompleteWithdrawalTxArguments = /*#__PURE__*/function () {
29402
29406
  swapDestMinDestAmount = tAssetInfos.reduce(function (acc, _ref6) {
29403
29407
  var estimatedMinReceiveAmount = _ref6.estimatedMinReceiveAmount;
29404
29408
  return acc.plus(estimatedMinReceiveAmount);
29405
- }, new BigNumber(0));
29409
+ }, new BigNumber__default(0));
29406
29410
  _context4.next = 28;
29407
29411
  return easySwapper.withdrawalContracts(pool.address);
29408
29412
 
@@ -29477,6 +29481,270 @@ var getCompleteWithdrawalTxData = /*#__PURE__*/function () {
29477
29481
  };
29478
29482
  }();
29479
29483
 
29484
+ var IPoolLimitOrderManager = [
29485
+ {
29486
+ inputs: [
29487
+ {
29488
+ components: [
29489
+ {
29490
+ internalType: "uint256",
29491
+ name: "amount",
29492
+ type: "uint256"
29493
+ },
29494
+ {
29495
+ internalType: "uint256",
29496
+ name: "stopLossPriceD18",
29497
+ type: "uint256"
29498
+ },
29499
+ {
29500
+ internalType: "uint256",
29501
+ name: "takeProfitPriceD18",
29502
+ type: "uint256"
29503
+ },
29504
+ {
29505
+ internalType: "address",
29506
+ name: "user",
29507
+ type: "address"
29508
+ },
29509
+ {
29510
+ internalType: "address",
29511
+ name: "pool",
29512
+ type: "address"
29513
+ },
29514
+ {
29515
+ internalType: "address",
29516
+ name: "pricingAsset",
29517
+ type: "address"
29518
+ }
29519
+ ],
29520
+ internalType: "struct IPoolLimitOrderManager.LimitOrderInfo",
29521
+ name: "limitOrderInfo",
29522
+ type: "tuple"
29523
+ }
29524
+ ],
29525
+ name: "createLimitOrder",
29526
+ outputs: [
29527
+ ],
29528
+ stateMutability: "nonpayable",
29529
+ type: "function"
29530
+ },
29531
+ {
29532
+ inputs: [
29533
+ {
29534
+ components: [
29535
+ {
29536
+ internalType: "uint256",
29537
+ name: "amount",
29538
+ type: "uint256"
29539
+ },
29540
+ {
29541
+ internalType: "uint256",
29542
+ name: "stopLossPriceD18",
29543
+ type: "uint256"
29544
+ },
29545
+ {
29546
+ internalType: "uint256",
29547
+ name: "takeProfitPriceD18",
29548
+ type: "uint256"
29549
+ },
29550
+ {
29551
+ internalType: "address",
29552
+ name: "user",
29553
+ type: "address"
29554
+ },
29555
+ {
29556
+ internalType: "address",
29557
+ name: "pool",
29558
+ type: "address"
29559
+ },
29560
+ {
29561
+ internalType: "address",
29562
+ name: "pricingAsset",
29563
+ type: "address"
29564
+ }
29565
+ ],
29566
+ internalType: "struct IPoolLimitOrderManager.LimitOrderInfo",
29567
+ name: "limitOrderInfo",
29568
+ type: "tuple"
29569
+ }
29570
+ ],
29571
+ name: "modifyLimitOrder",
29572
+ outputs: [
29573
+ ],
29574
+ stateMutability: "nonpayable",
29575
+ type: "function"
29576
+ },
29577
+ {
29578
+ inputs: [
29579
+ {
29580
+ internalType: "address",
29581
+ name: "pool_",
29582
+ type: "address"
29583
+ }
29584
+ ],
29585
+ name: "deleteLimitOrder",
29586
+ outputs: [
29587
+ ],
29588
+ stateMutability: "nonpayable",
29589
+ type: "function"
29590
+ },
29591
+ {
29592
+ inputs: [
29593
+ ],
29594
+ name: "getAllLimitOrderIds",
29595
+ outputs: [
29596
+ {
29597
+ internalType: "bytes32[]",
29598
+ name: "",
29599
+ type: "bytes32[]"
29600
+ }
29601
+ ],
29602
+ stateMutability: "view",
29603
+ type: "function"
29604
+ },
29605
+ {
29606
+ inputs: [
29607
+ {
29608
+ internalType: "bytes32",
29609
+ name: "orderId",
29610
+ type: "bytes32"
29611
+ }
29612
+ ],
29613
+ name: "limitOrders",
29614
+ outputs: [
29615
+ {
29616
+ internalType: "uint256",
29617
+ name: "amount",
29618
+ type: "uint256"
29619
+ },
29620
+ {
29621
+ internalType: "uint256",
29622
+ name: "stopLossPriceD18",
29623
+ type: "uint256"
29624
+ },
29625
+ {
29626
+ internalType: "uint256",
29627
+ name: "takeProfitPriceD18",
29628
+ type: "uint256"
29629
+ },
29630
+ {
29631
+ internalType: "address",
29632
+ name: "user",
29633
+ type: "address"
29634
+ },
29635
+ {
29636
+ internalType: "address",
29637
+ name: "pool",
29638
+ type: "address"
29639
+ },
29640
+ {
29641
+ internalType: "address",
29642
+ name: "pricingAsset",
29643
+ type: "address"
29644
+ }
29645
+ ],
29646
+ stateMutability: "view",
29647
+ type: "function"
29648
+ }
29649
+ ];
29650
+
29651
+ var iface = /*#__PURE__*/new ethers.ethers.utils.Interface(IPoolLimitOrderManager);
29652
+ function getLimitOrderId(userAddress, vaultAddress) {
29653
+ return ethers.ethers.utils.solidityKeccak256(["address", "address"], [userAddress, vaultAddress]);
29654
+ }
29655
+ function getCreateLimitOrderTxData(info) {
29656
+ return iface.encodeFunctionData("createLimitOrder", [[info.amount, info.stopLossPriceD18, info.takeProfitPriceD18, info.user, info.pool, info.pricingAsset]]);
29657
+ }
29658
+ function getModifyLimitOrderTxData(info) {
29659
+ return iface.encodeFunctionData("modifyLimitOrder", [[info.amount, info.stopLossPriceD18, info.takeProfitPriceD18, info.user, info.pool, info.pricingAsset]]);
29660
+ }
29661
+ function getDeleteLimitOrderTxData(vaultAddress) {
29662
+ return iface.encodeFunctionData("deleteLimitOrder", [vaultAddress]);
29663
+ }
29664
+ function getTorosLimitOrder(_x, _x2, _x3) {
29665
+ return _getTorosLimitOrder.apply(this, arguments);
29666
+ }
29667
+
29668
+ function _getTorosLimitOrder() {
29669
+ _getTorosLimitOrder = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(pool, userAddress, vaultAddress) {
29670
+ var managerAddress, orderId, contract, result;
29671
+ return runtime_1.wrap(function _callee$(_context) {
29672
+ while (1) {
29673
+ switch (_context.prev = _context.next) {
29674
+ case 0:
29675
+ managerAddress = limitOrderAddress[pool.network];
29676
+
29677
+ if (managerAddress) {
29678
+ _context.next = 3;
29679
+ break;
29680
+ }
29681
+
29682
+ return _context.abrupt("return", null);
29683
+
29684
+ case 3:
29685
+ orderId = getLimitOrderId(userAddress, vaultAddress);
29686
+ contract = new ethers.ethers.Contract(managerAddress, IPoolLimitOrderManager, pool.signer);
29687
+ _context.next = 7;
29688
+ return contract.limitOrders(orderId);
29689
+
29690
+ case 7:
29691
+ result = _context.sent;
29692
+
29693
+ if (!result.amount.isZero()) {
29694
+ _context.next = 10;
29695
+ break;
29696
+ }
29697
+
29698
+ return _context.abrupt("return", null);
29699
+
29700
+ case 10:
29701
+ return _context.abrupt("return", {
29702
+ amount: result.amount,
29703
+ stopLossPriceD18: result.stopLossPriceD18,
29704
+ takeProfitPriceD18: result.takeProfitPriceD18,
29705
+ user: result.user,
29706
+ pool: result.pool,
29707
+ pricingAsset: result.pricingAsset
29708
+ });
29709
+
29710
+ case 11:
29711
+ case "end":
29712
+ return _context.stop();
29713
+ }
29714
+ }
29715
+ }, _callee);
29716
+ }));
29717
+ return _getTorosLimitOrder.apply(this, arguments);
29718
+ }
29719
+
29720
+ function hasActiveTorosLimitOrder(_x4, _x5, _x6) {
29721
+ return _hasActiveTorosLimitOrder.apply(this, arguments);
29722
+ }
29723
+
29724
+ function _hasActiveTorosLimitOrder() {
29725
+ _hasActiveTorosLimitOrder = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, userAddress, vaultAddress) {
29726
+ var order;
29727
+ return runtime_1.wrap(function _callee2$(_context2) {
29728
+ while (1) {
29729
+ switch (_context2.prev = _context2.next) {
29730
+ case 0:
29731
+ _context2.next = 2;
29732
+ return getTorosLimitOrder(pool, userAddress, vaultAddress);
29733
+
29734
+ case 2:
29735
+ order = _context2.sent;
29736
+ return _context2.abrupt("return", order !== null);
29737
+
29738
+ case 4:
29739
+ case "end":
29740
+ return _context2.stop();
29741
+ }
29742
+ }
29743
+ }, _callee2);
29744
+ }));
29745
+ return _hasActiveTorosLimitOrder.apply(this, arguments);
29746
+ }
29747
+
29480
29748
  var kyberBaseUrl = "https://aggregator-api.kyberswap.com";
29481
29749
  function getKyberSwapTxData(_x, _x2, _x3, _x4, _x5) {
29482
29750
  return _getKyberSwapTxData.apply(this, arguments);
@@ -29542,6 +29810,574 @@ function _getKyberSwapTxData() {
29542
29810
  return _getKyberSwapTxData.apply(this, arguments);
29543
29811
  }
29544
29812
 
29813
+ var ICoreDepositWalletAbi = [
29814
+ {
29815
+ inputs: [
29816
+ {
29817
+ internalType: "address",
29818
+ name: "from",
29819
+ type: "address"
29820
+ },
29821
+ {
29822
+ internalType: "bytes32",
29823
+ name: "destinationRecipient",
29824
+ type: "bytes32"
29825
+ },
29826
+ {
29827
+ internalType: "uint32",
29828
+ name: "destinationChainId",
29829
+ type: "uint32"
29830
+ },
29831
+ {
29832
+ internalType: "uint256",
29833
+ name: "amount",
29834
+ type: "uint256"
29835
+ },
29836
+ {
29837
+ internalType: "uint64",
29838
+ name: "coreNonce",
29839
+ type: "uint64"
29840
+ },
29841
+ {
29842
+ internalType: "bytes",
29843
+ name: "data",
29844
+ type: "bytes"
29845
+ }
29846
+ ],
29847
+ name: "coreReceiveWithData",
29848
+ outputs: [
29849
+ ],
29850
+ stateMutability: "nonpayable",
29851
+ type: "function"
29852
+ },
29853
+ {
29854
+ inputs: [
29855
+ {
29856
+ internalType: "uint256",
29857
+ name: "amount",
29858
+ type: "uint256"
29859
+ },
29860
+ {
29861
+ internalType: "uint32",
29862
+ name: "destinationDex",
29863
+ type: "uint32"
29864
+ }
29865
+ ],
29866
+ name: "deposit",
29867
+ outputs: [
29868
+ ],
29869
+ stateMutability: "nonpayable",
29870
+ type: "function"
29871
+ },
29872
+ {
29873
+ inputs: [
29874
+ {
29875
+ internalType: "uint256",
29876
+ name: "amount",
29877
+ type: "uint256"
29878
+ },
29879
+ {
29880
+ internalType: "uint256",
29881
+ name: "authValidAfter",
29882
+ type: "uint256"
29883
+ },
29884
+ {
29885
+ internalType: "uint256",
29886
+ name: "authValidBefore",
29887
+ type: "uint256"
29888
+ },
29889
+ {
29890
+ internalType: "bytes32",
29891
+ name: "authNonce",
29892
+ type: "bytes32"
29893
+ },
29894
+ {
29895
+ internalType: "uint8",
29896
+ name: "v",
29897
+ type: "uint8"
29898
+ },
29899
+ {
29900
+ internalType: "bytes32",
29901
+ name: "r",
29902
+ type: "bytes32"
29903
+ },
29904
+ {
29905
+ internalType: "bytes32",
29906
+ name: "s",
29907
+ type: "bytes32"
29908
+ },
29909
+ {
29910
+ internalType: "uint32",
29911
+ name: "destinationDex",
29912
+ type: "uint32"
29913
+ }
29914
+ ],
29915
+ name: "depositWithAuth",
29916
+ outputs: [
29917
+ ],
29918
+ stateMutability: "nonpayable",
29919
+ type: "function"
29920
+ },
29921
+ {
29922
+ inputs: [
29923
+ {
29924
+ internalType: "address",
29925
+ name: "to",
29926
+ type: "address"
29927
+ },
29928
+ {
29929
+ internalType: "uint256",
29930
+ name: "amount",
29931
+ type: "uint256"
29932
+ }
29933
+ ],
29934
+ name: "transfer",
29935
+ outputs: [
29936
+ {
29937
+ internalType: "bool",
29938
+ name: "success",
29939
+ type: "bool"
29940
+ }
29941
+ ],
29942
+ stateMutability: "nonpayable",
29943
+ type: "function"
29944
+ }
29945
+ ];
29946
+
29947
+ var ICoreWriterAbi = [
29948
+ {
29949
+ anonymous: false,
29950
+ inputs: [
29951
+ {
29952
+ indexed: true,
29953
+ internalType: "address",
29954
+ name: "user",
29955
+ type: "address"
29956
+ },
29957
+ {
29958
+ indexed: false,
29959
+ internalType: "bytes",
29960
+ name: "data",
29961
+ type: "bytes"
29962
+ }
29963
+ ],
29964
+ name: "RawAction",
29965
+ type: "event"
29966
+ },
29967
+ {
29968
+ inputs: [
29969
+ {
29970
+ internalType: "bytes",
29971
+ name: "data",
29972
+ type: "bytes"
29973
+ }
29974
+ ],
29975
+ name: "sendRawAction",
29976
+ outputs: [
29977
+ ],
29978
+ stateMutability: "nonpayable",
29979
+ type: "function"
29980
+ }
29981
+ ];
29982
+
29983
+ var USDC_TOKEN_ID = 0;
29984
+ var USDC_CORE_ADDRESS = "0x2000000000000000000000000000000000000000";
29985
+ var CORE_WRITER_ADDRESS = "0x3333333333333333333333333333333333333333";
29986
+ var SPOT_DEX_ID = 4294967295; // max uint32;
29987
+
29988
+ var HYPERLIQUID_VERSION = 1; //Action IDs
29989
+
29990
+ var SPOT_SEND_ACTION = 6;
29991
+ var SEND_ASSET_ACTION = 13;
29992
+ var LIMIT_ORDER_ACTION = 1; //Order Time In Force options
29993
+ var LIMIT_ORDER_TIF_IOC = 3;
29994
+ var dexIdNameMap = {
29995
+ 0: "",
29996
+ 1: "xyz"
29997
+ };
29998
+ var API_URL = "https://api.hyperliquid.xyz/info";
29999
+
30000
+ var perpDexIndex = function perpDexIndex(assetId) {
30001
+ return Math.max(Math.floor((assetId - 100000) / 10000), 0);
30002
+ };
30003
+
30004
+ var assetIndex = function assetIndex(assetId) {
30005
+ if (assetId > 100000) {
30006
+ //builder-deployed perps
30007
+ return (assetId - 100000) % 10000;
30008
+ } else return assetId;
30009
+ };
30010
+
30011
+ var spotAssetIndex = function spotAssetIndex(assetId) {
30012
+ return assetId - 10000;
30013
+ };
30014
+ var isSpotAsset = function isSpotAsset(assetId) {
30015
+ return assetId > 10000 && assetId < 100000;
30016
+ };
30017
+ var getMidPrice = /*#__PURE__*/function () {
30018
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(assetId, assetName) {
30019
+ var response, raw, price;
30020
+ return runtime_1.wrap(function _callee$(_context) {
30021
+ while (1) {
30022
+ switch (_context.prev = _context.next) {
30023
+ case 0:
30024
+ _context.next = 2;
30025
+ return axios.post(API_URL, {
30026
+ type: "allMids",
30027
+ dex: dexIdNameMap[perpDexIndex(assetId)]
30028
+ });
30029
+
30030
+ case 2:
30031
+ response = _context.sent;
30032
+ raw = response.data[assetName];
30033
+
30034
+ if (!(raw === undefined || raw === null)) {
30035
+ _context.next = 6;
30036
+ break;
30037
+ }
30038
+
30039
+ throw new ApiError("Hyperliquid allMids response missing price for asset \"" + assetName + "\"");
30040
+
30041
+ case 6:
30042
+ price = +raw;
30043
+
30044
+ if (!isNaN(price)) {
30045
+ _context.next = 9;
30046
+ break;
30047
+ }
30048
+
30049
+ throw new ApiError("Hyperliquid allMids returned non-numeric price for asset \"" + assetName + "\": " + raw);
30050
+
30051
+ case 9:
30052
+ return _context.abrupt("return", price);
30053
+
30054
+ case 10:
30055
+ case "end":
30056
+ return _context.stop();
30057
+ }
30058
+ }
30059
+ }, _callee);
30060
+ }));
30061
+
30062
+ return function getMidPrice(_x, _x2) {
30063
+ return _ref.apply(this, arguments);
30064
+ };
30065
+ }();
30066
+ var getAssetInfo = /*#__PURE__*/function () {
30067
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(assetId) {
30068
+ var response, asset, baseToken, dex, _response, meta, assets, index, _asset;
30069
+
30070
+ return runtime_1.wrap(function _callee2$(_context2) {
30071
+ while (1) {
30072
+ switch (_context2.prev = _context2.next) {
30073
+ case 0:
30074
+ if (!isSpotAsset(assetId)) {
30075
+ _context2.next = 11;
30076
+ break;
30077
+ }
30078
+
30079
+ _context2.next = 3;
30080
+ return axios.post(API_URL, {
30081
+ type: "spotMeta"
30082
+ });
30083
+
30084
+ case 3:
30085
+ response = _context2.sent;
30086
+ asset = response.data.universe.find(function (e) {
30087
+ return e.index === spotAssetIndex(assetId);
30088
+ });
30089
+
30090
+ if (asset) {
30091
+ _context2.next = 7;
30092
+ break;
30093
+ }
30094
+
30095
+ throw new ApiError("Hyperliquid spotMeta response contains no asset for assetId " + assetId + " (index " + spotAssetIndex(assetId) + ")");
30096
+
30097
+ case 7:
30098
+ baseToken = response.data.tokens[asset.tokens[0]];
30099
+ return _context2.abrupt("return", {
30100
+ assetName: asset.name,
30101
+ szDecimals: baseToken.szDecimals,
30102
+ baseTokenName: baseToken.name
30103
+ });
30104
+
30105
+ case 11:
30106
+ dex = dexIdNameMap[perpDexIndex(assetId)];
30107
+ _context2.next = 14;
30108
+ return axios.post(API_URL, {
30109
+ type: "metaAndAssetCtxs",
30110
+ dex: dex
30111
+ });
30112
+
30113
+ case 14:
30114
+ _response = _context2.sent;
30115
+
30116
+ if (!(!Array.isArray(_response.data) || _response.data.length === 0)) {
30117
+ _context2.next = 17;
30118
+ break;
30119
+ }
30120
+
30121
+ throw new ApiError("Hyperliquid metaAndAssetCtxs response has invalid data for assetId " + assetId + " (dex " + String(dex) + ")");
30122
+
30123
+ case 17:
30124
+ meta = _response.data[0];
30125
+
30126
+ if (!(!meta || !Array.isArray(meta.universe))) {
30127
+ _context2.next = 20;
30128
+ break;
30129
+ }
30130
+
30131
+ throw new ApiError("Hyperliquid metaAndAssetCtxs response contains no universe for assetId " + assetId + " (dex " + String(dex) + ")");
30132
+
30133
+ case 20:
30134
+ assets = meta.universe;
30135
+ index = assetIndex(assetId);
30136
+
30137
+ if (!(index < 0 || index >= assets.length)) {
30138
+ _context2.next = 24;
30139
+ break;
30140
+ }
30141
+
30142
+ throw new ApiError("Hyperliquid metaAndAssetCtxs response contains no asset for assetId " + assetId + " (dex " + String(dex) + ", index " + index + ", universe length " + assets.length + ")");
30143
+
30144
+ case 24:
30145
+ _asset = assets[index];
30146
+ return _context2.abrupt("return", {
30147
+ assetName: _asset.name,
30148
+ szDecimals: _asset.szDecimals
30149
+ });
30150
+
30151
+ case 26:
30152
+ case "end":
30153
+ return _context2.stop();
30154
+ }
30155
+ }
30156
+ }, _callee2);
30157
+ }));
30158
+
30159
+ return function getAssetInfo(_x3) {
30160
+ return _ref2.apply(this, arguments);
30161
+ };
30162
+ }();
30163
+ var calculatePrice = function calculatePrice(isSpotAsset, szDecimals, midPrice, isBuy, slippage) {
30164
+ // 1. Apply slippage
30165
+ var price = midPrice * (isBuy ? 1 + slippage / 100 : 1 - slippage / 100); // 2. Round to 5 significant figures
30166
+
30167
+ var roundedSignificant = parseFloat(price.toPrecision(5)); // 3. For perp base decimals = 6
30168
+
30169
+ var baseDecimals = isSpotAsset ? 8 : 6;
30170
+ var finalDecimals = baseDecimals - szDecimals;
30171
+ var factor = Math.pow(10, finalDecimals);
30172
+ var roundedDecimals = Math.round(roundedSignificant * factor) / factor;
30173
+ return new BigNumber.BigNumber(roundedDecimals).times(1e8).toFixed(0);
30174
+ };
30175
+ var calculateSize = function calculateSize(szDecimals, value, price) {
30176
+ var factor = Math.pow(10, szDecimals);
30177
+ return new BigNumber.BigNumber(Math.round(value / price * factor) / factor).times(1e8).toFixed(0);
30178
+ };
30179
+ var scaleSize = function scaleSize(szDecimals, positionSize, percentageToClose) {
30180
+ var factor = Math.pow(10, szDecimals);
30181
+ return new BigNumber.BigNumber(Math.round(positionSize * percentageToClose / 100 * factor) / factor).times(1e8).abs().toFixed(0);
30182
+ };
30183
+
30184
+ var getPositionSize = /*#__PURE__*/function () {
30185
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(assetId, isSpot, assetName, user) {
30186
+ var response, balance, _response, position;
30187
+
30188
+ return runtime_1.wrap(function _callee$(_context) {
30189
+ while (1) {
30190
+ switch (_context.prev = _context.next) {
30191
+ case 0:
30192
+ if (!isSpot) {
30193
+ _context.next = 10;
30194
+ break;
30195
+ }
30196
+
30197
+ _context.next = 3;
30198
+ return axios.post(API_URL, {
30199
+ type: "spotClearinghouseState",
30200
+ user: user
30201
+ });
30202
+
30203
+ case 3:
30204
+ response = _context.sent;
30205
+ balance = response.data.balances.find(function (e) {
30206
+ return e.coin === assetName;
30207
+ });
30208
+
30209
+ if (balance) {
30210
+ _context.next = 7;
30211
+ break;
30212
+ }
30213
+
30214
+ throw new Error("No balance found for asset " + assetName);
30215
+
30216
+ case 7:
30217
+ return _context.abrupt("return", +balance.total);
30218
+
30219
+ case 10:
30220
+ _context.next = 12;
30221
+ return axios.post(API_URL, {
30222
+ type: "clearinghouseState",
30223
+ user: user,
30224
+ dex: dexIdNameMap[perpDexIndex(assetId)]
30225
+ });
30226
+
30227
+ case 12:
30228
+ _response = _context.sent;
30229
+ position = _response.data.assetPositions.find(function (e) {
30230
+ return e.position.coin === assetName;
30231
+ });
30232
+
30233
+ if (position) {
30234
+ _context.next = 16;
30235
+ break;
30236
+ }
30237
+
30238
+ throw new Error("No position found for asset " + assetName);
30239
+
30240
+ case 16:
30241
+ return _context.abrupt("return", +position.position.szi);
30242
+
30243
+ case 17:
30244
+ case "end":
30245
+ return _context.stop();
30246
+ }
30247
+ }
30248
+ }, _callee);
30249
+ }));
30250
+
30251
+ return function getPositionSize(_x, _x2, _x3, _x4) {
30252
+ return _ref.apply(this, arguments);
30253
+ };
30254
+ }();
30255
+
30256
+ var depositWallet = /*#__PURE__*/new ethers.ethers.utils.Interface(ICoreDepositWalletAbi);
30257
+ var coreWriter = /*#__PURE__*/new ethers.ethers.utils.Interface(ICoreWriterAbi);
30258
+ var getDepositHyperliquidTxData = function getDepositHyperliquidTxData(dexId, amount) {
30259
+ return depositWallet.encodeFunctionData("deposit", [amount, dexId]);
30260
+ };
30261
+ var getWithdrawSpotHyperliquidTxData = function getWithdrawSpotHyperliquidTxData(amount) {
30262
+ var coreAmount = ethers.ethers.BigNumber.from(amount).mul(100); //USDC on Core has two more decimals
30263
+ //Hardcoded to USDC address and id on Hyperliquid Core
30264
+ //From Spot to EVM
30265
+
30266
+ var innerEncoded = ethers.ethers.utils.defaultAbiCoder.encode( //to, token, amount
30267
+ ["address", "uint64", "uint64"], [USDC_CORE_ADDRESS, USDC_TOKEN_ID, coreAmount]);
30268
+ var rawTXData = ethers.ethers.utils.solidityPack(["uint8", "uint24", "bytes"], [HYPERLIQUID_VERSION, SPOT_SEND_ACTION, innerEncoded]);
30269
+ return coreWriter.encodeFunctionData("sendRawAction", [rawTXData]);
30270
+ };
30271
+ var getPerpToSpotHyperliquidTxData = function getPerpToSpotHyperliquidTxData(dexId, receiver, amount) {
30272
+ var coreAmount = ethers.ethers.BigNumber.from(amount).mul(100); //USDC on Core has two more decimals
30273
+ //From Perp to Spot
30274
+
30275
+ var innerEncoded = ethers.ethers.utils.defaultAbiCoder.encode( //destination, subAccount, sourceDex, destinationDex, token, amount
30276
+ ["address", "address", "uint32", "uint32", "uint64", "uint64"], [receiver, ethers.ethers.constants.AddressZero, dexId, SPOT_DEX_ID, USDC_TOKEN_ID, coreAmount]);
30277
+ var rawTXData = ethers.ethers.utils.solidityPack(["uint8", "uint24", "bytes"], [HYPERLIQUID_VERSION, SEND_ASSET_ACTION, innerEncoded]);
30278
+ return coreWriter.encodeFunctionData("sendRawAction", [rawTXData]);
30279
+ };
30280
+ var getLimitOrderHyperliquidTxData = /*#__PURE__*/function () {
30281
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(assetId, isLong, changeAmount, slippage) {
30282
+ var isBuy, reduceOnly, _yield$getAssetInfo, assetName, szDecimals, midPrice, price, size, innerEncoded, rawTXData;
30283
+
30284
+ return runtime_1.wrap(function _callee$(_context) {
30285
+ while (1) {
30286
+ switch (_context.prev = _context.next) {
30287
+ case 0:
30288
+ isBuy = isLong;
30289
+ reduceOnly = false;
30290
+
30291
+ if (changeAmount < 0) {
30292
+ changeAmount = changeAmount * -1;
30293
+ isBuy = !isLong;
30294
+ reduceOnly = !isSpotAsset(assetId);
30295
+ } //Calculate price with slippage
30296
+
30297
+
30298
+ _context.next = 5;
30299
+ return getAssetInfo(assetId);
30300
+
30301
+ case 5:
30302
+ _yield$getAssetInfo = _context.sent;
30303
+ assetName = _yield$getAssetInfo.assetName;
30304
+ szDecimals = _yield$getAssetInfo.szDecimals;
30305
+ _context.next = 10;
30306
+ return getMidPrice(assetId, assetName);
30307
+
30308
+ case 10:
30309
+ midPrice = _context.sent;
30310
+ price = calculatePrice(isSpotAsset(assetId), szDecimals, midPrice, isBuy, slippage);
30311
+ size = calculateSize(szDecimals, changeAmount, midPrice);
30312
+ innerEncoded = ethers.ethers.utils.defaultAbiCoder.encode( //assetIndex, isBuy, price, size, reduceOnly, tif, clientOrderId
30313
+ ["uint32", "bool", "uint64", "uint64", "bool", "uint8", "uint128"], [assetId, isBuy, price, size, reduceOnly, LIMIT_ORDER_TIF_IOC, ethers.ethers.BigNumber.from(0) //client order id
30314
+ ]);
30315
+ rawTXData = ethers.ethers.utils.solidityPack(["uint8", "uint24", "bytes"], [HYPERLIQUID_VERSION, LIMIT_ORDER_ACTION, innerEncoded]);
30316
+ return _context.abrupt("return", coreWriter.encodeFunctionData("sendRawAction", [rawTXData]));
30317
+
30318
+ case 16:
30319
+ case "end":
30320
+ return _context.stop();
30321
+ }
30322
+ }
30323
+ }, _callee);
30324
+ }));
30325
+
30326
+ return function getLimitOrderHyperliquidTxData(_x, _x2, _x3, _x4) {
30327
+ return _ref.apply(this, arguments);
30328
+ };
30329
+ }();
30330
+ var getClosePositionHyperliquidTxData = /*#__PURE__*/function () {
30331
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(assetId, percentageToClose, slippage, poolAddress) {
30332
+ var isSpot, _yield$getAssetInfo2, assetName, szDecimals, baseTokenName, positionSize, isBuy, sizeRaw, midPrice, price, innerEncoded, rawTXData;
30333
+
30334
+ return runtime_1.wrap(function _callee2$(_context2) {
30335
+ while (1) {
30336
+ switch (_context2.prev = _context2.next) {
30337
+ case 0:
30338
+ isSpot = isSpotAsset(assetId);
30339
+ _context2.next = 3;
30340
+ return getAssetInfo(assetId);
30341
+
30342
+ case 3:
30343
+ _yield$getAssetInfo2 = _context2.sent;
30344
+ assetName = _yield$getAssetInfo2.assetName;
30345
+ szDecimals = _yield$getAssetInfo2.szDecimals;
30346
+ baseTokenName = _yield$getAssetInfo2.baseTokenName;
30347
+ _context2.next = 9;
30348
+ return getPositionSize(assetId, isSpot, baseTokenName != null ? baseTokenName : assetName, poolAddress);
30349
+
30350
+ case 9:
30351
+ positionSize = _context2.sent;
30352
+ isBuy = positionSize < 0; // if position size is negative, we need to buy to close, otherwise sell
30353
+
30354
+ sizeRaw = scaleSize(szDecimals, positionSize, percentageToClose); //Calculate price with slippage
30355
+
30356
+ _context2.next = 14;
30357
+ return getMidPrice(assetId, assetName);
30358
+
30359
+ case 14:
30360
+ midPrice = _context2.sent;
30361
+ price = calculatePrice(isSpotAsset(assetId), szDecimals, midPrice, isBuy, slippage);
30362
+ innerEncoded = ethers.ethers.utils.defaultAbiCoder.encode( //assetIndex, isBuy, price, size, reduceOnly, tif, clientOrderId
30363
+ ["uint32", "bool", "uint64", "uint64", "bool", "uint8", "uint128"], [assetId, positionSize < 0, price, sizeRaw, !isSpot, LIMIT_ORDER_TIF_IOC, ethers.ethers.BigNumber.from(0) //client order id
30364
+ ]);
30365
+ rawTXData = ethers.ethers.utils.solidityPack(["uint8", "uint24", "bytes"], [HYPERLIQUID_VERSION, LIMIT_ORDER_ACTION, innerEncoded]);
30366
+ return _context2.abrupt("return", coreWriter.encodeFunctionData("sendRawAction", [rawTXData]));
30367
+
30368
+ case 19:
30369
+ case "end":
30370
+ return _context2.stop();
30371
+ }
30372
+ }
30373
+ }, _callee2);
30374
+ }));
30375
+
30376
+ return function getClosePositionHyperliquidTxData(_x5, _x6, _x7, _x8) {
30377
+ return _ref2.apply(this, arguments);
30378
+ };
30379
+ }();
30380
+
29545
30381
  var Pool = /*#__PURE__*/function () {
29546
30382
  function Pool(network, signer, poolLogic, mangerLogic, utils, factory, isDhedge) {
29547
30383
  if (isDhedge === void 0) {
@@ -33139,6 +33975,608 @@ var Pool = /*#__PURE__*/function () {
33139
33975
  }
33140
33976
 
33141
33977
  return mintPendle;
33978
+ }()
33979
+ /** Deposit USDC from EVM to a HyperCore trading dex via the CoreDepositWallet.
33980
+ * This bridges USDC on-chain to Hyperliquid for perp/spot trading.
33981
+ *
33982
+ * @param {BigNumber | string} amount USDC amount to deposit (6 decimals, e.g. "1000000" = 1 USDC)
33983
+ * @param {number} dexId Destination dex ID where USDC will be available (default 0)
33984
+ * - 0: Core Perp dex (standard perps like BTC, ETH)
33985
+ * - 1: xyz HIP-3 dex (builder perps like TSLA, GOLD)
33986
+ * @param {any} options Transaction options
33987
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
33988
+ * @returns {Promise<any>} Transaction
33989
+ */
33990
+ ;
33991
+
33992
+ _proto.depositHyperliquid =
33993
+ /*#__PURE__*/
33994
+ function () {
33995
+ var _depositHyperliquid = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee59(amount, dexId, options, sdkOptions) {
33996
+ var tx;
33997
+ return runtime_1.wrap(function _callee59$(_context59) {
33998
+ while (1) {
33999
+ switch (_context59.prev = _context59.next) {
34000
+ case 0:
34001
+ if (dexId === void 0) {
34002
+ dexId = 0;
34003
+ }
34004
+
34005
+ if (options === void 0) {
34006
+ options = null;
34007
+ }
34008
+
34009
+ if (sdkOptions === void 0) {
34010
+ sdkOptions = {
34011
+ estimateGas: false
34012
+ };
34013
+ }
34014
+
34015
+ _context59.next = 5;
34016
+ return getPoolTxOrGasEstimate(this, [routerAddress[this.network][exports.Dapp.HYPERLIQUID], getDepositHyperliquidTxData(dexId, amount), options], sdkOptions);
34017
+
34018
+ case 5:
34019
+ tx = _context59.sent;
34020
+ return _context59.abrupt("return", tx);
34021
+
34022
+ case 7:
34023
+ case "end":
34024
+ return _context59.stop();
34025
+ }
34026
+ }
34027
+ }, _callee59, this);
34028
+ }));
34029
+
34030
+ function depositHyperliquid(_x279, _x280, _x281, _x282) {
34031
+ return _depositHyperliquid.apply(this, arguments);
34032
+ }
34033
+
34034
+ return depositHyperliquid;
34035
+ }()
34036
+ /** Move USDC from a HyperCore trading dex to the Spot wallet.
34037
+ * Required before calling withdrawHyperliquid() to bridge USDC back to EVM.
34038
+ *
34039
+ * @param {number} dexId Source dex ID where USDC currently sits
34040
+ * - 0: Core Perp dex (standard perps like BTC, ETH)
34041
+ * - 1: xyz HIP-3 dex (builder perps like TSLA, GOLD)
34042
+ * @param {BigNumber | string} amount USDC amount to transfer (6 decimals, e.g. "1000000" = 1 USDC)
34043
+ * @param {any} options Transaction options
34044
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
34045
+ * @returns {Promise<any>} Transaction
34046
+ */
34047
+ ;
34048
+
34049
+ _proto.perpToSpotHyperliquid =
34050
+ /*#__PURE__*/
34051
+ function () {
34052
+ var _perpToSpotHyperliquid = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee60(dexId, amount, options, sdkOptions) {
34053
+ var tx;
34054
+ return runtime_1.wrap(function _callee60$(_context60) {
34055
+ while (1) {
34056
+ switch (_context60.prev = _context60.next) {
34057
+ case 0:
34058
+ if (options === void 0) {
34059
+ options = null;
34060
+ }
34061
+
34062
+ if (sdkOptions === void 0) {
34063
+ sdkOptions = {
34064
+ estimateGas: false
34065
+ };
34066
+ }
34067
+
34068
+ _context60.next = 4;
34069
+ return getPoolTxOrGasEstimate(this, [CORE_WRITER_ADDRESS, getPerpToSpotHyperliquidTxData(dexId, this.address, amount), options], sdkOptions);
34070
+
34071
+ case 4:
34072
+ tx = _context60.sent;
34073
+ return _context60.abrupt("return", tx);
34074
+
34075
+ case 6:
34076
+ case "end":
34077
+ return _context60.stop();
34078
+ }
34079
+ }
34080
+ }, _callee60, this);
34081
+ }));
34082
+
34083
+ function perpToSpotHyperliquid(_x283, _x284, _x285, _x286) {
34084
+ return _perpToSpotHyperliquid.apply(this, arguments);
34085
+ }
34086
+
34087
+ return perpToSpotHyperliquid;
34088
+ }()
34089
+ /** Withdraw USDC from Hyperliquid Spot wallet back to EVM.
34090
+ * USDC must be in the Spot wallet first — use perpToSpotHyperliquid() to move it from a trading dex.
34091
+ *
34092
+ * @param {BigNumber | string} amount USDC amount to withdraw (6 decimals, e.g. "1000000" = 1 USDC)
34093
+ * @param {any} options Transaction options
34094
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
34095
+ * @returns {Promise<any>} Transaction
34096
+ */
34097
+ ;
34098
+
34099
+ _proto.withdrawHyperliquid =
34100
+ /*#__PURE__*/
34101
+ function () {
34102
+ var _withdrawHyperliquid = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee61(amount, options, sdkOptions) {
34103
+ var tx;
34104
+ return runtime_1.wrap(function _callee61$(_context61) {
34105
+ while (1) {
34106
+ switch (_context61.prev = _context61.next) {
34107
+ case 0:
34108
+ if (options === void 0) {
34109
+ options = null;
34110
+ }
34111
+
34112
+ if (sdkOptions === void 0) {
34113
+ sdkOptions = {
34114
+ estimateGas: false
34115
+ };
34116
+ }
34117
+
34118
+ _context61.next = 4;
34119
+ return getPoolTxOrGasEstimate(this, [CORE_WRITER_ADDRESS, getWithdrawSpotHyperliquidTxData(amount), options], sdkOptions);
34120
+
34121
+ case 4:
34122
+ tx = _context61.sent;
34123
+ return _context61.abrupt("return", tx);
34124
+
34125
+ case 6:
34126
+ case "end":
34127
+ return _context61.stop();
34128
+ }
34129
+ }
34130
+ }, _callee61, this);
34131
+ }));
34132
+
34133
+ function withdrawHyperliquid(_x287, _x288, _x289) {
34134
+ return _withdrawHyperliquid.apply(this, arguments);
34135
+ }
34136
+
34137
+ return withdrawHyperliquid;
34138
+ }()
34139
+ /** Open a market order on Hyperliquid
34140
+ * @param {number} assetId Asset id
34141
+ * @param {boolean} isLong Long or short (Note: Spot assets only support long positions)
34142
+ * @param {number} value Order value in base asset units (positive for opening/increasing,
34143
+ * negative for closing/reducing or selling spot)
34144
+ * @param {number } slippage Slippage tolerance in %
34145
+ * @param {any} options Transaction options
34146
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
34147
+ * @returns {Promise<any>} Transaction
34148
+ */
34149
+ ;
34150
+
34151
+ _proto.openMarketOrderHyperliquid =
34152
+ /*#__PURE__*/
34153
+ function () {
34154
+ var _openMarketOrderHyperliquid = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee62(assetId, isLong, value, slippage, options, sdkOptions) {
34155
+ var tx;
34156
+ return runtime_1.wrap(function _callee62$(_context62) {
34157
+ while (1) {
34158
+ switch (_context62.prev = _context62.next) {
34159
+ case 0:
34160
+ if (slippage === void 0) {
34161
+ slippage = 0.5;
34162
+ }
34163
+
34164
+ if (options === void 0) {
34165
+ options = null;
34166
+ }
34167
+
34168
+ if (sdkOptions === void 0) {
34169
+ sdkOptions = {
34170
+ estimateGas: false
34171
+ };
34172
+ }
34173
+
34174
+ _context62.t0 = getPoolTxOrGasEstimate;
34175
+ _context62.t1 = this;
34176
+ _context62.t2 = CORE_WRITER_ADDRESS;
34177
+ _context62.next = 8;
34178
+ return getLimitOrderHyperliquidTxData(assetId, isLong, value, slippage);
34179
+
34180
+ case 8:
34181
+ _context62.t3 = _context62.sent;
34182
+ _context62.t4 = options;
34183
+ _context62.t5 = [_context62.t2, _context62.t3, _context62.t4];
34184
+ _context62.t6 = sdkOptions;
34185
+ _context62.next = 14;
34186
+ return (0, _context62.t0)(_context62.t1, _context62.t5, _context62.t6);
34187
+
34188
+ case 14:
34189
+ tx = _context62.sent;
34190
+ return _context62.abrupt("return", tx);
34191
+
34192
+ case 16:
34193
+ case "end":
34194
+ return _context62.stop();
34195
+ }
34196
+ }
34197
+ }, _callee62, this);
34198
+ }));
34199
+
34200
+ function openMarketOrderHyperliquid(_x290, _x291, _x292, _x293, _x294, _x295) {
34201
+ return _openMarketOrderHyperliquid.apply(this, arguments);
34202
+ }
34203
+
34204
+ return openMarketOrderHyperliquid;
34205
+ }()
34206
+ /** Close a position on Hyperliquid
34207
+ * @param {number} assetId Asset id
34208
+ * @param {number} percentageToClose Percentage of position to close (0-100)
34209
+ * @param {number } slippage Slippage tolerance in %
34210
+ * @param {any} options Transaction options
34211
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
34212
+ * @returns {Promise<any>} Transaction
34213
+ */
34214
+ ;
34215
+
34216
+ _proto.closePositionHyperliquid =
34217
+ /*#__PURE__*/
34218
+ function () {
34219
+ var _closePositionHyperliquid = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee63(assetId, percentageToClose, slippage, options, sdkOptions) {
34220
+ var tx;
34221
+ return runtime_1.wrap(function _callee63$(_context63) {
34222
+ while (1) {
34223
+ switch (_context63.prev = _context63.next) {
34224
+ case 0:
34225
+ if (percentageToClose === void 0) {
34226
+ percentageToClose = 100;
34227
+ }
34228
+
34229
+ if (slippage === void 0) {
34230
+ slippage = 0.5;
34231
+ }
34232
+
34233
+ if (options === void 0) {
34234
+ options = null;
34235
+ }
34236
+
34237
+ if (sdkOptions === void 0) {
34238
+ sdkOptions = {
34239
+ estimateGas: false
34240
+ };
34241
+ }
34242
+
34243
+ _context63.t0 = getPoolTxOrGasEstimate;
34244
+ _context63.t1 = this;
34245
+ _context63.t2 = CORE_WRITER_ADDRESS;
34246
+ _context63.next = 9;
34247
+ return getClosePositionHyperliquidTxData(assetId, percentageToClose, slippage, this.address);
34248
+
34249
+ case 9:
34250
+ _context63.t3 = _context63.sent;
34251
+ _context63.t4 = options;
34252
+ _context63.t5 = [_context63.t2, _context63.t3, _context63.t4];
34253
+ _context63.t6 = sdkOptions;
34254
+ _context63.next = 15;
34255
+ return (0, _context63.t0)(_context63.t1, _context63.t5, _context63.t6);
34256
+
34257
+ case 15:
34258
+ tx = _context63.sent;
34259
+ return _context63.abrupt("return", tx);
34260
+
34261
+ case 17:
34262
+ case "end":
34263
+ return _context63.stop();
34264
+ }
34265
+ }
34266
+ }, _callee63, this);
34267
+ }));
34268
+
34269
+ function closePositionHyperliquid(_x296, _x297, _x298, _x299, _x300) {
34270
+ return _closePositionHyperliquid.apply(this, arguments);
34271
+ }
34272
+
34273
+ return closePositionHyperliquid;
34274
+ }()
34275
+ /**
34276
+ * Approve the Toros vault token for the PoolLimitOrderManager
34277
+ * Must be called before createTorosLimitOrder
34278
+ * @param {string} vaultAddress Address of the Toros vault token to approve
34279
+ * @param {BigNumber | string} amount Amount to approve
34280
+ * @param {any} options Transaction options
34281
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
34282
+ * @returns {Promise<any>} Transaction
34283
+ */
34284
+ ;
34285
+
34286
+ _proto.approveTorosLimitOrder =
34287
+ /*#__PURE__*/
34288
+ function () {
34289
+ var _approveTorosLimitOrder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee64(vaultAddress, amount, options, sdkOptions) {
34290
+ var managerAddress, iERC20, approveTxData;
34291
+ return runtime_1.wrap(function _callee64$(_context64) {
34292
+ while (1) {
34293
+ switch (_context64.prev = _context64.next) {
34294
+ case 0:
34295
+ if (options === void 0) {
34296
+ options = null;
34297
+ }
34298
+
34299
+ if (sdkOptions === void 0) {
34300
+ sdkOptions = {
34301
+ estimateGas: false
34302
+ };
34303
+ }
34304
+
34305
+ managerAddress = limitOrderAddress[this.network];
34306
+ iERC20 = new ethers.ethers.utils.Interface(IERC20.abi);
34307
+ approveTxData = iERC20.encodeFunctionData("approve", [managerAddress, amount]);
34308
+ return _context64.abrupt("return", getPoolTxOrGasEstimate(this, [vaultAddress, approveTxData, options], sdkOptions));
34309
+
34310
+ case 6:
34311
+ case "end":
34312
+ return _context64.stop();
34313
+ }
34314
+ }
34315
+ }, _callee64, this);
34316
+ }));
34317
+
34318
+ function approveTorosLimitOrder(_x301, _x302, _x303, _x304) {
34319
+ return _approveTorosLimitOrder.apply(this, arguments);
34320
+ }
34321
+
34322
+ return approveTorosLimitOrder;
34323
+ }()
34324
+ /**
34325
+ * Create a Toros limit order (stop-loss / take-profit)
34326
+ * @param {string} vaultAddress Address of the Toros vault token
34327
+ * @param {BigNumber | string} amount Vault token amount (18 decimals)
34328
+ * @param {BigNumber | string | null | undefined} stopLossPriceD18 Stop-loss price in D18 (0 or null/undefined = disabled)
34329
+ * @param {BigNumber | string | null | undefined} takeProfitPriceD18 Take-profit price in D18 (MaxUint256 or null/undefined = disabled)
34330
+ * @param {string} pricingAsset Address of the pricing asset (e.g. USDC)
34331
+ * @param {any} options Transaction options
34332
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
34333
+ * @returns {Promise<any>} Transaction
34334
+ */
34335
+ ;
34336
+
34337
+ _proto.createTorosLimitOrder =
34338
+ /*#__PURE__*/
34339
+ function () {
34340
+ var _createTorosLimitOrder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee65(vaultAddress, amount, stopLossPriceD18, takeProfitPriceD18, pricingAsset, options, sdkOptions) {
34341
+ var managerAddress, resolvedStopLoss, resolvedTakeProfit, info, txData;
34342
+ return runtime_1.wrap(function _callee65$(_context65) {
34343
+ while (1) {
34344
+ switch (_context65.prev = _context65.next) {
34345
+ case 0:
34346
+ if (options === void 0) {
34347
+ options = null;
34348
+ }
34349
+
34350
+ if (sdkOptions === void 0) {
34351
+ sdkOptions = {
34352
+ estimateGas: false
34353
+ };
34354
+ }
34355
+
34356
+ managerAddress = limitOrderAddress[this.network];
34357
+
34358
+ if (managerAddress) {
34359
+ _context65.next = 5;
34360
+ break;
34361
+ }
34362
+
34363
+ throw new Error("Limit orders not supported on " + this.network);
34364
+
34365
+ case 5:
34366
+ resolvedStopLoss = stopLossPriceD18 == null ? ethers.BigNumber.from(0) : ethers.BigNumber.from(stopLossPriceD18);
34367
+ resolvedTakeProfit = takeProfitPriceD18 == null ? ethers.ethers.constants.MaxUint256 : ethers.BigNumber.from(takeProfitPriceD18);
34368
+ info = {
34369
+ amount: ethers.BigNumber.from(amount),
34370
+ stopLossPriceD18: resolvedStopLoss,
34371
+ takeProfitPriceD18: resolvedTakeProfit,
34372
+ user: this.address,
34373
+ pool: vaultAddress,
34374
+ pricingAsset: pricingAsset
34375
+ };
34376
+ txData = getCreateLimitOrderTxData(info);
34377
+ return _context65.abrupt("return", getPoolTxOrGasEstimate(this, [managerAddress, txData, options], sdkOptions));
34378
+
34379
+ case 10:
34380
+ case "end":
34381
+ return _context65.stop();
34382
+ }
34383
+ }
34384
+ }, _callee65, this);
34385
+ }));
34386
+
34387
+ function createTorosLimitOrder(_x305, _x306, _x307, _x308, _x309, _x310, _x311) {
34388
+ return _createTorosLimitOrder.apply(this, arguments);
34389
+ }
34390
+
34391
+ return createTorosLimitOrder;
34392
+ }()
34393
+ /**
34394
+ * Modify an existing Toros limit order
34395
+ * @param {string} vaultAddress Address of the Toros vault token
34396
+ * @param {BigNumber | string} amount New vault token amount (18 decimals)
34397
+ * @param {BigNumber | string | null | undefined} stopLossPriceD18 New stop-loss price in D18 (0 or null/undefined = disabled)
34398
+ * @param {BigNumber | string | null | undefined} takeProfitPriceD18 New take-profit price in D18 (MaxUint256 or null/undefined = disabled)
34399
+ * @param {string} pricingAsset Address of the pricing asset
34400
+ * @param {any} options Transaction options
34401
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
34402
+ * @returns {Promise<any>} Transaction
34403
+ */
34404
+ ;
34405
+
34406
+ _proto.modifyTorosLimitOrder =
34407
+ /*#__PURE__*/
34408
+ function () {
34409
+ var _modifyTorosLimitOrder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee66(vaultAddress, amount, stopLossPriceD18, takeProfitPriceD18, pricingAsset, options, sdkOptions) {
34410
+ var managerAddress, resolvedStopLoss, resolvedTakeProfit, info, txData;
34411
+ return runtime_1.wrap(function _callee66$(_context66) {
34412
+ while (1) {
34413
+ switch (_context66.prev = _context66.next) {
34414
+ case 0:
34415
+ if (options === void 0) {
34416
+ options = null;
34417
+ }
34418
+
34419
+ if (sdkOptions === void 0) {
34420
+ sdkOptions = {
34421
+ estimateGas: false
34422
+ };
34423
+ }
34424
+
34425
+ managerAddress = limitOrderAddress[this.network];
34426
+
34427
+ if (managerAddress) {
34428
+ _context66.next = 5;
34429
+ break;
34430
+ }
34431
+
34432
+ throw new Error("Limit orders not supported on " + this.network);
34433
+
34434
+ case 5:
34435
+ resolvedStopLoss = stopLossPriceD18 == null ? ethers.BigNumber.from(0) : ethers.BigNumber.from(stopLossPriceD18);
34436
+ resolvedTakeProfit = takeProfitPriceD18 == null ? ethers.ethers.constants.MaxUint256 : ethers.BigNumber.from(takeProfitPriceD18);
34437
+ info = {
34438
+ amount: ethers.BigNumber.from(amount),
34439
+ stopLossPriceD18: resolvedStopLoss,
34440
+ takeProfitPriceD18: resolvedTakeProfit,
34441
+ user: this.address,
34442
+ pool: vaultAddress,
34443
+ pricingAsset: pricingAsset
34444
+ };
34445
+ txData = getModifyLimitOrderTxData(info);
34446
+ return _context66.abrupt("return", getPoolTxOrGasEstimate(this, [managerAddress, txData, options], sdkOptions));
34447
+
34448
+ case 10:
34449
+ case "end":
34450
+ return _context66.stop();
34451
+ }
34452
+ }
34453
+ }, _callee66, this);
34454
+ }));
34455
+
34456
+ function modifyTorosLimitOrder(_x312, _x313, _x314, _x315, _x316, _x317, _x318) {
34457
+ return _modifyTorosLimitOrder.apply(this, arguments);
34458
+ }
34459
+
34460
+ return modifyTorosLimitOrder;
34461
+ }()
34462
+ /**
34463
+ * Delete an existing Toros limit order
34464
+ * @param {string} vaultAddress Address of the Toros vault token
34465
+ * @param {any} options Transaction options
34466
+ * @param {SDKOptions} sdkOptions SDK options including estimateGas
34467
+ * @returns {Promise<any>} Transaction
34468
+ */
34469
+ ;
34470
+
34471
+ _proto.deleteTorosLimitOrder =
34472
+ /*#__PURE__*/
34473
+ function () {
34474
+ var _deleteTorosLimitOrder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee67(vaultAddress, options, sdkOptions) {
34475
+ var managerAddress, txData;
34476
+ return runtime_1.wrap(function _callee67$(_context67) {
34477
+ while (1) {
34478
+ switch (_context67.prev = _context67.next) {
34479
+ case 0:
34480
+ if (options === void 0) {
34481
+ options = null;
34482
+ }
34483
+
34484
+ if (sdkOptions === void 0) {
34485
+ sdkOptions = {
34486
+ estimateGas: false
34487
+ };
34488
+ }
34489
+
34490
+ managerAddress = limitOrderAddress[this.network];
34491
+
34492
+ if (managerAddress) {
34493
+ _context67.next = 5;
34494
+ break;
34495
+ }
34496
+
34497
+ throw new Error("Limit orders not supported on " + this.network);
34498
+
34499
+ case 5:
34500
+ txData = getDeleteLimitOrderTxData(vaultAddress);
34501
+ return _context67.abrupt("return", getPoolTxOrGasEstimate(this, [managerAddress, txData, options], sdkOptions));
34502
+
34503
+ case 7:
34504
+ case "end":
34505
+ return _context67.stop();
34506
+ }
34507
+ }
34508
+ }, _callee67, this);
34509
+ }));
34510
+
34511
+ function deleteTorosLimitOrder(_x319, _x320, _x321) {
34512
+ return _deleteTorosLimitOrder.apply(this, arguments);
34513
+ }
34514
+
34515
+ return deleteTorosLimitOrder;
34516
+ }()
34517
+ /**
34518
+ * Fetch a Toros limit order for a given user and vault
34519
+ * @param {string} userAddress Address of the order owner (the dHEDGE pool)
34520
+ * @param {string} vaultAddress Address of the Toros vault token
34521
+ * @returns {Promise<LimitOrderInfo | null>} Order info, or null if none exists
34522
+ */
34523
+ ;
34524
+
34525
+ _proto.getTorosLimitOrder =
34526
+ /*#__PURE__*/
34527
+ function () {
34528
+ var _getTorosLimitOrder2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee68(userAddress, vaultAddress) {
34529
+ return runtime_1.wrap(function _callee68$(_context68) {
34530
+ while (1) {
34531
+ switch (_context68.prev = _context68.next) {
34532
+ case 0:
34533
+ return _context68.abrupt("return", getTorosLimitOrder(this, userAddress, vaultAddress));
34534
+
34535
+ case 1:
34536
+ case "end":
34537
+ return _context68.stop();
34538
+ }
34539
+ }
34540
+ }, _callee68, this);
34541
+ }));
34542
+
34543
+ function getTorosLimitOrder$1(_x322, _x323) {
34544
+ return _getTorosLimitOrder2.apply(this, arguments);
34545
+ }
34546
+
34547
+ return getTorosLimitOrder$1;
34548
+ }()
34549
+ /**
34550
+ * Check whether an active Toros limit order exists for a given user and vault
34551
+ * @param {string} userAddress Address of the order owner (the dHEDGE pool)
34552
+ * @param {string} vaultAddress Address of the Toros vault token
34553
+ * @returns {Promise<boolean>}
34554
+ */
34555
+ ;
34556
+
34557
+ _proto.hasActiveTorosLimitOrder =
34558
+ /*#__PURE__*/
34559
+ function () {
34560
+ var _hasActiveTorosLimitOrder2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee69(userAddress, vaultAddress) {
34561
+ return runtime_1.wrap(function _callee69$(_context69) {
34562
+ while (1) {
34563
+ switch (_context69.prev = _context69.next) {
34564
+ case 0:
34565
+ return _context69.abrupt("return", hasActiveTorosLimitOrder(this, userAddress, vaultAddress));
34566
+
34567
+ case 1:
34568
+ case "end":
34569
+ return _context69.stop();
34570
+ }
34571
+ }
34572
+ }, _callee69, this);
34573
+ }));
34574
+
34575
+ function hasActiveTorosLimitOrder$1(_x324, _x325) {
34576
+ return _hasActiveTorosLimitOrder2.apply(this, arguments);
34577
+ }
34578
+
34579
+ return hasActiveTorosLimitOrder$1;
33142
34580
  }();
33143
34581
 
33144
34582
  return Pool;