@gmx-io/sdk 1.4.1 → 2.0.0-alpha-1

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 (37) hide show
  1. package/build/cjs/src/configs/dataStore.js +6 -2
  2. package/build/cjs/src/configs/markets.js +35 -0
  3. package/build/cjs/src/configs/tokens.js +48 -169
  4. package/build/cjs/src/modules/orders/helpers.js +2 -0
  5. package/build/cjs/src/prebuilt/hashedKinkModelMarketRatesKeys.json +40 -0
  6. package/build/cjs/src/prebuilt/hashedMarketConfigKeys.json +285 -0
  7. package/build/cjs/src/prebuilt/hashedMarketValuesKeys.json +75 -0
  8. package/build/cjs/src/utils/multicall.js +2 -2
  9. package/build/cjs/src/utils/swap/__tests__/findSwapPathsBetweenTokens.spec.js +22 -0
  10. package/build/cjs/src/utils/swap/__tests__/mockRouting.spec.js +257 -0
  11. package/build/cjs/src/utils/swap/buildSwapStrategy.js +12 -4
  12. package/build/cjs/src/utils/swap/findSwapPathsBetweenTokens.js +8 -4
  13. package/build/cjs/src/utils/swap/swapValues.js +13 -6
  14. package/build/cjs/src/utils/trade/increase.js +3 -0
  15. package/build/esm/src/configs/dataStore.js +3 -0
  16. package/build/esm/src/configs/markets.js +35 -0
  17. package/build/esm/src/configs/tokens.js +48 -169
  18. package/build/esm/src/modules/orders/helpers.js +2 -0
  19. package/build/esm/src/prebuilt/hashedKinkModelMarketRatesKeys.json +40 -0
  20. package/build/esm/src/prebuilt/hashedMarketConfigKeys.json +285 -0
  21. package/build/esm/src/prebuilt/hashedMarketValuesKeys.json +75 -0
  22. package/build/esm/src/utils/multicall.js +2 -2
  23. package/build/esm/src/utils/swap/__tests__/findSwapPathsBetweenTokens.spec.js +22 -0
  24. package/build/esm/src/utils/swap/__tests__/mockRouting.spec.js +257 -0
  25. package/build/esm/src/utils/swap/buildSwapStrategy.js +13 -5
  26. package/build/esm/src/utils/swap/findSwapPathsBetweenTokens.js +8 -4
  27. package/build/esm/src/utils/swap/swapValues.js +14 -7
  28. package/build/esm/src/utils/trade/increase.js +3 -0
  29. package/build/types/src/configs/dataStore.d.ts +1 -0
  30. package/build/types/src/modules/markets/query-builders.d.ts +1 -1
  31. package/build/types/src/types/markets.d.ts +1 -0
  32. package/build/types/src/types/subsquid.d.ts +13 -0
  33. package/build/types/src/types/tokens.d.ts +0 -3
  34. package/build/types/src/utils/multicall.d.ts +2 -2
  35. package/build/types/src/utils/swap/buildSwapStrategy.d.ts +4 -2
  36. package/build/types/src/utils/swap/swapValues.d.ts +2 -0
  37. package/package.json +14 -6
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.POSITION_IMPACT_POOL_DISTRIBUTION_RATE_KEY = exports.MIN_POSITION_IMPACT_POOL_AMOUNT_KEY = exports.POSITION_IMPACT_POOL_AMOUNT_KEY = exports.LENT_POSITION_IMPACT_POOL_AMOUNT_KEY = exports.MAX_LENDABLE_IMPACT_FACTOR_FOR_WITHDRAWALS_KEY = exports.MAX_LENDABLE_IMPACT_USD_KEY = exports.MAX_LENDABLE_IMPACT_FACTOR_KEY = exports.CLAIMABLE_COLLATERAL_TIME_DIVISOR_KEY = exports.CLAIMABLE_COLLATERAL_REDUCTION_FACTOR_KEY = exports.CLAIMABLE_COLLATERAL_DELAY_KEY = exports.MAX_POSITION_IMPACT_FACTOR_FOR_LIQUIDATIONS_KEY = exports.MAX_PNL_FACTOR_FOR_TRADERS_KEY = exports.MAX_PNL_FACTOR_FOR_DEPOSITS_KEY = exports.MAX_PNL_FACTOR_FOR_WITHDRAWALS_KEY = exports.MAX_PNL_FACTOR_KEY = exports.THRESHOLD_FOR_DECREASE_FUNDING = exports.THRESHOLD_FOR_STABLE_FUNDING = exports.MAX_FUNDING_FACTOR_PER_SECOND = exports.MIN_FUNDING_FACTOR_PER_SECOND = exports.FUNDING_DECREASE_FACTOR_PER_SECOND = exports.FUNDING_INCREASE_FACTOR_PER_SECOND = exports.FUNDING_EXPONENT_FACTOR_KEY = exports.FUNDING_FACTOR_KEY = exports.TOTAL_BORROWING_KEY = exports.CUMULATIVE_BORROWING_FACTOR_KEY = exports.BORROWING_EXPONENT_FACTOR_KEY = exports.BORROWING_FACTOR_KEY = exports.NONCE_KEY = exports.MAX_OPEN_INTEREST_KEY = exports.OPEN_INTEREST_RESERVE_FACTOR_KEY = exports.RESERVE_FACTOR_KEY = exports.MAX_POOL_AMOUNT_KEY = exports.MAX_POOL_USD_FOR_DEPOSIT_KEY = exports.POOL_AMOUNT_KEY = exports.OPEN_INTEREST_IN_TOKENS_KEY = exports.OPEN_INTEREST_KEY = exports.FEE_RECEIVER_POSITION_FACTOR_KEY = exports.FEE_RECEIVER_SWAP_FACTOR_KEY = exports.FEE_RECEIVER_WITHDRAWAL_FACTOR_KEY = exports.BORROWING_FEE_RECEIVER_FACTOR_KEY = exports.FEE_RECEIVER_DEPOSIT_FACTOR_KEY = exports.WITHDRAWAL_FEE_FACTOR_KEY = exports.ATOMIC_SWAP_FEE_FACTOR_KEY = exports.SWAP_FEE_FACTOR_KEY = exports.SWAP_IMPACT_EXPONENT_FACTOR_KEY = exports.SWAP_IMPACT_FACTOR_KEY = exports.POSITION_FEE_FACTOR_KEY = exports.POSITION_IMPACT_EXPONENT_FACTOR_KEY = exports.MAX_POSITION_IMPACT_FACTOR_KEY = exports.POSITION_IMPACT_FACTOR_KEY = void 0;
4
4
  exports.SUBACCOUNT_EXPIRES_AT = exports.ABOVE_OPTIMAL_USAGE_BORROWING_FACTOR = exports.BASE_BORROWING_FACTOR = exports.OPTIMAL_USAGE_FACTOR = exports.MAX_AUTO_CANCEL_ORDERS_KEY = exports.GLV_PER_MARKET_GAS_LIMIT = exports.GLV_WITHDRAWAL_GAS_LIMIT = exports.GLV_DEPOSIT_GAS_LIMIT = exports.GLV_SHIFT_MIN_INTERVAL = exports.GLV_SHIFT_LAST_EXECUTED_AT = exports.IS_GLV_MARKET_DISABLED = exports.GLV_MAX_MARKET_TOKEN_BALANCE_AMOUNT = exports.MIN_COLLATERAL_FACTOR_FOR_LIQUIDATION_KEY = exports.GLV_MAX_MARKET_TOKEN_BALANCE_USD = exports.SUBACCOUNT_AUTO_TOP_UP_AMOUNT = exports.SUBACCOUNT_INTEGRATION_ID = exports.SUBACCOUNT_ORDER_ACTION = exports.SUBACCOUNT_ACTION_COUNT = exports.MAX_ALLOWED_SUBACCOUNT_ACTION_COUNT = exports.SUBACCOUNT_LIST_KEY = exports.UI_FEE_FACTOR = exports.IS_MARKET_DISABLED_KEY = exports.AFFILIATE_REWARD_KEY = exports.VIRTUAL_INVENTORY_FOR_SWAPS_KEY = exports.VIRTUAL_INVENTORY_FOR_POSITIONS_KEY = exports.VIRTUAL_MARKET_ID_KEY = exports.VIRTUAL_TOKEN_ID_KEY = exports.CLAIMABLE_FUNDING_AMOUNT = exports.ACCOUNT_ORDER_LIST_KEY = exports.ORDER_LIST_KEY = exports.POSITION_LIST_KEY = exports.MARKET_LIST_KEY = exports.ESTIMATED_GAS_FEE_MULTIPLIER_FACTOR = exports.ESTIMATED_GAS_FEE_PER_ORACLE_PRICE = exports.ESTIMATED_GAS_FEE_BASE_AMOUNT_V2_1 = exports.NATIVE_TOKEN_TRANSFER_GAS_LIMIT_KEY = exports.TOKEN_TRANSFER_GAS_LIMIT_KEY = exports.SINGLE_SWAP_GAS_LIMIT_KEY = exports.SHIFT_GAS_LIMIT_KEY = exports.SWAP_ORDER_GAS_LIMIT_KEY = exports.DECREASE_ORDER_GAS_LIMIT_KEY = exports.INCREASE_ORDER_GAS_LIMIT_KEY = exports.WITHDRAWAL_GAS_LIMIT_KEY = exports.DEPOSIT_GAS_LIMIT_KEY = exports.MAX_LEVERAGE_KEY = exports.MIN_POSITION_SIZE_USD_KEY = exports.MIN_COLLATERAL_FACTOR_FOR_OPEN_INTEREST_MULTIPLIER_KEY = exports.MIN_COLLATERAL_FACTOR_KEY = exports.MIN_COLLATERAL_USD_KEY = exports.SWAP_IMPACT_POOL_AMOUNT_KEY = void 0;
