@apex_labs/sdk 0.1.0 → 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.
package/dist/index.cjs CHANGED
@@ -46,15 +46,21 @@ __export(index_exports, {
46
46
  APEX_VAULT_BPS: () => APEX_VAULT_BPS,
47
47
  ApexCLFarm: () => ApexCLFarm,
48
48
  ApexClassicFarm: () => ApexClassicFarm,
49
- ApexFeeAmount: () => ApexFeeAmount,
49
+ ApexFeeAmount: () => CLFeeAmount,
50
50
  ApexSmartRouter: () => ApexSmartRouter,
51
+ ApexVault: () => ApexVault,
51
52
  ApexVaultPosition: () => ApexVaultPosition,
53
+ CLFeeAmount: () => CLFeeAmount,
54
+ CLMasterChef: () => CLMasterChef,
55
+ CL_TICK_SPACINGS: () => CL_TICK_SPACINGS,
56
+ ClassicChef: () => ClassicChef,
52
57
  DEPLOYER_ADDRESSES: () => DEPLOYER_ADDRESSES,
53
58
  FACTORY_ADDRESSES: () => FACTORY_ADDRESSES,
54
59
  FeeAmount: () => FeeAmount,
55
60
  FeeCalculator: () => FeeCalculator,
56
61
  FullMath: () => FullMath,
57
62
  LiquidityMath: () => LiquidityMath,
63
+ MAX_UINT128: () => MAX_UINT128,
58
64
  MasterChefV3: () => MasterChefV3,
59
65
  MaxUint128: () => MaxUint128,
60
66
  Multicall: () => Multicall,
@@ -69,6 +75,7 @@ __export(index_exports, {
69
75
  PositionMath: () => PositionMath,
70
76
  Route: () => Route,
71
77
  SelfPermit: () => SelfPermit,
78
+ SmartRouter: () => SmartRouter,
72
79
  SqrtPriceMath: () => SqrtPriceMath,
73
80
  Staker: () => Staker,
74
81
  SwapMath: () => SwapMath,
@@ -99,9 +106,13 @@ __export(index_exports, {
99
106
  computeCreate2Address: () => computeCreate2Address,
100
107
  computePoolAddress: () => computePoolAddress,
101
108
  createApexPool: () => createApexPool,
109
+ createCLPool: () => createCLPool,
102
110
  decodeApexMixedRoutePath: () => decodeApexMixedRoutePath,
111
+ decodeMixedRoutePath: () => decodeMixedRoutePath,
103
112
  encodeApexMixedRouteToPancakeQuoteParams: () => encodeApexMixedRouteToPancakeQuoteParams,
104
113
  encodeApexMixedRouteToPath: () => encodeApexMixedRouteToPath,
114
+ encodeMixedRouteToPancakeQuoteParams: () => encodeMixedRouteToPancakeQuoteParams,
115
+ encodeMixedRouteToPath: () => encodeMixedRouteToPath,
105
116
  encodeRouteToPath: () => encodeRouteToPath,
106
117
  encodeSqrtRatioX96: () => encodeSqrtRatioX96,
107
118
  feeCenterAbi: () => feeCenterAbi,
@@ -111,7 +122,9 @@ __export(index_exports, {
111
122
  getAmountsAtNewPrice: () => getAmountsAtNewPrice,
112
123
  getAmountsByLiquidityAndPrice: () => getAmountsByLiquidityAndPrice,
113
124
  getApexTickSpacing: () => getApexTickSpacing,
125
+ getApexVaultCompoundBucket: () => getApexVaultCompoundBucket,
114
126
  getAverageLiquidity: () => getAverageLiquidity,
127
+ getCLTickSpacing: () => getCLTickSpacing,
115
128
  getCurrency0Price: () => getCurrency0Price,
116
129
  getCurrency1Price: () => getCurrency1Price,
117
130
  getDependentAmount: () => getDependentAmount,
@@ -131,8 +144,10 @@ __export(index_exports, {
131
144
  getPriceOfCurrency1: () => getPriceOfCurrency1,
132
145
  hasInvolvedCurrency: () => hasInvolvedCurrency,
133
146
  installApexFeeTiers: () => installApexFeeTiers,
147
+ installCLFeeTiers: () => installCLFeeTiers,
134
148
  interfaceMulticallAbi: () => interfaceMulticallAbi,
135
149
  isApexCLFeeAmount: () => isApexCLFeeAmount,
150
+ isCLFeeAmount: () => isCLFeeAmount,
136
151
  isMint: () => isMint,
137
152
  isPoolTickInRange: () => isPoolTickInRange,
138
153
  isSorted: () => isSorted,
@@ -148,12 +163,15 @@ __export(index_exports, {
148
163
  nonfungiblePositionManagerAbi: () => nonfungiblePositionManagerAbi,
149
164
  normalizeAddress: () => normalizeAddress,
150
165
  packApexProtocolFees: () => packApexProtocolFees,
166
+ packProtocolFees: () => packProtocolFees,
151
167
  pancakeV3PoolABI: () => pancakeV3PoolABI,
152
168
  parseApexProtocolFeePacked: () => parseApexProtocolFeePacked,
169
+ parseProtocolFeePacked: () => parseProtocolFeePacked,
153
170
  parseProtocolFees: () => parseProtocolFees,
154
171
  peripheryPaymentsWithFeeABI: () => peripheryPaymentsWithFeeABI,
155
172
  priceToClosestTick: () => priceToClosestTick,
156
173
  quoteApexClassicExactInput: () => quoteApexClassicExactInput,
174
+ quoteClassicExactInput: () => quoteClassicExactInput,
157
175
  quoterABI: () => quoterABI,
158
176
  quoterAbi: () => quoterAbi,
159
177
  quoterV2ABI: () => quoterV2ABI,
@@ -170,6 +188,7 @@ __export(index_exports, {
170
188
  tickToPrice: () => tickToPrice,
171
189
  tickToPriceV2: () => tickToPriceV2,
172
190
  toApexFeeAmount: () => toApexFeeAmount,
191
+ toCLFeeAmount: () => toCLFeeAmount,
173
192
  toHex: () => toHex,
174
193
  tradeComparator: () => tradeComparator,
175
194
  v3PoolAbi: () => v3PoolAbi,
@@ -21858,18 +21877,18 @@ var veApexTokenAbi = VeApexToken_default;
21858
21877
  // src/apex.ts
21859
21878
  var import_tiny_invariant2 = __toESM(require("tiny-invariant"), 1);
21860
21879
  var APEX_CL_POOL_INIT_CODE_HASH = "0x729244f9ae271982f4db70bf3f8e3365ebd0885c52025b09324c6c1f79aae32c";
21861
- var ApexFeeAmount = /* @__PURE__ */ ((ApexFeeAmount2) => {
21862
- ApexFeeAmount2[ApexFeeAmount2["FEE_0_01"] = 100] = "FEE_0_01";
21863
- ApexFeeAmount2[ApexFeeAmount2["FEE_0_02"] = 200] = "FEE_0_02";
21864
- ApexFeeAmount2[ApexFeeAmount2["FEE_0_05"] = 500] = "FEE_0_05";
21865
- ApexFeeAmount2[ApexFeeAmount2["FEE_0_10"] = 1e3] = "FEE_0_10";
21866
- ApexFeeAmount2[ApexFeeAmount2["FEE_0_20"] = 2e3] = "FEE_0_20";
21867
- ApexFeeAmount2[ApexFeeAmount2["FEE_0_30"] = 3e3] = "FEE_0_30";
21868
- ApexFeeAmount2[ApexFeeAmount2["FEE_1_00"] = 1e4] = "FEE_1_00";
21869
- ApexFeeAmount2[ApexFeeAmount2["FEE_2_00"] = 2e4] = "FEE_2_00";
21870
- return ApexFeeAmount2;
21871
- })(ApexFeeAmount || {});
21872
- var APEX_CL_TICK_SPACINGS = {
21880
+ var CLFeeAmount = /* @__PURE__ */ ((CLFeeAmount2) => {
21881
+ CLFeeAmount2[CLFeeAmount2["FEE_0_01"] = 100] = "FEE_0_01";
21882
+ CLFeeAmount2[CLFeeAmount2["FEE_0_02"] = 200] = "FEE_0_02";
21883
+ CLFeeAmount2[CLFeeAmount2["FEE_0_05"] = 500] = "FEE_0_05";
21884
+ CLFeeAmount2[CLFeeAmount2["FEE_0_10"] = 1e3] = "FEE_0_10";
21885
+ CLFeeAmount2[CLFeeAmount2["FEE_0_20"] = 2e3] = "FEE_0_20";
21886
+ CLFeeAmount2[CLFeeAmount2["FEE_0_30"] = 3e3] = "FEE_0_30";
21887
+ CLFeeAmount2[CLFeeAmount2["FEE_1_00"] = 1e4] = "FEE_1_00";
21888
+ CLFeeAmount2[CLFeeAmount2["FEE_2_00"] = 2e4] = "FEE_2_00";
21889
+ return CLFeeAmount2;
21890
+ })(CLFeeAmount || {});
21891
+ var CL_TICK_SPACINGS = {
21873
21892
  [100 /* FEE_0_01 */]: 1,
21874
21893
  [200 /* FEE_0_02 */]: 4,
21875
21894
  [500 /* FEE_0_05 */]: 10,
@@ -21880,25 +21899,25 @@ var APEX_CL_TICK_SPACINGS = {
21880
21899
  [2e4 /* FEE_2_00 */]: 400
21881
21900
  };
21882
21901
  var APEX_CL_PROTOCOL_FEE_DENOMINATOR = 10000n;
21883
- function installApexFeeTiers() {
21884
- Object.assign(TICK_SPACINGS, APEX_CL_TICK_SPACINGS);
21902
+ function installCLFeeTiers() {
21903
+ Object.assign(TICK_SPACINGS, CL_TICK_SPACINGS);
21885
21904
  }
21886
- installApexFeeTiers();
21887
- function isApexCLFeeAmount(_fee) {
21888
- return Object.prototype.hasOwnProperty.call(APEX_CL_TICK_SPACINGS, _fee);
21905
+ installCLFeeTiers();
21906
+ function isCLFeeAmount(_fee) {
21907
+ return Object.prototype.hasOwnProperty.call(CL_TICK_SPACINGS, _fee);
21889
21908
  }
21890
- function toApexFeeAmount(_fee) {
21891
- (0, import_tiny_invariant2.default)(isApexCLFeeAmount(_fee), `unsupported Apex CL fee tier: ${_fee}`);
21909
+ function toCLFeeAmount(_fee) {
21910
+ (0, import_tiny_invariant2.default)(isCLFeeAmount(_fee), `unsupported CL fee tier: ${_fee}`);
21892
21911
  return _fee;
21893
21912
  }
21894
21913
  function asPancakeFeeAmount(_fee) {
21895
- return toApexFeeAmount(_fee);
21914
+ return toCLFeeAmount(_fee);
21896
21915
  }
21897
- function getApexTickSpacing(_fee) {
21898
- return APEX_CL_TICK_SPACINGS[toApexFeeAmount(_fee)];
21916
+ function getCLTickSpacing(_fee) {
21917
+ return CL_TICK_SPACINGS[toCLFeeAmount(_fee)];
21899
21918
  }
21900
- function createApexPool(_params) {
21901
- installApexFeeTiers();
21919
+ function createCLPool(_params) {
21920
+ installCLFeeTiers();
21902
21921
  return new Pool(
21903
21922
  _params.tokenA,
21904
21923
  _params.tokenB,
@@ -21918,13 +21937,19 @@ function computeCLPoolAddress(_params) {
21918
21937
  initCodeHashManualOverride: _params.config.clInitCodeHash ?? APEX_CL_POOL_INIT_CODE_HASH
21919
21938
  });
21920
21939
  }
21940
+ var APEX_CL_TICK_SPACINGS = CL_TICK_SPACINGS;
21941
+ var installApexFeeTiers = installCLFeeTiers;
21942
+ var isApexCLFeeAmount = isCLFeeAmount;
21943
+ var toApexFeeAmount = toCLFeeAmount;
21944
+ var getApexTickSpacing = getCLTickSpacing;
21945
+ var createApexPool = createCLPool;
21921
21946
  var computeApexCLPoolAddress = computeCLPoolAddress;
21922
21947
 
21923
21948
  // src/classic.ts
21924
21949
  var import_tiny_invariant3 = __toESM(require("tiny-invariant"), 1);
21925
21950
  var import_viem2 = require("viem");
21926
21951
  var APEX_CLASSIC_FEE_DENOMINATOR = 1000000n;
21927
- var APEX_CLASSIC_PAIR_INIT_CODE_HASH = "0x52603620cbb6c480ae58578ba02db722991cff92ab57c1aba88ef7c789ed4f67";
21952
+ var APEX_CLASSIC_PAIR_INIT_CODE_HASH = "0xf6b4be77658ce9f596d71610cf47612241d96a56c091415efa2ec2cdbc7c719c";
21928
21953
  function normalizeAddress(_address) {
21929
21954
  (0, import_tiny_invariant3.default)((0, import_viem2.isAddress)(_address), `invalid address: ${_address}`);
21930
21955
  return (0, import_viem2.getAddress)(_address);
@@ -21950,7 +21975,7 @@ function computeClassicPoolAddress(_params) {
21950
21975
  );
21951
21976
  }
21952
21977
  var computeApexClassicPairAddress = computeClassicPoolAddress;
21953
- function quoteApexClassicExactInput(_params) {
21978
+ function quoteClassicExactInput(_params) {
21954
21979
  const tokenIn = normalizeAddress(_params.tokenIn);
21955
21980
  const token0 = normalizeAddress(_params.token0);
21956
21981
  const token1 = normalizeAddress(_params.token1);
@@ -21977,6 +22002,7 @@ function quoteApexClassicExactInput(_params) {
21977
22002
  (0, import_tiny_invariant3.default)(amountOut > 0n, "INSUFFICIENT_OUTPUT_AMOUNT");
21978
22003
  return amountOut - 1n;
21979
22004
  }
22005
+ var quoteApexClassicExactInput = quoteClassicExactInput;
21980
22006
  function getVolatileAmountOut(_params) {
21981
22007
  const reserveA = _params.tokenIn === _params.token0 ? _params.reserve0 : _params.reserve1;
21982
22008
  const reserveB = _params.tokenIn === _params.token0 ? _params.reserve1 : _params.reserve0;
@@ -22045,8 +22071,8 @@ function toBigInt(_value) {
22045
22071
  // src/farming.ts
22046
22072
  var import_viem3 = require("viem");
22047
22073
  var import_tiny_invariant4 = __toESM(require("tiny-invariant"), 1);
22048
- var APEX_MAX_UINT128 = (1n << 128n) - 1n;
22049
- var ApexClassicFarm = class _ApexClassicFarm {
22074
+ var MAX_UINT128 = (1n << 128n) - 1n;
22075
+ var ClassicChef = class _ClassicChef {
22050
22076
  constructor() {
22051
22077
  }
22052
22078
  static encodeDeposit(_params) {
@@ -22057,7 +22083,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
22057
22083
  });
22058
22084
  }
22059
22085
  static depositCallParameters(_params) {
22060
- return { calldata: _ApexClassicFarm.encodeDeposit(_params), value: "0x0" };
22086
+ return { calldata: _ClassicChef.encodeDeposit(_params), value: "0x0" };
22061
22087
  }
22062
22088
  static encodeWithdraw(_params) {
22063
22089
  return (0, import_viem3.encodeFunctionData)({
@@ -22067,7 +22093,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
22067
22093
  });
22068
22094
  }
22069
22095
  static withdrawCallParameters(_params) {
22070
- return { calldata: _ApexClassicFarm.encodeWithdraw(_params), value: "0x0" };
22096
+ return { calldata: _ClassicChef.encodeWithdraw(_params), value: "0x0" };
22071
22097
  }
22072
22098
  static encodeHarvest(_params) {
22073
22099
  return (0, import_viem3.encodeFunctionData)({
@@ -22077,7 +22103,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
22077
22103
  });
22078
22104
  }
22079
22105
  static harvestCallParameters(_params) {
22080
- return { calldata: _ApexClassicFarm.encodeHarvest(_params), value: "0x0" };
22106
+ return { calldata: _ClassicChef.encodeHarvest(_params), value: "0x0" };
22081
22107
  }
22082
22108
  static encodeEmergencyWithdraw(_params) {
22083
22109
  return (0, import_viem3.encodeFunctionData)({
@@ -22088,7 +22114,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
22088
22114
  }
22089
22115
  static emergencyWithdrawCallParameters(_params) {
22090
22116
  return {
22091
- calldata: _ApexClassicFarm.encodeEmergencyWithdraw(_params),
22117
+ calldata: _ClassicChef.encodeEmergencyWithdraw(_params),
22092
22118
  value: "0x0"
22093
22119
  };
22094
22120
  }
@@ -22100,7 +22126,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
22100
22126
  });
22101
22127
  }
22102
22128
  };
22103
- var ApexCLFarm = class _ApexCLFarm {
22129
+ var CLMasterChef = class _CLMasterChef {
22104
22130
  constructor() {
22105
22131
  }
22106
22132
  static encodeMintAndStake(_params, _options) {
@@ -22117,12 +22143,12 @@ var ApexCLFarm = class _ApexCLFarm {
22117
22143
  });
22118
22144
  }
22119
22145
  static mintAndStakeCallParameters(_params, _options) {
22120
- const calldata = _ApexCLFarm.encodeMintAndStake(_params, _options);
22146
+ const calldata = _CLMasterChef.encodeMintAndStake(_params, _options);
22121
22147
  const value = toBigInt2(_options.value ?? 0n);
22122
22148
  return {
22123
- calldata: value === 0n ? calldata : _ApexCLFarm.encodeNfpMulticall([
22149
+ calldata: value === 0n ? calldata : _CLMasterChef.encodeNfpMulticall([
22124
22150
  calldata,
22125
- _ApexCLFarm.encodeNfpRefundETH()
22151
+ _CLMasterChef.encodeNfpRefundETH()
22126
22152
  ]),
22127
22153
  value: toHexValue(value)
22128
22154
  };
@@ -22136,8 +22162,8 @@ var ApexCLFarm = class _ApexCLFarm {
22136
22162
  }
22137
22163
  static increaseLiquidityCallParameters(_params, _value = 0n) {
22138
22164
  return {
22139
- calldata: _ApexCLFarm.encodeMulticall([
22140
- _ApexCLFarm.encodeIncreaseLiquidity(_params)
22165
+ calldata: _CLMasterChef.encodeMulticall([
22166
+ _CLMasterChef.encodeIncreaseLiquidity(_params)
22141
22167
  ]),
22142
22168
  value: toHexValue(_value)
22143
22169
  };
@@ -22157,8 +22183,8 @@ var ApexCLFarm = class _ApexCLFarm {
22157
22183
  {
22158
22184
  tokenId: toBigInt2(_params.tokenId),
22159
22185
  recipient: import_viem3.zeroAddress,
22160
- amount0Max: toBigInt2(_params.amount0Max ?? APEX_MAX_UINT128),
22161
- amount1Max: toBigInt2(_params.amount1Max ?? APEX_MAX_UINT128)
22186
+ amount0Max: toBigInt2(_params.amount0Max ?? MAX_UINT128),
22187
+ amount1Max: toBigInt2(_params.amount1Max ?? MAX_UINT128)
22162
22188
  },
22163
22189
  normalizeAddress2(_params.recipient)
22164
22190
  ]
@@ -22166,8 +22192,8 @@ var ApexCLFarm = class _ApexCLFarm {
22166
22192
  }
22167
22193
  static collectCallParameters(_params) {
22168
22194
  return {
22169
- calldata: _ApexCLFarm.encodeMulticall([
22170
- _ApexCLFarm.encodeCollectTo(_params)
22195
+ calldata: _CLMasterChef.encodeMulticall([
22196
+ _CLMasterChef.encodeCollectTo(_params)
22171
22197
  ]),
22172
22198
  value: "0x0"
22173
22199
  };
@@ -22178,9 +22204,9 @@ var ApexCLFarm = class _ApexCLFarm {
22178
22204
  "tokenId mismatch"
22179
22205
  );
22180
22206
  return {
22181
- calldata: _ApexCLFarm.encodeMulticall([
22182
- _ApexCLFarm.encodeDecreaseLiquidity(_decreaseParams),
22183
- _ApexCLFarm.encodeCollectTo(_collectParams)
22207
+ calldata: _CLMasterChef.encodeMulticall([
22208
+ _CLMasterChef.encodeDecreaseLiquidity(_decreaseParams),
22209
+ _CLMasterChef.encodeCollectTo(_collectParams)
22184
22210
  ]),
22185
22211
  value: "0x0"
22186
22212
  };
@@ -22191,14 +22217,14 @@ var ApexCLFarm = class _ApexCLFarm {
22191
22217
  "tokenId mismatch"
22192
22218
  );
22193
22219
  return {
22194
- calldata: _ApexCLFarm.encodeMulticall([
22195
- _ApexCLFarm.encodeHarvest({
22220
+ calldata: _CLMasterChef.encodeMulticall([
22221
+ _CLMasterChef.encodeHarvest({
22196
22222
  tokenId: _decreaseParams.tokenId,
22197
22223
  to: _collectParams.recipient
22198
22224
  }),
22199
- _ApexCLFarm.encodeDecreaseLiquidity(_decreaseParams),
22200
- _ApexCLFarm.encodeCollectTo(_collectParams),
22201
- _ApexCLFarm.encodeBurn({ tokenId: _decreaseParams.tokenId })
22225
+ _CLMasterChef.encodeDecreaseLiquidity(_decreaseParams),
22226
+ _CLMasterChef.encodeCollectTo(_collectParams),
22227
+ _CLMasterChef.encodeBurn({ tokenId: _decreaseParams.tokenId })
22202
22228
  ]),
22203
22229
  value: "0x0"
22204
22230
  };
@@ -22212,7 +22238,7 @@ var ApexCLFarm = class _ApexCLFarm {
22212
22238
  }
22213
22239
  static harvestCallParameters(_params) {
22214
22240
  return {
22215
- calldata: _ApexCLFarm.encodeMulticall([_ApexCLFarm.encodeHarvest(_params)]),
22241
+ calldata: _CLMasterChef.encodeMulticall([_CLMasterChef.encodeHarvest(_params)]),
22216
22242
  value: "0x0"
22217
22243
  };
22218
22244
  }
@@ -22225,8 +22251,8 @@ var ApexCLFarm = class _ApexCLFarm {
22225
22251
  }
22226
22252
  static withdrawCallParameters(_params) {
22227
22253
  return {
22228
- calldata: _ApexCLFarm.encodeMulticall([
22229
- _ApexCLFarm.encodeWithdraw(_params)
22254
+ calldata: _CLMasterChef.encodeMulticall([
22255
+ _CLMasterChef.encodeWithdraw(_params)
22230
22256
  ]),
22231
22257
  value: "0x0"
22232
22258
  };
@@ -22240,7 +22266,7 @@ var ApexCLFarm = class _ApexCLFarm {
22240
22266
  }
22241
22267
  static burnCallParameters(_params) {
22242
22268
  return {
22243
- calldata: _ApexCLFarm.encodeMulticall([_ApexCLFarm.encodeBurn(_params)]),
22269
+ calldata: _CLMasterChef.encodeMulticall([_CLMasterChef.encodeBurn(_params)]),
22244
22270
  value: "0x0"
22245
22271
  };
22246
22272
  }
@@ -22267,6 +22293,9 @@ var ApexCLFarm = class _ApexCLFarm {
22267
22293
  });
22268
22294
  }
22269
22295
  };
22296
+ var APEX_MAX_UINT128 = MAX_UINT128;
22297
+ var ApexClassicFarm = ClassicChef;
22298
+ var ApexCLFarm = CLMasterChef;
22270
22299
  function formatMintParams(_params) {
22271
22300
  return {
22272
22301
  token0: normalizeAddress2(_params.token0),
@@ -22336,7 +22365,7 @@ var APEX_MIXED_ROUTE_CLASSIC_VOLATILE = 8388609;
22336
22365
  var APEX_MIXED_ROUTE_PANCAKE_CLASSIC_PLACEHOLDER = APEX_MIXED_ROUTE_CLASSIC_STABLE;
22337
22366
  var APEX_MIXED_ROUTE_PANCAKE_VOLATILE_FLAG = 1;
22338
22367
  var APEX_MIXED_ROUTE_PANCAKE_STABLE_FLAG = 2;
22339
- function encodeApexMixedRouteToPath(_hops, _exactOutput = false) {
22368
+ function encodeMixedRouteToPath(_hops, _exactOutput = false) {
22340
22369
  (0, import_tiny_invariant5.default)(_hops.length > 0, "empty route");
22341
22370
  assertContinuousRoute(_hops);
22342
22371
  const hops = _exactOutput ? reverseRoute(_hops) : [..._hops];
@@ -22348,7 +22377,7 @@ function encodeApexMixedRouteToPath(_hops, _exactOutput = false) {
22348
22377
  }
22349
22378
  return (0, import_viem4.encodePacked)(types, values);
22350
22379
  }
22351
- function encodeApexMixedRouteToPancakeQuoteParams(_hops, _exactOutput = false) {
22380
+ function encodeMixedRouteToPancakeQuoteParams(_hops, _exactOutput = false) {
22352
22381
  (0, import_tiny_invariant5.default)(_hops.length > 0, "empty route");
22353
22382
  assertContinuousRoute(_hops);
22354
22383
  const hops = _exactOutput ? reverseRoute(_hops) : [..._hops];
@@ -22363,7 +22392,7 @@ function encodeApexMixedRouteToPancakeQuoteParams(_hops, _exactOutput = false) {
22363
22392
  }
22364
22393
  return { path: (0, import_viem4.encodePacked)(types, values), flags };
22365
22394
  }
22366
- function decodeApexMixedRoutePath(_path) {
22395
+ function decodeMixedRoutePath(_path) {
22367
22396
  const hex = _path.startsWith("0x") ? _path.slice(2) : _path;
22368
22397
  (0, import_tiny_invariant5.default)(hex.length >= 86 && (hex.length - 40) % 46 === 0, "invalid path length");
22369
22398
  const hops = [];
@@ -22414,6 +22443,9 @@ function pancakeRouteCode(_hop) {
22414
22443
  }
22415
22444
  return APEX_MIXED_ROUTE_PANCAKE_CLASSIC_PLACEHOLDER;
22416
22445
  }
22446
+ var encodeApexMixedRouteToPath = encodeMixedRouteToPath;
22447
+ var encodeApexMixedRouteToPancakeQuoteParams = encodeMixedRouteToPancakeQuoteParams;
22448
+ var decodeApexMixedRoutePath = decodeMixedRoutePath;
22417
22449
  function normalizeAddress3(_address) {
22418
22450
  (0, import_tiny_invariant5.default)((0, import_viem4.isAddress)(_address), `invalid address: ${_address}`);
22419
22451
  return (0, import_viem4.getAddress)(_address);
@@ -22424,36 +22456,38 @@ function readAddress(_hex, _offset) {
22424
22456
 
22425
22457
  // src/protocolFees.ts
22426
22458
  var APEX_CL_PROTOCOL_FEE_SPACING = 65536n;
22427
- function packApexProtocolFees(_token0ProtocolFee, _token1ProtocolFee) {
22459
+ function packProtocolFees(_token0ProtocolFee, _token1ProtocolFee) {
22428
22460
  return BigInt(_token0ProtocolFee) + BigInt(_token1ProtocolFee) * APEX_CL_PROTOCOL_FEE_SPACING;
22429
22461
  }
22430
- function parseApexProtocolFeePacked(_feeProtocol) {
22462
+ function parseProtocolFeePacked(_feeProtocol) {
22431
22463
  const packed = BigInt(_feeProtocol);
22432
22464
  return {
22433
22465
  token0ProtocolFee: packed % APEX_CL_PROTOCOL_FEE_SPACING,
22434
22466
  token1ProtocolFee: packed / APEX_CL_PROTOCOL_FEE_SPACING
22435
22467
  };
22436
22468
  }
22469
+ var packApexProtocolFees = packProtocolFees;
22470
+ var parseApexProtocolFeePacked = parseProtocolFeePacked;
22437
22471
 
22438
22472
  // src/smartRouter.ts
22439
22473
  var import_tiny_invariant6 = __toESM(require("tiny-invariant"), 1);
22440
22474
  var import_viem5 = require("viem");
22441
- var ApexSmartRouter = class _ApexSmartRouter {
22475
+ var SmartRouter = class _SmartRouter {
22442
22476
  constructor() {
22443
22477
  }
22444
22478
  static swapCallParameters(_calldata, _options) {
22445
22479
  return callParameters(Array.isArray(_calldata) ? [..._calldata] : [_calldata], _options);
22446
22480
  }
22447
22481
  static exactInputSingleCallParameters(_params, _options) {
22448
- return _ApexSmartRouter.swapCallParameters(_ApexSmartRouter.encodeExactInputSingle(_params), _options);
22482
+ return _SmartRouter.swapCallParameters(_SmartRouter.encodeExactInputSingle(_params), _options);
22449
22483
  }
22450
22484
  static exactInputCallParameters(_params, _options) {
22451
- return _ApexSmartRouter.swapCallParameters(_ApexSmartRouter.encodeExactInput(_params), _options);
22485
+ return _SmartRouter.swapCallParameters(_SmartRouter.encodeExactInput(_params), _options);
22452
22486
  }
22453
22487
  static mixedExactInputCallParameters(_params, _options) {
22454
- return _ApexSmartRouter.exactInputCallParameters(
22488
+ return _SmartRouter.exactInputCallParameters(
22455
22489
  {
22456
- path: encodeApexMixedRouteToPath(_params.hops),
22490
+ path: encodeMixedRouteToPath(_params.hops),
22457
22491
  recipient: _params.recipient,
22458
22492
  amountIn: _params.amountIn,
22459
22493
  amountOutMinimum: _params.amountOutMinimum
@@ -22462,16 +22496,16 @@ var ApexSmartRouter = class _ApexSmartRouter {
22462
22496
  );
22463
22497
  }
22464
22498
  static exactOutputSingleCallParameters(_params, _options) {
22465
- return _ApexSmartRouter.swapCallParameters(_ApexSmartRouter.encodeExactOutputSingle(_params), _options);
22499
+ return _SmartRouter.swapCallParameters(_SmartRouter.encodeExactOutputSingle(_params), _options);
22466
22500
  }
22467
22501
  static exactOutputCallParameters(_params, _options) {
22468
- return _ApexSmartRouter.swapCallParameters(_ApexSmartRouter.encodeExactOutput(_params), _options);
22502
+ return _SmartRouter.swapCallParameters(_SmartRouter.encodeExactOutput(_params), _options);
22469
22503
  }
22470
22504
  static classicExactInputCallParameters(_params, _options) {
22471
- return _ApexSmartRouter.swapCallParameters(_ApexSmartRouter.encodeClassicExactInput(_params), _options);
22505
+ return _SmartRouter.swapCallParameters(_SmartRouter.encodeClassicExactInput(_params), _options);
22472
22506
  }
22473
22507
  static stableExactInputCallParameters(_params, _options) {
22474
- return _ApexSmartRouter.swapCallParameters(_ApexSmartRouter.encodeStableExactInput(_params), _options);
22508
+ return _SmartRouter.swapCallParameters(_SmartRouter.encodeStableExactInput(_params), _options);
22475
22509
  }
22476
22510
  static encodeExactInputSingle(_params) {
22477
22511
  return (0, import_viem5.encodeFunctionData)({
@@ -22595,17 +22629,23 @@ var ApexSmartRouter = class _ApexSmartRouter {
22595
22629
  });
22596
22630
  }
22597
22631
  };
22632
+ var ApexSmartRouter = SmartRouter;
22598
22633
  function callParameters(_calldatas, _options) {
22599
- for (const payment of _options.payments ?? []) _calldatas.push(encodePayment(payment));
22634
+ const value = toBigInt3(_options.value ?? 0n);
22635
+ const payments = [..._options.payments ?? []];
22636
+ if (value > 0n && !payments.some((payment) => payment.kind === "REFUND_ETH")) {
22637
+ payments.push({ kind: "REFUND_ETH" });
22638
+ }
22639
+ for (const payment of payments) _calldatas.push(encodePayment(payment));
22600
22640
  return {
22601
- calldata: ApexSmartRouter.encodeMulticall(_calldatas, _options.deadlineOrPreviousBlockhash),
22602
- value: toHexValue2(_options.value ?? 0n)
22641
+ calldata: SmartRouter.encodeMulticall(_calldatas, _options.deadlineOrPreviousBlockhash),
22642
+ value: toHexValue2(value)
22603
22643
  };
22604
22644
  }
22605
22645
  function encodePayment(_payment) {
22606
- if (_payment.kind === "REFUND_ETH") return ApexSmartRouter.encodeRefundETH();
22607
- if (_payment.kind === "UNWRAP_WETH9") return ApexSmartRouter.encodeUnwrapWETH9(_payment.amountMinimum, _payment.recipient);
22608
- return ApexSmartRouter.encodeSweepToken(_payment.token, _payment.amountMinimum, _payment.recipient);
22646
+ if (_payment.kind === "REFUND_ETH") return SmartRouter.encodeRefundETH();
22647
+ if (_payment.kind === "UNWRAP_WETH9") return SmartRouter.encodeUnwrapWETH9(_payment.amountMinimum, _payment.recipient);
22648
+ return SmartRouter.encodeSweepToken(_payment.token, _payment.amountMinimum, _payment.recipient);
22609
22649
  }
22610
22650
  function normalizeAddress4(_address) {
22611
22651
  (0, import_tiny_invariant6.default)((0, import_viem5.isAddress)(_address), `invalid address: ${_address}`);
@@ -22630,10 +22670,11 @@ function toHexValue2(_value) {
22630
22670
  var import_viem6 = require("viem");
22631
22671
  var import_tiny_invariant7 = __toESM(require("tiny-invariant"), 1);
22632
22672
  var APEX_VAULT_BPS = 1e4;
22633
- function apexVaultCompoundBucket(_veNFT) {
22673
+ function getApexVaultCompoundBucket(_veNFT) {
22634
22674
  return normalizeAddress5(_veNFT);
22635
22675
  }
22636
- var ApexVaultPosition = class _ApexVaultPosition {
22676
+ var apexVaultCompoundBucket = getApexVaultCompoundBucket;
22677
+ var ApexVault = class _ApexVault {
22637
22678
  constructor() {
22638
22679
  }
22639
22680
  static encodeStake(_tokenId, _config) {
@@ -22646,7 +22687,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22646
22687
  });
22647
22688
  }
22648
22689
  static stakeCallParameters(_tokenId, _config) {
22649
- return { calldata: _ApexVaultPosition.encodeStake(_tokenId, _config), value: "0x0" };
22690
+ return { calldata: _ApexVault.encodeStake(_tokenId, _config), value: "0x0" };
22650
22691
  }
22651
22692
  static encodeSetUserConfig(_tokenId, _config) {
22652
22693
  const formatted = formatVaultConfig(_config);
@@ -22658,7 +22699,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22658
22699
  });
22659
22700
  }
22660
22701
  static setUserConfigCallParameters(_tokenId, _config) {
22661
- return { calldata: _ApexVaultPosition.encodeSetUserConfig(_tokenId, _config), value: "0x0" };
22702
+ return { calldata: _ApexVault.encodeSetUserConfig(_tokenId, _config), value: "0x0" };
22662
22703
  }
22663
22704
  static encodeClaim(_params) {
22664
22705
  (0, import_tiny_invariant7.default)(_params.rewardTokens.length > 0, "empty reward token list");
@@ -22669,7 +22710,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22669
22710
  });
22670
22711
  }
22671
22712
  static claimCallParameters(_params) {
22672
- return { calldata: _ApexVaultPosition.encodeClaim(_params), value: "0x0" };
22713
+ return { calldata: _ApexVault.encodeClaim(_params), value: "0x0" };
22673
22714
  }
22674
22715
  static encodeClaimAndExtendLock(_params) {
22675
22716
  (0, import_tiny_invariant7.default)(_params.rewardTokens.length > 0, "empty reward token list");
@@ -22680,7 +22721,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22680
22721
  });
22681
22722
  }
22682
22723
  static claimAndExtendLockCallParameters(_params) {
22683
- return { calldata: _ApexVaultPosition.encodeClaimAndExtendLock(_params), value: "0x0" };
22724
+ return { calldata: _ApexVault.encodeClaimAndExtendLock(_params), value: "0x0" };
22684
22725
  }
22685
22726
  static encodeUnstake(_params) {
22686
22727
  return (0, import_viem6.encodeFunctionData)({
@@ -22690,7 +22731,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22690
22731
  });
22691
22732
  }
22692
22733
  static unstakeCallParameters(_params) {
22693
- return { calldata: _ApexVaultPosition.encodeUnstake(_params), value: "0x0" };
22734
+ return { calldata: _ApexVault.encodeUnstake(_params), value: "0x0" };
22694
22735
  }
22695
22736
  static encodeExtendLock(_params) {
22696
22737
  return (0, import_viem6.encodeFunctionData)({
@@ -22700,7 +22741,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22700
22741
  });
22701
22742
  }
22702
22743
  static extendLockCallParameters(_params) {
22703
- return { calldata: _ApexVaultPosition.encodeExtendLock(_params), value: "0x0" };
22744
+ return { calldata: _ApexVault.encodeExtendLock(_params), value: "0x0" };
22704
22745
  }
22705
22746
  static encodeIncreaseAmount(_params) {
22706
22747
  return (0, import_viem6.encodeFunctionData)({
@@ -22710,7 +22751,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22710
22751
  });
22711
22752
  }
22712
22753
  static increaseAmountCallParameters(_params) {
22713
- return { calldata: _ApexVaultPosition.encodeIncreaseAmount(_params), value: "0x0" };
22754
+ return { calldata: _ApexVault.encodeIncreaseAmount(_params), value: "0x0" };
22714
22755
  }
22715
22756
  static encodeVeApexTokenApprove(_params) {
22716
22757
  return (0, import_viem6.encodeFunctionData)({
@@ -22734,6 +22775,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22734
22775
  });
22735
22776
  }
22736
22777
  };
22778
+ var ApexVaultPosition = ApexVault;
22737
22779
  function validateApexVaultUserConfig(_config) {
22738
22780
  formatVaultConfig(_config);
22739
22781
  }
@@ -22806,13 +22848,19 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22806
22848
  ApexClassicFarm,
22807
22849
  ApexFeeAmount,
22808
22850
  ApexSmartRouter,
22851
+ ApexVault,
22809
22852
  ApexVaultPosition,
22853
+ CLFeeAmount,
22854
+ CLMasterChef,
22855
+ CL_TICK_SPACINGS,
22856
+ ClassicChef,
22810
22857
  DEPLOYER_ADDRESSES,
22811
22858
  FACTORY_ADDRESSES,
22812
22859
  FeeAmount,
22813
22860
  FeeCalculator,
22814
22861
  FullMath,
22815
22862
  LiquidityMath,
22863
+ MAX_UINT128,
22816
22864
  MasterChefV3,
22817
22865
  MaxUint128,
22818
22866
  Multicall,
@@ -22827,6 +22875,7 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22827
22875
  PositionMath,
22828
22876
  Route,
22829
22877
  SelfPermit,
22878
+ SmartRouter,
22830
22879
  SqrtPriceMath,
22831
22880
  Staker,
22832
22881
  SwapMath,
@@ -22857,9 +22906,13 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22857
22906
  computeCreate2Address,
22858
22907
  computePoolAddress,
22859
22908
  createApexPool,
22909
+ createCLPool,
22860
22910
  decodeApexMixedRoutePath,
22911
+ decodeMixedRoutePath,
22861
22912
  encodeApexMixedRouteToPancakeQuoteParams,
22862
22913
  encodeApexMixedRouteToPath,
22914
+ encodeMixedRouteToPancakeQuoteParams,
22915
+ encodeMixedRouteToPath,
22863
22916
  encodeRouteToPath,
22864
22917
  encodeSqrtRatioX96,
22865
22918
  feeCenterAbi,
@@ -22869,7 +22922,9 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22869
22922
  getAmountsAtNewPrice,
22870
22923
  getAmountsByLiquidityAndPrice,
22871
22924
  getApexTickSpacing,
22925
+ getApexVaultCompoundBucket,
22872
22926
  getAverageLiquidity,
22927
+ getCLTickSpacing,
22873
22928
  getCurrency0Price,
22874
22929
  getCurrency1Price,
22875
22930
  getDependentAmount,
@@ -22889,8 +22944,10 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22889
22944
  getPriceOfCurrency1,
22890
22945
  hasInvolvedCurrency,
22891
22946
  installApexFeeTiers,
22947
+ installCLFeeTiers,
22892
22948
  interfaceMulticallAbi,
22893
22949
  isApexCLFeeAmount,
22950
+ isCLFeeAmount,
22894
22951
  isMint,
22895
22952
  isPoolTickInRange,
22896
22953
  isSorted,
@@ -22906,12 +22963,15 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22906
22963
  nonfungiblePositionManagerAbi,
22907
22964
  normalizeAddress,
22908
22965
  packApexProtocolFees,
22966
+ packProtocolFees,
22909
22967
  pancakeV3PoolABI,
22910
22968
  parseApexProtocolFeePacked,
22969
+ parseProtocolFeePacked,
22911
22970
  parseProtocolFees,
22912
22971
  peripheryPaymentsWithFeeABI,
22913
22972
  priceToClosestTick,
22914
22973
  quoteApexClassicExactInput,
22974
+ quoteClassicExactInput,
22915
22975
  quoterABI,
22916
22976
  quoterAbi,
22917
22977
  quoterV2ABI,
@@ -22928,6 +22988,7 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22928
22988
  tickToPrice,
22929
22989
  tickToPriceV2,
22930
22990
  toApexFeeAmount,
22991
+ toCLFeeAmount,
22931
22992
  toHex,
22932
22993
  tradeComparator,
22933
22994
  v3PoolAbi,