async function deployMultipleRanges(poolId: string, totalAmountA: string, totalAmountB: string) {
const ranges = [
{ priceLower: "80000", priceUpper: "85000", weight: 20 },
{ priceLower: "85000", priceUpper: "95000", weight: 60 },
{ priceLower: "95000", priceUpper: "100000", weight: 20 },
];
const totalWeight = ranges.reduce((sum, r) => sum + r.weight, 0);
for (const range of ranges) {
const amountA = (BigInt(totalAmountA) * BigInt(range.weight) / BigInt(totalWeight)).toString();
const amountB = (BigInt(totalAmountB) * BigInt(range.weight) / BigInt(totalWeight)).toString();
const tickRange = V3TickMath.tickRangeFromPrices({
priceLower: range.priceLower,
priceUpper: range.priceUpper,
baseDecimals: 8,
quoteDecimals: 6,
tickSpacing: 60,
});
await client.increaseLiquidity({
poolId,
tickLower: tickRange.tickLower,
tickUpper: tickRange.tickUpper,
amountADesired: amountA,
amountBDesired: amountB,
amountAMin: "0",
amountBMin: "0",
});
console.log(`Created position at ${range.priceLower}-${range.priceUpper}`);
}
}