5
- exports.withdrawalGasLimitKey = exports.depositGasLimitKey = exports.orderKey = exports.swapImpactPoolAmountKey = exports.maxPositionImpactFactorForLiquidationsKey = exports.positionImpactPoolDistributionRateKey = exports.minPositionImpactPoolAmountKey = exports.positionImpactPoolAmountKey = exports.maxPnlFactorKey = exports.thresholdForDecreaseFundingKey = exports.thresholdForStableFundingKey = exports.maxFundingFactorPerSecondKey = exports.minFundingFactorPerSecondKey = exports.fundingDecreaseFactorPerSecondKey = exports.fundingIncreaseFactorPerSecondKey = exports.fundingExponentFactorKey = exports.fundingFactorKey = exports.totalBorrowingKey = exports.cumulativeBorrowingFactorKey = exports.borrowingExponentFactorKey = exports.borrowingFactorKey = exports.maxOpenInterestKey = exports.openInterestReserveFactorKey = exports.reserveFactorKey = exports.poolAmountKey = exports.openInterestInTokensKey = exports.openInterestKey = exports.atomicSwapFeeFactorKey = exports.swapFeeFactorKey = exports.swapImpactExponentFactorKey = exports.swapImpactFactorKey = exports.positionFeeFactorKey = exports.maxPositionImpactFactorKey = exports.positionImpactExponentFactorKey = exports.positionImpactFactorKey = exports.isGlvDisabledKey = exports.glvMaxMarketTokenBalanceAmountKey = exports.glvMaxMarketTokenBalanceUsdKey = exports.glvShiftMinIntervalKey = exports.glvShiftLastExecutedAtKey = exports.subaccountExpiresAtKey = exports.USE_OPEN_INTEREST_IN_TOKENS_FOR_BALANCE = exports.GENERAL_CLAIM_FEATURE_DISABLED = exports.CLAIM_TERMS_KEY = exports.GMX_SIMULATION_ORIGIN = exports.REQUEST_EXPIRATION_TIME_KEY = exports.GELATO_RELAY_FEE_MULTIPLIER_FACTOR_KEY = exports.GASLESS_FEATURE_DISABLED_KEY = exports.PRICE_FEED_KEY = exports.MULTICHAIN_BALANCE = void 0;
6
- exports.claimsDisabledKey = exports.claimTermsKey = exports.gaslessFeatureDisabledKey = exports.priceFeedKey = exports.multichainBalanceKey = exports.subaccountAutoTopUpAmountKey = exports.subaccountIntegrationIdKey = exports.maxLendableImpactUsdKey = exports.maxLendableImpactFactorForWithdrawalsKey = exports.maxLendableImpactFactorKey = exports.subaccountActionCountKey = exports.maxAllowedSubaccountActionCountKey = exports.subaccountListKey = exports.uiFeeFactorKey = exports.maxPoolAmountKey = exports.maxPoolUsdForDepositKey = exports.isMarketDisabledKey = exports.affiliateRewardKey = exports.virtualInventoryForPositionsKey = exports.virtualInventoryForSwapsKey = exports.virtualMarketIdKey = exports.virtualTokenIdKey = exports.claimableFundingAmountKey = exports.hashedPositionKey = exports.minCollateralFactorForOpenInterest = exports.minCollateralFactorForLiquidationKey = exports.minCollateralFactorKey = exports.accountOrderListKey = exports.swapOrderGasLimitKey = exports.decreaseOrderGasLimitKey = exports.increaseOrderGasLimitKey = exports.singleSwapGasLimitKey = exports.shiftGasLimitKey = void 0;
5
+ exports.depositGasLimitKey = exports.orderKey = exports.swapImpactPoolAmountKey = exports.maxPositionImpactFactorForLiquidationsKey = exports.positionImpactPoolDistributionRateKey = exports.minPositionImpactPoolAmountKey = exports.positionImpactPoolAmountKey = exports.maxPnlFactorKey = exports.thresholdForDecreaseFundingKey = exports.thresholdForStableFundingKey = exports.maxFundingFactorPerSecondKey = exports.minFundingFactorPerSecondKey = exports.fundingDecreaseFactorPerSecondKey = exports.fundingIncreaseFactorPerSecondKey = exports.fundingExponentFactorKey = exports.fundingFactorKey = exports.totalBorrowingKey = exports.cumulativeBorrowingFactorKey = exports.borrowingExponentFactorKey = exports.borrowingFactorKey = exports.maxOpenInterestKey = exports.openInterestReserveFactorKey = exports.reserveFactorKey = exports.poolAmountKey = exports.openInterestInTokensKey = exports.openInterestKey = exports.withdrawalFeeFactorKey = exports.atomicSwapFeeFactorKey = exports.swapFeeFactorKey = exports.swapImpactExponentFactorKey = exports.swapImpactFactorKey = exports.positionFeeFactorKey = exports.maxPositionImpactFactorKey = exports.positionImpactExponentFactorKey = exports.positionImpactFactorKey = exports.isGlvDisabledKey = exports.glvMaxMarketTokenBalanceAmountKey = exports.glvMaxMarketTokenBalanceUsdKey = exports.glvShiftMinIntervalKey = exports.glvShiftLastExecutedAtKey = exports.subaccountExpiresAtKey = exports.USE_OPEN_INTEREST_IN_TOKENS_FOR_BALANCE = exports.GENERAL_CLAIM_FEATURE_DISABLED = exports.CLAIM_TERMS_KEY = exports.GMX_SIMULATION_ORIGIN = exports.REQUEST_EXPIRATION_TIME_KEY = exports.GELATO_RELAY_FEE_MULTIPLIER_FACTOR_KEY = exports.GASLESS_FEATURE_DISABLED_KEY = exports.PRICE_FEED_KEY = exports.MULTICHAIN_BALANCE = void 0;
6
+ exports.claimsDisabledKey = exports.claimTermsKey = exports.gaslessFeatureDisabledKey = exports.priceFeedKey = exports.multichainBalanceKey = exports.subaccountAutoTopUpAmountKey = exports.subaccountIntegrationIdKey = exports.maxLendableImpactUsdKey = exports.maxLendableImpactFactorForWithdrawalsKey = exports.maxLendableImpactFactorKey = exports.subaccountActionCountKey = exports.maxAllowedSubaccountActionCountKey = exports.subaccountListKey = exports.uiFeeFactorKey = exports.maxPoolAmountKey = exports.maxPoolUsdForDepositKey = exports.isMarketDisabledKey = exports.affiliateRewardKey = exports.virtualInventoryForPositionsKey = exports.virtualInventoryForSwapsKey = exports.virtualMarketIdKey = exports.virtualTokenIdKey = exports.claimableFundingAmountKey = exports.hashedPositionKey = exports.minCollateralFactorForOpenInterest = exports.minCollateralFactorForLiquidationKey = exports.minCollateralFactorKey = exports.accountOrderListKey = exports.swapOrderGasLimitKey = exports.decreaseOrderGasLimitKey = exports.increaseOrderGasLimitKey = exports.singleSwapGasLimitKey = exports.shiftGasLimitKey = exports.withdrawalGasLimitKey = void 0;
7
7
  const hash_1 = require("../utils/hash");
