UNPKG

@uniswap/v4-sdk

Version:

⚒️ An SDK for building applications on top of Uniswap V4

57 lines 2.43 kB
import { Actions, V4Planner } from './v4Planner'; import { Pool } from '../entities'; import { toAddress } from '../utils/currencyMap'; import { EMPTY_BYTES } from '../internalConstants'; // A wrapper around V4Planner to help handle PositionManager actions export class V4PositionPlanner extends V4Planner { // MINT_POSITION addMint(pool, tickLower, tickUpper, liquidity, amount0Max, amount1Max, owner, hookData = EMPTY_BYTES) { const inputs = [ Pool.getPoolKey(pool.currency0, pool.currency1, pool.fee, pool.tickSpacing, pool.hooks), tickLower, tickUpper, liquidity.toString(), amount0Max.toString(), amount1Max.toString(), owner, hookData, ]; this.addAction(Actions.MINT_POSITION, inputs); } // INCREASE_LIQUIDITY addIncrease(tokenId, liquidity, amount0Max, amount1Max, hookData = EMPTY_BYTES) { const inputs = [tokenId.toString(), liquidity.toString(), amount0Max.toString(), amount1Max.toString(), hookData]; this.addAction(Actions.INCREASE_LIQUIDITY, inputs); } // DECREASE_LIQUIDITY addDecrease(tokenId, liquidity, amount0Min, amount1Min, hookData = EMPTY_BYTES) { const inputs = [tokenId.toString(), liquidity.toString(), amount0Min.toString(), amount1Min.toString(), hookData]; this.addAction(Actions.DECREASE_LIQUIDITY, inputs); } // BURN_POSITION addBurn(tokenId, amount0Min, amount1Min, hookData = EMPTY_BYTES) { const inputs = [tokenId.toString(), amount0Min.toString(), amount1Min.toString(), hookData]; this.addAction(Actions.BURN_POSITION, inputs); } // SETTLE_PAIR addSettlePair(currency0, currency1) { const inputs = [toAddress(currency0), toAddress(currency1)]; this.addAction(Actions.SETTLE_PAIR, inputs); } // CLOSE_CURRENCY addCloseCurrency(currency) { const inputs = [toAddress(currency)]; this.addAction(Actions.CLOSE_CURRENCY, inputs); } // TAKE_PAIR addTakePair(currency0, currency1, recipient) { const inputs = [toAddress(currency0), toAddress(currency1), recipient]; this.addAction(Actions.TAKE_PAIR, inputs); } // SWEEP addSweep(currency, to) { const inputs = [toAddress(currency), to]; this.addAction(Actions.SWEEP, inputs); } } //# sourceMappingURL=v4PositionPlanner.js.map