@apex_labs/sdk 0.1.0 → 0.1.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.
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,18 @@ var ApexSmartRouter = class _ApexSmartRouter {
22595
22629
  });
22596
22630
  }
22597
22631
  };
22632
+ var ApexSmartRouter = SmartRouter;
22598
22633
  function callParameters(_calldatas, _options) {
22599
22634
  for (const payment of _options.payments ?? []) _calldatas.push(encodePayment(payment));
22600
22635
  return {
22601
- calldata: ApexSmartRouter.encodeMulticall(_calldatas, _options.deadlineOrPreviousBlockhash),
22636
+ calldata: SmartRouter.encodeMulticall(_calldatas, _options.deadlineOrPreviousBlockhash),
22602
22637
  value: toHexValue2(_options.value ?? 0n)
22603
22638
  };
22604
22639
  }
22605
22640
  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);
22641
+ if (_payment.kind === "REFUND_ETH") return SmartRouter.encodeRefundETH();
22642
+ if (_payment.kind === "UNWRAP_WETH9") return SmartRouter.encodeUnwrapWETH9(_payment.amountMinimum, _payment.recipient);
22643
+ return SmartRouter.encodeSweepToken(_payment.token, _payment.amountMinimum, _payment.recipient);
22609
22644
  }
22610
22645
  function normalizeAddress4(_address) {
22611
22646
  (0, import_tiny_invariant6.default)((0, import_viem5.isAddress)(_address), `invalid address: ${_address}`);
@@ -22630,10 +22665,11 @@ function toHexValue2(_value) {
22630
22665
  var import_viem6 = require("viem");
22631
22666
  var import_tiny_invariant7 = __toESM(require("tiny-invariant"), 1);
22632
22667
  var APEX_VAULT_BPS = 1e4;
22633
- function apexVaultCompoundBucket(_veNFT) {
22668
+ function getApexVaultCompoundBucket(_veNFT) {
22634
22669
  return normalizeAddress5(_veNFT);
22635
22670
  }
22636
- var ApexVaultPosition = class _ApexVaultPosition {
22671
+ var apexVaultCompoundBucket = getApexVaultCompoundBucket;
22672
+ var ApexVault = class _ApexVault {
22637
22673
  constructor() {
22638
22674
  }
22639
22675
  static encodeStake(_tokenId, _config) {
@@ -22646,7 +22682,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22646
22682
  });
22647
22683
  }
22648
22684
  static stakeCallParameters(_tokenId, _config) {
22649
- return { calldata: _ApexVaultPosition.encodeStake(_tokenId, _config), value: "0x0" };
22685
+ return { calldata: _ApexVault.encodeStake(_tokenId, _config), value: "0x0" };
22650
22686
  }
22651
22687
  static encodeSetUserConfig(_tokenId, _config) {
22652
22688
  const formatted = formatVaultConfig(_config);
@@ -22658,7 +22694,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22658
22694
  });
22659
22695
  }
22660
22696
  static setUserConfigCallParameters(_tokenId, _config) {
22661
- return { calldata: _ApexVaultPosition.encodeSetUserConfig(_tokenId, _config), value: "0x0" };
22697
+ return { calldata: _ApexVault.encodeSetUserConfig(_tokenId, _config), value: "0x0" };
22662
22698
  }
22663
22699
  static encodeClaim(_params) {
22664
22700
  (0, import_tiny_invariant7.default)(_params.rewardTokens.length > 0, "empty reward token list");
@@ -22669,7 +22705,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22669
22705
  });
22670
22706
  }
22671
22707
  static claimCallParameters(_params) {
22672
- return { calldata: _ApexVaultPosition.encodeClaim(_params), value: "0x0" };
22708
+ return { calldata: _ApexVault.encodeClaim(_params), value: "0x0" };
22673
22709
  }
22674
22710
  static encodeClaimAndExtendLock(_params) {
22675
22711
  (0, import_tiny_invariant7.default)(_params.rewardTokens.length > 0, "empty reward token list");
@@ -22680,7 +22716,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22680
22716
  });
22681
22717
  }
22682
22718
  static claimAndExtendLockCallParameters(_params) {
22683
- return { calldata: _ApexVaultPosition.encodeClaimAndExtendLock(_params), value: "0x0" };
22719
+ return { calldata: _ApexVault.encodeClaimAndExtendLock(_params), value: "0x0" };
22684
22720
  }
22685
22721
  static encodeUnstake(_params) {
22686
22722
  return (0, import_viem6.encodeFunctionData)({
@@ -22690,7 +22726,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22690
22726
  });
22691
22727
  }
22692
22728
  static unstakeCallParameters(_params) {
22693
- return { calldata: _ApexVaultPosition.encodeUnstake(_params), value: "0x0" };
22729
+ return { calldata: _ApexVault.encodeUnstake(_params), value: "0x0" };
22694
22730
  }
22695
22731
  static encodeExtendLock(_params) {
22696
22732
  return (0, import_viem6.encodeFunctionData)({
@@ -22700,7 +22736,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22700
22736
  });
22701
22737
  }
