import { DistributionMode } from "@picon-finance/dlmm-sdk";
// Open a position and deposit in one flow.
const openPositionIxs = await pool.openPosition(ownerSigner, positionMintSigner, {
lowerBinId: -10,
upperBinId: 10,
});
const position = await pool.getPositionByPositionMint(positionMintSigner.address);
// depositByWeight checks the deposit against the pool's cached activeBinId — if time has
// passed since the pool was fetched (other activity could've moved the price since), refresh
// it first so the deposit isn't built/checked against a stale active bin.
await pool.refresh();
const depositIxs = await position.depositByWeight(ownerSigner, {
amountX: 1_000_000n,
amountY: 1_000_000n,
lowerBinId: -10,
binWeights: Array(21).fill(1), // flat "Spot" weighting — see the note below
maxActiveBinSlippage: 5,
distributionMode: DistributionMode.Balanced,
});
// Later: claim fees, withdraw (partially or fully, by bps), close.
const claimFeeIxs = await position.claimFee(ownerSigner);
const withdrawIxs = await position.withdraw(ownerSigner, { bpsToRemove: 5_000 }); // bps, out of 10_000 = 100%
const closeIx = await position.close(ownerSigner);