@1inch/swap-vm-sdk 0.1.2-rc.4 → 0.1.2-rc.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 (104) hide show
  1. package/README.md +12 -12
  2. package/dist/index.d.mts +2 -1
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.js +160 -18
  5. package/dist/index.mjs +162 -14
  6. package/dist/swap-vm/instructions/balances/balances-args.d.mts +2 -2
  7. package/dist/swap-vm/instructions/balances/balances-args.d.ts +2 -2
  8. package/dist/swap-vm/instructions/base-fee-adjuster/base-fee-adjuster-args.d.mts +2 -2
  9. package/dist/swap-vm/instructions/base-fee-adjuster/base-fee-adjuster-args.d.ts +2 -2
  10. package/dist/swap-vm/instructions/base-fee-adjuster/opcodes.d.mts +3 -1
  11. package/dist/swap-vm/instructions/base-fee-adjuster/opcodes.d.ts +3 -1
  12. package/dist/swap-vm/instructions/concentrate/concentrate-grow-liquidity-2d-args.d.mts +2 -2
  13. package/dist/swap-vm/instructions/concentrate/concentrate-grow-liquidity-2d-args.d.ts +2 -2
  14. package/dist/swap-vm/instructions/concentrate/concentrate-liquidity-calculator/concentrate-liquidity-calculator.d.mts +61 -0
  15. package/dist/swap-vm/instructions/concentrate/concentrate-liquidity-calculator/concentrate-liquidity-calculator.d.ts +61 -0
  16. package/dist/swap-vm/instructions/concentrate/concentrate-liquidity-calculator/types.d.mts +5 -0
  17. package/dist/swap-vm/instructions/concentrate/concentrate-liquidity-calculator/types.d.ts +5 -0
  18. package/dist/swap-vm/instructions/concentrate/index.d.mts +2 -1
  19. package/dist/swap-vm/instructions/concentrate/index.d.ts +2 -1
  20. package/dist/swap-vm/instructions/concentrate/opcodes.d.mts +3 -1
  21. package/dist/swap-vm/instructions/concentrate/opcodes.d.ts +3 -1
  22. package/dist/swap-vm/instructions/controls/deadline-args.d.mts +2 -2
  23. package/dist/swap-vm/instructions/controls/deadline-args.d.ts +2 -2
  24. package/dist/swap-vm/instructions/controls/jump-args.d.mts +2 -2
  25. package/dist/swap-vm/instructions/controls/jump-args.d.ts +2 -2
  26. package/dist/swap-vm/instructions/controls/jump-if-token-args.d.mts +2 -2
  27. package/dist/swap-vm/instructions/controls/jump-if-token-args.d.ts +2 -2
  28. package/dist/swap-vm/instructions/controls/only-taker-token-balance-gte-args.d.mts +2 -2
  29. package/dist/swap-vm/instructions/controls/only-taker-token-balance-gte-args.d.ts +2 -2
  30. package/dist/swap-vm/instructions/controls/only-taker-token-balance-non-zero-args.d.mts +2 -2
  31. package/dist/swap-vm/instructions/controls/only-taker-token-balance-non-zero-args.d.ts +2 -2
  32. package/dist/swap-vm/instructions/controls/salt-args.d.mts +2 -2
  33. package/dist/swap-vm/instructions/controls/salt-args.d.ts +2 -2
  34. package/dist/swap-vm/instructions/debug/debug-empty-args.d.mts +1 -6
  35. package/dist/swap-vm/instructions/debug/debug-empty-args.d.ts +1 -6
  36. package/dist/swap-vm/instructions/debug/opcodes.d.mts +8 -7
  37. package/dist/swap-vm/instructions/debug/opcodes.d.ts +8 -7
  38. package/dist/swap-vm/instructions/debug/print-amount-for-swap.d.mts +1 -6
  39. package/dist/swap-vm/instructions/debug/print-amount-for-swap.d.ts +1 -6
  40. package/dist/swap-vm/instructions/debug/print-context.d.mts +1 -6
  41. package/dist/swap-vm/instructions/debug/print-context.d.ts +1 -6
  42. package/dist/swap-vm/instructions/debug/print-free-memory-pointer.d.mts +1 -6
  43. package/dist/swap-vm/instructions/debug/print-free-memory-pointer.d.ts +1 -6
  44. package/dist/swap-vm/instructions/debug/print-gas-left.d.mts +1 -6
  45. package/dist/swap-vm/instructions/debug/print-gas-left.d.ts +1 -6
  46. package/dist/swap-vm/instructions/debug/print-swap-query.d.mts +1 -6
  47. package/dist/swap-vm/instructions/debug/print-swap-query.d.ts +1 -6
  48. package/dist/swap-vm/instructions/debug/print-swap-registers.d.mts +1 -6
  49. package/dist/swap-vm/instructions/debug/print-swap-registers.d.ts +1 -6
  50. package/dist/swap-vm/instructions/decay/decay-xd-args.d.mts +2 -2
  51. package/dist/swap-vm/instructions/decay/decay-xd-args.d.ts +2 -2
  52. package/dist/swap-vm/instructions/decay/opcodes.d.mts +3 -1
  53. package/dist/swap-vm/instructions/decay/opcodes.d.ts +3 -1
  54. package/dist/swap-vm/instructions/dutch-auction/dutch-auction-args.d.mts +2 -2
  55. package/dist/swap-vm/instructions/dutch-auction/dutch-auction-args.d.ts +2 -2
  56. package/dist/swap-vm/instructions/dutch-auction/opcodes.d.mts +4 -2
  57. package/dist/swap-vm/instructions/dutch-auction/opcodes.d.ts +4 -2
  58. package/dist/swap-vm/instructions/extruction/extruction-args.d.mts +2 -2
  59. package/dist/swap-vm/instructions/extruction/extruction-args.d.ts +2 -2
  60. package/dist/swap-vm/instructions/extruction/opcodes.d.mts +3 -1
  61. package/dist/swap-vm/instructions/extruction/opcodes.d.ts +3 -1
  62. package/dist/swap-vm/instructions/fee/dynamic-protocol-fee/dynamic-protocol-fee-args.d.mts +2 -2
  63. package/dist/swap-vm/instructions/fee/dynamic-protocol-fee/dynamic-protocol-fee-args.d.ts +2 -2
  64. package/dist/swap-vm/instructions/fee/flat-fee/flat-fee-args.d.mts +2 -2
  65. package/dist/swap-vm/instructions/fee/flat-fee/flat-fee-args.d.ts +2 -2
  66. package/dist/swap-vm/instructions/fee/opcodes.d.mts +14 -10
  67. package/dist/swap-vm/instructions/fee/opcodes.d.ts +14 -10
  68. package/dist/swap-vm/instructions/fee/protocol-fee/protocol-fee-args.d.mts +2 -2
  69. package/dist/swap-vm/instructions/fee/protocol-fee/protocol-fee-args.d.ts +2 -2
  70. package/dist/swap-vm/instructions/invalidators/invalidate-bit-1d-args.d.mts +2 -2
  71. package/dist/swap-vm/instructions/invalidators/invalidate-bit-1d-args.d.ts +2 -2
  72. package/dist/swap-vm/instructions/invalidators/invalidate-token-in-1d-args.d.mts +2 -2
  73. package/dist/swap-vm/instructions/invalidators/invalidate-token-in-1d-args.d.ts +2 -2
  74. package/dist/swap-vm/instructions/invalidators/invalidate-token-out-1d-args.d.mts +2 -2
  75. package/dist/swap-vm/instructions/invalidators/invalidate-token-out-1d-args.d.ts +2 -2
  76. package/dist/swap-vm/instructions/invalidators/opcodes.d.mts +7 -3
  77. package/dist/swap-vm/instructions/invalidators/opcodes.d.ts +7 -3
  78. package/dist/swap-vm/instructions/limit-swap/limit-swap-direction-args.d.mts +2 -2
  79. package/dist/swap-vm/instructions/limit-swap/limit-swap-direction-args.d.ts +2 -2
  80. package/dist/swap-vm/instructions/limit-swap/opcodes.d.mts +4 -2
  81. package/dist/swap-vm/instructions/limit-swap/opcodes.d.ts +4 -2
  82. package/dist/swap-vm/instructions/min-rate/min-rate-args.d.mts +2 -2
  83. package/dist/swap-vm/instructions/min-rate/min-rate-args.d.ts +2 -2
  84. package/dist/swap-vm/instructions/min-rate/opcodes.d.mts +4 -2
  85. package/dist/swap-vm/instructions/min-rate/opcodes.d.ts +4 -2
  86. package/dist/swap-vm/instructions/oracle-price-adjuster/opcodes.d.mts +3 -1
  87. package/dist/swap-vm/instructions/oracle-price-adjuster/opcodes.d.ts +3 -1
  88. package/dist/swap-vm/instructions/oracle-price-adjuster/oracle-price-adjuster-args.d.mts +2 -2
  89. package/dist/swap-vm/instructions/oracle-price-adjuster/oracle-price-adjuster-args.d.ts +2 -2
  90. package/dist/swap-vm/instructions/pegged-swap/opcodes.d.mts +3 -1
  91. package/dist/swap-vm/instructions/pegged-swap/opcodes.d.ts +3 -1
  92. package/dist/swap-vm/instructions/pegged-swap/pegged-swap-args.d.mts +2 -2
  93. package/dist/swap-vm/instructions/pegged-swap/pegged-swap-args.d.ts +2 -2
  94. package/dist/swap-vm/instructions/twap-swap/opcodes.d.mts +3 -1
  95. package/dist/swap-vm/instructions/twap-swap/opcodes.d.ts +3 -1
  96. package/dist/swap-vm/instructions/twap-swap/twap-swap-args.d.mts +2 -2
  97. package/dist/swap-vm/instructions/twap-swap/twap-swap-args.d.ts +2 -2
  98. package/dist/swap-vm/instructions/xyc-swap/opcodes.d.mts +3 -1
  99. package/dist/swap-vm/instructions/xyc-swap/opcodes.d.ts +3 -1
  100. package/dist/swap-vm/instructions/xyc-swap/xyc-swap-xd-args.d.mts +2 -2
  101. package/dist/swap-vm/instructions/xyc-swap/xyc-swap-xd-args.d.ts +2 -2
  102. package/dist/swap-vm/maker-traits.d.mts +1 -1
  103. package/dist/swap-vm/maker-traits.d.ts +1 -1
  104. package/package.json +1 -1
