Ion Protocol
HomeDiscordTwitter
  • Overview
    • ๐Ÿ’งWelcome to Ion Protocol
    • ๐Ÿ“šUnderstanding the Staking and Restaking Ecosystem
    • ๐Ÿ”—Official Links
    • โ”FAQ
  • Ion Protocol
    • โš™๏ธHow Ion Works
    • ๐Ÿ‘ฅReferrals
    • ๐Ÿ’ฆIon Points
  • Lending
    • ๐Ÿ’ฐHow To Lend On Ion
    • ๐ŸŒETH-on-ETH Yield
    • ๐ŸงชLending Mechanisms
      • Composable Markets
      • ZKML-Supported Risk Underwriting
  • Borrowing
    • ๐Ÿ’ธHow To Borrow On Ion
    • ๐Ÿ“ˆMultiplying Rewards
    • ๐Ÿ› ๏ธBorrowing Mechanisms
      • Flash Leverage
      • Interest Rates
      • ZK Proof-of-Reserve
  • Liquidations
    • ๐Ÿ“‰Liquidation Mechanism
    • ๐Ÿง‘โ€๐Ÿ’ปKeepers
  • Supported Collateral
    • LSTs
    • LRTs
    • Exotic ETH-Backed Assets
  • Devs
    • ๐Ÿ’ปSmart Contract Architecture
      • Home
      • Admin
        • ProxyAdmin
        • TransparentUpgradeableProxy
        • ITransparentUpgradeableProxy
      • Flash
        • LRT
          • RsEthHandler
          • EzEthHandler
          • RswEthHandler
          • WeEthHandler
        • LST
          • SwEthHandler
          • EthXHandler
          • WstEthHandler
        • BalancerFlashloanDirectMintHandler constants
        • BalancerFlashloanDirectMintHandler
        • PtHandler
        • IonHandlerBase
        • UniswapFlashloanBalancerSwapHandler
        • UniswapFlashswapDirectMintHandler
        • UniswapFlashswapDirectMintHandlerWithDust
        • UniswapFlashswapHandler
      • Join
        • GemJoin
      • Libraries
        • LRT
          • KelpDaoLibrary
          • EtherFiLibrary
          • RestakedSwellLibrary
          • RenzoLibrary
        • LST
          • StaderLibrary
          • LidoLibrary
          • SwellLibrary
        • math
          • WadRayMath constants
          • WadRayMath
        • uniswap
          • UniswapOracleLibrary
          • TickMath
      • Oracles
        • Reserve
          • LRT
            • EzEthWstEthReserveOracle
            • RsEthWstEthReserveOracle
            • RswEthWstEthReserveOracle
            • WeEthWstEthReserveOracle
          • LST
            • SwEthReserveOracle
            • EthXReserveOracle
            • WstEthReserveOracle
          • Pendle
            • EzEthPtReserveOracle
            • RsEthPtReserveOracle
            • RswEthPtReserveOracle
            • WeEthPtReserveOracle
          • ReserveOracle
          • ReserveFeed
          • ReserveOracle constants
        • Spot
          • LRT
            • EzEthWstEthSpotOracle
            • RsEthWstEthSpotOracle
            • RswEthWstEthSpotOracle
            • WeEthWstEthSpotOracle
          • LST
            • EthXSpotOracle constants
            • EthXSpotOracle
            • IRedstonePriceFeed
            • SwEthSpotOracle
            • WstEthSpotOracle
          • SpotOracle
          • PtSpotOracle
      • Periphery
        • IonInvariants
        • IonLens
        • IlkSlot0
        • IonRegistry
      • Token
        • IERC20Errors
        • RewardToken
      • Vault
        • VaultFactory
        • Vault
      • Whitelist
      • YieldOracle constants
      • YieldOracle
      • YieldOracleNull
      • YieldOraclePendle
      • Errors
      • Constants
      • Seaport Leverage and Deleverage
    • ๐Ÿ“„Deployed Contracts
  • Security
    • ๐Ÿ”Security Reviews
  • Legal
    • Terms of Use
    • Privacy Policy
  • Import
    • ProxyAdmin
Powered by GitBook
On this page
  • State Variables
  • Functions
  • Errors
  1. Devs
  2. Smart Contract Architecture
  3. Flash

PtHandler

PreviousBalancerFlashloanDirectMintHandlerNextIonHandlerBase

Inherits: IonHandlerBase, IPMarketSwapCallback

This contract allows for easy creation of leverage positions for PT collateralized Ion markets.

State Variables

MARKET

IPMarketV3 public immutable MARKET;

SY

IStandardizedYield public immutable SY;

PT

IERC20 public immutable PT;

YT

IERC20 public immutable YT;

flashswapInitiated

uint256 private flashswapInitiated = 1;

Functions

constructor

Creates a new PtHandler instance

constructor(
    IonPool pool,
    GemJoin join,
    Whitelist whitelist,
    IPMarketV3 _market
)
    IonHandlerBase(0, pool, join, whitelist);

Parameters

Name
Type
Description

pool

IonPool

The related IonPool.

join

GemJoin

The related GemJoin.

whitelist

Whitelist

The whitelist contract.

_market

IPMarketV3

The related Pendle market.

ptLeverage

Allows a borrower to create a leveraged position on Ion Protocol

Transfer PT from user -> Flashswap PT token -> Deposit all PT into IonPool -> Borrow base asset -> Mint SY using base asset -> Repay Flashswap with SY.

function ptLeverage(
    uint256 initialDeposit,
    uint256 resultingAdditionalCollateral,
    uint256 maxResultingDebt,
    uint256 deadline,
    bytes32[] calldata proof
)
    external
    onlyWhitelistedBorrowers(proof)
    checkDeadline(deadline);

swapCallback

This function should never be called directly.

On small enough swaps, the SY to send back can be 0. This function can only be called by the market. This function can only be called by market if the swap was initiated by this contract.

function swapCallback(int256 ptToAccount, int256 syToAccount, bytes calldata data) external;

Parameters

Name
Type
Description

ptToAccount

int256

Amount of PT sent from the perspective of the pool (negative means pool is sending, positive means user is receiving)

syToAccount

int256

Amount of SY sent from the perspective of the pool (negative means pool is sending, positive means user is receiving)

data

bytes

Arbitrary data passed by the market

Errors

InvalidGemJoin

error InvalidGemJoin(address invalidJoin);

MarketMustBeCaller

error MarketMustBeCaller(address caller);

ExternalFlashswapNotAllowed

error ExternalFlashswapNotAllowed();

InvalidSwapDirection

error InvalidSwapDirection();

UnexpectedSyOut

error UnexpectedSyOut(uint256 amountSyOut, uint256 expectedSyOut);

FlashswapTooExpensive

error FlashswapTooExpensive(uint256 amountSyIn, uint256 maxResultingDebt);

๐Ÿ’ป
Git Source