@gmx-io/sdk 0.1.1 → 0.1.2

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 (77) hide show
  1. package/build/src/configs/chains.d.ts +3 -0
  2. package/build/src/configs/chains.js +6 -0
  3. package/build/src/configs/contracts.d.ts +220 -1
  4. package/build/src/configs/contracts.js +67 -8
  5. package/build/src/configs/markets.js +14 -0
  6. package/build/src/configs/tokens.js +40 -5
  7. package/build/src/modules/markets/index.js +1 -7
  8. package/build/src/modules/markets/query-builders.d.ts +1 -1
  9. package/build/src/modules/markets/types.d.ts +4 -1
  10. package/build/src/modules/orders/utils.js +1 -1
  11. package/build/src/modules/positions/positions.js +17 -4
  12. package/build/src/modules/utils/utils.d.ts +1 -1
  13. package/build/src/modules/utils/utils.js +1 -1
  14. package/build/src/prebuilt/hashedKinkModelMarketRatesKeys.json +16 -0
  15. package/build/src/prebuilt/hashedMarketConfigKeys.json +100 -0
  16. package/build/src/prebuilt/hashedMarketValuesKeys.json +30 -0
  17. package/build/src/types/common.d.ts +1 -0
  18. package/build/src/types/fees.d.ts +2 -1
  19. package/build/src/types/markets.d.ts +7 -19
  20. package/build/src/types/orders.d.ts +3 -5
  21. package/build/src/types/positions.d.ts +11 -4
  22. package/build/src/types/trade.d.ts +1 -0
  23. package/build/src/types/tradeHistory.d.ts +4 -1
  24. package/build/src/utils/__tests__/LruCache.spec.d.ts +1 -0
  25. package/build/src/utils/__tests__/LruCache.spec.js +42 -0
  26. package/build/src/utils/__tests__/bigmath.spec.d.ts +1 -0
  27. package/build/src/utils/__tests__/bigmath.spec.js +37 -0
  28. package/build/src/utils/__tests__/hash.spec.d.ts +1 -0
  29. package/build/src/utils/__tests__/hash.spec.js +40 -0
  30. package/build/src/utils/__tests__/markets.spec.d.ts +1 -0
  31. package/build/src/utils/__tests__/markets.spec.js +264 -0
  32. package/build/src/utils/__tests__/numbers.spec.d.ts +1 -0
  33. package/build/src/utils/__tests__/numbers.spec.js +56 -0
  34. package/build/src/utils/__tests__/objects.spec.d.ts +1 -0
  35. package/build/src/utils/__tests__/objects.spec.js +58 -0
  36. package/build/src/utils/__tests__/positions.spec.d.ts +1 -0
  37. package/build/src/utils/__tests__/positions.spec.js +177 -0
  38. package/build/src/utils/__tests__/prices.spec.d.ts +1 -0
  39. package/build/src/utils/__tests__/prices.spec.js +58 -0
  40. package/build/src/utils/__tests__/referrals.spec.d.ts +1 -0
  41. package/build/src/utils/__tests__/referrals.spec.js +17 -0
  42. package/build/src/utils/__tests__/subgraph.spec.d.ts +1 -0
  43. package/build/src/utils/__tests__/subgraph.spec.js +162 -0
  44. package/build/src/utils/__tests__/tokens.spec.d.ts +1 -0
  45. package/build/src/utils/__tests__/tokens.spec.js +82 -0
  46. package/build/src/utils/__tests__/trade.spec.d.ts +1 -0
  47. package/build/src/utils/__tests__/trade.spec.js +35 -0
  48. package/build/src/utils/bigmath.d.ts +1 -1
  49. package/build/src/utils/bigmath.js +6 -1
  50. package/build/src/utils/callContract.js +5 -1
  51. package/build/src/utils/contracts.d.ts +4 -0
  52. package/build/src/utils/contracts.js +2 -0
  53. package/build/src/utils/fees/executionFee.d.ts +1 -33
  54. package/build/src/utils/fees/executionFee.js +2 -48
  55. package/build/src/utils/fees/executionFee.spec.d.ts +1 -0
  56. package/build/src/utils/fees/executionFee.spec.js +64 -0
  57. package/build/src/utils/fees/index.d.ts +2 -0
  58. package/build/src/utils/fees/index.js +5 -0
  59. package/build/src/utils/markets.d.ts +9 -2
  60. package/build/src/utils/markets.js +33 -10
  61. package/build/src/utils/orders.js +0 -8
  62. package/build/src/utils/positions.js +3 -3
  63. package/build/src/utils/prices.d.ts +1 -6
  64. package/build/src/utils/prices.js +0 -9
  65. package/build/src/utils/referrals.d.ts +2 -0
  66. package/build/src/utils/referrals.js +17 -15
  67. package/build/src/utils/swapStats.d.ts +1 -0
  68. package/build/src/utils/swapStats.js +12 -1
  69. package/build/src/utils/testUtil.d.ts +5 -5
  70. package/build/src/utils/tokens.d.ts +4 -0
  71. package/build/src/utils/tokens.js +4 -0
  72. package/build/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +1 -1
  74. package/build/src/types/amounts.d.ts +0 -223
  75. package/build/src/types/amounts.js +0 -17
  76. package/build/src/types/syntheticsEvents.d.ts +0 -88
  77. /package/build/src/types/{syntheticsEvents.js → common.js} +0 -0
