@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/README.md +74 -72
- package/dist/index.cjs +145 -84
- package/dist/index.d.cts +240 -194
- package/dist/index.d.ts +240 -194
- package/dist/index.js +126 -84
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21677,18 +21677,18 @@ var veApexTokenAbi = VeApexToken_default;
|
|
|
21677
21677
|
// src/apex.ts
|
|
21678
21678
|
import invariant from "tiny-invariant";
|
|
21679
21679
|
var APEX_CL_POOL_INIT_CODE_HASH = "0x729244f9ae271982f4db70bf3f8e3365ebd0885c52025b09324c6c1f79aae32c";
|
|
21680
|
-
var
|
|
21681
|
-
|
|
21682
|
-
|
|
21683
|
-
|
|
21684
|
-
|
|
21685
|
-
|
|
21686
|
-
|
|
21687
|
-
|
|
21688
|
-
|
|
21689
|
-
return
|
|
21690
|
-
})(
|
|
21691
|
-
var
|
|
21680
|
+
var CLFeeAmount = /* @__PURE__ */ ((CLFeeAmount2) => {
|
|
21681
|
+
CLFeeAmount2[CLFeeAmount2["FEE_0_01"] = 100] = "FEE_0_01";
|
|
21682
|
+
CLFeeAmount2[CLFeeAmount2["FEE_0_02"] = 200] = "FEE_0_02";
|
|
21683
|
+
CLFeeAmount2[CLFeeAmount2["FEE_0_05"] = 500] = "FEE_0_05";
|
|
21684
|
+
CLFeeAmount2[CLFeeAmount2["FEE_0_10"] = 1e3] = "FEE_0_10";
|
|
21685
|
+
CLFeeAmount2[CLFeeAmount2["FEE_0_20"] = 2e3] = "FEE_0_20";
|
|
21686
|
+
CLFeeAmount2[CLFeeAmount2["FEE_0_30"] = 3e3] = "FEE_0_30";
|
|
21687
|
+
CLFeeAmount2[CLFeeAmount2["FEE_1_00"] = 1e4] = "FEE_1_00";
|
|
21688
|
+
CLFeeAmount2[CLFeeAmount2["FEE_2_00"] = 2e4] = "FEE_2_00";
|
|
21689
|
+
return CLFeeAmount2;
|
|
21690
|
+
})(CLFeeAmount || {});
|
|
21691
|
+
var CL_TICK_SPACINGS = {
|
|
21692
21692
|
[100 /* FEE_0_01 */]: 1,
|
|
21693
21693
|
[200 /* FEE_0_02 */]: 4,
|
|
21694
21694
|
[500 /* FEE_0_05 */]: 10,
|
|
@@ -21699,25 +21699,25 @@ var APEX_CL_TICK_SPACINGS = {
|
|
|
21699
21699
|
[2e4 /* FEE_2_00 */]: 400
|
|
21700
21700
|
};
|
|
21701
21701
|
var APEX_CL_PROTOCOL_FEE_DENOMINATOR = 10000n;
|
|
21702
|
-
function
|
|
21703
|
-
Object.assign(TICK_SPACINGS,
|
|
21702
|
+
function installCLFeeTiers() {
|
|
21703
|
+
Object.assign(TICK_SPACINGS, CL_TICK_SPACINGS);
|
|
21704
21704
|
}
|
|
21705
|
-
|
|
21706
|
-
function
|
|
21707
|
-
return Object.prototype.hasOwnProperty.call(
|
|
21705
|
+
installCLFeeTiers();
|
|
21706
|
+
function isCLFeeAmount(_fee) {
|
|
21707
|
+
return Object.prototype.hasOwnProperty.call(CL_TICK_SPACINGS, _fee);
|
|
21708
21708
|
}
|
|
21709
|
-
function
|
|
21710
|
-
invariant(
|
|
21709
|
+
function toCLFeeAmount(_fee) {
|
|
21710
|
+
invariant(isCLFeeAmount(_fee), `unsupported CL fee tier: ${_fee}`);
|
|
21711
21711
|
return _fee;
|
|
21712
21712
|
}
|
|
21713
21713
|
function asPancakeFeeAmount(_fee) {
|
|
21714
|
-
return
|
|
21714
|
+
return toCLFeeAmount(_fee);
|
|
21715
21715
|
}
|
|
21716
|
-
function
|
|
21717
|
-
return
|
|
21716
|
+
function getCLTickSpacing(_fee) {
|
|
21717
|
+
return CL_TICK_SPACINGS[toCLFeeAmount(_fee)];
|
|
21718
21718
|
}
|
|
21719
|
-
function
|
|
21720
|
-
|
|
21719
|
+
function createCLPool(_params) {
|
|
21720
|
+
installCLFeeTiers();
|
|
21721
21721
|
return new Pool(
|
|
21722
21722
|
_params.tokenA,
|
|
21723
21723
|
_params.tokenB,
|
|
@@ -21737,13 +21737,19 @@ function computeCLPoolAddress(_params) {
|
|
|
21737
21737
|
initCodeHashManualOverride: _params.config.clInitCodeHash ?? APEX_CL_POOL_INIT_CODE_HASH
|
|
21738
21738
|
});
|
|
21739
21739
|
}
|
|
21740
|
+
var APEX_CL_TICK_SPACINGS = CL_TICK_SPACINGS;
|
|
21741
|
+
var installApexFeeTiers = installCLFeeTiers;
|
|
21742
|
+
var isApexCLFeeAmount = isCLFeeAmount;
|
|
21743
|
+
var toApexFeeAmount = toCLFeeAmount;
|
|
21744
|
+
var getApexTickSpacing = getCLTickSpacing;
|
|
21745
|
+
var createApexPool = createCLPool;
|
|
21740
21746
|
var computeApexCLPoolAddress = computeCLPoolAddress;
|
|
21741
21747
|
|
|
21742
21748
|
// src/classic.ts
|
|
21743
21749
|
import invariant2 from "tiny-invariant";
|
|
21744
21750
|
import { concatHex, encodePacked as encodePacked2, getAddress as getAddress2, isAddress, keccak256 as keccak2562 } from "viem";
|
|
21745
21751
|
var APEX_CLASSIC_FEE_DENOMINATOR = 1000000n;
|
|
21746
|
-
var APEX_CLASSIC_PAIR_INIT_CODE_HASH = "
|
|
21752
|
+
var APEX_CLASSIC_PAIR_INIT_CODE_HASH = "0xf6b4be77658ce9f596d71610cf47612241d96a56c091415efa2ec2cdbc7c719c";
|
|
21747
21753
|
function normalizeAddress(_address) {
|
|
21748
21754
|
invariant2(isAddress(_address), `invalid address: ${_address}`);
|
|
21749
21755
|
return getAddress2(_address);
|
|
@@ -21769,7 +21775,7 @@ function computeClassicPoolAddress(_params) {
|
|
|
21769
21775
|
);
|
|
21770
21776
|
}
|
|
21771
21777
|
var computeApexClassicPairAddress = computeClassicPoolAddress;
|
|
21772
|
-
function
|
|
21778
|
+
function quoteClassicExactInput(_params) {
|
|
21773
21779
|
const tokenIn = normalizeAddress(_params.tokenIn);
|
|
21774
21780
|
const token0 = normalizeAddress(_params.token0);
|
|
21775
21781
|
const token1 = normalizeAddress(_params.token1);
|
|
@@ -21796,6 +21802,7 @@ function quoteApexClassicExactInput(_params) {
|
|
|
21796
21802
|
invariant2(amountOut > 0n, "INSUFFICIENT_OUTPUT_AMOUNT");
|
|
21797
21803
|
return amountOut - 1n;
|
|
21798
21804
|
}
|
|
21805
|
+
var quoteApexClassicExactInput = quoteClassicExactInput;
|
|
21799
21806
|
function getVolatileAmountOut(_params) {
|
|
21800
21807
|
const reserveA = _params.tokenIn === _params.token0 ? _params.reserve0 : _params.reserve1;
|
|
21801
21808
|
const reserveB = _params.tokenIn === _params.token0 ? _params.reserve1 : _params.reserve0;
|
|
@@ -21869,8 +21876,8 @@ import {
|
|
|
21869
21876
|
zeroAddress
|
|
21870
21877
|
} from "viem";
|
|
21871
21878
|
import invariant3 from "tiny-invariant";
|
|
21872
|
-
var
|
|
21873
|
-
var
|
|
21879
|
+
var MAX_UINT128 = (1n << 128n) - 1n;
|
|
21880
|
+
var ClassicChef = class _ClassicChef {
|
|
21874
21881
|
constructor() {
|
|
21875
21882
|
}
|
|
21876
21883
|
static encodeDeposit(_params) {
|
|
@@ -21881,7 +21888,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
|
|
|
21881
21888
|
});
|
|
21882
21889
|
}
|
|
21883
21890
|
static depositCallParameters(_params) {
|
|
21884
|
-
return { calldata:
|
|
21891
|
+
return { calldata: _ClassicChef.encodeDeposit(_params), value: "0x0" };
|
|
21885
21892
|
}
|
|
21886
21893
|
static encodeWithdraw(_params) {
|
|
21887
21894
|
return encodeFunctionData2({
|
|
@@ -21891,7 +21898,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
|
|
|
21891
21898
|
});
|
|
21892
21899
|
}
|
|
21893
21900
|
static withdrawCallParameters(_params) {
|
|
21894
|
-
return { calldata:
|
|
21901
|
+
return { calldata: _ClassicChef.encodeWithdraw(_params), value: "0x0" };
|
|
21895
21902
|
}
|
|
21896
21903
|
static encodeHarvest(_params) {
|
|
21897
21904
|
return encodeFunctionData2({
|
|
@@ -21901,7 +21908,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
|
|
|
21901
21908
|
});
|
|
21902
21909
|
}
|
|
21903
21910
|
static harvestCallParameters(_params) {
|
|
21904
|
-
return { calldata:
|
|
21911
|
+
return { calldata: _ClassicChef.encodeHarvest(_params), value: "0x0" };
|
|
21905
21912
|
}
|
|
21906
21913
|
static encodeEmergencyWithdraw(_params) {
|
|
21907
21914
|
return encodeFunctionData2({
|
|
@@ -21912,7 +21919,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
|
|
|
21912
21919
|
}
|
|
21913
21920
|
static emergencyWithdrawCallParameters(_params) {
|
|
21914
21921
|
return {
|
|
21915
|
-
calldata:
|
|
21922
|
+
calldata: _ClassicChef.encodeEmergencyWithdraw(_params),
|
|
21916
21923
|
value: "0x0"
|
|
21917
21924
|
};
|
|
21918
21925
|
}
|
|
@@ -21924,7 +21931,7 @@ var ApexClassicFarm = class _ApexClassicFarm {
|
|
|
21924
21931
|
});
|
|
21925
21932
|
}
|
|
21926
21933
|
};
|
|
21927
|
-
var
|
|
21934
|
+
var CLMasterChef = class _CLMasterChef {
|
|
21928
21935
|
constructor() {
|
|
21929
21936
|
}
|
|
21930
21937
|
static encodeMintAndStake(_params, _options) {
|
|
@@ -21941,12 +21948,12 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
21941
21948
|
});
|
|
21942
21949
|
}
|
|
21943
21950
|
static mintAndStakeCallParameters(_params, _options) {
|
|
21944
|
-
const calldata =
|
|
21951
|
+
const calldata = _CLMasterChef.encodeMintAndStake(_params, _options);
|
|
21945
21952
|
const value = toBigInt2(_options.value ?? 0n);
|
|
21946
21953
|
return {
|
|
21947
|
-
calldata: value === 0n ? calldata :
|
|
21954
|
+
calldata: value === 0n ? calldata : _CLMasterChef.encodeNfpMulticall([
|
|
21948
21955
|
calldata,
|
|
21949
|
-
|
|
21956
|
+
_CLMasterChef.encodeNfpRefundETH()
|
|
21950
21957
|
]),
|
|
21951
21958
|
value: toHexValue(value)
|
|
21952
21959
|
};
|
|
@@ -21960,8 +21967,8 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
21960
21967
|
}
|
|
21961
21968
|
static increaseLiquidityCallParameters(_params, _value = 0n) {
|
|
21962
21969
|
return {
|
|
21963
|
-
calldata:
|
|
21964
|
-
|
|
21970
|
+
calldata: _CLMasterChef.encodeMulticall([
|
|
21971
|
+
_CLMasterChef.encodeIncreaseLiquidity(_params)
|
|
21965
21972
|
]),
|
|
21966
21973
|
value: toHexValue(_value)
|
|
21967
21974
|
};
|
|
@@ -21981,8 +21988,8 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
21981
21988
|
{
|
|
21982
21989
|
tokenId: toBigInt2(_params.tokenId),
|
|
21983
21990
|
recipient: zeroAddress,
|
|
21984
|
-
amount0Max: toBigInt2(_params.amount0Max ??
|
|
21985
|
-
amount1Max: toBigInt2(_params.amount1Max ??
|
|
21991
|
+
amount0Max: toBigInt2(_params.amount0Max ?? MAX_UINT128),
|
|
21992
|
+
amount1Max: toBigInt2(_params.amount1Max ?? MAX_UINT128)
|
|
21986
21993
|
},
|
|
21987
21994
|
normalizeAddress2(_params.recipient)
|
|
21988
21995
|
]
|
|
@@ -21990,8 +21997,8 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
21990
21997
|
}
|
|
21991
21998
|
static collectCallParameters(_params) {
|
|
21992
21999
|
return {
|
|
21993
|
-
calldata:
|
|
21994
|
-
|
|
22000
|
+
calldata: _CLMasterChef.encodeMulticall([
|
|
22001
|
+
_CLMasterChef.encodeCollectTo(_params)
|
|
21995
22002
|
]),
|
|
21996
22003
|
value: "0x0"
|
|
21997
22004
|
};
|
|
@@ -22002,9 +22009,9 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
22002
22009
|
"tokenId mismatch"
|
|
22003
22010
|
);
|
|
22004
22011
|
return {
|
|
22005
|
-
calldata:
|
|
22006
|
-
|
|
22007
|
-
|
|
22012
|
+
calldata: _CLMasterChef.encodeMulticall([
|
|
22013
|
+
_CLMasterChef.encodeDecreaseLiquidity(_decreaseParams),
|
|
22014
|
+
_CLMasterChef.encodeCollectTo(_collectParams)
|
|
22008
22015
|
]),
|
|
22009
22016
|
value: "0x0"
|
|
22010
22017
|
};
|
|
@@ -22015,14 +22022,14 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
22015
22022
|
"tokenId mismatch"
|
|
22016
22023
|
);
|
|
22017
22024
|
return {
|
|
22018
|
-
calldata:
|
|
22019
|
-
|
|
22025
|
+
calldata: _CLMasterChef.encodeMulticall([
|
|
22026
|
+
_CLMasterChef.encodeHarvest({
|
|
22020
22027
|
tokenId: _decreaseParams.tokenId,
|
|
22021
22028
|
to: _collectParams.recipient
|
|
22022
22029
|
}),
|
|
22023
|
-
|
|
22024
|
-
|
|
22025
|
-
|
|
22030
|
+
_CLMasterChef.encodeDecreaseLiquidity(_decreaseParams),
|
|
22031
|
+
_CLMasterChef.encodeCollectTo(_collectParams),
|
|
22032
|
+
_CLMasterChef.encodeBurn({ tokenId: _decreaseParams.tokenId })
|
|
22026
22033
|
]),
|
|
22027
22034
|
value: "0x0"
|
|
22028
22035
|
};
|
|
@@ -22036,7 +22043,7 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
22036
22043
|
}
|
|
22037
22044
|
static harvestCallParameters(_params) {
|
|
22038
22045
|
return {
|
|
22039
|
-
calldata:
|
|
22046
|
+
calldata: _CLMasterChef.encodeMulticall([_CLMasterChef.encodeHarvest(_params)]),
|
|
22040
22047
|
value: "0x0"
|
|
22041
22048
|
};
|
|
22042
22049
|
}
|
|
@@ -22049,8 +22056,8 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
22049
22056
|
}
|
|
22050
22057
|
static withdrawCallParameters(_params) {
|
|
22051
22058
|
return {
|
|
22052
|
-
calldata:
|
|
22053
|
-
|
|
22059
|
+
calldata: _CLMasterChef.encodeMulticall([
|
|
22060
|
+
_CLMasterChef.encodeWithdraw(_params)
|
|
22054
22061
|
]),
|
|
22055
22062
|
value: "0x0"
|
|
22056
22063
|
};
|
|
@@ -22064,7 +22071,7 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
22064
22071
|
}
|
|
22065
22072
|
static burnCallParameters(_params) {
|
|
22066
22073
|
return {
|
|
22067
|
-
calldata:
|
|
22074
|
+
calldata: _CLMasterChef.encodeMulticall([_CLMasterChef.encodeBurn(_params)]),
|
|
22068
22075
|
value: "0x0"
|
|
22069
22076
|
};
|
|
22070
22077
|
}
|
|
@@ -22091,6 +22098,9 @@ var ApexCLFarm = class _ApexCLFarm {
|
|
|
22091
22098
|
});
|
|
22092
22099
|
}
|
|
22093
22100
|
};
|
|
22101
|
+
var APEX_MAX_UINT128 = MAX_UINT128;
|
|
22102
|
+
var ApexClassicFarm = ClassicChef;
|
|
22103
|
+
var ApexCLFarm = CLMasterChef;
|
|
22094
22104
|
function formatMintParams(_params) {
|
|
22095
22105
|
return {
|
|
22096
22106
|
token0: normalizeAddress2(_params.token0),
|
|
@@ -22160,7 +22170,7 @@ var APEX_MIXED_ROUTE_CLASSIC_VOLATILE = 8388609;
|
|
|
22160
22170
|
var APEX_MIXED_ROUTE_PANCAKE_CLASSIC_PLACEHOLDER = APEX_MIXED_ROUTE_CLASSIC_STABLE;
|
|
22161
22171
|
var APEX_MIXED_ROUTE_PANCAKE_VOLATILE_FLAG = 1;
|
|
22162
22172
|
var APEX_MIXED_ROUTE_PANCAKE_STABLE_FLAG = 2;
|
|
22163
|
-
function
|
|
22173
|
+
function encodeMixedRouteToPath(_hops, _exactOutput = false) {
|
|
22164
22174
|
invariant4(_hops.length > 0, "empty route");
|
|
22165
22175
|
assertContinuousRoute(_hops);
|
|
22166
22176
|
const hops = _exactOutput ? reverseRoute(_hops) : [..._hops];
|
|
@@ -22172,7 +22182,7 @@ function encodeApexMixedRouteToPath(_hops, _exactOutput = false) {
|
|
|
22172
22182
|
}
|
|
22173
22183
|
return encodePacked3(types, values);
|
|
22174
22184
|
}
|
|
22175
|
-
function
|
|
22185
|
+
function encodeMixedRouteToPancakeQuoteParams(_hops, _exactOutput = false) {
|
|
22176
22186
|
invariant4(_hops.length > 0, "empty route");
|
|
22177
22187
|
assertContinuousRoute(_hops);
|
|
22178
22188
|
const hops = _exactOutput ? reverseRoute(_hops) : [..._hops];
|
|
@@ -22187,7 +22197,7 @@ function encodeApexMixedRouteToPancakeQuoteParams(_hops, _exactOutput = false) {
|
|
|
22187
22197
|
}
|
|
22188
22198
|
return { path: encodePacked3(types, values), flags };
|
|
22189
22199
|
}
|
|
22190
|
-
function
|
|
22200
|
+
function decodeMixedRoutePath(_path) {
|
|
22191
22201
|
const hex = _path.startsWith("0x") ? _path.slice(2) : _path;
|
|
22192
22202
|
invariant4(hex.length >= 86 && (hex.length - 40) % 46 === 0, "invalid path length");
|
|
22193
22203
|
const hops = [];
|
|
@@ -22238,6 +22248,9 @@ function pancakeRouteCode(_hop) {
|
|
|
22238
22248
|
}
|
|
22239
22249
|
return APEX_MIXED_ROUTE_PANCAKE_CLASSIC_PLACEHOLDER;
|
|
22240
22250
|
}
|
|
22251
|
+
var encodeApexMixedRouteToPath = encodeMixedRouteToPath;
|
|
22252
|
+
var encodeApexMixedRouteToPancakeQuoteParams = encodeMixedRouteToPancakeQuoteParams;
|
|
22253
|
+
var decodeApexMixedRoutePath = decodeMixedRoutePath;
|
|
22241
22254
|
function normalizeAddress3(_address) {
|
|
22242
22255
|
invariant4(isAddress3(_address), `invalid address: ${_address}`);
|
|
22243
22256
|
return getAddress4(_address);
|
|
@@ -22248,36 +22261,38 @@ function readAddress(_hex, _offset) {
|
|
|
22248
22261
|
|
|
22249
22262
|
// src/protocolFees.ts
|
|
22250
22263
|
var APEX_CL_PROTOCOL_FEE_SPACING = 65536n;
|
|
22251
|
-
function
|
|
22264
|
+
function packProtocolFees(_token0ProtocolFee, _token1ProtocolFee) {
|
|
22252
22265
|
return BigInt(_token0ProtocolFee) + BigInt(_token1ProtocolFee) * APEX_CL_PROTOCOL_FEE_SPACING;
|
|
22253
22266
|
}
|
|
22254
|
-
function
|
|
22267
|
+
function parseProtocolFeePacked(_feeProtocol) {
|
|
22255
22268
|
const packed = BigInt(_feeProtocol);
|
|
22256
22269
|
return {
|
|
22257
22270
|
token0ProtocolFee: packed % APEX_CL_PROTOCOL_FEE_SPACING,
|
|
22258
22271
|
token1ProtocolFee: packed / APEX_CL_PROTOCOL_FEE_SPACING
|
|
22259
22272
|
};
|
|
22260
22273
|
}
|
|
22274
|
+
var packApexProtocolFees = packProtocolFees;
|
|
22275
|
+
var parseApexProtocolFeePacked = parseProtocolFeePacked;
|
|
22261
22276
|
|
|
22262
22277
|
// src/smartRouter.ts
|
|
22263
22278
|
import invariant5 from "tiny-invariant";
|
|
22264
22279
|
import { encodeFunctionData as encodeFunctionData3, getAddress as getAddress5, isAddress as isAddress4 } from "viem";
|
|
22265
|
-
var
|
|
22280
|
+
var SmartRouter = class _SmartRouter {
|
|
22266
22281
|
constructor() {
|
|
22267
22282
|
}
|
|
22268
22283
|
static swapCallParameters(_calldata, _options) {
|
|
22269
22284
|
return callParameters(Array.isArray(_calldata) ? [..._calldata] : [_calldata], _options);
|
|
22270
22285
|
}
|
|
22271
22286
|
static exactInputSingleCallParameters(_params, _options) {
|
|
22272
|
-
return
|
|
22287
|
+
return _SmartRouter.swapCallParameters(_SmartRouter.encodeExactInputSingle(_params), _options);
|
|
22273
22288
|
}
|
|
22274
22289
|
static exactInputCallParameters(_params, _options) {
|
|
22275
|
-
return
|
|
22290
|
+
return _SmartRouter.swapCallParameters(_SmartRouter.encodeExactInput(_params), _options);
|
|
22276
22291
|
}
|
|
22277
22292
|
static mixedExactInputCallParameters(_params, _options) {
|
|
22278
|
-
return
|
|
22293
|
+
return _SmartRouter.exactInputCallParameters(
|
|
22279
22294
|
{
|
|
22280
|
-
path:
|
|
22295
|
+
path: encodeMixedRouteToPath(_params.hops),
|
|
22281
22296
|
recipient: _params.recipient,
|
|
22282
22297
|
amountIn: _params.amountIn,
|
|
22283
22298
|
amountOutMinimum: _params.amountOutMinimum
|
|
@@ -22286,16 +22301,16 @@ var ApexSmartRouter = class _ApexSmartRouter {
|
|
|
22286
22301
|
);
|
|
22287
22302
|
}
|
|
22288
22303
|
static exactOutputSingleCallParameters(_params, _options) {
|
|
22289
|
-
return
|
|
22304
|
+
return _SmartRouter.swapCallParameters(_SmartRouter.encodeExactOutputSingle(_params), _options);
|
|
22290
22305
|
}
|
|
22291
22306
|
static exactOutputCallParameters(_params, _options) {
|
|
22292
|
-
return
|
|
22307
|
+
return _SmartRouter.swapCallParameters(_SmartRouter.encodeExactOutput(_params), _options);
|
|
22293
22308
|
}
|
|
22294
22309
|
static classicExactInputCallParameters(_params, _options) {
|
|
22295
|
-
return
|
|
22310
|
+
return _SmartRouter.swapCallParameters(_SmartRouter.encodeClassicExactInput(_params), _options);
|
|
22296
22311
|
}
|
|
22297
22312
|
static stableExactInputCallParameters(_params, _options) {
|
|
22298
|
-
return
|
|
22313
|
+
return _SmartRouter.swapCallParameters(_SmartRouter.encodeStableExactInput(_params), _options);
|
|
22299
22314
|
}
|
|
22300
22315
|
static encodeExactInputSingle(_params) {
|
|
22301
22316
|
return encodeFunctionData3({
|
|
@@ -22419,17 +22434,23 @@ var ApexSmartRouter = class _ApexSmartRouter {
|
|
|
22419
22434
|
});
|
|
22420
22435
|
}
|
|
22421
22436
|
};
|
|
22437
|
+
var ApexSmartRouter = SmartRouter;
|
|
22422
22438
|
function callParameters(_calldatas, _options) {
|
|
22423
|
-
|
|
22439
|
+
const value = toBigInt3(_options.value ?? 0n);
|
|
22440
|
+
const payments = [..._options.payments ?? []];
|
|
22441
|
+
if (value > 0n && !payments.some((payment) => payment.kind === "REFUND_ETH")) {
|
|
22442
|
+
payments.push({ kind: "REFUND_ETH" });
|
|
22443
|
+
}
|
|
22444
|
+
for (const payment of payments) _calldatas.push(encodePayment(payment));
|
|
22424
22445
|
return {
|
|
22425
|
-
calldata:
|
|
22426
|
-
value: toHexValue2(
|
|
22446
|
+
calldata: SmartRouter.encodeMulticall(_calldatas, _options.deadlineOrPreviousBlockhash),
|
|
22447
|
+
value: toHexValue2(value)
|
|
22427
22448
|
};
|
|
22428
22449
|
}
|
|
22429
22450
|
function encodePayment(_payment) {
|
|
22430
|
-
if (_payment.kind === "REFUND_ETH") return
|
|
22431
|
-
if (_payment.kind === "UNWRAP_WETH9") return
|
|
22432
|
-
return
|
|
22451
|
+
if (_payment.kind === "REFUND_ETH") return SmartRouter.encodeRefundETH();
|
|
22452
|
+
if (_payment.kind === "UNWRAP_WETH9") return SmartRouter.encodeUnwrapWETH9(_payment.amountMinimum, _payment.recipient);
|
|
22453
|
+
return SmartRouter.encodeSweepToken(_payment.token, _payment.amountMinimum, _payment.recipient);
|
|
22433
22454
|
}
|
|
22434
22455
|
function normalizeAddress4(_address) {
|
|
22435
22456
|
invariant5(isAddress4(_address), `invalid address: ${_address}`);
|
|
@@ -22454,10 +22475,11 @@ function toHexValue2(_value) {
|
|
|
22454
22475
|
import { encodeFunctionData as encodeFunctionData4, getAddress as getAddress6, isAddress as isAddress5, zeroAddress as zeroAddress2 } from "viem";
|
|
22455
22476
|
import invariant6 from "tiny-invariant";
|
|
22456
22477
|
var APEX_VAULT_BPS = 1e4;
|
|
22457
|
-
function
|
|
22478
|
+
function getApexVaultCompoundBucket(_veNFT) {
|
|
22458
22479
|
return normalizeAddress5(_veNFT);
|
|
22459
22480
|
}
|
|
22460
|
-
var
|
|
22481
|
+
var apexVaultCompoundBucket = getApexVaultCompoundBucket;
|
|
22482
|
+
var ApexVault = class _ApexVault {
|
|
22461
22483
|
constructor() {
|
|
22462
22484
|
}
|
|
22463
22485
|
static encodeStake(_tokenId, _config) {
|
|
@@ -22470,7 +22492,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
|
|
|
22470
22492
|
});
|
|
22471
22493
|
}
|
|
22472
22494
|
static stakeCallParameters(_tokenId, _config) {
|
|
22473
|
-
return { calldata:
|
|
22495
|
+
return { calldata: _ApexVault.encodeStake(_tokenId, _config), value: "0x0" };
|
|
22474
22496
|
}
|
|
22475
22497
|
static encodeSetUserConfig(_tokenId, _config) {
|
|
22476
22498
|
const formatted = formatVaultConfig(_config);
|
|
@@ -22482,7 +22504,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
|
|
|
22482
22504
|
});
|
|
22483
22505
|
}
|
|
22484
22506
|
static setUserConfigCallParameters(_tokenId, _config) {
|
|
22485
|
-
return { calldata:
|
|
22507
|
+
return { calldata: _ApexVault.encodeSetUserConfig(_tokenId, _config), value: "0x0" };
|
|
22486
22508
|
}
|
|
22487
22509
|
static encodeClaim(_params) {
|
|
22488
22510
|
invariant6(_params.rewardTokens.length > 0, "empty reward token list");
|
|
@@ -22493,7 +22515,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
|
|
|
22493
22515
|
});
|
|
22494
22516
|
}
|
|
22495
22517
|
static claimCallParameters(_params) {
|
|
22496
|
-
return { calldata:
|
|
22518
|
+
return { calldata: _ApexVault.encodeClaim(_params), value: "0x0" };
|
|
22497
22519
|
}
|
|
22498
22520
|
static encodeClaimAndExtendLock(_params) {
|
|
22499
22521
|
invariant6(_params.rewardTokens.length > 0, "empty reward token list");
|
|
@@ -22504,7 +22526,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
|
|
|
22504
22526
|
});
|
|
22505
22527
|
}
|
|
22506
22528
|
static claimAndExtendLockCallParameters(_params) {
|
|
22507
|
-
return { calldata:
|
|
22529
|
+
return { calldata: _ApexVault.encodeClaimAndExtendLock(_params), value: "0x0" };
|
|
22508
22530
|
}
|
|
22509
22531
|
static encodeUnstake(_params) {
|
|
22510
22532
|
return encodeFunctionData4({
|
|
@@ -22514,7 +22536,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
|
|
|
22514
22536
|
});
|
|
22515
22537
|
}
|
|
22516
22538
|
static unstakeCallParameters(_params) {
|
|
22517
|
-
return { calldata:
|
|
22539
|
+
return { calldata: _ApexVault.encodeUnstake(_params), value: "0x0" };
|
|
22518
22540
|
}
|
|
22519
22541
|
static encodeExtendLock(_params) {
|
|
22520
22542
|
return encodeFunctionData4({
|
|
@@ -22524,7 +22546,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
|
|
|
22524
22546
|
});
|
|
22525
22547
|
}
|
|
22526
22548
|
static extendLockCallParameters(_params) {
|
|
22527
|
-
return { calldata:
|
|
22549
|
+
return { calldata: _ApexVault.encodeExtendLock(_params), value: "0x0" };
|
|
22528
22550
|
}
|
|
22529
22551
|
static encodeIncreaseAmount(_params) {
|
|
22530
22552
|
return encodeFunctionData4({
|
|
@@ -22534,7 +22556,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
|
|
|
22534
22556
|
});
|
|
22535
22557
|
}
|
|
22536
22558
|
static increaseAmountCallParameters(_params) {
|
|
22537
|
-
return { calldata:
|
|
22559
|
+
return { calldata: _ApexVault.encodeIncreaseAmount(_params), value: "0x0" };
|
|
22538
22560
|
}
|
|
22539
22561
|
static encodeVeApexTokenApprove(_params) {
|
|
22540
22562
|
return encodeFunctionData4({
|
|
@@ -22558,6 +22580,7 @@ var ApexVaultPosition = class _ApexVaultPosition {
|
|
|
22558
22580
|
});
|
|
22559
22581
|
}
|
|
22560
22582
|
};
|
|
22583
|
+
var ApexVaultPosition = ApexVault;
|
|
22561
22584
|
function validateApexVaultUserConfig(_config) {
|
|
22562
22585
|
formatVaultConfig(_config);
|
|
22563
22586
|
}
|
|
@@ -22627,15 +22650,21 @@ export {
|
|
|
22627
22650
|
APEX_VAULT_BPS,
|
|
22628
22651
|
ApexCLFarm,
|
|
22629
22652
|
ApexClassicFarm,
|
|
22630
|
-
ApexFeeAmount,
|
|
22653
|
+
CLFeeAmount as ApexFeeAmount,
|
|
22631
22654
|
ApexSmartRouter,
|
|
22655
|
+
ApexVault,
|
|
22632
22656
|
ApexVaultPosition,
|
|
22657
|
+
CLFeeAmount,
|
|
22658
|
+
CLMasterChef,
|
|
22659
|
+
CL_TICK_SPACINGS,
|
|
22660
|
+
ClassicChef,
|
|
22633
22661
|
DEPLOYER_ADDRESSES,
|
|
22634
22662
|
FACTORY_ADDRESSES,
|
|
22635
22663
|
FeeAmount,
|
|
22636
22664
|
FeeCalculator,
|
|
22637
22665
|
FullMath,
|
|
22638
22666
|
LiquidityMath,
|
|
22667
|
+
MAX_UINT128,
|
|
22639
22668
|
MasterChefV3,
|
|
22640
22669
|
MaxUint128,
|
|
22641
22670
|
Multicall,
|
|
@@ -22650,6 +22679,7 @@ export {
|
|
|
22650
22679
|
PositionMath,
|
|
22651
22680
|
Route,
|
|
22652
22681
|
SelfPermit,
|
|
22682
|
+
SmartRouter,
|
|
22653
22683
|
SqrtPriceMath,
|
|
22654
22684
|
Staker,
|
|
22655
22685
|
SwapMath,
|
|
@@ -22680,9 +22710,13 @@ export {
|
|
|
22680
22710
|
computeCreate2Address,
|
|
22681
22711
|
computePoolAddress,
|
|
22682
22712
|
createApexPool,
|
|
22713
|
+
createCLPool,
|
|
22683
22714
|
decodeApexMixedRoutePath,
|
|
22715
|
+
decodeMixedRoutePath,
|
|
22684
22716
|
encodeApexMixedRouteToPancakeQuoteParams,
|
|
22685
22717
|
encodeApexMixedRouteToPath,
|
|
22718
|
+
encodeMixedRouteToPancakeQuoteParams,
|
|
22719
|
+
encodeMixedRouteToPath,
|
|
22686
22720
|
encodeRouteToPath,
|
|
22687
22721
|
encodeSqrtRatioX96,
|
|
22688
22722
|
feeCenterAbi,
|
|
@@ -22692,7 +22726,9 @@ export {
|
|
|
22692
22726
|
getAmountsAtNewPrice,
|
|
22693
22727
|
getAmountsByLiquidityAndPrice,
|
|
22694
22728
|
getApexTickSpacing,
|
|
22729
|
+
getApexVaultCompoundBucket,
|
|
22695
22730
|
getAverageLiquidity,
|
|
22731
|
+
getCLTickSpacing,
|
|
22696
22732
|
getCurrency0Price,
|
|
22697
22733
|
getCurrency1Price,
|
|
22698
22734
|
getDependentAmount,
|
|
@@ -22712,8 +22748,10 @@ export {
|
|
|
22712
22748
|
getPriceOfCurrency1,
|
|
22713
22749
|
hasInvolvedCurrency,
|
|
22714
22750
|
installApexFeeTiers,
|
|
22751
|
+
installCLFeeTiers,
|
|
22715
22752
|
interfaceMulticallAbi,
|
|
22716
22753
|
isApexCLFeeAmount,
|
|
22754
|
+
isCLFeeAmount,
|
|
22717
22755
|
isMint,
|
|
22718
22756
|
isPoolTickInRange,
|
|
22719
22757
|
isSorted,
|
|
@@ -22729,12 +22767,15 @@ export {
|
|
|
22729
22767
|
nonfungiblePositionManagerAbi,
|
|
22730
22768
|
normalizeAddress,
|
|
22731
22769
|
packApexProtocolFees,
|
|
22770
|
+
packProtocolFees,
|
|
22732
22771
|
pancakeV3PoolABI,
|
|
22733
22772
|
parseApexProtocolFeePacked,
|
|
22773
|
+
parseProtocolFeePacked,
|
|
22734
22774
|
parseProtocolFees,
|
|
22735
22775
|
peripheryPaymentsWithFeeABI,
|
|
22736
22776
|
priceToClosestTick,
|
|
22737
22777
|
quoteApexClassicExactInput,
|
|
22778
|
+
quoteClassicExactInput,
|
|
22738
22779
|
quoterABI,
|
|
22739
22780
|
quoterAbi,
|
|
22740
22781
|
quoterV2ABI,
|
|
@@ -22751,6 +22792,7 @@ export {
|
|
|
22751
22792
|
tickToPrice,
|
|
22752
22793
|
tickToPriceV2,
|
|
22753
22794
|
toApexFeeAmount,
|
|
22795
|
+
toCLFeeAmount,
|
|
22754
22796
|
toHex,
|
|
22755
22797
|
tradeComparator,
|
|
22756
22798
|
v3PoolAbi,
|