Skip to main content

approve(spender, amount)

Set an allowance on ctAssets (vault shares). This is not required for a normal deposit. Use it if another contract (or account) needs permission to move your shares via transferFrom.

Signature

await vault.approve(spender: string, amount: bigint): Promise<Tx>

Parameters

  • spender: the vault address (vault.getAddress()).
  • amount: allowance in underlying token units (BigInt).

Returns

  • Tx: an Ethers v6 TransactionResponselike object (use await tx.wait() for confirmation).

Example

const spender = "0xSpender...";
const allowance = await vault.toBigInt("100.0"); // 100 shares
const tx = await vault.approve(spender, allowance);
await tx.wait();

Approve: Underlying vs. Shares

There are two separate approvals you may encounter when working with Concrete Vaults.

TypeWhen to UseMethodUnitsRequired?
Underlying ApprovalBefore calling deposit — vault must be allowed to pull the underlying ERC20 (e.g. USDC, WETH).details.underlaying.erc20.approve(vault.getAddress(), amount)Underlying decimalsAlways required for deposits
Share ApprovalIf another contract/account needs to move your vault shares (ctAssets) with transferFrom.vault.approve(spender, amount)Share decimalsOnly for external share movement (not required for deposits)

Examples

// Approve underlying (required before deposit)
const amount = await vault.toUnderlyingBigInt("1.0");
await (await details.underlaying.erc20.approve(vault.getAddress(), amount)).wait();

// Approve shares (optional, for transferFrom)
const shareAllowance = await vault.toBigInt("50.0");
await (await vault.approve(spender, shareAllowance)).wait();