Curvance
  • Protocol Overview
    • Click Less, Earn More
    • Protocol Architecture
    • Asset Types
    • Liquidity Markets
      • Borrowing
      • Liquidations
      • Interest Rates
      • Oracles
      • Collateral Caps
      • Bad Debt Socialization
    • Application Specific Sequencing
    • New Age Liquidity Mining
      • Protocols
    • How Are New Assets Integrated
    • Plugin System
    • Universal Account Balance
    • Token Approval Management
    • Lending Risks
  • Security
    • Security and Audits
  • Miscellaneous
    • RPCs and Testnet Stability
    • Glossary
    • TL;DR
      • Customer Types and Benefits
    • Brand Assets
    • Weblinks
    • Disclaimer
    • Frequently Asked Questions
  • Developer Docs
    • Overview
    • Quick Start Guides
      • Atlas Fastlane Auctions (coming soon)
      • Plugin Integration
        • List of Delegable Actions
      • Loans & Collateral
        • Lend Assets
        • Deposit into pTokens
        • Withdraw Loans
        • Withdraw pTokens
      • Borrowing & Repayment
        • Borrow
        • Repaying Debt
      • Leverage
        • Leveraging
        • Deleveraging
    • Lending Protocol
      • Market Manager
      • Position Tokens (pToken)
      • Earn Tokens (eTokens)
      • Dynamic Interest Rate Model
      • Universal Balance
    • Position Management
      • Leverage
      • Deleverage / Fold
    • Dynamic Liquidation Engine (DLE)
      • OEV Liquidation System
      • Bad Debt Socialization
    • Plugin & Delegation System
      • Transfer Lock Mechanism
      • Delegable Actions
    • Cross-Chain Functionality
      • Messaging Hub
      • Fee Manager
      • Reward Manager
    • Auxiliary Functionality
Powered by GitBook
On this page
Export as PDF
  1. Developer Docs
  2. Quick Start Guides
  3. Loans & Collateral

Withdraw pTokens

PreviousWithdraw LoansNextBorrowing & Repayment

Last updated 6 days ago

For a detailed explanation of pTokens, check out this article:

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.

Removing collateral should be done with extreme caution. Removing collateral can increase the user's loan to value ratio, which increases the risk of liquidation.

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 .

Position Tokens (pToken)
Delegation Walkthrough