8
8
  exports.POSITION_IMPACT_FACTOR_KEY = (0, hash_1.hashString)("POSITION_IMPACT_FACTOR");
9
9
  exports.MAX_POSITION_IMPACT_FACTOR_KEY = (0, hash_1.hashString)("MAX_POSITION_IMPACT_FACTOR");
@@ -170,6 +170,10 @@ function atomicSwapFeeFactorKey(market) {
170
170
  return (0, hash_1.hashData)(["bytes32", "address"], [exports.ATOMIC_SWAP_FEE_FACTOR_KEY, market]);
171
171
  }
172
172
  exports.atomicSwapFeeFactorKey = atomicSwapFeeFactorKey;
173
+ function withdrawalFeeFactorKey(market, forBalanceWasImproved) {
174
+ return (0, hash_1.hashData)(["bytes32", "address", "bool"], [exports.WITHDRAWAL_FEE_FACTOR_KEY, market, forBalanceWasImproved]);
175
+ }
176
+ exports.withdrawalFeeFactorKey = withdrawalFeeFactorKey;
173
177
  function openInterestKey(market, collateralToken, isLong) {
174
178
  return (0, hash_1.hashData)(["bytes32", "address", "address", "bool"], [exports.OPEN_INTEREST_KEY, market, collateralToken, isLong]);
175
179
  }