@@ -2999,6 +2999,106 @@
2999
2999
  "virtualMarketId": "0x056468869fcbcf8bbcf7b726adf30aea71c65d61a2dde85829d025ebd638b67f",
3000
3000
  "virtualLongTokenId": "0xa59040b7efb6b7122a74cb318a192ebc6732849dff5332ee3ba40b90dfa0a04f",
3001
3001
  "virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
3002
+ },
3003
+ "0x467C4A46287F6C4918dDF780D4fd7b46419c2291": {
3004
+ "isDisabled": "0x6f3365eca94c4988056075630326d3e1c377e2ab66c8143882c92be098d9716e",
3005
+ "maxLongPoolAmount": "0x70e783db2dbfb9f8386ef938695fba15f20d82fdab616ce3265f6c6dcf8acb7a",
3006
+ "maxShortPoolAmount": "0x05598ea0252f22e4960a4e49ead7aec4aeca88f2419d24d4c2f1e716feb44486",
3007
+ "maxLongPoolUsdForDeposit": "0xb6caf755277c13afd74a5462065520082790b272ab64597cc64fbc4bf37a655f",
3008
+ "maxShortPoolUsdForDeposit": "0xe7bdc6a2c661f4199305e3406f92307216f45eefb0effeb89ec39c2637af6007",
3009
+ "longPoolAmountAdjustment": "0xd942467dfa81165590c0580a3a64033941b1dd90c26bbb54c18b42b92fa860d9",
3010
+ "shortPoolAmountAdjustment": "0x764480ff473502e42b573856ea6cd47b4180560aefa0d06c654033b74a15f20d",
3011
+ "reserveFactorLong": "0x7031f30e0b032d9c2585344dfa69075d500cd77f054df747614786dfb02c9218",
3012
+ "reserveFactorShort": "0x79f2662f5af9a48ed9fc6632789164d0f88553348da1c665bd93fd78e61c327d",
3013
+ "openInterestReserveFactorLong": "0x646efd7060f02bde654b8b3a32cea4d7d77d049f04a1b156c0462e329bbad53d",
3014
+ "openInterestReserveFactorShort": "0xce92b2ed972f29c42b97fcfba7a6804b9fb432937543bb45f0dbede2f9e8d227",
3015
+ "maxOpenInterestLong": "0xcb3e3ddac689e96245b0585e82abc3d5bbf7a72e0e6f9dd714558c97e5405b1d",
3016
+ "maxOpenInterestShort": "0xd8a8b33a1b9ef5626722637e4c2aa25bf70d58f53420eba9f4950a0ae4094004",
3017
+ "minPositionImpactPoolAmount": "0xca10e0f0e6426b4364e46b53b7f941d913d356ed0c1cd6ca2763586b3f71695f",
3018
+ "positionImpactPoolDistributionRate": "0xc9c2d3378576b591400b454b49e3e89b66548a963c76957bfaa8c58b1118e6cc",
3019
+ "borrowingFactorLong": "0xa2d1c70cad9d2191543bdae7210024a64578f411ce240ae38d941be526a8bc7b",
3020
+ "borrowingFactorShort": "0x215e38e7657cc20889a58ed67cd23496e5efc09653af1ddaf46f4d872263f390",
3021
+ "borrowingExponentFactorLong": "0x3166f16d2dfcad51d3d1f8c4253b2bfebff0749fc680f60a746aad3eefd300de",
3022
+ "borrowingExponentFactorShort": "0xb04b5b494d07cc905288b1cbe2e0a6a582c792cebafe4fc8f87696d14bfd3b78",
3023
+ "fundingFactor": "0x1c930ab75664d8f2db4410f3819cb6e46f58ee2dc97d37b33aef159ccb3040f2",
3024
+ "fundingExponentFactor": "0xfad3cad6ae5c4734b621bfbbfefbb0a924a03efeef536d76865f6da3adec7f2a",
3025
+ "fundingIncreaseFactorPerSecond": "0x4feac8b1e703644821adfd4f92f92fa492729b39a15d13d57b88cd5a13fcfbf5",
3026
+ "fundingDecreaseFactorPerSecond": "0xed54d1f0f6afecb754c649a41d67fc609997527087d11ef7bc901d436235da51",
3027
+ "thresholdForStableFunding": "0x34c41d8ee40a3a5468750d422308a8b8f631d9db5f3ba441eba7315139e9c3a9",
3028
+ "thresholdForDecreaseFunding": "0x30c538df069cec73a5ef197585b7199cabea52ebd492d80c7734678073364cbd",
3029
+ "minFundingFactorPerSecond": "0xd452e450c06605620af3d7febc6e9fd774d5355ff913436acc7ba2b977a0b306",
3030
+ "maxFundingFactorPerSecond": "0x958ff648969e44b4659d79a393f28042f97cfcfdc8fc698c9010fa1da452fd3f",
3031
+ "maxPnlFactorForTradersLong": "0xd8ccd387611f6b39a5f16eb0f13c0835179bf58208af7938f7a6ea98ffcfbfae",
3032
+ "maxPnlFactorForTradersShort": "0x626e1b71533247a7b932b107904f1433bbc09b1de4bbd51932958fa8d444f613",
3033
+ "positionFeeFactorForPositiveImpact": "0x3ba3e82158ca7a20ec5ac93874ab157c9467cb8ff224e0b0a1b7e1e2dc21f874",
3034
+ "positionFeeFactorForNegativeImpact": "0x699524c62e892e3db59c9a3c858ed04d9f514dcb47513187c9aad9ae3815269c",
3035
+ "positionImpactFactorPositive": "0xdc6271c18394b8a7062c7e9b84361c35e34e920fac4f7e13f9ef1a4595aebb9b",
3036
+ "positionImpactFactorNegative": "0x156aa170f4820ef2479670eb20af8fc7ea2e5491f603493dbc2b9070cc948e52",
3037
+ "maxPositionImpactFactorPositive": "0xeca13146281a419baa821b94f4498cbc4276ff0992e34aa2737f8fb79b508223",
3038
+ "maxPositionImpactFactorNegative": "0x7c36e7cd53d579958cb553bb9fd79face0c9a226720cf88b05c3620ad9c54dda",
3039
+ "maxPositionImpactFactorForLiquidations": "0xe1b63d9189f4f9f092128feec975a80cc218a5078db1338445d96c1bf9db4526",
3040
+ "minCollateralFactor": "0xc119284ca99194e4d943a6af90e4dd7fb4bb14b050a974fb83142774cba81786",
3041
+ "minCollateralFactorForOpenInterestLong": "0xdc7d2b11c98f133ad856f4e38b92fae525d6a2ae80ceeb3b420e240dfad9849a",
3042
+ "minCollateralFactorForOpenInterestShort": "0x5c5f8d9af53545a1214654f78ad1e9a6ab37aecd5469c2e5c4cbcf8cd2e63551",
3043
+ "positionImpactExponentFactor": "0xcc823670635973134c5087c8d47979affcca515532603cc92ebc945c51ed08c4",
3044
+ "swapFeeFactorForPositiveImpact": "0x014fda6121726da59e193a952cc3a1cfd31b925febc198a559b2cc1e4d27f819",
3045
+ "swapFeeFactorForNegativeImpact": "0x1a0c447e52ff673b57162b390edd27e8040ee4be5e52ea646e13630bf98457ba",
3046
+ "swapImpactFactorPositive": "0x2f10e629b89a4e353d8d563afb62870a006f03e0cbd77759101e3e646d7f9631",
3047
+ "swapImpactFactorNegative": "0xe6988279f833b1014b0483425d0eb061c1b244073b18b54d1eebf3a9de1f75cb",
3048
+ "swapImpactExponentFactor": "0xd4eea362f0a2ac992a6ede6c2defb41e3416cef42c033d97ff2ac8b70db7e3b5",
3049
+ "virtualMarketId": "0x773ccb8ee7deeaf0b761a6290f2317392066dc69ccf0e6b019722007598c5a9a",
3050
+ "virtualLongTokenId": "0xa59040b7efb6b7122a74cb318a192ebc6732849dff5332ee3ba40b90dfa0a04f",
3051
+ "virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
3052
+ },
3053
+ "0x16466a03449CB9218EB6A980Aa4a44aaCEd27C25": {
3054
+ "isDisabled": "0x421193dc127795dace90f01dea0586f1c183cfd5695f15f8e99b1ee000d852f1",
3055
+ "maxLongPoolAmount": "0x028ead75d5ed15329febb14a355ecdb3ad8ba66c5ba3ab59adebc8f018c7781c",
3056
+ "maxShortPoolAmount": "0x60fd8899e9d8c59873eb62351943fa8353d3cb5c01e4e4930ee8f9d2ca9494c3",
3057
+ "maxLongPoolUsdForDeposit": "0xb1829172c867cbafe0e28440454f76d6f8fda2f2081740553bd75e86c75e93aa",
3058
+ "maxShortPoolUsdForDeposit": "0x689d10c40af7eae5e82b72140c22943c59ef5b0ebb9f09d8ae2daf96295233a9",
3059
+ "longPoolAmountAdjustment": "0x0f082d041e3ae2a85bbb0310fd76ce5a4bb8aed09ca7cb8d7694da35512277b5",
3060
+ "shortPoolAmountAdjustment": "0xbfdc51f7f2cbc1d9c9e36f96e47a7a06b9ab80daa6514749759fb6dc78c9dc20",
3061
+ "reserveFactorLong": "0x8ef363631a21ed0e5c86e8d2efcbb11571959f31b2b630c13e8803980a2f93d9",
3062
+ "reserveFactorShort": "0xd8da6bc0e6fa20d0641dda4ac9982576e311714f9526df49fa3c050c742d0564",
3063
+ "openInterestReserveFactorLong": "0xf2e0a7c7820ab0405f366b8cb2c9de19e3c3180562dd48bce308d9572b84eb1f",
3064
+ "openInterestReserveFactorShort": "0x29231a90857f720c2d6d49afbe2e320870cf78807fda02dd0d07c53db879c523",
3065
+ "maxOpenInterestLong": "0x1a52b88b58b5648cff40e22ce3873acaba7f95144836bf685eebce91fa61a0bd",
3066
+ "maxOpenInterestShort": "0x12fd44cdf72d58efdced9ae25f2d23b5b52e6a80075309c70b5bb175c69efb18",
3067
+ "minPositionImpactPoolAmount": "0x0b04f17eff6632562f5b25fc2d97e9a4374569b62331e791aa80c01da4109393",
3068
+ "positionImpactPoolDistributionRate": "0xfcaa17a583c8b4f640e61641a84f3d61034075a88d6f90a3022087f5d38df399",
3069
+ "borrowingFactorLong": "0x911d212f44f3b4d1f532f52cd6ec4e3227159961d4aea9d6cb432f67ee5596ff",
3070
+ "borrowingFactorShort": "0x6f250f42f90ad6dad8f85adb80f1337f515e3526f48678d6f89c17e81de30073",
3071
+ "borrowingExponentFactorLong": "0xb7fb1947aec2f9904cfdabb2ded2b633faa20340e94cd35e0c920c149c2d027c",
3072
+ "borrowingExponentFactorShort": "0x6ab1ceda067d94e4a61a9dfcc1e4d0823781d4f8239c5fa720c56e5cdb80a105",
3073
+ "fundingFactor": "0xcb0b6f93301a6ee4cf48b4d5a7a7fee29894112aed033f8ba179ed426b4cab89",
3074
+ "fundingExponentFactor": "0x50fdf17406706f8e95f48e3fa8af6abbfe8f698fa8f5f3d63995cca28f79ba42",
3075
+ "fundingIncreaseFactorPerSecond": "0x0d4e7ddd68f22aee486308112ccd42605c1ef072fc136687468a85794732c6c7",
3076
+ "fundingDecreaseFactorPerSecond": "0x024b837fa1884678e64395af495daceffdb1cbd31bd15f135e76a45f69b544b8",
3077
+ "thresholdForStableFunding": "0xe36c265a5b450ef48a22ed194e730d7fe9782223579082b589b26ad364a81284",
3078
+ "thresholdForDecreaseFunding": "0xbbe56c818c14d5e594a0a64feb8f5c91ae07f8671ace0ae776f65efbd0601d2c",
3079
+ "minFundingFactorPerSecond": "0xd32c84184c6daa18a6784539ee7c201369216316a7d2b368f32b47b62789fa5d",
3080
+ "maxFundingFactorPerSecond": "0x2ad9d83577d571a8ce3521912811bf5b7c2770021a2c8af368fe8848a1bc4395",
3081
+ "maxPnlFactorForTradersLong": "0x0f01b59ae43dd839e912fd5b24f5406c50afa7c2c37fce4f2268023e9c569959",
3082
+ "maxPnlFactorForTradersShort": "0x46626df8db05a87d31252ce589cf2d44633ae1b0a2593ff6e43642ac83380acf",
3083
+ "positionFeeFactorForPositiveImpact": "0xa17412d9fb8836576acf564f6b7d917e2523edc2b22e54160bf847b075938f12",
3084
+ "positionFeeFactorForNegativeImpact": "0xa283b96249bd91fa6bf8027982b11be3b157850d5a7a9409a1bd92993b352d34",
3085
+ "positionImpactFactorPositive": "0x98286b1d1ff96f67cba51e90d3335fa9395fbffee6ea6d6188f2f4d785fa5730",
3086
+ "positionImpactFactorNegative": "0x8a2e5ca0fcd5b03675d20b12386f3b185a06f71604235ef8d305d427e65161cf",
3087
+ "maxPositionImpactFactorPositive": "0xc81436f5558cb283c8c590d8b08d2685f138a0a10bf14cf46e547a0bda68720b",
3088
+ "maxPositionImpactFactorNegative": "0xb375a902c092145cac64c3a449027132cd12c0e9cef6b72d54024276ab1fd84b",
3089
+ "maxPositionImpactFactorForLiquidations": "0xfd8dcd34d1379f246478a28f69d7ffb710935582517b883cc2114ccd8e574e5e",
3090
+ "minCollateralFactor": "0xc3b683211f897fd3d5139249aff11aa9339db2b59342fb4dde8b9f241ac744b7",
3091
+ "minCollateralFactorForOpenInterestLong": "0x632d6bc9d36199ead3660e1d54803d97147abc31e2cac1b18dd386d250f44a2a",
3092
+ "minCollateralFactorForOpenInterestShort": "0x03289b688ce32f30e096f9f305f6f1e4d654785db89ccc5a81812876233e02ab",
3093
+ "positionImpactExponentFactor": "0x6af5e63b59afc60c71a45a325ded80a245d81947f6c9a9bff20d5f97e402fbc8",
3094
+ "swapFeeFactorForPositiveImpact": "0x4f5ebafeb87725474637f4b264962f556c830765f047576f68ff7e5dde5ba384",
3095
+ "swapFeeFactorForNegativeImpact": "0xec05b3db52f1252fa492f3bfd694cbe7c6b86bfba73abfea88f0a55026e61f3c",
3096
+ "swapImpactFactorPositive": "0x40d4a5c09e6e2f7d78e3dccf44cdd2813b205c5f57942264bda60aee2add42db",
3097
+ "swapImpactFactorNegative": "0x60918f5a146bcc03569cbf6e35e786a85e270d98a4db0043a431be58ecb5a3fc",
3098
+ "swapImpactExponentFactor": "0x5c57dc3f5ad0d71a0263608d9d0eb53f3b54328e7d41e272393409353c21bc90",
3099
+ "virtualMarketId": "0x2e1b50cd933617e9a08cda4f3cbe390c1f17523a16453e477dd04fb28c7eb61b",
3100
+ "virtualLongTokenId": "0xa59040b7efb6b7122a74cb318a192ebc6732849dff5332ee3ba40b90dfa0a04f",
3101
+ "virtualShortTokenId": "0xd5258cb84f0039be58306488e8df941c05f3cf4f219e92aacb6561c736bbb960"
3002
3102
  }
