lock
Description:
Boost your osToken apy using leverage staking
Arguments:
| Name | Type | Required | Description |
|---|---|---|---|
| amount | bigint | Yes | Boost amount |
| userAddress | string | Yes | The user address |
| vaultAddress | string | Yes | The address of the vault that will mint osTokens for leverage staking |
| boostAddress | string | Yes | The address of the strategy proxy using the sdk.boost.getLeverageStrategyProxy method |
| referrerAddress | string | No | The address of the referrer |
| permitParams | PermitParams | No | The permit signature is required if there isn’t enough osToken allowance for the strategy proxy contract. For MultiSig The permit signature is not necessary for Multi Sig (e.g. Safe Wallet), as it should use sdk.contracts.tokens.mintToken.approve(boostAddress, MaxUint256) instead of a permit call to set up osToken allowance. This will be called in the action if needed.For other wallets The permit signature is optional since it will be obtained automatically using the utils.getPermitSignature method. |
| approveParams | ApproveParams | No | Force an on-chain approve instead of an off-chain permit, so the approval can be one of the bundled calls in an EIP-5792 transaction batch. When provided, lock.encode returns approveTxData for EOAs too (not only MultiSig) and lockTxData omits the permit. amount is the approval amount, must be greater than 0 — pass MaxUint256 for unlimited allowance. |
| leverageStrategyData | LeverageStrategyData | No | Leverage strategy data from sdk.boost.getLeverageStrategyData. If not provided, it will be fetched automatically during the transaction |
type LeverageStrategyData = {
version: number
isUpgradeRequired: boolean
}
type PermitParams = {
vault: string
amount: bigint
deadline: number
v: number
r: string
s: string
}
type ApproveParams = {
amount: bigint
}
Example:
const leverageStrategyData = await sdk.boost.getLeverageStrategyData({
userAddress: '0x...',
vaultAddress: '0x...',
})
const params = {
amount: parseEther('1'),
userAddress: '0x...',
vaultAddress: '0x...',
boostAddress: '0x...',
leverageStrategyData,
}
// Send transaction
const hash = await sdk.boost.lock(params)
// Wait for the transaction to be confirmed and indexed
await sdk.provider.waitForTransaction(hash)
await sdk.utils.waitForSubgraph({ hash })
// When you sign transactions on the backend (for custodians)
// `lockTxData` will always be returned, while `approveTxData` will only be returned for MultiSig e.g. Safe Wallet
// if there isn’t enough osToken allowance, otherwise it will be null
// and `upgradeLeverageStrategyTxData` will be returned if the leverage strategy contract upgrade is required
const { lockTxData, approveTxData, upgradeLeverageStrategyTxData } = await sdk.boost.lock.encode(params)
// Get an approximate gas per transaction
const gas = await sdk.boost.lock.estimateGas(params)