22702
22738
  static extendLockCallParameters(_params) {
22703
- return { calldata: _ApexVaultPosition.encodeExtendLock(_params), value: "0x0" };
22739
+ return { calldata: _ApexVault.encodeExtendLock(_params), value: "0x0" };
22704
22740
  }
22705
22741
  static encodeIncreaseAmount(_params) {
22706
22742
  return (0, import_viem6.encodeFunctionData)({
@@ -22710,7 +22746,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22710
22746
  });
22711
22747
  }
22712
22748
  static increaseAmountCallParameters(_params) {
22713
- return { calldata: _ApexVaultPosition.encodeIncreaseAmount(_params), value: "0x0" };
22749
+ return { calldata: _ApexVault.encodeIncreaseAmount(_params), value: "0x0" };
22714
22750
  }
22715
22751
  static encodeVeApexTokenApprove(_params) {
22716
22752
  return (0, import_viem6.encodeFunctionData)({
@@ -22734,6 +22770,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
22734
22770
  });
22735
22771
  }
22736
22772
  };
22773
+ var ApexVaultPosition = ApexVault;
22737
22774
  function validateApexVaultUserConfig(_config) {
22738
22775
  formatVaultConfig(_config);
22739
22776
  }
@@ -22806,13 +22843,19 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22806
22843
  ApexClassicFarm,
22807
22844
  ApexFeeAmount,
22808
22845
  ApexSmartRouter,
22846
+ ApexVault,
22809
22847
  ApexVaultPosition,
22848
+ CLFeeAmount,
22849
+ CLMasterChef,
22850
+ CL_TICK_SPACINGS,
22851
+ ClassicChef,
22810
22852
  DEPLOYER_ADDRESSES,
22811
22853
  FACTORY_ADDRESSES,
22812
22854
  FeeAmount,
22813
22855
  FeeCalculator,
22814
22856
  FullMath,
22815
22857
  LiquidityMath,
22858
+ MAX_UINT128,
22816
22859
  MasterChefV3,
22817
22860
  MaxUint128,
22818
22861
  Multicall,
@@ -22827,6 +22870,7 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22827
22870
  PositionMath,
22828
22871
  Route,
22829
22872
  SelfPermit,
22873
+ SmartRouter,
22830
22874
  SqrtPriceMath,
22831
22875
  Staker,
22832
22876
  SwapMath,
@@ -22857,9 +22901,13 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22857
22901
  computeCreate2Address,
22858
22902
  computePoolAddress,
22859
22903
  createApexPool,
22904
+ createCLPool,
22860
22905
  decodeApexMixedRoutePath,
22906
+ decodeMixedRoutePath,
22861
22907
  encodeApexMixedRouteToPancakeQuoteParams,
22862
22908
  encodeApexMixedRouteToPath,
22909
+ encodeMixedRouteToPancakeQuoteParams,
22910
+ encodeMixedRouteToPath,
22863
22911
  encodeRouteToPath,
22864
22912
  encodeSqrtRatioX96,
22865
22913
  feeCenterAbi,
@@ -22869,7 +22917,9 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22869
22917
  getAmountsAtNewPrice,
22870
22918
  getAmountsByLiquidityAndPrice,
22871
22919
  getApexTickSpacing,
22920
+ getApexVaultCompoundBucket,
22872
22921
  getAverageLiquidity,
22922
+ getCLTickSpacing,
22873
22923
  getCurrency0Price,
22874
22924
  getCurrency1Price,
22875
22925
  getDependentAmount,
@@ -22889,8 +22939,10 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22889
22939
  getPriceOfCurrency1,
22890
22940
  hasInvolvedCurrency,
22891
22941
  installApexFeeTiers,
22942
+ installCLFeeTiers,
22892
22943
  interfaceMulticallAbi,
22893
22944
  isApexCLFeeAmount,
22945
+ isCLFeeAmount,
22894
22946
  isMint,
22895
22947
  isPoolTickInRange,
22896
22948
  isSorted,
@@ -22906,12 +22958,15 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22906
22958
  nonfungiblePositionManagerAbi,
22907
22959
  normalizeAddress,
22908
22960
  packApexProtocolFees,
22961
+ packProtocolFees,
22909
22962
  pancakeV3PoolABI,
22910
22963
  parseApexProtocolFeePacked,
22964
+ parseProtocolFeePacked,
22911
22965
  parseProtocolFees,
22912
22966
  peripheryPaymentsWithFeeABI,
22913
22967
  priceToClosestTick,
22914
22968
  quoteApexClassicExactInput,
22969
+ quoteClassicExactInput,
22915
22970
  quoterABI,
22916
22971
  quoterAbi,
22917
22972
  quoterV2ABI,
@@ -22928,6 +22983,7 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
22928
22983
  tickToPrice,
22929
22984
  tickToPriceV2,
22930
22985
  toApexFeeAmount,
22986
+ toCLFeeAmount,
22931
22987
  toHex,
22932
22988
  tradeComparator,
22933
22989
  v3PoolAbi,