3003
3103
  },
3004
3104
  "43113": {
@@ -899,6 +899,36 @@
899
899
  "longInterestInTokensUsingShortToken": "0x14f339c76f04621b9ba15768d956b9a222125ad2b853794298c5c7eecd4e22f0",
900
900
  "shortInterestInTokensUsingLongToken": "0x781c00d9f9a188b6173b99ed7a04104754daf7bcc9bda9f9227e5cb787c0e0cc",
901
901
  "shortInterestInTokensUsingShortToken": "0x62d44383e14f1701c86a8900747d74284de95144d266b776d5037ca0d0426b1a"
902
+ },
903
+ "0x467C4A46287F6C4918dDF780D4fd7b46419c2291": {
904
+ "longPoolAmount": "0xed2a44283e5b723607e9f2024b3502e6bb8f61b2ac3245978b0da7f63636970c",
905
+ "shortPoolAmount": "0x3d7a43632386c44a5981a6cf24522d343f823868ffa05fed04f75d49e0c97907",
906
+ "positionImpactPoolAmount": "0x471f73a9671f6887a87a301e2f2bc1ab883b21c4d1035801225fa58523733756",
907
+ "swapImpactPoolAmountLong": "0x687a328d60932d3ac69f7810b263b1c07ec99c0e37bfd01a9c17c666bc8c6110",
908
+ "swapImpactPoolAmountShort": "0xb84694866ac2a61e4d84d7a354d0c7dc2d6760b5bf2950afea404b1c31e8f0f2",
909
+ "longInterestUsingLongToken": "0xc2dda98062f969440629a5c6f6a5fca3222956090f5f315648356101a49c1a87",
910
+ "longInterestUsingShortToken": "0xff2966344db8d78bf4c02adb695514d0163f84dc5fd9fb67f497982de8dfac9e",
911
+ "shortInterestUsingLongToken": "0xf93df38dc031f2c31cf490c394f3ea19a0c293992e57985602feca70834d0811",
912
+ "shortInterestUsingShortToken": "0x5bfcd9e0bb32a72c0012b1bca0285e1e1a7539da1f65339e05597d35006a4c9f",
913
+ "longInterestInTokensUsingLongToken": "0xe4391da2db8603da20de593ef4ffb4942ca7f2a7a68d5c5153334b483272d548",
914
+ "longInterestInTokensUsingShortToken": "0x85c979ceff7627c1dc697698ffb801cf4e43cac7aa41ebb02a1cb2f9c44419d0",
915
+ "shortInterestInTokensUsingLongToken": "0xb7de073113438300ef9d0b4e24149ced70eb5d04c644be98e268469d36d389a6",
916
+ "shortInterestInTokensUsingShortToken": "0xff62257ef67048abc448c8d0449eed2b8f08edd8dc0a7dcc5b167a2f54bc28f2"
917
+ },
918
+ "0x16466a03449CB9218EB6A980Aa4a44aaCEd27C25": {
919
+ "longPoolAmount": "0x0ecb8edaa2832d50c0c830f32e245070bf349ba6743287a175038b6bc6d00683",
920
+ "shortPoolAmount": "0xd7afc9563364ce8a2f36a288be6fa8ae7a81b573115e4d6d53b48360adbfdd35",
921
+ "positionImpactPoolAmount": "0x4aeda8ea6156723440606890aa6c5757bba22d3a8eb9409513eafb62567c4f90",
922
+ "swapImpactPoolAmountLong": "0xa6c434f9c2d761c4d4f15da3a91f737c23148686c0d80cb9960759cbb0a8ab07",
923
+ "swapImpactPoolAmountShort": "0x64db2d4159c309ed40e72fb7cdfff533995ef96e76e8ed0cd94ea75901fe4fbf",
924
+ "longInterestUsingLongToken": "0xdd3adf73d0abf54fd9abdce40a85a186d67332c9243489e4dbbdf934434ef807",
925
+ "longInterestUsingShortToken": "0xdaa066ec159484d8c956dcf395dc82088712d34ec3075ef91c5b7b2900a2fbc5",
926
+ "shortInterestUsingLongToken": "0xfbf3063e9909c1b72fdea2c6874a3f63797b959c5543f7e119ca53d2b130b11b",
927
+ "shortInterestUsingShortToken": "0xbe8c41944b45076535be05314622ea6f2b8d86cb03befb01aed93b529bd7fc8a",
928
+ "longInterestInTokensUsingLongToken": "0x59712b99752c154054e328b264eab231b6217ad70be24ad017fe1ba6760e9d92",
929
+ "longInterestInTokensUsingShortToken": "0x60bb5a56bfec8db56c94c97fc1fa228a87523379609015edd2088d97afd1c0fa",
930
+ "shortInterestInTokensUsingLongToken": "0x1793772d09dd54f5c5fcd10d9ed7b33e03049c07c9b5005292ed5060cb72a90a",
931
+ "shortInterestInTokensUsingShortToken": "0xaa4b8343388d5ecb9e0e7659c31dd342129613204041f28a3dcc9c5a85791850"
902
932
  }
