Withdraw pTokens

For a detailed explanation of pTokens, check out this article: Position Tokens (pToken)

Withdrawing AeroSTETH_ETHPToken

When withdrawing from pTokens, you have a few choices of functions to call depending on the needs of your platform.

  • withdraw() - If you would like to input the amount of underlying shares to withdraw, burning pTokens that are not being used as collateral.

  • redeem() - If you would like to redeem pTokens, that are currently being yield optimized but also not being used as collateral.

  • redeemCollateral() - If you would like to redeem pTokens that are currently being used as collateral.

  • redeemFor() - If you would like to redeem pTokens that are not being used as collateral, on behalf of a user. Requires the user to delegate your platform.

  • redeemCollateralFor() - If you would like to redeem pTokens that are currently being used as collateral, on behalf of a user. Requires the user to delegate your platform.

If the msg.sender is the user who owns the pTokens, ERC20 approval is not required. When called by a third party on behalf of the owner, standard ERC20 approval is required.

Using withdraw()

When calling withdraw, you may call it with the following arguments:

Type
Name
Description

uint256

assets

The amount of underlying assets to withdraw.

address

receiver

The account that should receive the assets.

address

owner

The account that will burn their shares to withdraw assets.

Code snippets:

// Get the pToken contract with signer
const pToken = new ethers.Contract(
  ADDRESSES.AERO_STETH_ETH_PTOKEN,
  PTOKEN_ABI,
  signer
);

// 1 Aerodrome stETH/ETH LP token
const assetsToWithdraw = ethers.utils.parseUnits("1",18);

// OPTIONAL: If you want to move tokens as a third party without delegation you can have
// the user approve your platform to spend their pTokens.
pToken.approve(YOUR_PLATFORM_ADDRESS, amountToWithdraw);

// call withdraw
const assetsWithdrawn = await pToken.withdraw(assetsToWithdraw, receiverAddress, owner);

Using redeem()

When calling redeem, you may use the following arguments:

Type
Name
Description

uint256

shares

The amount of shares to redeem.

address

receiver

The account that should receive the assets.

address

owner

The account that will burn their shares to receive assets.

Code snippet:

// Get the pToken contract with signer
const pToken = new ethers.Contract(
  ADDRESSES.AERO_STETH_ETH_PTOKEN,
  PTOKEN_ABI,
  signer
);

// 1 Curvance AeroSTETH_ETHPToken
const sharesToWithdraw = ethers.utils.parseUnits("1", 18);

// OPTIONAL: If you want to move tokens as a third party without delegation you can have
// the user approve your platform to spend their pTokens.
pToken.approve(YOUR_PLATFORM_ADDRESS, sharesToWithdraw);

// Call redeem
pToken.redeem(pTokensToWithdraw, YOUR_PLATFORM_ADDRESS, sharesToWithdraw);

Using redeemCollateral()

when calling redeemCollateral, you may use the following arguments:

Type
Name
Description

uint256

shares

The amount of collateralized shares to redeem.

address

receiver

The account that should receive the assets.

address

owner

The account that owns the shares being redeemed.

Code snippet:

// Get the pToken contract with signer
const pToken = new ethers.Contract(
  ADDRESSES.AERO_STETH_ETH_PTOKEN,
  PTOKEN_ABI,
  signer
);

// 1 Curvance AeroSTETH_ETHPToken
const sharesToWithdraw = ethers.utils.parseUnits("1", 18);

// OPTIONAL: If you want to move tokens as a third party without delegation you can have
// the user approve your platform to spend their pTokens.
pToken.approve(YOUR_PLATFORM_ADDRESS, sharesToWithdraw);

// Call redeem
pToken.redeemCollateral(pTokensToWithdraw, YOUR_PLATFORM_ADDRESS, sharesToWithdraw);

To significantly reduce the number of transactions required, consider using our delegation system. Utilize redeemFor() and redeemCollateralFor(). You can follow our detailed Delegation Walkthrough.

Last updated