@uniswap/v4-sdk
Version:
⚒️ An SDK for building applications on top of Uniswap V4
61 lines • 2.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.V4PositionPlanner = void 0;
const v4Planner_1 = require("./v4Planner");
const entities_1 = require("../entities");
const currencyMap_1 = require("../utils/currencyMap");
const internalConstants_1 = require("../internalConstants");
// A wrapper around V4Planner to help handle PositionManager actions
class V4PositionPlanner extends v4Planner_1.V4Planner {
// MINT_POSITION
addMint(pool, tickLower, tickUpper, liquidity, amount0Max, amount1Max, owner, hookData = internalConstants_1.EMPTY_BYTES) {
const inputs = [
entities_1.Pool.getPoolKey(pool.currency0, pool.currency1, pool.fee, pool.tickSpacing, pool.hooks),
tickLower,
tickUpper,
liquidity.toString(),
amount0Max.toString(),
amount1Max.toString(),
owner,
hookData,
];
this.addAction(v4Planner_1.Actions.MINT_POSITION, inputs);
}
// INCREASE_LIQUIDITY
addIncrease(tokenId, liquidity, amount0Max, amount1Max, hookData = internalConstants_1.EMPTY_BYTES) {
const inputs = [tokenId.toString(), liquidity.toString(), amount0Max.toString(), amount1Max.toString(), hookData];
this.addAction(v4Planner_1.Actions.INCREASE_LIQUIDITY, inputs);
}
// DECREASE_LIQUIDITY
addDecrease(tokenId, liquidity, amount0Min, amount1Min, hookData = internalConstants_1.EMPTY_BYTES) {
const inputs = [tokenId.toString(), liquidity.toString(), amount0Min.toString(), amount1Min.toString(), hookData];
this.addAction(v4Planner_1.Actions.DECREASE_LIQUIDITY, inputs);
}
// BURN_POSITION
addBurn(tokenId, amount0Min, amount1Min, hookData = internalConstants_1.EMPTY_BYTES) {
const inputs = [tokenId.toString(), amount0Min.toString(), amount1Min.toString(), hookData];
this.addAction(v4Planner_1.Actions.BURN_POSITION, inputs);
}
// SETTLE_PAIR
addSettlePair(currency0, currency1) {
const inputs = [(0, currencyMap_1.toAddress)(currency0), (0, currencyMap_1.toAddress)(currency1)];
this.addAction(v4Planner_1.Actions.SETTLE_PAIR, inputs);
}
// CLOSE_CURRENCY
addCloseCurrency(currency) {
const inputs = [(0, currencyMap_1.toAddress)(currency)];
this.addAction(v4Planner_1.Actions.CLOSE_CURRENCY, inputs);
}
// TAKE_PAIR
addTakePair(currency0, currency1, recipient) {
const inputs = [(0, currencyMap_1.toAddress)(currency0), (0, currencyMap_1.toAddress)(currency1), recipient];
this.addAction(v4Planner_1.Actions.TAKE_PAIR, inputs);
}
// SWEEP
addSweep(currency, to) {
const inputs = [(0, currencyMap_1.toAddress)(currency), to];
this.addAction(v4Planner_1.Actions.SWEEP, inputs);
}
}
exports.V4PositionPlanner = V4PositionPlanner;
//# sourceMappingURL=v4PositionPlanner.js.map