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

Deposit into pTokens

PreviousLend AssetsNextWithdraw Loans

Last updated 11 days ago

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

Depositing AeroSTETH_ETHPToken

When depositing into the AeroSTETH_ETHPToken, you're providing Aerodrome stETH-ETH LP tokens that will automatically earn yields through Aerodrome. Here's how to do it:

First, check the user's balance and ensure they have enough LP tokens:

const lpToken = new ethers.Contract(ADDRESSES.STETH_ETH_LP, ERC20_ABI, provider);
const balance = await lpToken.balanceOf(userAddress);
const depositAmount = ethers.utils.parseEther("10"); // 10 LP tokens

if (balance.lt(depositAmount)) {
  throw new Error("Insufficient LP token balance");
}

Then approve and make the deposit by calling deposit() in the pToken contract, or depositAsCollateral() to both deposit and post as collateral all in one transaction.

Function arguments when:

calling deposit()

Type
Name
Description

uint256

assets

The amount of underlying assets to deposit.

address

receiver

The account that should receive the pToken shares.

calling depositAsCollateral()

Type
Name
Description

uint256

assets

The amount of underlying assets to deposit.

uint256

receiver

The account that should receive the pToken shares.

// Approve the pToken to spend LP tokens
await lpToken.approve(ADDRESSES.AERO_STETH_ETH_PTOKEN, depositAmount);

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

// Deposit as collateral or regular deposit
if (asCollateral) {
  await pToken.depositAsCollateral(depositAmount);
} else {
  await pToken.deposit(depositAmount, userAddress);
}

Alternatively, if your app requires users depositing for another address, you can use depositAsCollateralFor().

What Happens Behind the Scenes

When you deposit LP tokens into this yield-optimized pToken:

  1. Your Aerodrome stETH-ETH LP tokens are transferred to the pToken contract.

  2. The pToken automatically stakes these LP tokens in Aerodrome.

  3. The staked position begins earning AERO rewards.

  4. When harvested, these rewards are swapped to ETH and STETH and then deposited into to the Aerodrome pool to mint new LP tokens, which are then staked back in Aerodrome gauge.

  5. This increases the total assets of the pToken, vesting until the next harvest, benefiting all depositors proportionally.

Position Tokens (pToken)