LogoLogo
  • ⚒️Introduction
  • Overview
    • 📖Public Repositories
    • ⛓️Smart Contracts Addresses
      • ⛓️Mainnet
      • 🟣Polygon
      • 🔴Optimism
      • 🔵Arbitrum
      • 🕸️Other Sidechains and L2s
  • Developer Guides
    • 💱Using Transmuter
    • 💸Integrating Savings Contracts
    • ⚡Flash Loans
    • 🍶Liquidations in the Borrowing Module
    • 🌻Auto-Leverage and Capital-Efficiency in the Borrowing Module
  • Tools
    • 🔌API - Accessing Angle Data
  • Governance and Cross-Module Contracts
    • ⚖️AgToken - Stablecoin Contracts
    • 🛣️Router - Combining Protocol Interactions
    • 💫FlashAngle - Instant AgToken liquidity
    • 💗CoreBorrow - Access Control Manager
    • 🗳️ANGLE and veANGLE - Governance Token
  • Borrowing Module Contracts
    • 🔜Architecture Overview
    • 📀Smart Contracts Docs
      • 🏦VaultManager - Borrowing AgTokens
      • 👮Treasury - Stablecoin Accounting
      • 🔱Oracles - Getting Price Feeds
      • 🗡️Settlement - Closing VaultManager contracts
      • 💱Swapper - Helper for Liquidations and Auto-Leverage
    • 🔬Implementation Details
Powered by GitBook
On this page
  • 1. Introduction
  • 2. Contract Details
  • Interfaces
  • Parameters and Mappings
  • Access Control
  • 3. Key Mechanisms & Concepts
  • ERC3156 Methods
  • Maintenance Function
  • Governance Functions

Was this helpful?

  1. Governance and Cross-Module Contracts

FlashAngle - Instant AgToken liquidity

Flash loans on top of Angle Protocol stablecoins

PreviousRouter - Combining Protocol InteractionsNextCoreBorrow - Access Control Manager

Last updated 1 year ago

Was this helpful?

  • Contract Name: FlashAngle

  • Contract Source:

1. Introduction

FlashAngle is a contract to take flash loans on top of Angle Protocol AgTokens. With this contract and for a whitelisted stablecoin, any address can take a flash-loan of AgToken.

The innovation here is that stablecoins given out in flash loans are minted during the transaction and burnt at the end of it: this means that this contract could be used to take theorically uncapped and free flash loans on Angle Protocol stablecoins.

2. Contract Details

Interfaces

Implements IFlashAngle, IERC3156FlashLender, ReentrancyGuardUpgradeable and Initializable. This contract is upgradeable.

Parameters and Mappings

  • core: Reference to the CoreBorrow contract

  • stablecoinMap: Maps a stablecoin to its associated parameters and reference, that is to say: the treasury contract associated to the stablecoin, the maximum amount borrowable through a flash-loan and the fee taken on each flash loan.

Access Control

Some functions can only be called by the CoreBorrow contract as such a custom modifier onlyCore has been defined. This contract also reads in its associated core contract to know whether addresses have the guardian role.

3. Key Mechanisms & Concepts

ERC3156 Methods

All standard ERC3156 methods are implemented, such as flashFee(), maxFlashLoan() and flashLoan().

    function flashLoan(
        IERC3156FlashBorrower receiver,
        address token,
        uint256 amount,
        bytes calldata data
    ) external returns (bool);

The flashLoan implementation differs from other standard implementations in that stablecoins are minted to the receiver address.

This address must have a function onFlashLoan to receive the flash-loan, and this function should return keccak256("ERC3156FlashBorrower.onFlashLoan") after being called. If there are some fees setup for this function, then if amount of stablecoins have been sent to the receiver, then amount + amount * fees will have to be burnt from the receiver contract.

This function will revert if it is called on a token, that is to say a stablecoin, that has not been whitelisted.

Maintenance Function

If fees are taken, then this contract may make revenue. There is a accrueInterestToTreasury function to pass these fees to Treasury contract responsible for doing the accounting of profits and losses.

There can never be a loss by the FlashAngle contract.

Governance Functions

The FlashAngle contract can be made aware that it supports a new stablecoin by associating a non-zero treasury address to the stablecoin address in the stablecoinMap.

This can be done by the core contract in the addStablecoinSupport function. The core contract can also remove a stablecoin through the removeStablecoinSupport function, or pass its role to another contract with the setCore function.

Parameters for flash loans and for a given stablecoin can be changed by governance with the setFlashLoanParameters function.

💫
https://github.com/AngleProtocol/borrow-contracts/tree/main/contracts/flashloan
6KB
FlashAngle.json
FlashAngle ABI