903
933
  },
904
934
  "43113": {
@@ -0,0 +1 @@
1
+ export type BytesLike = string | Uint8Array;
@@ -3,13 +3,14 @@ export type ExecutionFee = {
3
3
  feeUsd: bigint;
4
4
  feeTokenAmount: bigint;
5
5
  feeToken: Token;
6
- warning?: string;
6
+ gasLimit: bigint;
7
7
  isFeeHigh: boolean;
8
8
  isFeeVeryHigh: boolean;
9
9
  };
10
10
  export type FeeItem = {
11
11
  deltaUsd: bigint;
12
12
  bps: bigint;
13
+ precisePercentage: bigint;
13
14
  };
14
15
  export type SwapFeeItem = FeeItem & {
15
16
  marketAddress: string;
@@ -34,12 +34,6 @@ export type MarketInfo = Market & MarketPoolTokens & {
34
34
  shortPoolAmountAdjustment: bigint;
35
35
  poolValueMax: bigint;
36
36
  poolValueMin: bigint;
37
- pnlLongMin: bigint;
38
- pnlLongMax: bigint;
39
- pnlShortMin: bigint;
40
- pnlShortMax: bigint;
41
- netPnlMin: bigint;
42
- netPnlMax: bigint;
43
37
  reserveFactorLong: bigint;
44
38
  reserveFactorShort: bigint;
45
39
  openInterestReserveFactorLong: bigint;
@@ -99,19 +93,6 @@ export type MarketInfo = Market & MarketPoolTokens & {
99
93
  virtualLongTokenId: string;
100
94
  virtualShortTokenId: string;
101
95
  };
102
- export type FastMarketInfo = Omit<MarketInfo, keyof MarketPoolTokens | keyof Market> & {
103
- marketTokenAddress: string;
104
- longTokenAddress: string;
105
- shortTokenAddress: string;
106
- indexTokenAddress: string;
107
- };
108
- export type ClaimableFunding = {
109
- claimableFundingAmountLong: bigint;
110
- claimableFundingAmountShort: bigint;
111
- };
112
- export type ClaimableFundingData = {
113
- [marketAddress: string]: ClaimableFunding;
114
- };
115
96
  export type MarketsData = {
116
97
  [marketTokenAddress: string]: Market;
117
98
  };
@@ -148,3 +129,10 @@ export type ContractMarketPrices = {
148
129
  max: bigint;
149
130
  };
150
131
  };
132
+ export type ClaimableFunding = {
133
+ claimableFundingAmountLong: bigint;
134
+ claimableFundingAmountShort: bigint;
135
+ };
136
+ export type ClaimableFundingData = {
137
+ [marketAddress: string]: ClaimableFunding;
138
+ };
@@ -1,4 +1,3 @@
1
- import { Address } from "viem";
2
1
  import { MarketInfo } from "./markets";
3
2
  import { TokenData, TokensRatio } from "./tokens";
4
3
  import { SwapPathStats, TriggerThresholdType } from "./trade";
@@ -26,7 +25,7 @@ export type Order = {
26
25
  key: string;
27
26
  account: string;
28
27
  callbackContract: string;
29
- initialCollateralTokenAddress: Address;
28
+ initialCollateralTokenAddress: string;
30
29
  marketAddress: string;
31
30
  decreasePositionSwapType: DecreasePositionSwapType;
32
31
  receiver: string;
@@ -43,18 +42,17 @@ export type Order = {
43
42
  isLong: boolean;
44
43
  orderType: OrderType;
45
44
  shouldUnwrapNativeToken: boolean;
46
- data: string;
47
45
  autoCancel: boolean;
46
+ data: string;
47
+ title?: string;
48
48
  };
49
49
  export type SwapOrderInfo = Order & {
50
- title?: string;
51
50
  swapPathStats?: SwapPathStats;
52
51
  triggerRatio?: TokensRatio;
53
52
  initialCollateralToken: TokenData;
54
53
  targetCollateralToken: TokenData;
55
54
  };
56
55
  export type PositionOrderInfo = Order & {
57
- title: string;
58
56
  marketInfo: MarketInfo;
59
57
  swapPathStats?: SwapPathStats;
60
58
  indexToken: TokenData;
@@ -1,5 +1,4 @@
1
- import { MarketInfo } from "./markets";
2
- import { PendingPositionUpdate } from "./syntheticsEvents";
1
+ import { Market, MarketInfo } from "./markets";
3
2
  import { TokenData } from "./tokens";
4
3
  export type Position = {
5
4
  key: string;
@@ -18,12 +17,20 @@ export type Position = {
18
17
  claimableLongTokenAmount: bigint;
19
18
  claimableShortTokenAmount: bigint;
20
19
  isOpening?: boolean;
21
- pendingUpdate?: PendingPositionUpdate;
20
+ pnl: bigint;
21
+ positionFeeAmount: bigint;
22
+ traderDiscountAmount: bigint;
23
+ uiFeeAmount: bigint;
22
24
  data: string;
23
25
  };
24
26
  export type PositionInfo = Position & {
25
- marketInfo: MarketInfo;
27
+ marketInfo: MarketInfo | undefined;
28
+ market: Market;
26
29
  indexToken: TokenData;
30
+ longToken: TokenData;
31
+ shortToken: TokenData;
32
+ indexName: string;
33
+ poolName: string;
27
34
  collateralToken: TokenData;
28
35
  pnlToken: TokenData;
29
36
  markPrice: bigint;
@@ -143,6 +143,7 @@ export type SwapStats = {
143
143
  isWrap: boolean;
144
144
  isUnwrap: boolean;
145
145
  isOutLiquidity?: boolean;
146
+ isOutCapacity?: boolean;
146
147
  swapFeeAmount: bigint;
147
148
  swapFeeUsd: bigint;
148
149
  priceImpactDeltaUsd: bigint;
@@ -1,3 +1,4 @@
1
+ import { BytesLike } from "./common";
1
2
  import { MarketInfo } from "./markets";
2
3
  import { OrderType } from "./orders";
3
4
  import { TokenData } from "./tokens";
@@ -27,6 +28,7 @@ export type RawTradeAction = {
27
28
  positionFeeAmount?: string;
28
29
  borrowingFeeAmount?: string;
29
30
  fundingFeeAmount?: string;
31
+ liquidationFeeAmount?: string;
30
32
  pnlUsd?: string;
31
33
  basePnlUsd?: string;
32
34
  collateralTokenPriceMax?: string;
@@ -38,7 +40,7 @@ export type RawTradeAction = {
38
40
  isLong?: boolean;
39
41
  shouldUnwrapNativeToken?: boolean;
40
42
  reason?: string;
41
- reasonBytes?: string | Uint8Array;
43
+ reasonBytes?: BytesLike;
42
44
  transaction: {
43
45
  timestamp: number;
44
46
  hash: string;
@@ -78,6 +80,7 @@ export type PositionTradeAction = {
78
80
  reason?: string;
79
81
  reasonBytes?: string | Uint8Array;
80
82
  shouldUnwrapNativeToken: boolean;
83
+ liquidationFeeAmount?: bigint;
81
84
  transaction: {
82
85
  timestamp: number;
83
86
  hash: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ import { LRUCache } from "../LruCache";
2
+ describe("LruCache", () => {
3
+ it("should store and retrieve values", () => {
4
+ const cache = new LRUCache(2);
5
+ cache.set("a", 1);
6
+ expect(cache.get("a")).toBe(1);
7
+ });
8
+ it("should return undefined for non-existing keys", () => {
9
+ const cache = new LRUCache(2);
10
+ expect(cache.get("x")).toBeUndefined();
11
+ });
12
+ it("should update recent usage when getting a key", () => {
13
+ const cache = new LRUCache(2);
14
+ cache.set("a", 1);
15
+ cache.set("b", 2);
16
+ cache.get("a"); // 'a' is now the most recently used
17
+ cache.set("c", 3); // 'b' should be evicted
18
+ expect(cache.has("b")).toBe(false);
19
+ expect(cache.has("a")).toBe(true);
20
+ });
21
+ it("should evict the least recently used key when capacity is exceeded", () => {
22
+ const cache = new LRUCache(2);
23
+ cache.set("a", 1);
24
+ cache.set("b", 2);
25
+ cache.set("c", 3); // 'a' is removed
26
+ expect(cache.has("a")).toBe(false);
27
+ expect(cache.has("b")).toBe(true);
28
+ expect(cache.get("c")).toBe(3);
29
+ });
30
+ it("should update existing keys without eviction", () => {
31
+ const cache = new LRUCache(2);
32
+ cache.set("a", 1);
33
+ cache.set("b", 2);
34
+ cache.set("a", 10); // update 'a'
35
+ expect(cache.get("a")).toBe(10);
36
+ expect(cache.has("b")).toBe(true);
37
+ });
38
+ it("should throw error if key is not a string", () => {
39
+ const cache = new LRUCache(2);
40
+ expect(() => cache.set(123, 1)).toThrow("Key must be a string");
41
+ });
42
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { bigMath } from "../bigmath";
2
+ describe("bigMath", () => {
3
+ describe("abs", () => {
4
+ it("should return the absolute value of a number", () => {
5
+ expect(bigMath.abs(10n)).toBe(10n);
6
+ expect(bigMath.abs(-10n)).toBe(10n);
7
+ });
8
+ });
9
+ describe("mulDiv", () => {
10
+ it("should return the result of multiplying two numbers and dividing by a third", () => {
11
+ expect(bigMath.mulDiv(10n, 10n, 2n)).toBe(50n);
12
+ expect(bigMath.mulDiv(10n, 10n, 3n)).toBe(33n);
13
+ });
14
+ });
15
+ describe("max", () => {
16
+ it("should return the maximum value of a list of numbers", () => {
17
+ expect(bigMath.max(10n, 20n, -30n)).toBe(20n);
18
+ expect(bigMath.max(30n, 20n, 10n)).toBe(30n);
19
+ });
20
+ });
21
+ describe("min", () => {
22
+ it("should return the minimum value of a list of numbers", () => {
23
+ expect(bigMath.min(10n, 20n, -30n)).toBe(-30n);
24
+ expect(bigMath.min(30n, 20n, 10n)).toBe(10n);
25
+ });
26
+ });
27
+ describe("avg", () => {
28
+ it("should return the average value of a list of numbers", () => {
29
+ expect(bigMath.avg(10n, 20n, 30n)).toBe(20n);
30
+ expect(bigMath.avg(10n, 20n, 30n, 40n, undefined)).toBe(25n);
31
+ });
32
+ it("should return undefined if no values are provided", () => {
33
+ expect(bigMath.avg()).toBe(undefined);
34
+ expect(bigMath.avg(undefined, undefined)).toBe(undefined);
35
+ });
36
+ });
37
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { hashData, hashString, hashDataMap } from "../hash";
2
+ import { LRUCache } from "../LruCache";
3
+ describe("hashData", () => {
4
+ it("returns a valid hash and caches it", () => {
5
+ const inputTypes = ["uint256", "string"];
6
+ const inputValues = [123n, "hello"];
7
+ const result = hashData(inputTypes, inputValues);
8
+ expect(result).toBe("0x18a25ed45d79546dfca2565caa2ee3102fb46159dea4fde1d0a9c0cc78ce94e3");
9
+ // Check cache
10
+ const key = JSON.stringify({ dataTypes: inputTypes, dataValues: ["123", "hello"] });
11
+ expect(new LRUCache(10000).has(key)).toBe(false);
12
+ });
13
+ it("returns cached hash if already computed", () => {
14
+ const inputTypes = ["bool"];
15
+ const inputValues = [true];
16
+ const result1 = hashData(inputTypes, inputValues);
17
+ const result2 = hashData(inputTypes, inputValues);
18
+ expect(result1).toBe(result2);
19
+ });
20
+ });
21
+ describe("hashString", () => {
22
+ it("returns a valid hash for a string and caches it", () => {
23
+ const str = "test-string";
24
+ const hash1 = hashString(str);
25
+ const hash2 = hashString(str);
26
+ expect(hash1).toBe(hash2);
27
+ });
28
+ });
29
+ describe("hashDataMap", () => {
30
+ it("returns hashes for a given record map", () => {
31
+ const result = hashDataMap({
32
+ first: [["string"], ["hello"]],
33
+ second: [["uint256"], [42n]],
34
+ empty: undefined,
35
+ });
36
+ expect(Object.keys(result)).toContain("first");
37
+ expect(Object.keys(result)).toContain("second");
38
+ expect(Object.keys(result)).not.toContain("empty");
39
+ });
40
+ });
@@ -0,0 +1 @@
1
+ export {};