@@ -834,6 +834,41 @@ exports.MARKETS = {
834
834
  longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
835
835
  shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
836
836
  },
837
+ // AR/USD [WBTC-USDC]
838
+ "0xfa19f7d23a475575BD0270AE7de4FC6852442945": {
839
+ marketTokenAddress: "0xfa19f7d23a475575BD0270AE7de4FC6852442945",
840
+ indexTokenAddress: "0x4b9a2b862E1a30e6E844c991D31Dc6387c9d65D5",
841
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
842
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
843
+ },
844
+ // DASH/USD [WBTC-USDC]
845
+ "0x728Ff0679c89267434D6EF1824c8C8eED4aC3DBC": {
846
+ marketTokenAddress: "0x728Ff0679c89267434D6EF1824c8C8eED4aC3DBC",
847
+ indexTokenAddress: "0x426FE015a5F4E6Ad4E6497ad79265D07EA9F121e",
848
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
849
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
850
+ },
851
+ // JTO/USD [WBTC-USDC]
852
+ "0x3B4689d69516b9D4b1aaf7545c6fC4d3ED70b70b": {
853
+ marketTokenAddress: "0x3B4689d69516b9D4b1aaf7545c6fC4d3ED70b70b",
854
+ indexTokenAddress: "0xF01D2AA2f3f903A93D57c4Bf672C8096DE485FA7",
855
+ longTokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
856
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
857
+ },
858
+ // SYRUP/USD [WETH-USDC]
859
+ "0x8965e821c7C8c09c6eB3Cb9cCf7Eb6f386441EA2": {
860
+ marketTokenAddress: "0x8965e821c7C8c09c6eB3Cb9cCf7Eb6f386441EA2",
861
+ indexTokenAddress: "0x9759C297fb6C91e252c7292cECa30a509558E5De",
862
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
863
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
864
+ },
865
+ // CHZ/USD [WETH-USDC]
866
+ "0x3600592DdEd7e6E0B05029DfB637fFc5A85D6f6B": {
867
+ marketTokenAddress: "0x3600592DdEd7e6E0B05029DfB637fFc5A85D6f6B",
868
+ indexTokenAddress: "0x5dB4692926C8ceebF6Da0995358Bbc438F3fd80C",
869
+ longTokenAddress: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
870
+ shortTokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
871
+ },
837
872
  },
838
873
  [chains_1.AVALANCHE]: {
839
874
  // BTC/USD [BTC-USDC]