package/README.md CHANGED
@@ -523,18 +523,18 @@ The SDK includes pre-configured contract addresses of `AquaSwapVMRouter` for the
523
523
 
524
524
  | Network | Chain ID | Address |
525
525
  |---------|----------|---------|
526
- | Ethereum | 1 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://etherscan.io/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
527
- | BNB Chain | 56 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://bscscan.com/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
528
- | Polygon | 137 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://polygonscan.com/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
529
- | Arbitrum | 42161 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://arbiscan.io/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
530
- | Avalanche | 43114 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](http://snowscan.xyz/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
531
- | Gnosis | 100 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://gnosisscan.io/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
532
- | Coinbase Base | 8453 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://basescan.org/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
533
- | Optimism | 10 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://optimistic.etherscan.io/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
534
- | zkSync Era | 324 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://era.zksync.network/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
535
- | Linea | 59144 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://lineascan.build/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
536
- | Unichain | 1301 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://uniscan.xyz/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
537
- | Sonic | 146 | [0x8fdd04dbf6111437b44bbca99c28882434e0958f](https://sonicscan.org/address/0x8fdd04dbf6111437b44bbca99c28882434e0958f) |
526
+ | Ethereum | 1 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://etherscan.io/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
527
+ | BNB Chain | 56 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://bscscan.com/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
528
+ | Polygon | 137 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://polygonscan.com/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
529
+ | Arbitrum | 42161 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://arbiscan.io/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
530
+ | Avalanche | 43114 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](http://snowscan.xyz/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
531
+ | Gnosis | 100 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://gnosisscan.io/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
532
+ | Coinbase Base | 8453 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://basescan.org/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
533
+ | Optimism | 10 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://optimistic.etherscan.io/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
534
+ | zkSync Era | 324 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://era.zksync.network/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
535
+ | Linea | 59144 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://lineascan.build/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
536
+ | Unichain | 1301 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://uniscan.xyz/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
537
+ | Sonic | 146 | [0xdfd05fe230bfe7b212878414270c72c8345506fa](https://sonicscan.org/address/0xdfd05fe230bfe7b212878414270c72c8345506fa) |
538
538
 
539
539
  Access addresses using:
540
540
 
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './swap-vm-contract';
2
2
  export * from './swap-vm';
3
3
  export * as ABI from './abi';
4
- export { Address, HexString, NetworkEnum, CallInfo } from '@1inch/sdk-core';
4
+ export { Address, HexString, NetworkEnum } from '@1inch/sdk-core';
5
+ export type { CallInfo } from '@1inch/sdk-core';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './swap-vm-contract';
2
2
  export * from './swap-vm';
3
3
  export * as ABI from './abi';
4
- export { Address, HexString, NetworkEnum, CallInfo } from '@1inch/sdk-core';
4
+ export { Address, HexString, NetworkEnum } from '@1inch/sdk-core';
5
+ export type { CallInfo } from '@1inch/sdk-core';
package/dist/index.js CHANGED
@@ -725,18 +725,18 @@ var SwapVMContract = class SwapVMContract {
725
725
  * @see "../swap-vm/programs/aqua-program-builder"
726
726
  */
727
727
  const AQUA_SWAP_VM_CONTRACT_ADDRESSES = {
728
- [__1inch_sdk_core.NetworkEnum.ETHEREUM]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
729
- [__1inch_sdk_core.NetworkEnum.BINANCE]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
730
- [__1inch_sdk_core.NetworkEnum.POLYGON]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
731
- [__1inch_sdk_core.NetworkEnum.ARBITRUM]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
732
- [__1inch_sdk_core.NetworkEnum.AVALANCHE]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
733
- [__1inch_sdk_core.NetworkEnum.GNOSIS]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
734
- [__1inch_sdk_core.NetworkEnum.COINBASE]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
735
- [__1inch_sdk_core.NetworkEnum.OPTIMISM]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
736
- [__1inch_sdk_core.NetworkEnum.ZKSYNC]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
737
- [__1inch_sdk_core.NetworkEnum.LINEA]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
738
- [__1inch_sdk_core.NetworkEnum.UNICHAIN]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
739
- [__1inch_sdk_core.NetworkEnum.SONIC]: new __1inch_sdk_core.Address("0x8fdd04dbf6111437b44bbca99c28882434e0958f")
728
+ [__1inch_sdk_core.NetworkEnum.ETHEREUM]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
729
+ [__1inch_sdk_core.NetworkEnum.BINANCE]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
730
+ [__1inch_sdk_core.NetworkEnum.POLYGON]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
731
+ [__1inch_sdk_core.NetworkEnum.ARBITRUM]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
732
+ [__1inch_sdk_core.NetworkEnum.AVALANCHE]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
733
+ [__1inch_sdk_core.NetworkEnum.GNOSIS]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
734
+ [__1inch_sdk_core.NetworkEnum.COINBASE]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
735
+ [__1inch_sdk_core.NetworkEnum.OPTIMISM]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
736
+ [__1inch_sdk_core.NetworkEnum.ZKSYNC]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
737
+ [__1inch_sdk_core.NetworkEnum.LINEA]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
738
+ [__1inch_sdk_core.NetworkEnum.UNICHAIN]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
739
+ [__1inch_sdk_core.NetworkEnum.SONIC]: new __1inch_sdk_core.Address("0xdfd05fe230bfe7b212878414270c72c8345506fa")
740
740
  };
741
741
 
742
742
  //#endregion
@@ -2024,11 +2024,159 @@ function mulDiv(a, b, c) {
2024
2024
  return a * b / c;
2025
2025
  }
2026
2026
 
2027
+ //#endregion
2028
+ //#region src/swap-vm/instructions/concentrate/concentrate-liquidity-calculator/concentrate-liquidity-calculator.ts
2029
+ /**
2030
+ * Calculator for concentrated liquidity: given two tokens and a price range (min, spot, max),
2031
+ * computes sqrt prices and token reserves for "max allocation" (use all available balances)
2032
+ * or "fixed allocation" (fix one token amount and solve for the other).
2033
+ *
2034
+ * Token ordering follows the pool convention: token0 = lower address, token1 = higher address.
2035
+ * Prices are supplied as ScaledPrices with scale 10^(token0Decimals + token1Decimals); they are
2036
+ * converted internally to P = token1/token0 in 1e18 and then to sqrt(P * 1e18) for the math.
2037
+ */
2038
+ var ConcentrateLiquidityCalculator = class ConcentrateLiquidityCalculator {
2039
+ static ONE_E18 = 10n ** 18n;
2040
+ constructor(tokenA, tokenB) {
2041
+ this.tokenA = tokenA;
2042
+ this.tokenB = tokenB;
2043
+ }
2044
+ /**
2045
+ * Token with the smaller address (token0 in pool convention; "Lt" in the math).
2046
+ */
2047
+ get token0() {
2048
+ return this.tokenA.address.lt(this.tokenB.address) ? this.tokenA : this.tokenB;
2049
+ }
2050
+ /**
2051
+ * Token with the larger address (token1 in pool convention; "Gt" in the math).
2052
+ */
2053
+ get token1() {
2054
+ return this.tokenA.address.lt(this.tokenB.address) ? this.tokenB : this.tokenA;
2055
+ }
2056
+ static new(data) {
2057
+ return new ConcentrateLiquidityCalculator(data.tokenA, data.tokenB);
2058
+ }
2059
+ /**
2060
+ * Compute reserves when one token amount is fixed: the position uses exactly
2061
+ * `fixedReserve` of `fixedReserveForToken` and the other token amount is derived
2062
+ * to keep the same liquidity L. Returns sqrt prices and token0/token1
2063
+ * reserves (raw amounts).
2064
+ * Due to integer math (floor division, sqrt), the fixed asset amount in the result
2065
+ * may be less than requested by a few wei.
2066
+ */
2067
+ computeFixedAllocation(scaledPrices, fixedReserveForToken, fixedReserve) {
2068
+ const { minPriceRaw, spotPriceRaw, maxPriceRaw } = this.computeRawPrices(scaledPrices);
2069
+ const sqrtPriceMin = bigintSqrt(minPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2070
+ const sqrtPriceSpot = bigintSqrt(spotPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2071
+ const sqrtPriceMax = bigintSqrt(maxPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2072
+ const isFixedLt = fixedReserveForToken.equal(this.token0.address);
2073
+ const availableLt = isFixedLt ? fixedReserve : __1inch_byte_utils.UINT_256_MAX;
2074
+ const availableGt = isFixedLt ? __1inch_byte_utils.UINT_256_MAX : fixedReserve;
2075
+ const { actualLt, actualGt } = computeLiquidityFromAmounts(availableLt, availableGt, sqrtPriceSpot, sqrtPriceMin, sqrtPriceMax);
2076
+ return {
2077
+ sqrtPriceMin,
2078
+ sqrtPriceSpot,
2079
+ sqrtPriceMax,
2080
+ token0Reserve: actualLt,
2081
+ token1Reserve: actualGt
2082
+ };
2083
+ }
2084
+ /**
2085
+ * Compute reserves when both token amounts are taken from token info: uses
2086
+ * token0.maxAvailableLiquidity and token1.maxAvailableLiquidity to maximize
2087
+ * L. Returns sqrt prices and the token0/token1 reserves that achieve
2088
+ * that maximum.
2089
+ */
2090
+ computeMaxAllocation(scaledPrices) {
2091
+ const { minPriceRaw, spotPriceRaw, maxPriceRaw } = this.computeRawPrices(scaledPrices);
2092
+ const sqrtPriceMin = bigintSqrt(minPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2093
+ const sqrtPriceSpot = bigintSqrt(spotPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2094
+ const sqrtPriceMax = bigintSqrt(maxPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2095
+ const { actualLt, actualGt } = computeLiquidityFromAmounts(this.token0.maxAvailableLiquidity, this.token1.maxAvailableLiquidity, sqrtPriceSpot, sqrtPriceMin, sqrtPriceMax);
2096
+ return {
2097
+ sqrtPriceMin,
2098
+ sqrtPriceSpot,
2099
+ sqrtPriceMax,
2100
+ token0Reserve: actualLt,
2101
+ token1Reserve: actualGt
2102
+ };
2103
+ }
2104
+ /**
2105
+ * Implied spot sqrt price from token0/token1 balances and a scaled price range
2106
+ * (same convention as {@link computeMaxAllocation}). Inverse of the allocation math; wraps
2107
+ * {@link computeLiquidityAndPrice} from concentrate-liquidity-math.
2108
+ *
2109
+ * @returns sqrt(P_spot) in 1e18 fixed-point (same as {@link ConcentratedLiquidityInfo.sqrtPriceSpot}).
2110
+ */
2111
+ computeSpotPrice(token0Balance, token1Balance, scaledPriceBounds) {
2112
+ const { sqrtPriceMin, sqrtPriceMax } = this.computeSqrtPriceBounds(scaledPriceBounds);
2113
+ const { sqrtPriceSpot } = computeLiquidityAndPrice(token0Balance, token1Balance, sqrtPriceMin, sqrtPriceMax);
2114
+ return sqrtPriceSpot;
2115
+ }
2116
+ /**
2117
+ * Convert user-facing ScaledPrices (scale 10^(token0Decimals+token1Decimals)) into internal
2118
+ * raw prices P = token1/token0 (before sqrt), so that sqrt(P * 1e18) can be
2119
+ * passed to the liquidity math. Handles both quote = token0 and quote = token1.
2120
+ */
2121
+ computeRawPrices(scaledPrices) {
2122
+ const { minPriceRaw, maxPriceRaw } = this.computeRawPriceBounds(scaledPrices);
2123
+ const token0 = this.token0;
2124
+ const token1 = this.token1;
2125
+ if (scaledPrices.quoteToken.equal(token0.address)) {
2126
+ const numerator = 10n ** (token1.decimals + token1.decimals) * ConcentrateLiquidityCalculator.ONE_E18;
2127
+ return {
2128
+ minPriceRaw,
2129
+ spotPriceRaw: numerator / scaledPrices.spotPriceRaw,
2130
+ maxPriceRaw
2131
+ };
2132
+ }
2133
+ if (scaledPrices.quoteToken.equal(token1.address)) {
2134
+ const denominator = 10n ** (token0.decimals + token0.decimals);
2135
+ return {
2136
+ minPriceRaw,
2137
+ spotPriceRaw: scaledPrices.spotPriceRaw * ConcentrateLiquidityCalculator.ONE_E18 / denominator,
2138
+ maxPriceRaw
2139
+ };
2140
+ }
2141
+ throw new Error("unknown quote token");
2142
+ }
2143
+ computeSqrtPriceBounds(scaledPriceBounds) {
2144
+ const { minPriceRaw, maxPriceRaw } = this.computeRawPriceBounds(scaledPriceBounds);
2145
+ return {
2146
+ sqrtPriceMin: bigintSqrt(minPriceRaw * ConcentrateLiquidityCalculator.ONE_E18),
2147
+ sqrtPriceMax: bigintSqrt(maxPriceRaw * ConcentrateLiquidityCalculator.ONE_E18)
2148
+ };
2149
+ }
2150
+ /**
2151
+ * Internal P = token1/token0 (1e18) from scaled min/max only (same mapping as {@link computeRawPrices}).
2152
+ */
2153
+ computeRawPriceBounds(scaledPriceBounds) {
2154
+ const token0 = this.token0;
2155
+ const token1 = this.token1;
2156
+ if (scaledPriceBounds.quoteToken.equal(token0.address)) {
2157
+ const numerator = 10n ** (token1.decimals + token1.decimals) * ConcentrateLiquidityCalculator.ONE_E18;
2158
+ return {
2159
+ minPriceRaw: numerator / scaledPriceBounds.maxPriceRaw,
2160
+ maxPriceRaw: numerator / scaledPriceBounds.minPriceRaw
2161
+ };
2162
+ }
2163
+ if (scaledPriceBounds.quoteToken.equal(token1.address)) {
2164
+ const denominator = 10n ** (token0.decimals + token0.decimals);
2165
+ return {
2166
+ minPriceRaw: scaledPriceBounds.minPriceRaw * ConcentrateLiquidityCalculator.ONE_E18 / denominator,
2167
+ maxPriceRaw: scaledPriceBounds.maxPriceRaw * ConcentrateLiquidityCalculator.ONE_E18 / denominator
2168
+ };
2169
+ }
2170
+ throw new Error("unknown quote token");
2171
+ }
2172
+ };
2173
+
2027
2174
  //#endregion
2028
2175
  //#region src/swap-vm/instructions/concentrate/index.ts
2029
2176
  var concentrate_exports = {};
2030
2177
  __export(concentrate_exports, {
2031
2178
  ConcentrateGrowLiquidity2DArgs: () => ConcentrateGrowLiquidity2DArgs,
2179
+ ConcentrateLiquidityCalculator: () => ConcentrateLiquidityCalculator,
2032
2180
  ONE_E18: () => ONE_E18,
2033
2181
  bigintSqrt: () => bigintSqrt,
2034
2182
  computeBalances: () => computeBalances,
@@ -4082,12 +4230,6 @@ exports.AquaAMMStrategy = AquaAMMStrategy;
4082
4230
  exports.AquaPeggedAmmStrategy = AquaPeggedAmmStrategy;
4083
4231
  exports.AquaProgramBuilder = AquaProgramBuilder;
4084
4232
  exports.AquaXYCAmmStrategy = AquaXYCAmmStrategy;
4085
- Object.defineProperty(exports, 'CallInfo', {
4086
- enumerable: true,
4087
- get: function () {
4088
- return __1inch_sdk_core.CallInfo;
4089
- }
4090
- });
4091
4233
  Object.defineProperty(exports, 'HexString', {
4092
4234
  enumerable: true,
4093
4235
  get: function () {
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { decodeAbiParameters, decodeEventLog, encodeAbiParameters, encodeFunctionData, hashTypedData, keccak256 } from "viem";
2
- import { Address, Address as Address$1, AddressHalf, CallInfo, HexString, HexString as HexString$1, Interaction, NetworkEnum, NetworkEnum as NetworkEnum$1 } from "@1inch/sdk-core";
2
+ import { Address, Address as Address$1, AddressHalf, HexString, HexString as HexString$1, Interaction, NetworkEnum, NetworkEnum as NetworkEnum$1 } from "@1inch/sdk-core";
3
3
  import { BN, BitMask, BytesBuilder, BytesIter, UINT_16_MAX, UINT_24_MAX, UINT_256_MAX, UINT_32_MAX, UINT_40_MAX, UINT_64_MAX, UINT_8_MAX, UINT_96_MAX, add0x, trim0x } from "@1inch/byte-utils";
4
4
  import assert from "assert";
5
5
  import { UINT_64_MAX as UINT_64_MAX$1 } from "@1inch/byte-utils/dist/constants";
@@ -706,18 +706,18 @@ var SwapVMContract = class SwapVMContract {
706
706
  * @see "../swap-vm/programs/aqua-program-builder"
707
707
  */
708
708
  const AQUA_SWAP_VM_CONTRACT_ADDRESSES = {
709
- [NetworkEnum$1.ETHEREUM]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
710
- [NetworkEnum$1.BINANCE]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
711
- [NetworkEnum$1.POLYGON]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
712
- [NetworkEnum$1.ARBITRUM]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
713
- [NetworkEnum$1.AVALANCHE]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
714
- [NetworkEnum$1.GNOSIS]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
715
- [NetworkEnum$1.COINBASE]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
716
- [NetworkEnum$1.OPTIMISM]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
717
- [NetworkEnum$1.ZKSYNC]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
718
- [NetworkEnum$1.LINEA]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
719
- [NetworkEnum$1.UNICHAIN]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f"),
720
- [NetworkEnum$1.SONIC]: new Address$1("0x8fdd04dbf6111437b44bbca99c28882434e0958f")
709
+ [NetworkEnum$1.ETHEREUM]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
710
+ [NetworkEnum$1.BINANCE]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
711
+ [NetworkEnum$1.POLYGON]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
712
+ [NetworkEnum$1.ARBITRUM]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
713
+ [NetworkEnum$1.AVALANCHE]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
714
+ [NetworkEnum$1.GNOSIS]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
715
+ [NetworkEnum$1.COINBASE]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
716
+ [NetworkEnum$1.OPTIMISM]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
717
+ [NetworkEnum$1.ZKSYNC]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
718
+ [NetworkEnum$1.LINEA]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
719
+ [NetworkEnum$1.UNICHAIN]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa"),
720
+ [NetworkEnum$1.SONIC]: new Address$1("0xdfd05fe230bfe7b212878414270c72c8345506fa")
721
721
  };
722
722
 
723
723
  //#endregion
@@ -2005,11 +2005,159 @@ function mulDiv(a, b, c) {
2005
2005
  return a * b / c;
2006
2006
  }
2007
2007
 
2008
+ //#endregion
2009
+ //#region src/swap-vm/instructions/concentrate/concentrate-liquidity-calculator/concentrate-liquidity-calculator.ts
2010
+ /**
2011
+ * Calculator for concentrated liquidity: given two tokens and a price range (min, spot, max),
2012
+ * computes sqrt prices and token reserves for "max allocation" (use all available balances)
2013
+ * or "fixed allocation" (fix one token amount and solve for the other).
2014
+ *
2015
+ * Token ordering follows the pool convention: token0 = lower address, token1 = higher address.
2016
+ * Prices are supplied as ScaledPrices with scale 10^(token0Decimals + token1Decimals); they are
2017
+ * converted internally to P = token1/token0 in 1e18 and then to sqrt(P * 1e18) for the math.
2018
+ */
2019
+ var ConcentrateLiquidityCalculator = class ConcentrateLiquidityCalculator {
2020
+ static ONE_E18 = 10n ** 18n;
2021
+ constructor(tokenA, tokenB) {
2022
+ this.tokenA = tokenA;
2023
+ this.tokenB = tokenB;
2024
+ }
2025
+ /**
2026
+ * Token with the smaller address (token0 in pool convention; "Lt" in the math).
2027
+ */
2028
+ get token0() {
2029
+ return this.tokenA.address.lt(this.tokenB.address) ? this.tokenA : this.tokenB;
2030
+ }
2031
+ /**
2032
+ * Token with the larger address (token1 in pool convention; "Gt" in the math).
2033
+ */
2034
+ get token1() {
2035
+ return this.tokenA.address.lt(this.tokenB.address) ? this.tokenB : this.tokenA;
2036
+ }
2037
+ static new(data) {
2038
+ return new ConcentrateLiquidityCalculator(data.tokenA, data.tokenB);
2039
+ }
2040
+ /**
2041
+ * Compute reserves when one token amount is fixed: the position uses exactly
2042
+ * `fixedReserve` of `fixedReserveForToken` and the other token amount is derived
2043
+ * to keep the same liquidity L. Returns sqrt prices and token0/token1
2044
+ * reserves (raw amounts).
2045
+ * Due to integer math (floor division, sqrt), the fixed asset amount in the result
2046
+ * may be less than requested by a few wei.
2047
+ */
2048
+ computeFixedAllocation(scaledPrices, fixedReserveForToken, fixedReserve) {
2049
+ const { minPriceRaw, spotPriceRaw, maxPriceRaw } = this.computeRawPrices(scaledPrices);
2050
+ const sqrtPriceMin = bigintSqrt(minPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2051
+ const sqrtPriceSpot = bigintSqrt(spotPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2052
+ const sqrtPriceMax = bigintSqrt(maxPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2053
+ const isFixedLt = fixedReserveForToken.equal(this.token0.address);
2054
+ const availableLt = isFixedLt ? fixedReserve : UINT_256_MAX;
2055
+ const availableGt = isFixedLt ? UINT_256_MAX : fixedReserve;
2056
+ const { actualLt, actualGt } = computeLiquidityFromAmounts(availableLt, availableGt, sqrtPriceSpot, sqrtPriceMin, sqrtPriceMax);
2057
+ return {
2058
+ sqrtPriceMin,
2059
+ sqrtPriceSpot,
2060
+ sqrtPriceMax,
2061
+ token0Reserve: actualLt,
2062
+ token1Reserve: actualGt
2063
+ };
2064
+ }
2065
+ /**
2066
+ * Compute reserves when both token amounts are taken from token info: uses
2067
+ * token0.maxAvailableLiquidity and token1.maxAvailableLiquidity to maximize
2068
+ * L. Returns sqrt prices and the token0/token1 reserves that achieve
2069
+ * that maximum.
2070
+ */
2071
+ computeMaxAllocation(scaledPrices) {
2072
+ const { minPriceRaw, spotPriceRaw, maxPriceRaw } = this.computeRawPrices(scaledPrices);
2073
+ const sqrtPriceMin = bigintSqrt(minPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2074
+ const sqrtPriceSpot = bigintSqrt(spotPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2075
+ const sqrtPriceMax = bigintSqrt(maxPriceRaw * ConcentrateLiquidityCalculator.ONE_E18);
2076
+ const { actualLt, actualGt } = computeLiquidityFromAmounts(this.token0.maxAvailableLiquidity, this.token1.maxAvailableLiquidity, sqrtPriceSpot, sqrtPriceMin, sqrtPriceMax);
2077
+ return {
2078
+ sqrtPriceMin,
2079
+ sqrtPriceSpot,
2080
+ sqrtPriceMax,
2081
+ token0Reserve: actualLt,
2082
+ token1Reserve: actualGt
2083
+ };
2084
+ }
2085
+ /**
2086
+ * Implied spot sqrt price from token0/token1 balances and a scaled price range
2087
+ * (same convention as {@link computeMaxAllocation}). Inverse of the allocation math; wraps
2088
+ * {@link computeLiquidityAndPrice} from concentrate-liquidity-math.
2089
+ *
2090
+ * @returns sqrt(P_spot) in 1e18 fixed-point (same as {@link ConcentratedLiquidityInfo.sqrtPriceSpot}).
2091
+ */
2092
+ computeSpotPrice(token0Balance, token1Balance, scaledPriceBounds) {
2093
+ const { sqrtPriceMin, sqrtPriceMax } = this.computeSqrtPriceBounds(scaledPriceBounds);
2094
+ const { sqrtPriceSpot } = computeLiquidityAndPrice(token0Balance, token1Balance, sqrtPriceMin, sqrtPriceMax);
2095
+ return sqrtPriceSpot;
2096
+ }
2097
+ /**
2098
+ * Convert user-facing ScaledPrices (scale 10^(token0Decimals+token1Decimals)) into internal
2099
+ * raw prices P = token1/token0 (before sqrt), so that sqrt(P * 1e18) can be
2100
+ * passed to the liquidity math. Handles both quote = token0 and quote = token1.
2101
+ */
2102
+ computeRawPrices(scaledPrices) {
2103
+ const { minPriceRaw, maxPriceRaw } = this.computeRawPriceBounds(scaledPrices);
2104
+ const token0 = this.token0;
2105
+ const token1 = this.token1;
2106
+ if (scaledPrices.quoteToken.equal(token0.address)) {
2107
+ const numerator = 10n ** (token1.decimals + token1.decimals) * ConcentrateLiquidityCalculator.ONE_E18;
2108
+ return {
2109
+ minPriceRaw,
2110
+ spotPriceRaw: numerator / scaledPrices.spotPriceRaw,
2111
+ maxPriceRaw
2112
+ };
2113
+ }
2114
+ if (scaledPrices.quoteToken.equal(token1.address)) {
2115
+ const denominator = 10n ** (token0.decimals + token0.decimals);
2116
+ return {
2117
+ minPriceRaw,
2118
+ spotPriceRaw: scaledPrices.spotPriceRaw * ConcentrateLiquidityCalculator.ONE_E18 / denominator,
2119
+ maxPriceRaw
2120
+ };
2121
+ }
2122
+ throw new Error("unknown quote token");
2123
+ }
2124
+ computeSqrtPriceBounds(scaledPriceBounds) {
2125
+ const { minPriceRaw, maxPriceRaw } = this.computeRawPriceBounds(scaledPriceBounds);
2126
+ return {
2127
+ sqrtPriceMin: bigintSqrt(minPriceRaw * ConcentrateLiquidityCalculator.ONE_E18),
2128
+ sqrtPriceMax: bigintSqrt(maxPriceRaw * ConcentrateLiquidityCalculator.ONE_E18)
2129
+ };
2130
+ }
2131
+ /**
2132
+ * Internal P = token1/token0 (1e18) from scaled min/max only (same mapping as {@link computeRawPrices}).
2133
+ */
2134
+ computeRawPriceBounds(scaledPriceBounds) {
2135
+ const token0 = this.token0;
2136
+ const token1 = this.token1;
2137
+ if (scaledPriceBounds.quoteToken.equal(token0.address)) {
2138
+ const numerator = 10n ** (token1.decimals + token1.decimals) * ConcentrateLiquidityCalculator.ONE_E18;
2139
+ return {
2140
+ minPriceRaw: numerator / scaledPriceBounds.maxPriceRaw,
2141
+ maxPriceRaw: numerator / scaledPriceBounds.minPriceRaw
2142
+ };
2143
+ }
2144
+ if (scaledPriceBounds.quoteToken.equal(token1.address)) {
2145
+ const denominator = 10n ** (token0.decimals + token0.decimals);
2146
+ return {
2147
+ minPriceRaw: scaledPriceBounds.minPriceRaw * ConcentrateLiquidityCalculator.ONE_E18 / denominator,
2148
+ maxPriceRaw: scaledPriceBounds.maxPriceRaw * ConcentrateLiquidityCalculator.ONE_E18 / denominator
2149
+ };
2150
+ }
2151
+ throw new Error("unknown quote token");
2152
+ }
2153
+ };
2154
+
2008
2155
  //#endregion
2009
2156
  //#region src/swap-vm/instructions/concentrate/index.ts
2010
2157
  var concentrate_exports = {};
2011
2158
  __export(concentrate_exports, {
2012
2159
  ConcentrateGrowLiquidity2DArgs: () => ConcentrateGrowLiquidity2DArgs,
2160
+ ConcentrateLiquidityCalculator: () => ConcentrateLiquidityCalculator,
2013
2161
  ONE_E18: () => ONE_E18,
2014
2162
  bigintSqrt: () => bigintSqrt,
2015
2163
  computeBalances: () => computeBalances,
@@ -4046,4 +4194,4 @@ var abi_exports = {};
4046
4194
  __export(abi_exports, { SWAP_VM_ABI: () => SWAP_VM_ABI });
4047
4195
 
4048
4196
  //#endregion
4049
- export { abi_exports as ABI, AQUA_SWAP_VM_CONTRACT_ADDRESSES, Address, AquaAMMStrategy, AquaPeggedAmmStrategy, AquaProgramBuilder, AquaXYCAmmStrategy, CallInfo, HexString, MakerTraits, NetworkEnum, Order, ProgramBuilder, RegularProgramBuilder, SwapVMContract, SwapVmProgram, SwappedEvent, TakerTraits, instructions_exports as instructions };
4197
+ export { abi_exports as ABI, AQUA_SWAP_VM_CONTRACT_ADDRESSES, Address, AquaAMMStrategy, AquaPeggedAmmStrategy, AquaProgramBuilder, AquaXYCAmmStrategy, HexString, MakerTraits, NetworkEnum, Order, ProgramBuilder, RegularProgramBuilder, SwapVMContract, SwapVmProgram, SwappedEvent, TakerTraits, instructions_exports as instructions };
@@ -1,13 +1,13 @@
1
1
  import type { HexString } from '@1inch/sdk-core';
2
2
  import type { TokenBalance } from './types';
3
- import type { IArgsData } from '../types';
3
+ import type { IArgsCoder, IArgsData } from '../types';
4
4
  /**
5
5
  * Arguments for setBalances and balances instructions containing token-amount pairs
6
6
  * @see https://github.com/1inch/swap-vm/blob/main/src/instructions/Balances.sol#L10
7
7
  **/
8
8
  export declare class BalancesArgs implements IArgsData {
9
9
  readonly tokenBalances: TokenBalance[];
10
- static readonly CODER: any;
10
+ static readonly CODER: IArgsCoder<BalancesArgs>;
11
11
  constructor(tokenBalances: TokenBalance[]);
12
12
  /**
13
13
  * Decodes hex data into BalancesArgs instance
@@ -1,13 +1,13 @@
1
1
  import type { HexString } from '@1inch/sdk-core';
2
2
  import type { TokenBalance } from './types';
3
- import type { IArgsData } from '../types';
3
+ import type { IArgsCoder, IArgsData } from '../types';
4
4
  /**
5
5
  * Arguments for setBalances and balances instructions containing token-amount pairs
6
6
  * @see https://github.com/1inch/swap-vm/blob/main/src/instructions/Balances.sol#L10
7
7
  **/
8
8
  export declare class BalancesArgs implements IArgsData {
9
9
  readonly tokenBalances: TokenBalance[];
10
- static readonly CODER: any;
10
+ static readonly CODER: IArgsCoder<BalancesArgs>;
11
11
  constructor(tokenBalances: TokenBalance[]);
12
12
  /**
13
13
  * Decodes hex data into BalancesArgs instance
@@ -1,5 +1,5 @@
1
1
  import type { HexString } from '@1inch/sdk-core';
2
- import type { IArgsData } from '../types';
2
+ import type { IArgsCoder, IArgsData } from '../types';
3
3
  /**
4
4
  * @notice Base Fee Gas Price Adjuster instruction for dynamic price adjustment based on network gas costs
5
5
  * @dev Adjusts swap prices based on current gas conditions to compensate for transaction costs:
@@ -24,7 +24,7 @@ export declare class BaseFeeAdjusterArgs implements IArgsData {
24
24
  readonly ethToToken1Price: bigint;
25
25
  readonly gasAmount: bigint;
26
26
  readonly maxPriceDecay: bigint;
27
- static readonly CODER: any;
27
+ static readonly CODER: IArgsCoder<BaseFeeAdjusterArgs>;
28
28
  /**
29
29
  * baseGasPrice - base gas price for comparison (uint64)
30
30
  * ethToToken1Price - ETH price in token1 units, e.g.,
@@ -1,5 +1,5 @@
1
1
  import type { HexString } from '@1inch/sdk-core';
2
- import type { IArgsData } from '../types';
2
+ import type { IArgsCoder, IArgsData } from '../types';
3
3
  /**
4
4
  * @notice Base Fee Gas Price Adjuster instruction for dynamic price adjustment based on network gas costs
5
5
  * @dev Adjusts swap prices based on current gas conditions to compensate for transaction costs:
@@ -24,7 +24,7 @@ export declare class BaseFeeAdjusterArgs implements IArgsData {
24
24
  readonly ethToToken1Price: bigint;
25
25
  readonly gasAmount: bigint;
26
26
  readonly maxPriceDecay: bigint;
27
- static readonly CODER: any;
27
+ static readonly CODER: IArgsCoder<BaseFeeAdjusterArgs>;
28
28
  /**
29
29
  * baseGasPrice - base gas price for comparison (uint64)
30
30
  * ethToToken1Price - ETH price in token1 units, e.g.,
@@ -1,5 +1,7 @@
1
+ import { BaseFeeAdjusterArgs } from './base-fee-adjuster-args';
2
+ import { Opcode } from '../opcode';
1
3
  /**
2
4
  * Adjusts swap prices based on network gas costs
3
5
  * @see https://github.com/1inch/swap-vm/blob/main/src/instructions/BaseFeeAdjuster.sol#L75
4
6
  **/
5
- export declare const baseFeeAdjuster1D: any;
7
+ export declare const baseFeeAdjuster1D: Opcode<BaseFeeAdjusterArgs>;
@@ -1,5 +1,7 @@
1
+ import { BaseFeeAdjusterArgs } from './base-fee-adjuster-args';
2
+ import { Opcode } from '../opcode';
1
3
  /**
2
4
  * Adjusts swap prices based on network gas costs
3
5
  * @see https://github.com/1inch/swap-vm/blob/main/src/instructions/BaseFeeAdjuster.sol#L75
4
6
  **/
5
- export declare const baseFeeAdjuster1D: any;
7
+ export declare const baseFeeAdjuster1D: Opcode<BaseFeeAdjusterArgs>;
@@ -1,5 +1,5 @@
1
1
  import type { HexString } from '@1inch/sdk-core';
2
- import type { IArgsData } from '../types';
2
+ import type { IArgsCoder, IArgsData } from '../types';
3
3
  export declare const ONE_E18: bigint;
4
4
  /**
5
5
  * Arguments for concentrateGrowLiquidity2D instruction
@@ -10,7 +10,7 @@ export declare const ONE_E18: bigint;
10
10
  export declare class ConcentrateGrowLiquidity2DArgs implements IArgsData {
11
11
  readonly sqrtPriceMin: bigint;
12
12
  readonly sqrtPriceMax: bigint;
13
- static readonly CODER: any;
13
+ static readonly CODER: IArgsCoder<ConcentrateGrowLiquidity2DArgs>;
14
14
  constructor(sqrtPriceMin: bigint, sqrtPriceMax: bigint);
15
15
  /**
16
16
  * Build args from sqrt prices (1e18 fixed-point).
@@ -1,5 +1,5 @@
1
1
  import type { HexString } from '@1inch/sdk-core';
2
- import type { IArgsData } from '../types';
2
+ import type { IArgsCoder, IArgsData } from '../types';
3
3
  export declare const ONE_E18: bigint;
4
4
  /**
5
5
  * Arguments for concentrateGrowLiquidity2D instruction
@@ -10,7 +10,7 @@ export declare const ONE_E18: bigint;
10
10
  export declare class ConcentrateGrowLiquidity2DArgs implements IArgsData {
11
11
  readonly sqrtPriceMin: bigint;
12
12
  readonly sqrtPriceMax: bigint;
13
- static readonly CODER: any;
13
+ static readonly CODER: IArgsCoder<ConcentrateGrowLiquidity2DArgs>;
14
14
  constructor(sqrtPriceMin: bigint, sqrtPriceMax: bigint);
15
15
  /**
16
16
  * Build args from sqrt prices (1e18 fixed-point).
@@ -0,0 +1,61 @@
1
+ import type { Address } from '@1inch/sdk-core';
2
+ import type { ConcentratedLiquidityInfo, ConcentrateLiquidityCalculatorArgs, ConcentrateTokenInfo, ScaledPriceBounds, ScaledPrices } from './types';
3
+ /**
4
+ * Calculator for concentrated liquidity: given two tokens and a price range (min, spot, max),
5
+ * computes sqrt prices and token reserves for "max allocation" (use all available balances)
6
+ * or "fixed allocation" (fix one token amount and solve for the other).
7
+ *
8
+ * Token ordering follows the pool convention: token0 = lower address, token1 = higher address.
9
+ * Prices are supplied as ScaledPrices with scale 10^(token0Decimals + token1Decimals); they are
10
+ * converted internally to P = token1/token0 in 1e18 and then to sqrt(P * 1e18) for the math.
11
+ */
12
+ export declare class ConcentrateLiquidityCalculator {
13
+ private readonly tokenA;
14
+ private readonly tokenB;
15
+ static readonly ONE_E18: bigint;
16
+ constructor(tokenA: ConcentrateTokenInfo, tokenB: ConcentrateTokenInfo);
17
+ /**
18
+ * Token with the smaller address (token0 in pool convention; "Lt" in the math).
19
+ */
20
+ get token0(): ConcentrateTokenInfo;
21
+ /**
22
+ * Token with the larger address (token1 in pool convention; "Gt" in the math).
23
+ */
24
+ get token1(): ConcentrateTokenInfo;
25
+ static new(data: ConcentrateLiquidityCalculatorArgs): ConcentrateLiquidityCalculator;
26
+ /**
27
+ * Compute reserves when one token amount is fixed: the position uses exactly
28
+ * `fixedReserve` of `fixedReserveForToken` and the other token amount is derived
29
+ * to keep the same liquidity L. Returns sqrt prices and token0/token1
30
+ * reserves (raw amounts).
31
+ * Due to integer math (floor division, sqrt), the fixed asset amount in the result
32
+ * may be less than requested by a few wei.
33
+ */
34
+ computeFixedAllocation(scaledPrices: ScaledPrices, fixedReserveForToken: Address, fixedReserve: bigint): ConcentratedLiquidityInfo;
35
+ /**
36
+ * Compute reserves when both token amounts are taken from token info: uses
37
+ * token0.maxAvailableLiquidity and token1.maxAvailableLiquidity to maximize
38
+ * L. Returns sqrt prices and the token0/token1 reserves that achieve
39
+ * that maximum.
40
+ */
41
+ computeMaxAllocation(scaledPrices: ScaledPrices): ConcentratedLiquidityInfo;
42
+ /**
43
+ * Implied spot sqrt price from token0/token1 balances and a scaled price range
44
+ * (same convention as {@link computeMaxAllocation}). Inverse of the allocation math; wraps
45
+ * {@link computeLiquidityAndPrice} from concentrate-liquidity-math.
46
+ *
47
+ * @returns sqrt(P_spot) in 1e18 fixed-point (same as {@link ConcentratedLiquidityInfo.sqrtPriceSpot}).
48
+ */
49
+ computeSpotPrice(token0Balance: bigint, token1Balance: bigint, scaledPriceBounds: ScaledPriceBounds): bigint;
50
+ /**
51
+ * Convert user-facing ScaledPrices (scale 10^(token0Decimals+token1Decimals)) into internal
52
+ * raw prices P = token1/token0 (before sqrt), so that sqrt(P * 1e18) can be
53
+ * passed to the liquidity math. Handles both quote = token0 and quote = token1.
54
+ */
55
+ private computeRawPrices;
56
+ private computeSqrtPriceBounds;
57
+ /**
58
+ * Internal P = token1/token0 (1e18) from scaled min/max only (same mapping as {@link computeRawPrices}).
59
+ */
60
+ private computeRawPriceBounds;
61
+ }