@apex_labs/sdk 0.1.1 → 0.2.0
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 +12 -14
- package/dist/index.cjs +27 -1158
- package/dist/index.d.cts +629 -7905
- package/dist/index.d.ts +629 -7905
- package/dist/index.js +23 -1058
- package/package.json +3 -4
- package/vendor/pancake-v3-sdk/README.md +0 -5
- package/vendor/pancake-v3-sdk/package.json +0 -19
package/dist/index.js
CHANGED
|
@@ -97,13 +97,6 @@ var NFT_POSITION_MANAGER_ADDRESSES = {
|
|
|
97
97
|
[ChainId.MONAD_MAINNET]: NFT_POSITION_MANAGER_ADDRESS,
|
|
98
98
|
[ChainId.MONAD_TESTNET]: "0x075A0Ba7bc4cdFBBdc9d8De5f228C834246e5AFc"
|
|
99
99
|
};
|
|
100
|
-
var FeeAmount = /* @__PURE__ */ ((FeeAmount4) => {
|
|
101
|
-
FeeAmount4[FeeAmount4["LOWEST"] = 100] = "LOWEST";
|
|
102
|
-
FeeAmount4[FeeAmount4["LOW"] = 500] = "LOW";
|
|
103
|
-
FeeAmount4[FeeAmount4["MEDIUM"] = 2500] = "MEDIUM";
|
|
104
|
-
FeeAmount4[FeeAmount4["HIGH"] = 1e4] = "HIGH";
|
|
105
|
-
return FeeAmount4;
|
|
106
|
-
})(FeeAmount || {});
|
|
107
100
|
var TICK_SPACINGS = {
|
|
108
101
|
[
|
|
109
102
|
100
|
|
@@ -826,25 +819,6 @@ function tickToPrice(baseToken, quoteToken, tick) {
|
|
|
826
819
|
const ratioX192 = sqrtRatioX96 * sqrtRatioX96;
|
|
827
820
|
return isCurrencySorted(baseToken, quoteToken) ? new Price$1(baseToken, quoteToken, Q192, ratioX192) : new Price$1(baseToken, quoteToken, ratioX192, Q192);
|
|
828
821
|
}
|
|
829
|
-
function tickToPriceV2(baseToken, quoteToken, tick) {
|
|
830
|
-
const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(tick);
|
|
831
|
-
const ratioX192 = sqrtRatioX96 * sqrtRatioX96;
|
|
832
|
-
return sortCurrencies([baseToken, quoteToken])[0] === baseToken ? new Price$1(baseToken, quoteToken, Q192, ratioX192) : new Price$1(baseToken, quoteToken, ratioX192, Q192);
|
|
833
|
-
}
|
|
834
|
-
function priceToClosestTick(price) {
|
|
835
|
-
const sorted = isCurrencySorted(price.baseCurrency, price.quoteCurrency);
|
|
836
|
-
const sqrtRatioX96 = sorted ? encodeSqrtRatioX96(price.numerator, price.denominator) : encodeSqrtRatioX96(price.denominator, price.numerator);
|
|
837
|
-
let tick = TickMath.getTickAtSqrtRatio(sqrtRatioX96);
|
|
838
|
-
const nextTickPrice = tickToPrice(price.baseCurrency, price.quoteCurrency, tick + 1);
|
|
839
|
-
if (sorted) {
|
|
840
|
-
if (!price.lessThan(nextTickPrice)) {
|
|
841
|
-
tick++;
|
|
842
|
-
}
|
|
843
|
-
} else if (!price.greaterThan(nextTickPrice)) {
|
|
844
|
-
tick++;
|
|
845
|
-
}
|
|
846
|
-
return tick;
|
|
847
|
-
}
|
|
848
822
|
function getToken0Amount(tickCurrent, tickLower, tickUpper, sqrtRatioX96, liquidity) {
|
|
849
823
|
if (tickCurrent < tickLower) {
|
|
850
824
|
return SqrtPriceMath.getAmount0Delta(
|
|
@@ -1657,54 +1631,7 @@ var Trade = class {
|
|
|
1657
1631
|
return bestTrades;
|
|
1658
1632
|
}
|
|
1659
1633
|
};
|
|
1660
|
-
var getCurrency0Price = ([currency0, currency1], currentSqrtRatioX96) => {
|
|
1661
|
-
const ratio192 = BigInt(currentSqrtRatioX96) * BigInt(currentSqrtRatioX96);
|
|
1662
|
-
return new Price(currency0, currency1, Q192, ratio192);
|
|
1663
|
-
};
|
|
1664
|
-
var getCurrency1Price = ([currency0, currency1], currentSqrtRatioX96) => {
|
|
1665
|
-
const ratio192 = BigInt(currentSqrtRatioX96) * BigInt(currentSqrtRatioX96);
|
|
1666
|
-
return new Price(currency1, currency0, Q192, ratio192);
|
|
1667
|
-
};
|
|
1668
1634
|
var NO_TICK_DATA_PROVIDER_DEFAULT2 = new NoTickDataProvider();
|
|
1669
|
-
var MAX_FEE_AMOUNT = 1000000n;
|
|
1670
|
-
var getPool = ({
|
|
1671
|
-
currencyA,
|
|
1672
|
-
currencyB,
|
|
1673
|
-
fee,
|
|
1674
|
-
sqrtRatioX96,
|
|
1675
|
-
liquidity,
|
|
1676
|
-
tickCurrent,
|
|
1677
|
-
tickSpacing,
|
|
1678
|
-
ticks = NO_TICK_DATA_PROVIDER_DEFAULT2
|
|
1679
|
-
}) => {
|
|
1680
|
-
invariant9(Number.isInteger(fee) && BigInt(fee) < MAX_FEE_AMOUNT, "FEE");
|
|
1681
|
-
const [currency0, currency1] = sortCurrencies([currencyA, currencyB]);
|
|
1682
|
-
return {
|
|
1683
|
-
currency0,
|
|
1684
|
-
currency1,
|
|
1685
|
-
fee,
|
|
1686
|
-
tickCurrent,
|
|
1687
|
-
tickSpacing,
|
|
1688
|
-
sqrtRatioX96: BigInt(sqrtRatioX96),
|
|
1689
|
-
liquidity: BigInt(liquidity),
|
|
1690
|
-
tickDataProvider: Array.isArray(ticks) ? new TickListDataProvider(ticks) : ticks
|
|
1691
|
-
};
|
|
1692
|
-
};
|
|
1693
|
-
var getPriceOfCurrency = (pool, currency) => {
|
|
1694
|
-
if (currency.isNative) {
|
|
1695
|
-
invariant9(pool.currency0.isNative, "CURRENCY");
|
|
1696
|
-
return getCurrency0Price([pool.currency0, pool.currency1], pool.sqrtRatioX96);
|
|
1697
|
-
}
|
|
1698
|
-
invariant9(pool.currency0.equals(currency) || pool.currency1.equals(currency), "CURRENCY");
|
|
1699
|
-
return pool.currency0.equals(currency) ? getCurrency0Price([pool.currency0, pool.currency1], pool.sqrtRatioX96) : getCurrency1Price([pool.currency0, pool.currency1], pool.sqrtRatioX96);
|
|
1700
|
-
};
|
|
1701
|
-
var getPriceOfCurrency0 = (pool) => getCurrency0Price([pool.currency0, pool.currency1], pool.sqrtRatioX96);
|
|
1702
|
-
var getPriceOfCurrency1 = (pool) => getCurrency1Price([pool.currency0, pool.currency1], pool.sqrtRatioX96);
|
|
1703
|
-
var hasInvolvedCurrency = (pool, currency) => {
|
|
1704
|
-
if (currency.isNative)
|
|
1705
|
-
return pool.currency0.isNative && pool.currency1.chainId === currency.chainId;
|
|
1706
|
-
return pool.currency0.equals(currency) || pool.currency1.equals(currency);
|
|
1707
|
-
};
|
|
1708
1635
|
function toHex(bigintIsh) {
|
|
1709
1636
|
const bigInt = BigInt(bigintIsh);
|
|
1710
1637
|
let hex = bigInt.toString(16);
|
|
@@ -1748,403 +1675,8 @@ function nearestUsableTick(tick, tickSpacing) {
|
|
|
1748
1675
|
return rounded - tickSpacing;
|
|
1749
1676
|
return rounded;
|
|
1750
1677
|
}
|
|
1751
|
-
var PositionLibrary = class {
|
|
1752
|
-
/**
|
|
1753
|
-
* Cannot be constructed.
|
|
1754
|
-
*/
|
|
1755
|
-
constructor() {
|
|
1756
|
-
}
|
|
1757
|
-
// replicates the portions of Position#update required to compute unaccounted fees
|
|
1758
|
-
static getTokensOwed(feeGrowthInside0LastX128, feeGrowthInside1LastX128, liquidity, feeGrowthInside0X128, feeGrowthInside1X128) {
|
|
1759
|
-
const tokensOwed0 = subIn256(feeGrowthInside0X128, feeGrowthInside0LastX128) * liquidity / Q128;
|
|
1760
|
-
const tokensOwed1 = subIn256(feeGrowthInside1X128, feeGrowthInside1LastX128) * liquidity / Q128;
|
|
1761
|
-
return [tokensOwed0, tokensOwed1];
|
|
1762
|
-
}
|
|
1763
|
-
};
|
|
1764
1678
|
var Q256 = 2n ** 256n;
|
|
1765
|
-
function subIn256(x, y) {
|
|
1766
|
-
const difference = x - y;
|
|
1767
|
-
if (difference < ZERO) {
|
|
1768
|
-
return Q256 + difference;
|
|
1769
|
-
}
|
|
1770
|
-
return difference;
|
|
1771
|
-
}
|
|
1772
|
-
var TickLibrary = class {
|
|
1773
|
-
/**
|
|
1774
|
-
* Cannot be constructed.
|
|
1775
|
-
*/
|
|
1776
|
-
constructor() {
|
|
1777
|
-
}
|
|
1778
|
-
static getFeeGrowthInside(feeGrowthOutsideLower, feeGrowthOutsideUpper, tickLower, tickUpper, tickCurrent, feeGrowthGlobal0X128, feeGrowthGlobal1X128) {
|
|
1779
|
-
let feeGrowthBelow0X128;
|
|
1780
|
-
let feeGrowthBelow1X128;
|
|
1781
|
-
if (tickCurrent >= tickLower) {
|
|
1782
|
-
feeGrowthBelow0X128 = feeGrowthOutsideLower.feeGrowthOutside0X128;
|
|
1783
|
-
feeGrowthBelow1X128 = feeGrowthOutsideLower.feeGrowthOutside1X128;
|
|
1784
|
-
} else {
|
|
1785
|
-
feeGrowthBelow0X128 = subIn256(feeGrowthGlobal0X128, feeGrowthOutsideLower.feeGrowthOutside0X128);
|
|
1786
|
-
feeGrowthBelow1X128 = subIn256(feeGrowthGlobal1X128, feeGrowthOutsideLower.feeGrowthOutside1X128);
|
|
1787
|
-
}
|
|
1788
|
-
let feeGrowthAbove0X128;
|
|
1789
|
-
let feeGrowthAbove1X128;
|
|
1790
|
-
if (tickCurrent < tickUpper) {
|
|
1791
|
-
feeGrowthAbove0X128 = feeGrowthOutsideUpper.feeGrowthOutside0X128;
|
|
1792
|
-
feeGrowthAbove1X128 = feeGrowthOutsideUpper.feeGrowthOutside1X128;
|
|
1793
|
-
} else {
|
|
1794
|
-
feeGrowthAbove0X128 = subIn256(feeGrowthGlobal0X128, feeGrowthOutsideUpper.feeGrowthOutside0X128);
|
|
1795
|
-
feeGrowthAbove1X128 = subIn256(feeGrowthGlobal1X128, feeGrowthOutsideUpper.feeGrowthOutside1X128);
|
|
1796
|
-
}
|
|
1797
|
-
return [
|
|
1798
|
-
subIn256(subIn256(feeGrowthGlobal0X128, feeGrowthBelow0X128), feeGrowthAbove0X128),
|
|
1799
|
-
subIn256(subIn256(feeGrowthGlobal1X128, feeGrowthBelow1X128), feeGrowthAbove1X128)
|
|
1800
|
-
];
|
|
1801
|
-
}
|
|
1802
|
-
};
|
|
1803
|
-
function parseNumberToFraction(num, precision = 6) {
|
|
1804
|
-
if (Number.isNaN(num) || !Number.isFinite(num)) {
|
|
1805
|
-
return void 0;
|
|
1806
|
-
}
|
|
1807
|
-
const scalar = 10 ** precision;
|
|
1808
|
-
const scaledNum = num * scalar;
|
|
1809
|
-
if (Number.isNaN(scaledNum) || !Number.isFinite(scaledNum)) {
|
|
1810
|
-
return void 0;
|
|
1811
|
-
}
|
|
1812
|
-
return new Fraction$1(BigInt(Math.floor(scaledNum)), BigInt(scalar));
|
|
1813
|
-
}
|
|
1814
|
-
var FeeCalculator = {
|
|
1815
|
-
getEstimatedLPFee,
|
|
1816
|
-
getEstimatedLPFeeByAmounts,
|
|
1817
|
-
getLiquidityFromTick,
|
|
1818
|
-
getLiquidityFromSqrtRatioX96,
|
|
1819
|
-
getAverageLiquidity,
|
|
1820
|
-
getLiquidityBySingleAmount,
|
|
1821
|
-
getDependentAmount,
|
|
1822
|
-
getLiquidityByAmountsAndPrice,
|
|
1823
|
-
getAmountsByLiquidityAndPrice,
|
|
1824
|
-
getAmountsAtNewPrice
|
|
1825
|
-
};
|
|
1826
|
-
function getEstimatedLPFeeWithProtocolFee({ amount, currency, ...rest }) {
|
|
1827
|
-
return getEstimatedLPFeeByAmountsWithProtocolFee({
|
|
1828
|
-
...rest,
|
|
1829
|
-
amountA: amount,
|
|
1830
|
-
amountB: CurrencyAmount$1.fromRawAmount(currency, MaxUint256)
|
|
1831
|
-
});
|
|
1832
|
-
}
|
|
1833
|
-
function getEstimatedLPFee({ amount, currency, ...rest }) {
|
|
1834
|
-
return getEstimatedLPFeeByAmounts({
|
|
1835
|
-
...rest,
|
|
1836
|
-
amountA: amount,
|
|
1837
|
-
amountB: CurrencyAmount$1.fromRawAmount(currency, MaxUint256)
|
|
1838
|
-
});
|
|
1839
|
-
}
|
|
1840
|
-
function getEstimatedLPFeeByAmountsWithProtocolFee(options) {
|
|
1841
|
-
try {
|
|
1842
|
-
return tryGetEstimatedLPFeeByAmounts(options);
|
|
1843
|
-
} catch (e) {
|
|
1844
|
-
console.error(e);
|
|
1845
|
-
return new Fraction$1(ZERO$1);
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
function getEstimatedLPFeeByAmounts({ protocolFee = ZERO_PERCENT, ...rest }) {
|
|
1849
|
-
try {
|
|
1850
|
-
const fee = tryGetEstimatedLPFeeByAmounts(rest);
|
|
1851
|
-
return ONE_HUNDRED_PERCENT.subtract(protocolFee).multiply(fee).asFraction;
|
|
1852
|
-
} catch (e) {
|
|
1853
|
-
console.error(e);
|
|
1854
|
-
return new Fraction$1(ZERO$1);
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
function tryGetEstimatedLPFeeByAmounts({
|
|
1858
|
-
amountA,
|
|
1859
|
-
amountB,
|
|
1860
|
-
volume24H,
|
|
1861
|
-
sqrtRatioX96,
|
|
1862
|
-
tickLower,
|
|
1863
|
-
tickUpper,
|
|
1864
|
-
mostActiveLiquidity,
|
|
1865
|
-
fee,
|
|
1866
|
-
insidePercentage = ONE_HUNDRED_PERCENT
|
|
1867
|
-
}) {
|
|
1868
|
-
invariant9(!Number.isNaN(fee) && fee >= 0, "INVALID_FEE");
|
|
1869
|
-
const tickCurrent = TickMath.getTickAtSqrtRatio(sqrtRatioX96);
|
|
1870
|
-
if (tickCurrent < tickLower || tickCurrent >= tickUpper) {
|
|
1871
|
-
return new Fraction$1(ZERO$1);
|
|
1872
|
-
}
|
|
1873
|
-
const liquidity = FeeCalculator.getLiquidityByAmountsAndPrice({
|
|
1874
|
-
amountA,
|
|
1875
|
-
amountB,
|
|
1876
|
-
tickUpper,
|
|
1877
|
-
tickLower,
|
|
1878
|
-
sqrtRatioX96
|
|
1879
|
-
});
|
|
1880
|
-
if (!liquidity) {
|
|
1881
|
-
return new Fraction$1(ZERO$1);
|
|
1882
|
-
}
|
|
1883
|
-
const volumeInFraction = parseNumberToFraction(volume24H) || new Fraction$1(ZERO$1);
|
|
1884
|
-
return insidePercentage.multiply(volumeInFraction.multiply(BigInt(fee)).multiply(liquidity)).divide(MAX_FEE * (liquidity + mostActiveLiquidity)).asFraction;
|
|
1885
|
-
}
|
|
1886
|
-
function getDependentAmount(options) {
|
|
1887
|
-
const { currency, amount, sqrtRatioX96, tickLower, tickUpper } = options;
|
|
1888
|
-
const currentTick = TickMath.getTickAtSqrtRatio(sqrtRatioX96);
|
|
1889
|
-
const liquidity = FeeCalculator.getLiquidityBySingleAmount(options);
|
|
1890
|
-
const isToken0 = currency.wrapped.sortsBefore(amount.currency.wrapped);
|
|
1891
|
-
const getTokenAmount = isToken0 ? PositionMath.getToken0Amount : PositionMath.getToken1Amount;
|
|
1892
|
-
if (!liquidity) {
|
|
1893
|
-
return void 0;
|
|
1894
|
-
}
|
|
1895
|
-
return CurrencyAmount$1.fromRawAmount(
|
|
1896
|
-
currency,
|
|
1897
|
-
getTokenAmount(currentTick, tickLower, tickUpper, sqrtRatioX96, liquidity)
|
|
1898
|
-
);
|
|
1899
|
-
}
|
|
1900
|
-
function getLiquidityBySingleAmount({ amount, currency, ...rest }) {
|
|
1901
|
-
return getLiquidityByAmountsAndPrice({
|
|
1902
|
-
amountA: amount,
|
|
1903
|
-
amountB: CurrencyAmount$1.fromRawAmount(currency, MaxUint256),
|
|
1904
|
-
...rest
|
|
1905
|
-
});
|
|
1906
|
-
}
|
|
1907
|
-
function getLiquidityByAmountsAndPrice({
|
|
1908
|
-
amountA,
|
|
1909
|
-
amountB,
|
|
1910
|
-
tickUpper,
|
|
1911
|
-
tickLower,
|
|
1912
|
-
sqrtRatioX96
|
|
1913
|
-
}) {
|
|
1914
|
-
const isToken0 = amountA.currency.wrapped.address !== amountB.currency.wrapped.address ? amountA.currency.wrapped.sortsBefore(amountB.currency.wrapped) : true;
|
|
1915
|
-
const [inputAmount0, inputAmount1] = isToken0 ? [amountA.quotient, amountB.quotient] : [amountB.quotient, amountA.quotient];
|
|
1916
|
-
const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);
|
|
1917
|
-
const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);
|
|
1918
|
-
try {
|
|
1919
|
-
return maxLiquidityForAmounts(sqrtRatioX96, sqrtRatioAX96, sqrtRatioBX96, inputAmount0, inputAmount1, true);
|
|
1920
|
-
} catch (e) {
|
|
1921
|
-
console.error(e);
|
|
1922
|
-
return void 0;
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
function getAmountsByLiquidityAndPrice(options) {
|
|
1926
|
-
const { currencyA, currencyB, liquidity, sqrtRatioX96, tickLower, tickUpper } = options;
|
|
1927
|
-
const currentTick = TickMath.getTickAtSqrtRatio(sqrtRatioX96);
|
|
1928
|
-
const isToken0 = currencyA.wrapped.sortsBefore(currencyB.wrapped);
|
|
1929
|
-
const adjustedAmount0 = PositionMath.getToken0Amount(currentTick, tickLower, tickUpper, sqrtRatioX96, liquidity);
|
|
1930
|
-
const adjustedAmount1 = PositionMath.getToken1Amount(currentTick, tickLower, tickUpper, sqrtRatioX96, liquidity);
|
|
1931
|
-
return [
|
|
1932
|
-
CurrencyAmount$1.fromRawAmount(currencyA, isToken0 ? adjustedAmount0 : adjustedAmount1),
|
|
1933
|
-
CurrencyAmount$1.fromRawAmount(currencyB, isToken0 ? adjustedAmount1 : adjustedAmount0)
|
|
1934
|
-
];
|
|
1935
|
-
}
|
|
1936
|
-
function getAmountsAtNewPrice({ newSqrtRatioX96, ...rest }) {
|
|
1937
|
-
const { tickLower, tickUpper, amountA, amountB } = rest;
|
|
1938
|
-
const liquidity = FeeCalculator.getLiquidityByAmountsAndPrice(rest);
|
|
1939
|
-
if (!liquidity) {
|
|
1940
|
-
return void 0;
|
|
1941
|
-
}
|
|
1942
|
-
return FeeCalculator.getAmountsByLiquidityAndPrice({
|
|
1943
|
-
liquidity,
|
|
1944
|
-
currencyA: amountA.currency,
|
|
1945
|
-
currencyB: amountB.currency,
|
|
1946
|
-
tickLower,
|
|
1947
|
-
tickUpper,
|
|
1948
|
-
sqrtRatioX96: newSqrtRatioX96
|
|
1949
|
-
});
|
|
1950
|
-
}
|
|
1951
|
-
function getAverageLiquidity(ticks, tickSpacing, tickLower, tickUpper) {
|
|
1952
|
-
invariant9(tickLower <= tickUpper, "INVALID_TICK_RANGE");
|
|
1953
|
-
TickList.validateList(ticks, tickSpacing);
|
|
1954
|
-
if (tickLower === tickUpper) {
|
|
1955
|
-
return FeeCalculator.getLiquidityFromTick(ticks, tickLower);
|
|
1956
|
-
}
|
|
1957
|
-
const lowerOutOfBound = tickLower < ticks[0].index;
|
|
1958
|
-
let lastTick = lowerOutOfBound ? new Tick({ index: TickMath.MIN_TICK, liquidityNet: ZERO$1, liquidityGross: ZERO$1 }) : TickList.nextInitializedTick(ticks, tickLower, true);
|
|
1959
|
-
let currentTick = TickList.nextInitializedTick(ticks, tickLower, false);
|
|
1960
|
-
let currentL = lowerOutOfBound ? ZERO$1 : FeeCalculator.getLiquidityFromTick(ticks, currentTick.index);
|
|
1961
|
-
let weightedL = ZERO$1;
|
|
1962
|
-
const getWeightedLFromLastTickTo = (toTick) => currentL * BigInt(toTick - Math.max(lastTick.index, tickLower));
|
|
1963
|
-
while (currentTick.index < tickUpper) {
|
|
1964
|
-
weightedL += getWeightedLFromLastTickTo(currentTick.index);
|
|
1965
|
-
currentL += currentTick.liquidityNet;
|
|
1966
|
-
lastTick = currentTick;
|
|
1967
|
-
if (currentTick.index === ticks[ticks.length - 1].index) {
|
|
1968
|
-
break;
|
|
1969
|
-
}
|
|
1970
|
-
currentTick = TickList.nextInitializedTick(ticks, currentTick.index, false);
|
|
1971
|
-
}
|
|
1972
|
-
weightedL += getWeightedLFromLastTickTo(tickUpper);
|
|
1973
|
-
return weightedL / BigInt(tickUpper - tickLower);
|
|
1974
|
-
}
|
|
1975
|
-
function getLiquidityFromSqrtRatioX96(ticks, sqrtRatioX96) {
|
|
1976
|
-
const tick = TickMath.getTickAtSqrtRatio(sqrtRatioX96);
|
|
1977
|
-
return FeeCalculator.getLiquidityFromTick(ticks, tick);
|
|
1978
|
-
}
|
|
1979
|
-
function getLiquidityFromTick(ticks, tick) {
|
|
1980
|
-
let liquidity = ZERO$1;
|
|
1981
|
-
if (!ticks?.length)
|
|
1982
|
-
return liquidity;
|
|
1983
|
-
if (tick < ticks[0].index || tick > ticks[ticks.length - 1].index) {
|
|
1984
|
-
return liquidity;
|
|
1985
|
-
}
|
|
1986
|
-
for (let i = 0; i < ticks.length - 1; ++i) {
|
|
1987
|
-
liquidity += ticks[i].liquidityNet;
|
|
1988
|
-
const lowerTick = ticks[i].index;
|
|
1989
|
-
const upperTick = ticks[i + 1]?.index;
|
|
1990
|
-
if (lowerTick <= tick && tick <= upperTick) {
|
|
1991
|
-
break;
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
return liquidity;
|
|
1995
|
-
}
|
|
1996
1679
|
var FEE_BASE = 10n ** 4n;
|
|
1997
|
-
function parseProtocolFees(feeProtocol) {
|
|
1998
|
-
const packed = Number(feeProtocol);
|
|
1999
|
-
if (Number.isNaN(packed)) {
|
|
2000
|
-
throw new Error(`Invalid fee protocol ${feeProtocol}`);
|
|
2001
|
-
}
|
|
2002
|
-
const token0ProtocolFee = packed % 2 ** 16;
|
|
2003
|
-
const token1ProtocolFee = packed >> 16;
|
|
2004
|
-
return [new Percent(token0ProtocolFee, FEE_BASE), new Percent(token1ProtocolFee, FEE_BASE)];
|
|
2005
|
-
}
|
|
2006
|
-
function sqrtRatioX96ToPrice(sqrtRatioX96, currencyA, currencyB) {
|
|
2007
|
-
const ratioX192 = sqrtRatioX96 * sqrtRatioX96;
|
|
2008
|
-
return currencyA.wrapped.sortsBefore(currencyB.wrapped) ? new Price$1(currencyA.wrapped, currencyB.wrapped, Q192, ratioX192) : new Price$1(currencyA.wrapped, currencyB.wrapped, ratioX192, Q192);
|
|
2009
|
-
}
|
|
2010
|
-
var isPoolTickInRange = (pool, tickLower, tickUpper) => {
|
|
2011
|
-
if (!pool)
|
|
2012
|
-
return false;
|
|
2013
|
-
const below = typeof tickLower === "number" ? pool.tickCurrent < tickLower : void 0;
|
|
2014
|
-
const above = typeof tickUpper === "number" ? pool.tickCurrent >= tickUpper : void 0;
|
|
2015
|
-
return typeof below === "boolean" && typeof above === "boolean" ? !below && !above : false;
|
|
2016
|
-
};
|
|
2017
|
-
var swap = async ({
|
|
2018
|
-
pool,
|
|
2019
|
-
zeroForOne,
|
|
2020
|
-
amountSpecified,
|
|
2021
|
-
sqrtPriceLimitX96
|
|
2022
|
-
}) => {
|
|
2023
|
-
if (!sqrtPriceLimitX96)
|
|
2024
|
-
sqrtPriceLimitX96 = zeroForOne ? TickMath.MIN_SQRT_RATIO + ONE : TickMath.MAX_SQRT_RATIO - ONE;
|
|
2025
|
-
if (zeroForOne) {
|
|
2026
|
-
invariant9(sqrtPriceLimitX96 > TickMath.MIN_SQRT_RATIO, "RATIO_MIN");
|
|
2027
|
-
invariant9(sqrtPriceLimitX96 < pool.sqrtRatioX96, "RATIO_CURRENT");
|
|
2028
|
-
} else {
|
|
2029
|
-
invariant9(sqrtPriceLimitX96 < TickMath.MAX_SQRT_RATIO, "RATIO_MAX");
|
|
2030
|
-
invariant9(sqrtPriceLimitX96 > pool.sqrtRatioX96, "RATIO_CURRENT");
|
|
2031
|
-
}
|
|
2032
|
-
const exactInput = amountSpecified >= ZERO;
|
|
2033
|
-
const state = {
|
|
2034
|
-
amountSpecifiedRemaining: amountSpecified,
|
|
2035
|
-
amountCalculated: ZERO,
|
|
2036
|
-
sqrtPriceX96: pool.sqrtRatioX96,
|
|
2037
|
-
tick: pool.tickCurrent,
|
|
2038
|
-
liquidity: pool.liquidity
|
|
2039
|
-
};
|
|
2040
|
-
while (state.amountSpecifiedRemaining !== ZERO && state.sqrtPriceX96 != sqrtPriceLimitX96) {
|
|
2041
|
-
const step = {};
|
|
2042
|
-
step.sqrtPriceStartX96 = state.sqrtPriceX96;
|
|
2043
|
-
[step.tickNext, step.initialized] = await pool.tickDataProvider.nextInitializedTickWithinOneWord(
|
|
2044
|
-
state.tick,
|
|
2045
|
-
zeroForOne,
|
|
2046
|
-
pool.tickSpacing
|
|
2047
|
-
);
|
|
2048
|
-
if (step.tickNext < TickMath.MIN_TICK) {
|
|
2049
|
-
step.tickNext = TickMath.MIN_TICK;
|
|
2050
|
-
} else if (step.tickNext > TickMath.MAX_TICK) {
|
|
2051
|
-
step.tickNext = TickMath.MAX_TICK;
|
|
2052
|
-
}
|
|
2053
|
-
step.sqrtPriceNextX96 = TickMath.getSqrtRatioAtTick(step.tickNext);
|
|
2054
|
-
[state.sqrtPriceX96, step.amountIn, step.amountOut, step.feeAmount] = SwapMath.computeSwapStep(
|
|
2055
|
-
state.sqrtPriceX96,
|
|
2056
|
-
(zeroForOne ? step.sqrtPriceNextX96 < sqrtPriceLimitX96 : step.sqrtPriceNextX96 > sqrtPriceLimitX96) ? sqrtPriceLimitX96 : step.sqrtPriceNextX96,
|
|
2057
|
-
state.liquidity,
|
|
2058
|
-
state.amountSpecifiedRemaining,
|
|
2059
|
-
pool.fee
|
|
2060
|
-
);
|
|
2061
|
-
if (exactInput) {
|
|
2062
|
-
state.amountSpecifiedRemaining -= step.amountIn + step.feeAmount;
|
|
2063
|
-
state.amountCalculated = state.amountCalculated - step.amountOut;
|
|
2064
|
-
} else {
|
|
2065
|
-
state.amountSpecifiedRemaining = state.amountSpecifiedRemaining + step.amountOut;
|
|
2066
|
-
state.amountCalculated = state.amountCalculated + (step.amountIn + step.feeAmount);
|
|
2067
|
-
}
|
|
2068
|
-
if (state.sqrtPriceX96 === step.sqrtPriceNextX96) {
|
|
2069
|
-
if (step.initialized) {
|
|
2070
|
-
let liquidityNet = BigInt((await pool.tickDataProvider.getTick(step.tickNext)).liquidityNet);
|
|
2071
|
-
if (zeroForOne)
|
|
2072
|
-
liquidityNet *= NEGATIVE_ONE;
|
|
2073
|
-
state.liquidity = LiquidityMath.addDelta(state.liquidity, liquidityNet);
|
|
2074
|
-
}
|
|
2075
|
-
state.tick = zeroForOne ? step.tickNext - 1 : step.tickNext;
|
|
2076
|
-
} else if (state.sqrtPriceX96 !== step.sqrtPriceStartX96) {
|
|
2077
|
-
state.tick = TickMath.getTickAtSqrtRatio(state.sqrtPriceX96);
|
|
2078
|
-
}
|
|
2079
|
-
}
|
|
2080
|
-
return {
|
|
2081
|
-
amountSpecifiedRemaining: state.amountSpecifiedRemaining,
|
|
2082
|
-
amountCalculated: state.amountCalculated,
|
|
2083
|
-
sqrtRatioX96: state.sqrtPriceX96,
|
|
2084
|
-
liquidity: state.liquidity,
|
|
2085
|
-
tickCurrent: state.tick
|
|
2086
|
-
};
|
|
2087
|
-
};
|
|
2088
|
-
var getOutputAmount = async (pool, inputAmount, options) => {
|
|
2089
|
-
invariant9(hasInvolvedCurrency(pool, inputAmount.currency), "CURRENCY");
|
|
2090
|
-
const zeroForOne = inputAmount.currency.equals(pool.currency0);
|
|
2091
|
-
const { sqrtPriceLimitX96, exact } = options || {};
|
|
2092
|
-
const {
|
|
2093
|
-
amountCalculated: outputAmount,
|
|
2094
|
-
sqrtRatioX96,
|
|
2095
|
-
liquidity,
|
|
2096
|
-
tickCurrent,
|
|
2097
|
-
amountSpecifiedRemaining
|
|
2098
|
-
} = await swap({
|
|
2099
|
-
pool,
|
|
2100
|
-
zeroForOne,
|
|
2101
|
-
amountSpecified: inputAmount.quotient,
|
|
2102
|
-
sqrtPriceLimitX96
|
|
2103
|
-
});
|
|
2104
|
-
const outputToken = zeroForOne ? pool.currency1 : pool.currency0;
|
|
2105
|
-
if (exact) {
|
|
2106
|
-
invariant9(amountSpecifiedRemaining === ZERO, "INSUFFICIENT_LIQUIDITY");
|
|
2107
|
-
}
|
|
2108
|
-
return [
|
|
2109
|
-
CurrencyAmount.fromRawAmount(outputToken, outputAmount * NEGATIVE_ONE),
|
|
2110
|
-
{
|
|
2111
|
-
...pool,
|
|
2112
|
-
sqrtRatioX96,
|
|
2113
|
-
liquidity,
|
|
2114
|
-
tickCurrent
|
|
2115
|
-
}
|
|
2116
|
-
];
|
|
2117
|
-
};
|
|
2118
|
-
var getInputAmount = async (pool, outputAmount, options) => {
|
|
2119
|
-
invariant9(hasInvolvedCurrency(pool, outputAmount.currency), "CURRENCY");
|
|
2120
|
-
const zeroForOne = outputAmount.currency.equals(pool.currency1);
|
|
2121
|
-
const { sqrtPriceLimitX96, exact } = options || {};
|
|
2122
|
-
const {
|
|
2123
|
-
amountCalculated: inputAmount,
|
|
2124
|
-
sqrtRatioX96,
|
|
2125
|
-
liquidity,
|
|
2126
|
-
tickCurrent,
|
|
2127
|
-
amountSpecifiedRemaining
|
|
2128
|
-
} = await swap({
|
|
2129
|
-
pool,
|
|
2130
|
-
zeroForOne,
|
|
2131
|
-
amountSpecified: outputAmount.quotient * NEGATIVE_ONE,
|
|
2132
|
-
sqrtPriceLimitX96
|
|
2133
|
-
});
|
|
2134
|
-
if (exact) {
|
|
2135
|
-
invariant9(amountSpecifiedRemaining === ZERO, "INSUFFICIENT_LIQUIDITY");
|
|
2136
|
-
}
|
|
2137
|
-
const inputCurrency = zeroForOne ? pool.currency0 : pool.currency1;
|
|
2138
|
-
return [
|
|
2139
|
-
CurrencyAmount.fromRawAmount(inputCurrency, inputAmount),
|
|
2140
|
-
{
|
|
2141
|
-
...pool,
|
|
2142
|
-
sqrtRatioX96,
|
|
2143
|
-
liquidity,
|
|
2144
|
-
tickCurrent
|
|
2145
|
-
}
|
|
2146
|
-
];
|
|
2147
|
-
};
|
|
2148
1680
|
var IMulticall = [
|
|
2149
1681
|
{
|
|
2150
1682
|
inputs: [
|
|
@@ -6259,462 +5791,6 @@ var _SwapRouter = class {
|
|
|
6259
5791
|
};
|
|
6260
5792
|
var SwapRouter = _SwapRouter;
|
|
6261
5793
|
SwapRouter.ABI = swapRouterABI;
|
|
6262
|
-
var pancakeV3PoolABI = [
|
|
6263
|
-
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
6264
|
-
{
|
|
6265
|
-
anonymous: false,
|
|
6266
|
-
inputs: [
|
|
6267
|
-
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
6268
|
-
{ indexed: true, internalType: "int24", name: "tickLower", type: "int24" },
|
|
6269
|
-
{ indexed: true, internalType: "int24", name: "tickUpper", type: "int24" },
|
|
6270
|
-
{ indexed: false, internalType: "uint128", name: "amount", type: "uint128" },
|
|
6271
|
-
{ indexed: false, internalType: "uint256", name: "amount0", type: "uint256" },
|
|
6272
|
-
{ indexed: false, internalType: "uint256", name: "amount1", type: "uint256" }
|
|
6273
|
-
],
|
|
6274
|
-
name: "Burn",
|
|
6275
|
-
type: "event"
|
|
6276
|
-
},
|
|
6277
|
-
{
|
|
6278
|
-
anonymous: false,
|
|
6279
|
-
inputs: [
|
|
6280
|
-
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
6281
|
-
{ indexed: false, internalType: "address", name: "recipient", type: "address" },
|
|
6282
|
-
{ indexed: true, internalType: "int24", name: "tickLower", type: "int24" },
|
|
6283
|
-
{ indexed: true, internalType: "int24", name: "tickUpper", type: "int24" },
|
|
6284
|
-
{ indexed: false, internalType: "uint128", name: "amount0", type: "uint128" },
|
|
6285
|
-
{ indexed: false, internalType: "uint128", name: "amount1", type: "uint128" }
|
|
6286
|
-
],
|
|
6287
|
-
name: "Collect",
|
|
6288
|
-
type: "event"
|
|
6289
|
-
},
|
|
6290
|
-
{
|
|
6291
|
-
anonymous: false,
|
|
6292
|
-
inputs: [
|
|
6293
|
-
{ indexed: true, internalType: "address", name: "sender", type: "address" },
|
|
6294
|
-
{ indexed: true, internalType: "address", name: "recipient", type: "address" },
|
|
6295
|
-
{ indexed: false, internalType: "uint128", name: "amount0", type: "uint128" },
|
|
6296
|
-
{ indexed: false, internalType: "uint128", name: "amount1", type: "uint128" }
|
|
6297
|
-
],
|
|
6298
|
-
name: "CollectProtocol",
|
|
6299
|
-
type: "event"
|
|
6300
|
-
},
|
|
6301
|
-
{
|
|
6302
|
-
anonymous: false,
|
|
6303
|
-
inputs: [
|
|
6304
|
-
{ indexed: true, internalType: "address", name: "sender", type: "address" },
|
|
6305
|
-
{ indexed: true, internalType: "address", name: "recipient", type: "address" },
|
|
6306
|
-
{ indexed: false, internalType: "uint256", name: "amount0", type: "uint256" },
|
|
6307
|
-
{ indexed: false, internalType: "uint256", name: "amount1", type: "uint256" },
|
|
6308
|
-
{ indexed: false, internalType: "uint256", name: "paid0", type: "uint256" },
|
|
6309
|
-
{ indexed: false, internalType: "uint256", name: "paid1", type: "uint256" }
|
|
6310
|
-
],
|
|
6311
|
-
name: "Flash",
|
|
6312
|
-
type: "event"
|
|
6313
|
-
},
|
|
6314
|
-
{
|
|
6315
|
-
anonymous: false,
|
|
6316
|
-
inputs: [
|
|
6317
|
-
{ indexed: false, internalType: "uint16", name: "observationCardinalityNextOld", type: "uint16" },
|
|
6318
|
-
{ indexed: false, internalType: "uint16", name: "observationCardinalityNextNew", type: "uint16" }
|
|
6319
|
-
],
|
|
6320
|
-
name: "IncreaseObservationCardinalityNext",
|
|
6321
|
-
type: "event"
|
|
6322
|
-
},
|
|
6323
|
-
{
|
|
6324
|
-
anonymous: false,
|
|
6325
|
-
inputs: [
|
|
6326
|
-
{ indexed: false, internalType: "uint160", name: "sqrtPriceX96", type: "uint160" },
|
|
6327
|
-
{ indexed: false, internalType: "int24", name: "tick", type: "int24" }
|
|
6328
|
-
],
|
|
6329
|
-
name: "Initialize",
|
|
6330
|
-
type: "event"
|
|
6331
|
-
},
|
|
6332
|
-
{
|
|
6333
|
-
anonymous: false,
|
|
6334
|
-
inputs: [
|
|
6335
|
-
{ indexed: false, internalType: "address", name: "sender", type: "address" },
|
|
6336
|
-
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
6337
|
-
{ indexed: true, internalType: "int24", name: "tickLower", type: "int24" },
|
|
6338
|
-
{ indexed: true, internalType: "int24", name: "tickUpper", type: "int24" },
|
|
6339
|
-
{ indexed: false, internalType: "uint128", name: "amount", type: "uint128" },
|
|
6340
|
-
{ indexed: false, internalType: "uint256", name: "amount0", type: "uint256" },
|
|
6341
|
-
{ indexed: false, internalType: "uint256", name: "amount1", type: "uint256" }
|
|
6342
|
-
],
|
|
6343
|
-
name: "Mint",
|
|
6344
|
-
type: "event"
|
|
6345
|
-
},
|
|
6346
|
-
{
|
|
6347
|
-
anonymous: false,
|
|
6348
|
-
inputs: [
|
|
6349
|
-
{ indexed: false, internalType: "uint32", name: "feeProtocol0Old", type: "uint32" },
|
|
6350
|
-
{ indexed: false, internalType: "uint32", name: "feeProtocol1Old", type: "uint32" },
|
|
6351
|
-
{ indexed: false, internalType: "uint32", name: "feeProtocol0New", type: "uint32" },
|
|
6352
|
-
{ indexed: false, internalType: "uint32", name: "feeProtocol1New", type: "uint32" }
|
|
6353
|
-
],
|
|
6354
|
-
name: "SetFeeProtocol",
|
|
6355
|
-
type: "event"
|
|
6356
|
-
},
|
|
6357
|
-
{
|
|
6358
|
-
anonymous: false,
|
|
6359
|
-
inputs: [{ indexed: false, internalType: "address", name: "addr", type: "address" }],
|
|
6360
|
-
name: "SetLmPoolEvent",
|
|
6361
|
-
type: "event"
|
|
6362
|
-
},
|
|
6363
|
-
{
|
|
6364
|
-
anonymous: false,
|
|
6365
|
-
inputs: [
|
|
6366
|
-
{ indexed: true, internalType: "address", name: "sender", type: "address" },
|
|
6367
|
-
{ indexed: true, internalType: "address", name: "recipient", type: "address" },
|
|
6368
|
-
{ indexed: false, internalType: "int256", name: "amount0", type: "int256" },
|
|
6369
|
-
{ indexed: false, internalType: "int256", name: "amount1", type: "int256" },
|
|
6370
|
-
{ indexed: false, internalType: "uint160", name: "sqrtPriceX96", type: "uint160" },
|
|
6371
|
-
{ indexed: false, internalType: "uint128", name: "liquidity", type: "uint128" },
|
|
6372
|
-
{ indexed: false, internalType: "int24", name: "tick", type: "int24" },
|
|
6373
|
-
{ indexed: false, internalType: "uint128", name: "protocolFeesToken0", type: "uint128" },
|
|
6374
|
-
{ indexed: false, internalType: "uint128", name: "protocolFeesToken1", type: "uint128" }
|
|
6375
|
-
],
|
|
6376
|
-
name: "Swap",
|
|
6377
|
-
type: "event"
|
|
6378
|
-
},
|
|
6379
|
-
{
|
|
6380
|
-
inputs: [
|
|
6381
|
-
{ internalType: "int24", name: "tickLower", type: "int24" },
|
|
6382
|
-
{ internalType: "int24", name: "tickUpper", type: "int24" },
|
|
6383
|
-
{ internalType: "uint128", name: "amount", type: "uint128" }
|
|
6384
|
-
],
|
|
6385
|
-
name: "burn",
|
|
6386
|
-
outputs: [
|
|
6387
|
-
{ internalType: "uint256", name: "amount0", type: "uint256" },
|
|
6388
|
-
{ internalType: "uint256", name: "amount1", type: "uint256" }
|
|
6389
|
-
],
|
|
6390
|
-
stateMutability: "nonpayable",
|
|
6391
|
-
type: "function"
|
|
6392
|
-
},
|
|
6393
|
-
{
|
|
6394
|
-
inputs: [
|
|
6395
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
6396
|
-
{ internalType: "int24", name: "tickLower", type: "int24" },
|
|
6397
|
-
{ internalType: "int24", name: "tickUpper", type: "int24" },
|
|
6398
|
-
{ internalType: "uint128", name: "amount0Requested", type: "uint128" },
|
|
6399
|
-
{ internalType: "uint128", name: "amount1Requested", type: "uint128" }
|
|
6400
|
-
],
|
|
6401
|
-
name: "collect",
|
|
6402
|
-
outputs: [
|
|
6403
|
-
{ internalType: "uint128", name: "amount0", type: "uint128" },
|
|
6404
|
-
{ internalType: "uint128", name: "amount1", type: "uint128" }
|
|
6405
|
-
],
|
|
6406
|
-
stateMutability: "nonpayable",
|
|
6407
|
-
type: "function"
|
|
6408
|
-
},
|
|
6409
|
-
{
|
|
6410
|
-
inputs: [
|
|
6411
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
6412
|
-
{ internalType: "uint128", name: "amount0Requested", type: "uint128" },
|
|
6413
|
-
{ internalType: "uint128", name: "amount1Requested", type: "uint128" }
|
|
6414
|
-
],
|
|
6415
|
-
name: "collectProtocol",
|
|
6416
|
-
outputs: [
|
|
6417
|
-
{ internalType: "uint128", name: "amount0", type: "uint128" },
|
|
6418
|
-
{ internalType: "uint128", name: "amount1", type: "uint128" }
|
|
6419
|
-
],
|
|
6420
|
-
stateMutability: "nonpayable",
|
|
6421
|
-
type: "function"
|
|
6422
|
-
},
|
|
6423
|
-
{
|
|
6424
|
-
inputs: [],
|
|
6425
|
-
name: "factory",
|
|
6426
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6427
|
-
stateMutability: "view",
|
|
6428
|
-
type: "function"
|
|
6429
|
-
},
|
|
6430
|
-
{
|
|
6431
|
-
inputs: [],
|
|
6432
|
-
name: "fee",
|
|
6433
|
-
outputs: [{ internalType: "uint24", name: "", type: "uint24" }],
|
|
6434
|
-
stateMutability: "view",
|
|
6435
|
-
type: "function"
|
|
6436
|
-
},
|
|
6437
|
-
{
|
|
6438
|
-
inputs: [],
|
|
6439
|
-
name: "feeGrowthGlobal0X128",
|
|
6440
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
6441
|
-
stateMutability: "view",
|
|
6442
|
-
type: "function"
|
|
6443
|
-
},
|
|
6444
|
-
{
|
|
6445
|
-
inputs: [],
|
|
6446
|
-
name: "feeGrowthGlobal1X128",
|
|
6447
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
6448
|
-
stateMutability: "view",
|
|
6449
|
-
type: "function"
|
|
6450
|
-
},
|
|
6451
|
-
{
|
|
6452
|
-
inputs: [
|
|
6453
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
6454
|
-
{ internalType: "uint256", name: "amount0", type: "uint256" },
|
|
6455
|
-
{ internalType: "uint256", name: "amount1", type: "uint256" },
|
|
6456
|
-
{ internalType: "bytes", name: "data", type: "bytes" }
|
|
6457
|
-
],
|
|
6458
|
-
name: "flash",
|
|
6459
|
-
outputs: [],
|
|
6460
|
-
stateMutability: "nonpayable",
|
|
6461
|
-
type: "function"
|
|
6462
|
-
},
|
|
6463
|
-
{
|
|
6464
|
-
inputs: [{ internalType: "uint16", name: "observationCardinalityNext", type: "uint16" }],
|
|
6465
|
-
name: "increaseObservationCardinalityNext",
|
|
6466
|
-
outputs: [],
|
|
6467
|
-
stateMutability: "nonpayable",
|
|
6468
|
-
type: "function"
|
|
6469
|
-
},
|
|
6470
|
-
{
|
|
6471
|
-
inputs: [{ internalType: "uint160", name: "sqrtPriceX96", type: "uint160" }],
|
|
6472
|
-
name: "initialize",
|
|
6473
|
-
outputs: [],
|
|
6474
|
-
stateMutability: "nonpayable",
|
|
6475
|
-
type: "function"
|
|
6476
|
-
},
|
|
6477
|
-
{
|
|
6478
|
-
inputs: [],
|
|
6479
|
-
name: "liquidity",
|
|
6480
|
-
outputs: [{ internalType: "uint128", name: "", type: "uint128" }],
|
|
6481
|
-
stateMutability: "view",
|
|
6482
|
-
type: "function"
|
|
6483
|
-
},
|
|
6484
|
-
{
|
|
6485
|
-
inputs: [],
|
|
6486
|
-
name: "lmPool",
|
|
6487
|
-
outputs: [{ internalType: "contract IPancakeV3LmPool", name: "", type: "address" }],
|
|
6488
|
-
stateMutability: "view",
|
|
6489
|
-
type: "function"
|
|
6490
|
-
},
|
|
6491
|
-
{
|
|
6492
|
-
inputs: [],
|
|
6493
|
-
name: "maxLiquidityPerTick",
|
|
6494
|
-
outputs: [{ internalType: "uint128", name: "", type: "uint128" }],
|
|
6495
|
-
stateMutability: "view",
|
|
6496
|
-
type: "function"
|
|
6497
|
-
},
|
|
6498
|
-
{
|
|
6499
|
-
inputs: [
|
|
6500
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
6501
|
-
{ internalType: "int24", name: "tickLower", type: "int24" },
|
|
6502
|
-
{ internalType: "int24", name: "tickUpper", type: "int24" },
|
|
6503
|
-
{ internalType: "uint128", name: "amount", type: "uint128" },
|
|
6504
|
-
{ internalType: "bytes", name: "data", type: "bytes" }
|
|
6505
|
-
],
|
|
6506
|
-
name: "mint",
|
|
6507
|
-
outputs: [
|
|
6508
|
-
{ internalType: "uint256", name: "amount0", type: "uint256" },
|
|
6509
|
-
{ internalType: "uint256", name: "amount1", type: "uint256" }
|
|
6510
|
-
],
|
|
6511
|
-
stateMutability: "nonpayable",
|
|
6512
|
-
type: "function"
|
|
6513
|
-
},
|
|
6514
|
-
{
|
|
6515
|
-
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
6516
|
-
name: "observations",
|
|
6517
|
-
outputs: [
|
|
6518
|
-
{ internalType: "uint32", name: "blockTimestamp", type: "uint32" },
|
|
6519
|
-
{ internalType: "int56", name: "tickCumulative", type: "int56" },
|
|
6520
|
-
{ internalType: "uint160", name: "secondsPerLiquidityCumulativeX128", type: "uint160" },
|
|
6521
|
-
{ internalType: "bool", name: "initialized", type: "bool" }
|
|
6522
|
-
],
|
|
6523
|
-
stateMutability: "view",
|
|
6524
|
-
type: "function"
|
|
6525
|
-
},
|
|
6526
|
-
{
|
|
6527
|
-
inputs: [{ internalType: "uint32[]", name: "secondsAgos", type: "uint32[]" }],
|
|
6528
|
-
name: "observe",
|
|
6529
|
-
outputs: [
|
|
6530
|
-
{ internalType: "int56[]", name: "tickCumulatives", type: "int56[]" },
|
|
6531
|
-
{ internalType: "uint160[]", name: "secondsPerLiquidityCumulativeX128s", type: "uint160[]" }
|
|
6532
|
-
],
|
|
6533
|
-
stateMutability: "view",
|
|
6534
|
-
type: "function"
|
|
6535
|
-
},
|
|
6536
|
-
{
|
|
6537
|
-
inputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
6538
|
-
name: "positions",
|
|
6539
|
-
outputs: [
|
|
6540
|
-
{ internalType: "uint128", name: "liquidity", type: "uint128" },
|
|
6541
|
-
{ internalType: "uint256", name: "feeGrowthInside0LastX128", type: "uint256" },
|
|
6542
|
-
{ internalType: "uint256", name: "feeGrowthInside1LastX128", type: "uint256" },
|
|
6543
|
-
{ internalType: "uint128", name: "tokensOwed0", type: "uint128" },
|
|
6544
|
-
{ internalType: "uint128", name: "tokensOwed1", type: "uint128" }
|
|
6545
|
-
],
|
|
6546
|
-
stateMutability: "view",
|
|
6547
|
-
type: "function"
|
|
6548
|
-
},
|
|
6549
|
-
{
|
|
6550
|
-
inputs: [],
|
|
6551
|
-
name: "protocolFees",
|
|
6552
|
-
outputs: [
|
|
6553
|
-
{ internalType: "uint128", name: "token0", type: "uint128" },
|
|
6554
|
-
{ internalType: "uint128", name: "token1", type: "uint128" }
|
|
6555
|
-
],
|
|
6556
|
-
stateMutability: "view",
|
|
6557
|
-
type: "function"
|
|
6558
|
-
},
|
|
6559
|
-
{
|
|
6560
|
-
inputs: [
|
|
6561
|
-
{ internalType: "uint32", name: "feeProtocol0", type: "uint32" },
|
|
6562
|
-
{ internalType: "uint32", name: "feeProtocol1", type: "uint32" }
|
|
6563
|
-
],
|
|
6564
|
-
name: "setFeeProtocol",
|
|
6565
|
-
outputs: [],
|
|
6566
|
-
stateMutability: "nonpayable",
|
|
6567
|
-
type: "function"
|
|
6568
|
-
},
|
|
6569
|
-
{
|
|
6570
|
-
inputs: [{ internalType: "address", name: "_lmPool", type: "address" }],
|
|
6571
|
-
name: "setLmPool",
|
|
6572
|
-
outputs: [],
|
|
6573
|
-
stateMutability: "nonpayable",
|
|
6574
|
-
type: "function"
|
|
6575
|
-
},
|
|
6576
|
-
{
|
|
6577
|
-
inputs: [],
|
|
6578
|
-
name: "slot0",
|
|
6579
|
-
outputs: [
|
|
6580
|
-
{ internalType: "uint160", name: "sqrtPriceX96", type: "uint160" },
|
|
6581
|
-
{ internalType: "int24", name: "tick", type: "int24" },
|
|
6582
|
-
{ internalType: "uint16", name: "observationIndex", type: "uint16" },
|
|
6583
|
-
{ internalType: "uint16", name: "observationCardinality", type: "uint16" },
|
|
6584
|
-
{ internalType: "uint16", name: "observationCardinalityNext", type: "uint16" },
|
|
6585
|
-
{ internalType: "uint32", name: "feeProtocol", type: "uint32" },
|
|
6586
|
-
{ internalType: "bool", name: "unlocked", type: "bool" }
|
|
6587
|
-
],
|
|
6588
|
-
stateMutability: "view",
|
|
6589
|
-
type: "function"
|
|
6590
|
-
},
|
|
6591
|
-
{
|
|
6592
|
-
inputs: [
|
|
6593
|
-
{ internalType: "int24", name: "tickLower", type: "int24" },
|
|
6594
|
-
{ internalType: "int24", name: "tickUpper", type: "int24" }
|
|
6595
|
-
],
|
|
6596
|
-
name: "snapshotCumulativesInside",
|
|
6597
|
-
outputs: [
|
|
6598
|
-
{ internalType: "int56", name: "tickCumulativeInside", type: "int56" },
|
|
6599
|
-
{ internalType: "uint160", name: "secondsPerLiquidityInsideX128", type: "uint160" },
|
|
6600
|
-
{ internalType: "uint32", name: "secondsInside", type: "uint32" }
|
|
6601
|
-
],
|
|
6602
|
-
stateMutability: "view",
|
|
6603
|
-
type: "function"
|
|
6604
|
-
},
|
|
6605
|
-
{
|
|
6606
|
-
inputs: [
|
|
6607
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
6608
|
-
{ internalType: "bool", name: "zeroForOne", type: "bool" },
|
|
6609
|
-
{ internalType: "int256", name: "amountSpecified", type: "int256" },
|
|
6610
|
-
{ internalType: "uint160", name: "sqrtPriceLimitX96", type: "uint160" },
|
|
6611
|
-
{ internalType: "bytes", name: "data", type: "bytes" }
|
|
6612
|
-
],
|
|
6613
|
-
name: "swap",
|
|
6614
|
-
outputs: [
|
|
6615
|
-
{ internalType: "int256", name: "amount0", type: "int256" },
|
|
6616
|
-
{ internalType: "int256", name: "amount1", type: "int256" }
|
|
6617
|
-
],
|
|
6618
|
-
stateMutability: "nonpayable",
|
|
6619
|
-
type: "function"
|
|
6620
|
-
},
|
|
6621
|
-
{
|
|
6622
|
-
inputs: [{ internalType: "int16", name: "", type: "int16" }],
|
|
6623
|
-
name: "tickBitmap",
|
|
6624
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
6625
|
-
stateMutability: "view",
|
|
6626
|
-
type: "function"
|
|
6627
|
-
},
|
|
6628
|
-
{
|
|
6629
|
-
inputs: [],
|
|
6630
|
-
name: "tickSpacing",
|
|
6631
|
-
outputs: [{ internalType: "int24", name: "", type: "int24" }],
|
|
6632
|
-
stateMutability: "view",
|
|
6633
|
-
type: "function"
|
|
6634
|
-
},
|
|
6635
|
-
{
|
|
6636
|
-
inputs: [{ internalType: "int24", name: "", type: "int24" }],
|
|
6637
|
-
name: "ticks",
|
|
6638
|
-
outputs: [
|
|
6639
|
-
{ internalType: "uint128", name: "liquidityGross", type: "uint128" },
|
|
6640
|
-
{ internalType: "int128", name: "liquidityNet", type: "int128" },
|
|
6641
|
-
{ internalType: "uint256", name: "feeGrowthOutside0X128", type: "uint256" },
|
|
6642
|
-
{ internalType: "uint256", name: "feeGrowthOutside1X128", type: "uint256" },
|
|
6643
|
-
{ internalType: "int56", name: "tickCumulativeOutside", type: "int56" },
|
|
6644
|
-
{ internalType: "uint160", name: "secondsPerLiquidityOutsideX128", type: "uint160" },
|
|
6645
|
-
{ internalType: "uint32", name: "secondsOutside", type: "uint32" },
|
|
6646
|
-
{ internalType: "bool", name: "initialized", type: "bool" }
|
|
6647
|
-
],
|
|
6648
|
-
stateMutability: "view",
|
|
6649
|
-
type: "function"
|
|
6650
|
-
},
|
|
6651
|
-
{
|
|
6652
|
-
inputs: [],
|
|
6653
|
-
name: "token0",
|
|
6654
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6655
|
-
stateMutability: "view",
|
|
6656
|
-
type: "function"
|
|
6657
|
-
},
|
|
6658
|
-
{
|
|
6659
|
-
inputs: [],
|
|
6660
|
-
name: "token1",
|
|
6661
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6662
|
-
stateMutability: "view",
|
|
6663
|
-
type: "function"
|
|
6664
|
-
}
|
|
6665
|
-
];
|
|
6666
|
-
var v3PoolAbi = [
|
|
6667
|
-
{
|
|
6668
|
-
inputs: [],
|
|
6669
|
-
name: "liquidity",
|
|
6670
|
-
outputs: [{ internalType: "uint128", name: "", type: "uint128" }],
|
|
6671
|
-
stateMutability: "view",
|
|
6672
|
-
type: "function"
|
|
6673
|
-
},
|
|
6674
|
-
{
|
|
6675
|
-
inputs: [],
|
|
6676
|
-
name: "slot0",
|
|
6677
|
-
outputs: [
|
|
6678
|
-
{
|
|
6679
|
-
internalType: "uint160",
|
|
6680
|
-
name: "sqrtPriceX96",
|
|
6681
|
-
type: "uint160"
|
|
6682
|
-
},
|
|
6683
|
-
{
|
|
6684
|
-
internalType: "int24",
|
|
6685
|
-
name: "tick",
|
|
6686
|
-
type: "int24"
|
|
6687
|
-
},
|
|
6688
|
-
{
|
|
6689
|
-
internalType: "uint16",
|
|
6690
|
-
name: "observationIndex",
|
|
6691
|
-
type: "uint16"
|
|
6692
|
-
},
|
|
6693
|
-
{
|
|
6694
|
-
internalType: "uint16",
|
|
6695
|
-
name: "observationCardinality",
|
|
6696
|
-
type: "uint16"
|
|
6697
|
-
},
|
|
6698
|
-
{
|
|
6699
|
-
internalType: "uint16",
|
|
6700
|
-
name: "observationCardinalityNext",
|
|
6701
|
-
type: "uint16"
|
|
6702
|
-
},
|
|
6703
|
-
{
|
|
6704
|
-
internalType: "uint32",
|
|
6705
|
-
name: "feeProtocol",
|
|
6706
|
-
type: "uint32"
|
|
6707
|
-
},
|
|
6708
|
-
{
|
|
6709
|
-
internalType: "bool",
|
|
6710
|
-
name: "unlocked",
|
|
6711
|
-
type: "bool"
|
|
6712
|
-
}
|
|
6713
|
-
],
|
|
6714
|
-
stateMutability: "view",
|
|
6715
|
-
type: "function"
|
|
6716
|
-
}
|
|
6717
|
-
];
|
|
6718
5794
|
|
|
6719
5795
|
// src/abi/ClassicFactory.json
|
|
6720
5796
|
var ClassicFactory_default = [
|
|
@@ -21710,7 +20786,7 @@ function toCLFeeAmount(_fee) {
|
|
|
21710
20786
|
invariant(isCLFeeAmount(_fee), `unsupported CL fee tier: ${_fee}`);
|
|
21711
20787
|
return _fee;
|
|
21712
20788
|
}
|
|
21713
|
-
function
|
|
20789
|
+
function toPoolFeeAmount(_fee) {
|
|
21714
20790
|
return toCLFeeAmount(_fee);
|
|
21715
20791
|
}
|
|
21716
20792
|
function getCLTickSpacing(_fee) {
|
|
@@ -21721,7 +20797,7 @@ function createCLPool(_params) {
|
|
|
21721
20797
|
return new Pool(
|
|
21722
20798
|
_params.tokenA,
|
|
21723
20799
|
_params.tokenB,
|
|
21724
|
-
|
|
20800
|
+
toPoolFeeAmount(_params.fee),
|
|
21725
20801
|
_params.sqrtRatioX96,
|
|
21726
20802
|
_params.liquidity,
|
|
21727
20803
|
_params.tickCurrent,
|
|
@@ -21733,17 +20809,10 @@ function computeCLPoolAddress(_params) {
|
|
|
21733
20809
|
deployerAddress: _params.config.clPoolDeployer,
|
|
21734
20810
|
tokenA: _params.tokenA,
|
|
21735
20811
|
tokenB: _params.tokenB,
|
|
21736
|
-
fee:
|
|
20812
|
+
fee: toPoolFeeAmount(_params.fee),
|
|
21737
20813
|
initCodeHashManualOverride: _params.config.clInitCodeHash ?? APEX_CL_POOL_INIT_CODE_HASH
|
|
21738
20814
|
});
|
|
21739
20815
|
}
|
|
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;
|
|
21746
|
-
var computeApexCLPoolAddress = computeCLPoolAddress;
|
|
21747
20816
|
|
|
21748
20817
|
// src/classic.ts
|
|
21749
20818
|
import invariant2 from "tiny-invariant";
|
|
@@ -21774,7 +20843,6 @@ function computeClassicPoolAddress(_params) {
|
|
|
21774
20843
|
_params.config.classicPairInitCodeHash ?? APEX_CLASSIC_PAIR_INIT_CODE_HASH
|
|
21775
20844
|
);
|
|
21776
20845
|
}
|
|
21777
|
-
var computeApexClassicPairAddress = computeClassicPoolAddress;
|
|
21778
20846
|
function quoteClassicExactInput(_params) {
|
|
21779
20847
|
const tokenIn = normalizeAddress(_params.tokenIn);
|
|
21780
20848
|
const token0 = normalizeAddress(_params.token0);
|
|
@@ -21802,7 +20870,6 @@ function quoteClassicExactInput(_params) {
|
|
|
21802
20870
|
invariant2(amountOut > 0n, "INSUFFICIENT_OUTPUT_AMOUNT");
|
|
21803
20871
|
return amountOut - 1n;
|
|
21804
20872
|
}
|
|
21805
|
-
var quoteApexClassicExactInput = quoteClassicExactInput;
|
|
21806
20873
|
function getVolatileAmountOut(_params) {
|
|
21807
20874
|
const reserveA = _params.tokenIn === _params.token0 ? _params.reserve0 : _params.reserve1;
|
|
21808
20875
|
const reserveB = _params.tokenIn === _params.token0 ? _params.reserve1 : _params.reserve0;
|
|
@@ -22098,9 +21165,6 @@ var CLMasterChef = class _CLMasterChef {
|
|
|
22098
21165
|
});
|
|
22099
21166
|
}
|
|
22100
21167
|
};
|
|
22101
|
-
var APEX_MAX_UINT128 = MAX_UINT128;
|
|
22102
|
-
var ApexClassicFarm = ClassicChef;
|
|
22103
|
-
var ApexCLFarm = CLMasterChef;
|
|
22104
21168
|
function formatMintParams(_params) {
|
|
22105
21169
|
return {
|
|
22106
21170
|
token0: normalizeAddress2(_params.token0),
|
|
@@ -22167,9 +21231,9 @@ import invariant4 from "tiny-invariant";
|
|
|
22167
21231
|
import { encodePacked as encodePacked3, getAddress as getAddress4, isAddress as isAddress3 } from "viem";
|
|
22168
21232
|
var APEX_MIXED_ROUTE_CLASSIC_STABLE = 8388608;
|
|
22169
21233
|
var APEX_MIXED_ROUTE_CLASSIC_VOLATILE = 8388609;
|
|
22170
|
-
var
|
|
22171
|
-
var
|
|
22172
|
-
var
|
|
21234
|
+
var APEX_MIXED_ROUTE_CLASSIC_PLACEHOLDER = APEX_MIXED_ROUTE_CLASSIC_STABLE;
|
|
21235
|
+
var APEX_MIXED_ROUTE_VOLATILE_FLAG = 1;
|
|
21236
|
+
var APEX_MIXED_ROUTE_STABLE_FLAG = 2;
|
|
22173
21237
|
function encodeMixedRouteToPath(_hops, _exactOutput = false) {
|
|
22174
21238
|
invariant4(_hops.length > 0, "empty route");
|
|
22175
21239
|
assertContinuousRoute(_hops);
|
|
@@ -22182,7 +21246,7 @@ function encodeMixedRouteToPath(_hops, _exactOutput = false) {
|
|
|
22182
21246
|
}
|
|
22183
21247
|
return encodePacked3(types, values);
|
|
22184
21248
|
}
|
|
22185
|
-
function
|
|
21249
|
+
function encodeMixedRouteToQuoteParams(_hops, _exactOutput = false) {
|
|
22186
21250
|
invariant4(_hops.length > 0, "empty route");
|
|
22187
21251
|
assertContinuousRoute(_hops);
|
|
22188
21252
|
const hops = _exactOutput ? reverseRoute(_hops) : [..._hops];
|
|
@@ -22191,9 +21255,9 @@ function encodeMixedRouteToPancakeQuoteParams(_hops, _exactOutput = false) {
|
|
|
22191
21255
|
const flags = [];
|
|
22192
21256
|
for (const hop of hops) {
|
|
22193
21257
|
types.push("uint24", "address");
|
|
22194
|
-
values.push(
|
|
22195
|
-
if (hop.kind === "CLASSIC_STABLE") flags.push(
|
|
22196
|
-
if (hop.kind === "CLASSIC_VOLATILE") flags.push(
|
|
21258
|
+
values.push(quoteRouteCode(hop), normalizeAddress3(hop.tokenOut));
|
|
21259
|
+
if (hop.kind === "CLASSIC_STABLE") flags.push(APEX_MIXED_ROUTE_STABLE_FLAG);
|
|
21260
|
+
if (hop.kind === "CLASSIC_VOLATILE") flags.push(APEX_MIXED_ROUTE_VOLATILE_FLAG);
|
|
22197
21261
|
}
|
|
22198
21262
|
return { path: encodePacked3(types, values), flags };
|
|
22199
21263
|
}
|
|
@@ -22241,16 +21305,13 @@ function routeCode(_hop) {
|
|
|
22241
21305
|
invariant4(Number.isInteger(_hop.fee) && _hop.fee >= 0 && _hop.fee <= 8388607, "invalid CL fee");
|
|
22242
21306
|
return _hop.fee;
|
|
22243
21307
|
}
|
|
22244
|
-
function
|
|
21308
|
+
function quoteRouteCode(_hop) {
|
|
22245
21309
|
if (_hop.kind === "CL") {
|
|
22246
21310
|
invariant4(Number.isInteger(_hop.fee) && _hop.fee >= 0 && _hop.fee <= 8388607, "invalid CL fee");
|
|
22247
21311
|
return _hop.fee;
|
|
22248
21312
|
}
|
|
22249
|
-
return
|
|
21313
|
+
return APEX_MIXED_ROUTE_CLASSIC_PLACEHOLDER;
|
|
22250
21314
|
}
|
|
22251
|
-
var encodeApexMixedRouteToPath = encodeMixedRouteToPath;
|
|
22252
|
-
var encodeApexMixedRouteToPancakeQuoteParams = encodeMixedRouteToPancakeQuoteParams;
|
|
22253
|
-
var decodeApexMixedRoutePath = decodeMixedRoutePath;
|
|
22254
21315
|
function normalizeAddress3(_address) {
|
|
22255
21316
|
invariant4(isAddress3(_address), `invalid address: ${_address}`);
|
|
22256
21317
|
return getAddress4(_address);
|
|
@@ -22271,8 +21332,6 @@ function parseProtocolFeePacked(_feeProtocol) {
|
|
|
22271
21332
|
token1ProtocolFee: packed / APEX_CL_PROTOCOL_FEE_SPACING
|
|
22272
21333
|
};
|
|
22273
21334
|
}
|
|
22274
|
-
var packApexProtocolFees = packProtocolFees;
|
|
22275
|
-
var parseApexProtocolFeePacked = parseProtocolFeePacked;
|
|
22276
21335
|
|
|
22277
21336
|
// src/smartRouter.ts
|
|
22278
21337
|
import invariant5 from "tiny-invariant";
|
|
@@ -22434,12 +21493,16 @@ var SmartRouter = class _SmartRouter {
|
|
|
22434
21493
|
});
|
|
22435
21494
|
}
|
|
22436
21495
|
};
|
|
22437
|
-
var ApexSmartRouter = SmartRouter;
|
|
22438
21496
|
function callParameters(_calldatas, _options) {
|
|
22439
|
-
|
|
21497
|
+
const value = toBigInt3(_options.value ?? 0n);
|
|
21498
|
+
const payments = [..._options.payments ?? []];
|
|
21499
|
+
if (value > 0n && !payments.some((payment) => payment.kind === "REFUND_ETH")) {
|
|
21500
|
+
payments.push({ kind: "REFUND_ETH" });
|
|
21501
|
+
}
|
|
21502
|
+
for (const payment of payments) _calldatas.push(encodePayment(payment));
|
|
22440
21503
|
return {
|
|
22441
21504
|
calldata: SmartRouter.encodeMulticall(_calldatas, _options.deadlineOrPreviousBlockhash),
|
|
22442
|
-
value: toHexValue2(
|
|
21505
|
+
value: toHexValue2(value)
|
|
22443
21506
|
};
|
|
22444
21507
|
}
|
|
22445
21508
|
function encodePayment(_payment) {
|
|
@@ -22473,7 +21536,6 @@ var APEX_VAULT_BPS = 1e4;
|
|
|
22473
21536
|
function getApexVaultCompoundBucket(_veNFT) {
|
|
22474
21537
|
return normalizeAddress5(_veNFT);
|
|
22475
21538
|
}
|
|
22476
|
-
var apexVaultCompoundBucket = getApexVaultCompoundBucket;
|
|
22477
21539
|
var ApexVault = class _ApexVault {
|
|
22478
21540
|
constructor() {
|
|
22479
21541
|
}
|
|
@@ -22575,7 +21637,6 @@ var ApexVault = class _ApexVault {
|
|
|
22575
21637
|
});
|
|
22576
21638
|
}
|
|
22577
21639
|
};
|
|
22578
|
-
var ApexVaultPosition = ApexVault;
|
|
22579
21640
|
function validateApexVaultUserConfig(_config) {
|
|
22580
21641
|
formatVaultConfig(_config);
|
|
22581
21642
|
}
|
|
@@ -22629,169 +21690,73 @@ function selectFunctionAbi(_abi, _name, _inputCount) {
|
|
|
22629
21690
|
return [item];
|
|
22630
21691
|
}
|
|
22631
21692
|
export {
|
|
22632
|
-
ADDRESS_ZERO,
|
|
22633
21693
|
APEX_CLASSIC_FEE_DENOMINATOR,
|
|
22634
21694
|
APEX_CLASSIC_PAIR_INIT_CODE_HASH,
|
|
22635
21695
|
APEX_CL_POOL_INIT_CODE_HASH,
|
|
22636
21696
|
APEX_CL_PROTOCOL_FEE_DENOMINATOR,
|
|
22637
21697
|
APEX_CL_PROTOCOL_FEE_SPACING,
|
|
22638
|
-
|
|
22639
|
-
APEX_MAX_UINT128,
|
|
21698
|
+
APEX_MIXED_ROUTE_CLASSIC_PLACEHOLDER,
|
|
22640
21699
|
APEX_MIXED_ROUTE_CLASSIC_STABLE,
|
|
22641
21700
|
APEX_MIXED_ROUTE_CLASSIC_VOLATILE,
|
|
22642
|
-
|
|
22643
|
-
|
|
22644
|
-
APEX_MIXED_ROUTE_PANCAKE_VOLATILE_FLAG,
|
|
21701
|
+
APEX_MIXED_ROUTE_STABLE_FLAG,
|
|
21702
|
+
APEX_MIXED_ROUTE_VOLATILE_FLAG,
|
|
22645
21703
|
APEX_VAULT_BPS,
|
|
22646
|
-
ApexCLFarm,
|
|
22647
|
-
ApexClassicFarm,
|
|
22648
|
-
CLFeeAmount as ApexFeeAmount,
|
|
22649
|
-
ApexSmartRouter,
|
|
22650
21704
|
ApexVault,
|
|
22651
|
-
ApexVaultPosition,
|
|
22652
21705
|
CLFeeAmount,
|
|
22653
21706
|
CLMasterChef,
|
|
22654
21707
|
CL_TICK_SPACINGS,
|
|
22655
21708
|
ClassicChef,
|
|
22656
|
-
DEPLOYER_ADDRESSES,
|
|
22657
|
-
FACTORY_ADDRESSES,
|
|
22658
|
-
FeeAmount,
|
|
22659
|
-
FeeCalculator,
|
|
22660
|
-
FullMath,
|
|
22661
|
-
LiquidityMath,
|
|
22662
21709
|
MAX_UINT128,
|
|
22663
|
-
MasterChefV3,
|
|
22664
|
-
MaxUint128,
|
|
22665
|
-
Multicall,
|
|
22666
|
-
NFT_POSITION_MANAGER_ADDRESSES,
|
|
22667
|
-
NoTickDataProvider,
|
|
22668
21710
|
NonfungiblePositionManager,
|
|
22669
|
-
POOL_INIT_CODE_HASHES,
|
|
22670
|
-
Payments,
|
|
22671
21711
|
Pool,
|
|
22672
21712
|
Position,
|
|
22673
|
-
PositionLibrary,
|
|
22674
|
-
PositionMath,
|
|
22675
21713
|
Route,
|
|
22676
|
-
SelfPermit,
|
|
22677
21714
|
SmartRouter,
|
|
22678
|
-
SqrtPriceMath,
|
|
22679
|
-
Staker,
|
|
22680
|
-
SwapMath,
|
|
22681
21715
|
SwapQuoter,
|
|
22682
21716
|
SwapRouter,
|
|
22683
|
-
TICK_SPACINGS,
|
|
22684
21717
|
Tick,
|
|
22685
|
-
TickLibrary,
|
|
22686
|
-
TickList,
|
|
22687
|
-
TickListDataProvider,
|
|
22688
21718
|
TickMath,
|
|
22689
21719
|
Trade,
|
|
22690
21720
|
apexControllerAbi,
|
|
22691
21721
|
apexTokenAbi,
|
|
22692
21722
|
apexVaultAbi,
|
|
22693
|
-
apexVaultCompoundBucket,
|
|
22694
|
-
asPancakeFeeAmount,
|
|
22695
21723
|
clFactoryAbi,
|
|
22696
21724
|
clMasterChefAbi,
|
|
22697
21725
|
clPoolAbi,
|
|
22698
21726
|
classicChefAbi,
|
|
22699
21727
|
classicFactoryAbi,
|
|
22700
21728
|
classicPoolAbi,
|
|
22701
|
-
computeApexCLPoolAddress,
|
|
22702
|
-
computeApexClassicPairAddress,
|
|
22703
21729
|
computeCLPoolAddress,
|
|
22704
21730
|
computeClassicPoolAddress,
|
|
22705
21731
|
computeCreate2Address,
|
|
22706
|
-
computePoolAddress,
|
|
22707
|
-
createApexPool,
|
|
22708
21732
|
createCLPool,
|
|
22709
|
-
decodeApexMixedRoutePath,
|
|
22710
21733
|
decodeMixedRoutePath,
|
|
22711
|
-
encodeApexMixedRouteToPancakeQuoteParams,
|
|
22712
|
-
encodeApexMixedRouteToPath,
|
|
22713
|
-
encodeMixedRouteToPancakeQuoteParams,
|
|
22714
21734
|
encodeMixedRouteToPath,
|
|
22715
|
-
|
|
21735
|
+
encodeMixedRouteToQuoteParams,
|
|
22716
21736
|
encodeSqrtRatioX96,
|
|
22717
21737
|
feeCenterAbi,
|
|
22718
21738
|
feeReceiverAbi,
|
|
22719
21739
|
feeSwapperAbi,
|
|
22720
21740
|
formatVaultConfig,
|
|
22721
|
-
getAmountsAtNewPrice,
|
|
22722
|
-
getAmountsByLiquidityAndPrice,
|
|
22723
|
-
getApexTickSpacing,
|
|
22724
21741
|
getApexVaultCompoundBucket,
|
|
22725
|
-
getAverageLiquidity,
|
|
22726
21742
|
getCLTickSpacing,
|
|
22727
|
-
getCurrency0Price,
|
|
22728
|
-
getCurrency1Price,
|
|
22729
|
-
getDependentAmount,
|
|
22730
|
-
getEstimatedLPFee,
|
|
22731
|
-
getEstimatedLPFeeByAmounts,
|
|
22732
|
-
getEstimatedLPFeeByAmountsWithProtocolFee,
|
|
22733
|
-
getEstimatedLPFeeWithProtocolFee,
|
|
22734
|
-
getInputAmount,
|
|
22735
|
-
getLiquidityByAmountsAndPrice,
|
|
22736
|
-
getLiquidityBySingleAmount,
|
|
22737
|
-
getLiquidityFromSqrtRatioX96,
|
|
22738
|
-
getLiquidityFromTick,
|
|
22739
|
-
getOutputAmount,
|
|
22740
|
-
getPool,
|
|
22741
|
-
getPriceOfCurrency,
|
|
22742
|
-
getPriceOfCurrency0,
|
|
22743
|
-
getPriceOfCurrency1,
|
|
22744
|
-
hasInvolvedCurrency,
|
|
22745
|
-
installApexFeeTiers,
|
|
22746
21743
|
installCLFeeTiers,
|
|
22747
21744
|
interfaceMulticallAbi,
|
|
22748
|
-
isApexCLFeeAmount,
|
|
22749
21745
|
isCLFeeAmount,
|
|
22750
|
-
isMint,
|
|
22751
|
-
isPoolTickInRange,
|
|
22752
|
-
isSorted,
|
|
22753
|
-
masterChefV3ABI,
|
|
22754
|
-
maxLiquidityForAmount0Imprecise,
|
|
22755
|
-
maxLiquidityForAmount0Precise,
|
|
22756
|
-
maxLiquidityForAmount1,
|
|
22757
|
-
maxLiquidityForAmounts,
|
|
22758
21746
|
mixedQuoterAbi,
|
|
22759
|
-
mostSignificantBit,
|
|
22760
21747
|
nearestUsableTick,
|
|
22761
|
-
nonfungiblePositionManagerABI,
|
|
22762
21748
|
nonfungiblePositionManagerAbi,
|
|
22763
21749
|
normalizeAddress,
|
|
22764
|
-
packApexProtocolFees,
|
|
22765
21750
|
packProtocolFees,
|
|
22766
|
-
pancakeV3PoolABI,
|
|
22767
|
-
parseApexProtocolFeePacked,
|
|
22768
21751
|
parseProtocolFeePacked,
|
|
22769
|
-
parseProtocolFees,
|
|
22770
|
-
peripheryPaymentsWithFeeABI,
|
|
22771
|
-
priceToClosestTick,
|
|
22772
|
-
quoteApexClassicExactInput,
|
|
22773
21752
|
quoteClassicExactInput,
|
|
22774
|
-
quoterABI,
|
|
22775
21753
|
quoterAbi,
|
|
22776
|
-
quoterV2ABI,
|
|
22777
21754
|
quoterV2Abi,
|
|
22778
|
-
selfPermitABI,
|
|
22779
21755
|
smartRouterAbi,
|
|
22780
21756
|
sortAddresses,
|
|
22781
|
-
sqrtRatioX96ToPrice,
|
|
22782
|
-
subIn256,
|
|
22783
|
-
swap,
|
|
22784
|
-
swapRouterABI,
|
|
22785
21757
|
swapRouterAbi,
|
|
22786
21758
|
tickLensAbi,
|
|
22787
|
-
tickToPrice,
|
|
22788
|
-
tickToPriceV2,
|
|
22789
|
-
toApexFeeAmount,
|
|
22790
21759
|
toCLFeeAmount,
|
|
22791
|
-
toHex,
|
|
22792
|
-
tradeComparator,
|
|
22793
|
-
v3PoolAbi,
|
|
22794
|
-
v3StakerABI,
|
|
22795
21760
|
validateApexVaultUserConfig,
|
|
22796
21761
|
veApexTokenAbi
|
|
22797
21762
|
};
|