punkkit-sdk 1.0.26 → 1.0.27
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.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +74 -62
- package/dist/index.mjs +74 -62
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -131,6 +131,16 @@ interface ModifyPositionParams {
|
|
|
131
131
|
|
|
132
132
|
declare function addLiq(wallet: Wallet, priceLower: number, priceUpper: number, amount0: bigint | number, amount1: bigint | number, poolKey: PoolKey): Promise<ethers.providers.TransactionReceipt>;
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Removes liquidity by directly specifying exact tick ranges and the liquidity delta to remove.
|
|
136
|
+
* This is primarily used when matching with the frontend's position data.
|
|
137
|
+
*/
|
|
138
|
+
declare function removeLiqByPosition(wallet: Wallet, tickLower: number, tickUpper: number, liquidityToRemove: bigint | string): Promise<providers.TransactionReceipt>;
|
|
139
|
+
/**
|
|
140
|
+
* Legacy support: calculate liquidity to remove via token amount projections.
|
|
141
|
+
*/
|
|
142
|
+
declare function removeLiq(wallet: Wallet, priceLower: number, priceUpper: number, amount0: bigint, amount1: bigint, poolKey: PoolKey): Promise<providers.TransactionReceipt>;
|
|
143
|
+
|
|
134
144
|
interface UserPosition {
|
|
135
145
|
tokenId: number;
|
|
136
146
|
tickLower: number;
|
|
@@ -204,4 +214,4 @@ declare function balanceOf(contractAddress: string, provider: SignerOrProvider,
|
|
|
204
214
|
declare function getAllVouchers(contractAddress: string, provider: SignerOrProvider): Promise<string[]>;
|
|
205
215
|
declare function BuildUseVoucherTx(tx: providers.TransactionRequest, voucherName: string): providers.TransactionRequest;
|
|
206
216
|
|
|
207
|
-
export { BuildUseVoucherTx, type ChallengeMatchResultParams, type CreateAuctionConfigParams, type CreateAuctionParams, type ModifyPositionParams, type PlaceBidParams, type PoolKey, type RevealBidParams, type RevealLockParams, type SetUnlockStrategyParams, type SignerOrProvider, type SubmitMatchResultsParams, type SwapParams, type UnlockTokensParams, type UserPosition, type WithdrawMatchResultParams, addLiq, amount0, amount1, balanceOf, buyVoucher, buyVoucherWithEth, calculateLiqDelta, calculatePriceFromTick, calculateTickFromPrice, calculateTickFromPriceWithSpacing, createAuction$1 as createAuction, createAuctionConfig, createAuction as createAuctionOnVault, createVoucher, getActiveAuctionsCount, getAllVouchers, getAuctionContract, getAuctionInfo, getAuctionLockInfo, getContract, getCurrentTick, getLiquidity, getLockInfo, getMatchResult, getPoolId, getPoolPrice, getPoolSqrtPrice, getProvider, getSqrtPriceAtTick, getUserPositions, getVoucherContract, getVoucherInfo, liquidity0, liquidity1, main, modifyPosition, mutiVoucherABI, placeBid, priceToSqrtPrice, revealBid, revealLock, submitMatchResults, swap, toWei, unlockTokens, useVoucher, withdrawMatchResult };
|
|
217
|
+
export { BuildUseVoucherTx, type ChallengeMatchResultParams, type CreateAuctionConfigParams, type CreateAuctionParams, type ModifyPositionParams, type PlaceBidParams, type PoolKey, type RevealBidParams, type RevealLockParams, type SetUnlockStrategyParams, type SignerOrProvider, type SubmitMatchResultsParams, type SwapParams, type UnlockTokensParams, type UserPosition, type WithdrawMatchResultParams, addLiq, amount0, amount1, balanceOf, buyVoucher, buyVoucherWithEth, calculateLiqDelta, calculatePriceFromTick, calculateTickFromPrice, calculateTickFromPriceWithSpacing, createAuction$1 as createAuction, createAuctionConfig, createAuction as createAuctionOnVault, createVoucher, getActiveAuctionsCount, getAllVouchers, getAuctionContract, getAuctionInfo, getAuctionLockInfo, getContract, getCurrentTick, getLiquidity, getLockInfo, getMatchResult, getPoolId, getPoolPrice, getPoolSqrtPrice, getProvider, getSqrtPriceAtTick, getUserPositions, getVoucherContract, getVoucherInfo, liquidity0, liquidity1, main, modifyPosition, mutiVoucherABI, placeBid, priceToSqrtPrice, removeLiq, removeLiqByPosition, revealBid, revealLock, submitMatchResults, swap, toWei, unlockTokens, useVoucher, withdrawMatchResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -131,6 +131,16 @@ interface ModifyPositionParams {
|
|
|
131
131
|
|
|
132
132
|
declare function addLiq(wallet: Wallet, priceLower: number, priceUpper: number, amount0: bigint | number, amount1: bigint | number, poolKey: PoolKey): Promise<ethers.providers.TransactionReceipt>;
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Removes liquidity by directly specifying exact tick ranges and the liquidity delta to remove.
|
|
136
|
+
* This is primarily used when matching with the frontend's position data.
|
|
137
|
+
*/
|
|
138
|
+
declare function removeLiqByPosition(wallet: Wallet, tickLower: number, tickUpper: number, liquidityToRemove: bigint | string): Promise<providers.TransactionReceipt>;
|
|
139
|
+
/**
|
|
140
|
+
* Legacy support: calculate liquidity to remove via token amount projections.
|
|
141
|
+
*/
|
|
142
|
+
declare function removeLiq(wallet: Wallet, priceLower: number, priceUpper: number, amount0: bigint, amount1: bigint, poolKey: PoolKey): Promise<providers.TransactionReceipt>;
|
|
143
|
+
|
|
134
144
|
interface UserPosition {
|
|
135
145
|
tokenId: number;
|
|
136
146
|
tickLower: number;
|
|
@@ -204,4 +214,4 @@ declare function balanceOf(contractAddress: string, provider: SignerOrProvider,
|
|
|
204
214
|
declare function getAllVouchers(contractAddress: string, provider: SignerOrProvider): Promise<string[]>;
|
|
205
215
|
declare function BuildUseVoucherTx(tx: providers.TransactionRequest, voucherName: string): providers.TransactionRequest;
|
|
206
216
|
|
|
207
|
-
export { BuildUseVoucherTx, type ChallengeMatchResultParams, type CreateAuctionConfigParams, type CreateAuctionParams, type ModifyPositionParams, type PlaceBidParams, type PoolKey, type RevealBidParams, type RevealLockParams, type SetUnlockStrategyParams, type SignerOrProvider, type SubmitMatchResultsParams, type SwapParams, type UnlockTokensParams, type UserPosition, type WithdrawMatchResultParams, addLiq, amount0, amount1, balanceOf, buyVoucher, buyVoucherWithEth, calculateLiqDelta, calculatePriceFromTick, calculateTickFromPrice, calculateTickFromPriceWithSpacing, createAuction$1 as createAuction, createAuctionConfig, createAuction as createAuctionOnVault, createVoucher, getActiveAuctionsCount, getAllVouchers, getAuctionContract, getAuctionInfo, getAuctionLockInfo, getContract, getCurrentTick, getLiquidity, getLockInfo, getMatchResult, getPoolId, getPoolPrice, getPoolSqrtPrice, getProvider, getSqrtPriceAtTick, getUserPositions, getVoucherContract, getVoucherInfo, liquidity0, liquidity1, main, modifyPosition, mutiVoucherABI, placeBid, priceToSqrtPrice, revealBid, revealLock, submitMatchResults, swap, toWei, unlockTokens, useVoucher, withdrawMatchResult };
|
|
217
|
+
export { BuildUseVoucherTx, type ChallengeMatchResultParams, type CreateAuctionConfigParams, type CreateAuctionParams, type ModifyPositionParams, type PlaceBidParams, type PoolKey, type RevealBidParams, type RevealLockParams, type SetUnlockStrategyParams, type SignerOrProvider, type SubmitMatchResultsParams, type SwapParams, type UnlockTokensParams, type UserPosition, type WithdrawMatchResultParams, addLiq, amount0, amount1, balanceOf, buyVoucher, buyVoucherWithEth, calculateLiqDelta, calculatePriceFromTick, calculateTickFromPrice, calculateTickFromPriceWithSpacing, createAuction$1 as createAuction, createAuctionConfig, createAuction as createAuctionOnVault, createVoucher, getActiveAuctionsCount, getAllVouchers, getAuctionContract, getAuctionInfo, getAuctionLockInfo, getContract, getCurrentTick, getLiquidity, getLockInfo, getMatchResult, getPoolId, getPoolPrice, getPoolSqrtPrice, getProvider, getSqrtPriceAtTick, getUserPositions, getVoucherContract, getVoucherInfo, liquidity0, liquidity1, main, modifyPosition, mutiVoucherABI, placeBid, priceToSqrtPrice, removeLiq, removeLiqByPosition, revealBid, revealLock, submitMatchResults, swap, toWei, unlockTokens, useVoucher, withdrawMatchResult };
|
package/dist/index.js
CHANGED
|
@@ -36119,64 +36119,6 @@ var init_contract = __esm({
|
|
|
36119
36119
|
}
|
|
36120
36120
|
});
|
|
36121
36121
|
|
|
36122
|
-
// src/uniswap/1-marketprice/removeLiquidity.ts
|
|
36123
|
-
var require_removeLiquidity = __commonJS({
|
|
36124
|
-
"src/uniswap/1-marketprice/removeLiquidity.ts"(exports2, module2) {
|
|
36125
|
-
"use strict";
|
|
36126
|
-
init_lib49();
|
|
36127
|
-
init_uniswap_config();
|
|
36128
|
-
init_pool();
|
|
36129
|
-
init_ERC20();
|
|
36130
|
-
init_liqCalculation();
|
|
36131
|
-
init_contract();
|
|
36132
|
-
async function removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, poolKey) {
|
|
36133
|
-
const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
|
|
36134
|
-
const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
|
|
36135
|
-
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
36136
|
-
const sqrtCurrent = await getPoolSqrtPrice(liqPool);
|
|
36137
|
-
const [liqDelta, amount0Rmv, amount1Rmv] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
|
|
36138
|
-
console.log(`Attempting to remove liquidity ${liqDelta} to price range [${priceLower}, ${priceUpper}] with amount0[${amount0Rmv.toString()}], amount1[${amount1Rmv.toString()}]`);
|
|
36139
|
-
const modifyPositionParams = {
|
|
36140
|
-
tickLower: ticklow,
|
|
36141
|
-
tickUpper: tickhigh,
|
|
36142
|
-
liquidityDelta: liqDelta * BigInt(-1)
|
|
36143
|
-
};
|
|
36144
|
-
await modifyPosition(liqPool, modifyPositionParams, "0x00");
|
|
36145
|
-
}
|
|
36146
|
-
async function main3() {
|
|
36147
|
-
const provider2 = new lib_exports3.JsonRpcProvider(RPC_URL);
|
|
36148
|
-
const wallet2 = new Wallet(PRIVATE_KEY, provider2);
|
|
36149
|
-
const liqPoolAddress = CONTRACT_ADDRESSES.LiquidPool;
|
|
36150
|
-
const token0 = await getContract(wallet2, "Token0");
|
|
36151
|
-
const token1 = await getContract(wallet2, "Token1");
|
|
36152
|
-
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
36153
|
-
let poolPrice = await getPoolPrice(liqPool);
|
|
36154
|
-
console.log(`Current price of pool ${liqPool.address} before removing liquidity is ${poolPrice}`);
|
|
36155
|
-
const token0Before = await getERC20Balance(token0, wallet2.address);
|
|
36156
|
-
const token1Before = await getERC20Balance(token1, wallet2.address);
|
|
36157
|
-
console.log("Token0 balance before removing liquidity:", token0Before.toString());
|
|
36158
|
-
console.log("Token1 balance before removing liquidity:", token1Before.toString());
|
|
36159
|
-
const priceLower = 0.5;
|
|
36160
|
-
const priceUpper = 1.5;
|
|
36161
|
-
const amount02 = 100n;
|
|
36162
|
-
const amount12 = 100n;
|
|
36163
|
-
await removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, POOL_KEYS.limitOrderPoolKey);
|
|
36164
|
-
poolPrice = await getPoolPrice(liqPool);
|
|
36165
|
-
console.log(`Current price of pool ${liqPool.address} after removing liquidity is ${poolPrice}`);
|
|
36166
|
-
const token0After = await getERC20Balance(token0, wallet2.address);
|
|
36167
|
-
const token1After = await getERC20Balance(token1, wallet2.address);
|
|
36168
|
-
console.log("Token0 change:", token0After - token0Before);
|
|
36169
|
-
console.log("Token1 change:", token1After - token1Before);
|
|
36170
|
-
}
|
|
36171
|
-
if (typeof require !== "undefined" && typeof module2 !== "undefined" && require.main === module2) {
|
|
36172
|
-
main3().catch((error) => {
|
|
36173
|
-
console.error(error);
|
|
36174
|
-
process.exit(1);
|
|
36175
|
-
});
|
|
36176
|
-
}
|
|
36177
|
-
}
|
|
36178
|
-
});
|
|
36179
|
-
|
|
36180
36122
|
// src/uniswap/2-limitorder/place.ts
|
|
36181
36123
|
var require_place = __commonJS({
|
|
36182
36124
|
"src/uniswap/2-limitorder/place.ts"(exports2, module2) {
|
|
@@ -36237,7 +36179,7 @@ var require_place = __commonJS({
|
|
|
36237
36179
|
const epoch = await placeLimitOrder(hook, poolKey, ticklow, zeroForOne, liquidity);
|
|
36238
36180
|
return epoch;
|
|
36239
36181
|
}
|
|
36240
|
-
async function
|
|
36182
|
+
async function main4() {
|
|
36241
36183
|
const provider2 = new ethers_exports.providers.JsonRpcProvider(RPC_URL);
|
|
36242
36184
|
const wallet2 = new ethers_exports.Wallet(PRIVATE_KEY, provider2);
|
|
36243
36185
|
const token0 = await getContract(wallet2, "Token0");
|
|
@@ -36254,7 +36196,7 @@ var require_place = __commonJS({
|
|
|
36254
36196
|
console.log("Token1 change:", token1After - token1Before);
|
|
36255
36197
|
}
|
|
36256
36198
|
if (typeof require !== "undefined" && typeof module2 !== "undefined" && require.main === module2) {
|
|
36257
|
-
|
|
36199
|
+
main4().catch((error) => {
|
|
36258
36200
|
console.error(error);
|
|
36259
36201
|
process.exit(1);
|
|
36260
36202
|
});
|
|
@@ -36305,6 +36247,8 @@ __export(index_exports, {
|
|
|
36305
36247
|
mutiVoucherABI: () => mutiVoucherABI,
|
|
36306
36248
|
placeBid: () => placeBid,
|
|
36307
36249
|
priceToSqrtPrice: () => priceToSqrtPrice,
|
|
36250
|
+
removeLiq: () => removeLiq,
|
|
36251
|
+
removeLiqByPosition: () => removeLiqByPosition,
|
|
36308
36252
|
revealBid: () => revealBid,
|
|
36309
36253
|
revealLock: () => revealLock,
|
|
36310
36254
|
submitMatchResults: () => submitMatchResults,
|
|
@@ -38699,8 +38643,74 @@ if (typeof require !== "undefined" && typeof module !== "undefined" && require.m
|
|
|
38699
38643
|
});
|
|
38700
38644
|
}
|
|
38701
38645
|
|
|
38702
|
-
// src/
|
|
38703
|
-
|
|
38646
|
+
// src/uniswap/1-marketprice/removeLiquidity.ts
|
|
38647
|
+
init_lib49();
|
|
38648
|
+
init_uniswap_config();
|
|
38649
|
+
init_pool();
|
|
38650
|
+
init_ERC20();
|
|
38651
|
+
init_liqCalculation();
|
|
38652
|
+
init_contract();
|
|
38653
|
+
async function removeLiqByPosition(wallet2, tickLower, tickUpper, liquidityToRemove) {
|
|
38654
|
+
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
38655
|
+
let liqDelta = BigInt(liquidityToRemove.toString());
|
|
38656
|
+
if (liqDelta > 0n) {
|
|
38657
|
+
liqDelta = liqDelta * -1n;
|
|
38658
|
+
}
|
|
38659
|
+
console.log(`[SDK] Attempting to remove liquidity ${liqDelta} from ticks [${tickLower}, ${tickUpper}]`);
|
|
38660
|
+
const modifyPositionParams = {
|
|
38661
|
+
tickLower,
|
|
38662
|
+
tickUpper,
|
|
38663
|
+
liquidityDelta: liqDelta
|
|
38664
|
+
};
|
|
38665
|
+
const receipt = await modifyPosition(liqPool, modifyPositionParams, "0x00");
|
|
38666
|
+
return receipt;
|
|
38667
|
+
}
|
|
38668
|
+
async function removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, poolKey) {
|
|
38669
|
+
const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
|
|
38670
|
+
const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
|
|
38671
|
+
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
38672
|
+
const sqrtCurrent = await getPoolSqrtPrice(liqPool);
|
|
38673
|
+
const [liqDelta, amount0Rmv, amount1Rmv] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
|
|
38674
|
+
console.log(`Attempting to remove liquidity ${liqDelta} to price range [${priceLower}, ${priceUpper}] with amount0[${amount0Rmv.toString()}], amount1[${amount1Rmv.toString()}]`);
|
|
38675
|
+
const modifyPositionParams = {
|
|
38676
|
+
tickLower: ticklow,
|
|
38677
|
+
tickUpper: tickhigh,
|
|
38678
|
+
liquidityDelta: liqDelta * -1n
|
|
38679
|
+
};
|
|
38680
|
+
const receipt = await modifyPosition(liqPool, modifyPositionParams, "0x00");
|
|
38681
|
+
return receipt;
|
|
38682
|
+
}
|
|
38683
|
+
async function main3() {
|
|
38684
|
+
const provider2 = new lib_exports3.JsonRpcProvider(RPC_URL);
|
|
38685
|
+
const wallet2 = new Wallet(PRIVATE_KEY, provider2);
|
|
38686
|
+
const liqPoolAddress = CONTRACT_ADDRESSES.LiquidPool;
|
|
38687
|
+
const token0 = await getContract(wallet2, "Token0");
|
|
38688
|
+
const token1 = await getContract(wallet2, "Token1");
|
|
38689
|
+
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
38690
|
+
let poolPrice = await getPoolPrice(liqPool);
|
|
38691
|
+
console.log(`Current price of pool ${liqPool.address} before removing liquidity is ${poolPrice}`);
|
|
38692
|
+
const token0Before = await getERC20Balance(token0, wallet2.address);
|
|
38693
|
+
const token1Before = await getERC20Balance(token1, wallet2.address);
|
|
38694
|
+
console.log("Token0 balance before removing liquidity:", token0Before.toString());
|
|
38695
|
+
console.log("Token1 balance before removing liquidity:", token1Before.toString());
|
|
38696
|
+
const priceLower = 0.5;
|
|
38697
|
+
const priceUpper = 1.5;
|
|
38698
|
+
const amount02 = 100n;
|
|
38699
|
+
const amount12 = 100n;
|
|
38700
|
+
await removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, POOL_KEYS.limitOrderPoolKey);
|
|
38701
|
+
poolPrice = await getPoolPrice(liqPool);
|
|
38702
|
+
console.log(`Current price of pool ${liqPool.address} after removing liquidity is ${poolPrice}`);
|
|
38703
|
+
const token0After = await getERC20Balance(token0, wallet2.address);
|
|
38704
|
+
const token1After = await getERC20Balance(token1, wallet2.address);
|
|
38705
|
+
console.log("Token0 change:", token0After - token0Before);
|
|
38706
|
+
console.log("Token1 change:", token1After - token1Before);
|
|
38707
|
+
}
|
|
38708
|
+
if (typeof require !== "undefined" && typeof module !== "undefined" && require.main === module) {
|
|
38709
|
+
main3().catch((error) => {
|
|
38710
|
+
console.error(error);
|
|
38711
|
+
process.exit(1);
|
|
38712
|
+
});
|
|
38713
|
+
}
|
|
38704
38714
|
|
|
38705
38715
|
// src/uniswap/1-marketprice/getPositions.ts
|
|
38706
38716
|
init_contract();
|
|
@@ -39033,6 +39043,8 @@ function BuildUseVoucherTx(tx, voucherName) {
|
|
|
39033
39043
|
mutiVoucherABI,
|
|
39034
39044
|
placeBid,
|
|
39035
39045
|
priceToSqrtPrice,
|
|
39046
|
+
removeLiq,
|
|
39047
|
+
removeLiqByPosition,
|
|
39036
39048
|
revealBid,
|
|
39037
39049
|
revealLock,
|
|
39038
39050
|
submitMatchResults,
|
package/dist/index.mjs
CHANGED
|
@@ -36123,64 +36123,6 @@ var init_contract = __esm({
|
|
|
36123
36123
|
}
|
|
36124
36124
|
});
|
|
36125
36125
|
|
|
36126
|
-
// src/uniswap/1-marketprice/removeLiquidity.ts
|
|
36127
|
-
var require_removeLiquidity = __commonJS({
|
|
36128
|
-
"src/uniswap/1-marketprice/removeLiquidity.ts"(exports, module2) {
|
|
36129
|
-
"use strict";
|
|
36130
|
-
init_lib49();
|
|
36131
|
-
init_uniswap_config();
|
|
36132
|
-
init_pool();
|
|
36133
|
-
init_ERC20();
|
|
36134
|
-
init_liqCalculation();
|
|
36135
|
-
init_contract();
|
|
36136
|
-
async function removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, poolKey) {
|
|
36137
|
-
const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
|
|
36138
|
-
const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
|
|
36139
|
-
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
36140
|
-
const sqrtCurrent = await getPoolSqrtPrice(liqPool);
|
|
36141
|
-
const [liqDelta, amount0Rmv, amount1Rmv] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
|
|
36142
|
-
console.log(`Attempting to remove liquidity ${liqDelta} to price range [${priceLower}, ${priceUpper}] with amount0[${amount0Rmv.toString()}], amount1[${amount1Rmv.toString()}]`);
|
|
36143
|
-
const modifyPositionParams = {
|
|
36144
|
-
tickLower: ticklow,
|
|
36145
|
-
tickUpper: tickhigh,
|
|
36146
|
-
liquidityDelta: liqDelta * BigInt(-1)
|
|
36147
|
-
};
|
|
36148
|
-
await modifyPosition(liqPool, modifyPositionParams, "0x00");
|
|
36149
|
-
}
|
|
36150
|
-
async function main3() {
|
|
36151
|
-
const provider2 = new lib_exports3.JsonRpcProvider(RPC_URL);
|
|
36152
|
-
const wallet2 = new Wallet(PRIVATE_KEY, provider2);
|
|
36153
|
-
const liqPoolAddress = CONTRACT_ADDRESSES.LiquidPool;
|
|
36154
|
-
const token0 = await getContract(wallet2, "Token0");
|
|
36155
|
-
const token1 = await getContract(wallet2, "Token1");
|
|
36156
|
-
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
36157
|
-
let poolPrice = await getPoolPrice(liqPool);
|
|
36158
|
-
console.log(`Current price of pool ${liqPool.address} before removing liquidity is ${poolPrice}`);
|
|
36159
|
-
const token0Before = await getERC20Balance(token0, wallet2.address);
|
|
36160
|
-
const token1Before = await getERC20Balance(token1, wallet2.address);
|
|
36161
|
-
console.log("Token0 balance before removing liquidity:", token0Before.toString());
|
|
36162
|
-
console.log("Token1 balance before removing liquidity:", token1Before.toString());
|
|
36163
|
-
const priceLower = 0.5;
|
|
36164
|
-
const priceUpper = 1.5;
|
|
36165
|
-
const amount02 = 100n;
|
|
36166
|
-
const amount12 = 100n;
|
|
36167
|
-
await removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, POOL_KEYS.limitOrderPoolKey);
|
|
36168
|
-
poolPrice = await getPoolPrice(liqPool);
|
|
36169
|
-
console.log(`Current price of pool ${liqPool.address} after removing liquidity is ${poolPrice}`);
|
|
36170
|
-
const token0After = await getERC20Balance(token0, wallet2.address);
|
|
36171
|
-
const token1After = await getERC20Balance(token1, wallet2.address);
|
|
36172
|
-
console.log("Token0 change:", token0After - token0Before);
|
|
36173
|
-
console.log("Token1 change:", token1After - token1Before);
|
|
36174
|
-
}
|
|
36175
|
-
if (typeof __require !== "undefined" && typeof module2 !== "undefined" && __require.main === module2) {
|
|
36176
|
-
main3().catch((error) => {
|
|
36177
|
-
console.error(error);
|
|
36178
|
-
process.exit(1);
|
|
36179
|
-
});
|
|
36180
|
-
}
|
|
36181
|
-
}
|
|
36182
|
-
});
|
|
36183
|
-
|
|
36184
36126
|
// src/uniswap/2-limitorder/place.ts
|
|
36185
36127
|
var require_place = __commonJS({
|
|
36186
36128
|
"src/uniswap/2-limitorder/place.ts"(exports, module2) {
|
|
@@ -36241,7 +36183,7 @@ var require_place = __commonJS({
|
|
|
36241
36183
|
const epoch = await placeLimitOrder(hook, poolKey, ticklow, zeroForOne, liquidity);
|
|
36242
36184
|
return epoch;
|
|
36243
36185
|
}
|
|
36244
|
-
async function
|
|
36186
|
+
async function main4() {
|
|
36245
36187
|
const provider2 = new ethers_exports.providers.JsonRpcProvider(RPC_URL);
|
|
36246
36188
|
const wallet2 = new ethers_exports.Wallet(PRIVATE_KEY, provider2);
|
|
36247
36189
|
const token0 = await getContract(wallet2, "Token0");
|
|
@@ -36258,7 +36200,7 @@ var require_place = __commonJS({
|
|
|
36258
36200
|
console.log("Token1 change:", token1After - token1Before);
|
|
36259
36201
|
}
|
|
36260
36202
|
if (typeof __require !== "undefined" && typeof module2 !== "undefined" && __require.main === module2) {
|
|
36261
|
-
|
|
36203
|
+
main4().catch((error) => {
|
|
36262
36204
|
console.error(error);
|
|
36263
36205
|
process.exit(1);
|
|
36264
36206
|
});
|
|
@@ -36309,6 +36251,8 @@ __export(index_exports, {
|
|
|
36309
36251
|
mutiVoucherABI: () => mutiVoucherABI,
|
|
36310
36252
|
placeBid: () => placeBid,
|
|
36311
36253
|
priceToSqrtPrice: () => priceToSqrtPrice,
|
|
36254
|
+
removeLiq: () => removeLiq,
|
|
36255
|
+
removeLiqByPosition: () => removeLiqByPosition,
|
|
36312
36256
|
revealBid: () => revealBid,
|
|
36313
36257
|
revealLock: () => revealLock,
|
|
36314
36258
|
submitMatchResults: () => submitMatchResults,
|
|
@@ -38702,8 +38646,74 @@ if (typeof __require !== "undefined" && typeof module !== "undefined" && __requi
|
|
|
38702
38646
|
});
|
|
38703
38647
|
}
|
|
38704
38648
|
|
|
38705
|
-
// src/
|
|
38706
|
-
|
|
38649
|
+
// src/uniswap/1-marketprice/removeLiquidity.ts
|
|
38650
|
+
init_lib49();
|
|
38651
|
+
init_uniswap_config();
|
|
38652
|
+
init_pool();
|
|
38653
|
+
init_ERC20();
|
|
38654
|
+
init_liqCalculation();
|
|
38655
|
+
init_contract();
|
|
38656
|
+
async function removeLiqByPosition(wallet2, tickLower, tickUpper, liquidityToRemove) {
|
|
38657
|
+
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
38658
|
+
let liqDelta = BigInt(liquidityToRemove.toString());
|
|
38659
|
+
if (liqDelta > 0n) {
|
|
38660
|
+
liqDelta = liqDelta * -1n;
|
|
38661
|
+
}
|
|
38662
|
+
console.log(`[SDK] Attempting to remove liquidity ${liqDelta} from ticks [${tickLower}, ${tickUpper}]`);
|
|
38663
|
+
const modifyPositionParams = {
|
|
38664
|
+
tickLower,
|
|
38665
|
+
tickUpper,
|
|
38666
|
+
liquidityDelta: liqDelta
|
|
38667
|
+
};
|
|
38668
|
+
const receipt = await modifyPosition(liqPool, modifyPositionParams, "0x00");
|
|
38669
|
+
return receipt;
|
|
38670
|
+
}
|
|
38671
|
+
async function removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, poolKey) {
|
|
38672
|
+
const ticklow = calculateTickFromPriceWithSpacing(priceLower, poolKey.tickSpacing);
|
|
38673
|
+
const tickhigh = calculateTickFromPriceWithSpacing(priceUpper, poolKey.tickSpacing);
|
|
38674
|
+
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
38675
|
+
const sqrtCurrent = await getPoolSqrtPrice(liqPool);
|
|
38676
|
+
const [liqDelta, amount0Rmv, amount1Rmv] = calculateLiqDelta(ticklow, sqrtCurrent, tickhigh, amount02, amount12);
|
|
38677
|
+
console.log(`Attempting to remove liquidity ${liqDelta} to price range [${priceLower}, ${priceUpper}] with amount0[${amount0Rmv.toString()}], amount1[${amount1Rmv.toString()}]`);
|
|
38678
|
+
const modifyPositionParams = {
|
|
38679
|
+
tickLower: ticklow,
|
|
38680
|
+
tickUpper: tickhigh,
|
|
38681
|
+
liquidityDelta: liqDelta * -1n
|
|
38682
|
+
};
|
|
38683
|
+
const receipt = await modifyPosition(liqPool, modifyPositionParams, "0x00");
|
|
38684
|
+
return receipt;
|
|
38685
|
+
}
|
|
38686
|
+
async function main3() {
|
|
38687
|
+
const provider2 = new lib_exports3.JsonRpcProvider(RPC_URL);
|
|
38688
|
+
const wallet2 = new Wallet(PRIVATE_KEY, provider2);
|
|
38689
|
+
const liqPoolAddress = CONTRACT_ADDRESSES.LiquidPool;
|
|
38690
|
+
const token0 = await getContract(wallet2, "Token0");
|
|
38691
|
+
const token1 = await getContract(wallet2, "Token1");
|
|
38692
|
+
const liqPool = await getContract(wallet2, "LiquidPool");
|
|
38693
|
+
let poolPrice = await getPoolPrice(liqPool);
|
|
38694
|
+
console.log(`Current price of pool ${liqPool.address} before removing liquidity is ${poolPrice}`);
|
|
38695
|
+
const token0Before = await getERC20Balance(token0, wallet2.address);
|
|
38696
|
+
const token1Before = await getERC20Balance(token1, wallet2.address);
|
|
38697
|
+
console.log("Token0 balance before removing liquidity:", token0Before.toString());
|
|
38698
|
+
console.log("Token1 balance before removing liquidity:", token1Before.toString());
|
|
38699
|
+
const priceLower = 0.5;
|
|
38700
|
+
const priceUpper = 1.5;
|
|
38701
|
+
const amount02 = 100n;
|
|
38702
|
+
const amount12 = 100n;
|
|
38703
|
+
await removeLiq(wallet2, priceLower, priceUpper, amount02, amount12, POOL_KEYS.limitOrderPoolKey);
|
|
38704
|
+
poolPrice = await getPoolPrice(liqPool);
|
|
38705
|
+
console.log(`Current price of pool ${liqPool.address} after removing liquidity is ${poolPrice}`);
|
|
38706
|
+
const token0After = await getERC20Balance(token0, wallet2.address);
|
|
38707
|
+
const token1After = await getERC20Balance(token1, wallet2.address);
|
|
38708
|
+
console.log("Token0 change:", token0After - token0Before);
|
|
38709
|
+
console.log("Token1 change:", token1After - token1Before);
|
|
38710
|
+
}
|
|
38711
|
+
if (typeof __require !== "undefined" && typeof module !== "undefined" && __require.main === module) {
|
|
38712
|
+
main3().catch((error) => {
|
|
38713
|
+
console.error(error);
|
|
38714
|
+
process.exit(1);
|
|
38715
|
+
});
|
|
38716
|
+
}
|
|
38707
38717
|
|
|
38708
38718
|
// src/uniswap/1-marketprice/getPositions.ts
|
|
38709
38719
|
init_contract();
|
|
@@ -39035,6 +39045,8 @@ export {
|
|
|
39035
39045
|
mutiVoucherABI,
|
|
39036
39046
|
placeBid,
|
|
39037
39047
|
priceToSqrtPrice,
|
|
39048
|
+
removeLiq,
|
|
39049
|
+
removeLiqByPosition,
|
|
39038
39050
|
revealBid,
|
|
39039
39051
|
revealLock,
|
|
39040
39052
|
submitMatchResults,
|