Skip to content

Commit

Permalink
fix: Remove redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
quangkeu95 committed Jan 22, 2025
1 parent 074eace commit f076399
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 64 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,14 @@ bun run src/seed_liquidity_lfg.ts --config ./config/seed_liquidity_lfg.json

** Create M3M3 farm**
This script requires you to create the token mint and the pool first.
After that you need to lock the liquidity before creating the M3M3 farm. The addresses in the allocations should contains the fee farm address.
```bash
bun run src/create_m3m3_farm.ts --config ./config/create_m3m3_farm.json
bun run src/lock_liquidity.ts --config ./config/create_m3m3_farm.json
```

After running the script to create M3M3 farm, get the fee farm address and paste it into the config file to lock the liquidity. The address in the allocation is the fee farm address.
Create the M3M3 fee farm
```bash
bun run src/lock_liquidity.ts --config ./config/create_m3m3_farm.json
bun run src/create_m3m3_farm.ts --config ./config/create_m3m3_farm.json
```

## After deployment
Expand Down
62 changes: 1 addition & 61 deletions src/libs/create_m3m3_farm_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,64 +85,4 @@ export async function create_m3m3_farm(
`>>> M3M3 farm initialized successfully with tx hash: ${txHash}`,
);
}
}

export async function lockLiquidityToFeeVault(
connection: Connection,
poolKey: PublicKey,
pool: AmmImpl,
payer: Keypair,
lockBps: number,
dryRun: boolean,
computeUnitPriceMicroLamports: number,
opts?: {
m3m3ProgramId: PublicKey;
},
) {
const m3m3ProgramId =
opts?.m3m3ProgramId ?? new PublicKey(M3M3_PROGRAM_IDS["mainnet-beta"]);
const feeVaultKey = deriveFeeVault(poolKey, m3m3ProgramId);

const poolLpAta = getAssociatedTokenAddressSync(
pool.poolState.lpMint,
payer.publicKey,
);

const lpAmount = await connection
.getTokenAccountBalance(poolLpAta)
.then((info) => new BN(info.value.amount.toString()));

const lockBpsBN = new BN(Math.min(10_000, lockBps));
const lockAmount = lpAmount.mul(lockBpsBN).div(new BN(10_000));

const lockTx = await pool.lockLiquidity(
feeVaultKey,
lockAmount,
payer.publicKey,
{
stakeLiquidity: {
ratio: new Decimal(1), // 0 to 1; 1 means 100%
},
},
);

modifyComputeUnitPriceIx(lockTx, computeUnitPriceMicroLamports);

if (dryRun) {
console.log(`> Simulating lock liquidity to fee farm tx...`);
await runSimulateTransaction(connection, [payer], payer.publicKey, [
lockTx,
]);
} else {
console.log(`>> Sending lock liquidity to fee farm transaction...`);
const txHash = await sendAndConfirmTransaction(connection, lockTx, [
payer,
]).catch((err) => {
console.error(err);
throw err;
});
console.log(
`>>> Lock liquidity to fee farm successfully with tx hash: ${txHash}`,
);
}
}
}

0 comments on commit f076399

Please sign in to comment.