Simulate the deposit to preview important details such as the LP token master address and the estimated LP token amount.
// Simulate the deposit payload
const { result, getDepositPayload } = await sdk.simulateDeposit(depositParams);
console.log(`LP Tokens Out: ${result.lpTokenOut.toString()}`);
console.log(`LP Total Supply After: ${result.lpTotalSupplyAfter.toString()}`);
console.log(`Min LP Tokens Out: ${result.minLpTokenOut?.toString() || '(You did not specify slippage tolerance)'}`); // prettier-ignore
console.log(`Get ${lpTokenAmount} LP from ${lpTokenMaster}`);
Example Output
LP Tokens Out: 12345678901234567890
LP Total Supply After: 98765432109876543210
Min LP Tokens Out: 12000000000000000000
4. Execute the Deposit
Send the deposit transaction and retrieve the msgHash to track its status.
4.1 Execute Swap with Simulation Result
// Get BoC and send transaction
const sender = wallet.address;
const senderArgs = await sdk.getDepositPayload(sender, depositParams);
const msgHash = await send(senderArgs);
console.log(`Transaction sent with msghash: ${msgHash}`);
4.2 Execute Swap Directly with Swap Params
const sender = wallet.address;
const senderArgs = await sdk.getDepositPayload(sender, {
blockNumber: blockNumber, // Optional, but it will speed up a lot if you provided the latest blockNumber here
});
const msgHash = await send(senderArgs);
console.log(`Transaction sent with msghash: ${msgHash}`)