Unstake Pool Shares

Enable the user to unstake their staked pool shares.

The following references the stake pool ABI and addresses from the page: Stake Pool Shares

The following code example is in typescript. These smart contract integrations can be generalized to any codebase.

UNSTAKE

If the user’s shares are staked, they must withdraw them from staking first, before redeeming to assets.

export async function unstake({
  client, account, vault, staking, sharesStr, vaultShareDecimals,
}: {
  client:any; account:`0x${string}`; vault:`0x${string}`; staking:`0x${string}`;
  sharesStr:string; vaultShareDecimals:number;
}) {
  const shares = parseUnits(sharesStr, vaultShareDecimals);

  // Unstake shares from Thirdweb
  await client.writeContract({
    address: staking, abi: stakingErc20Abi, functionName: 'withdraw', args: [shares],
  });
}

Last updated