Developers
Search…
βš–
AgToken - Stablecoin Contracts
Angle's Protocol Stablecoins
The updated AgToken contract associated to Angle Borrowing Module is not yet available and will soon be open-sourced.

1. Introduction

agTokens are Angle's protocol stablecoins. Depending on the stablecoin, different smart contracts may have minting rights on agTokens.
In the Core Module, agTokens they are minted upon calling mint() or burn() in a StableMaster contract. The StableMaster contract then calls the AgToken to issue or burn the tokens. These tokens are convertible against one of the collateral of the protocol at oracle value and with very small fees. It is possible to mint agTokens using for instance USDC and to use these agTokens to redeem DAI: the collateral that was used to mint the agTokens does not prevent holders to claim another collateral from the agToken.
For some tokens, the FlashLoan contract may have minting right on the token, just like some VaultManager contracts associated to the Borrowing Module.
Addresses associated to algorithmic market operations of the protocol can also get a minting right on the stablecoin.
Like any ERC-20 token, they can be transferred to any address. They can for instance be staked in Angle's staking contracts to get governance tokens in exchange. agTokens are regular ERC-20 tokens based on the OpenZeppelin ERC20PermitUpgradeable code.

2. Contract Details

Interfaces

Implements IAgToken and ERC20PermitUpgradeable. This contract is upgradeable.

Parameters and Mappings

Depending on the implementation deployed, here are some of the usual parameters found in AgToken contracts
  • stableMaster: Reference to the StableMaster contract associated to this agToken.
  • treasury: Reference to the Treasury contract associated to this agToken. This concerns AgTokens which can be minted from Angle Borrowing Module
  • isMinter: In the Borrowing Module, maps an address to whether it has the minting right on the AgToken.

Access Control

There is no specific access control in this file. A custom modifier onlyStableMaster() has been defined to restrict access to some functions to just the stableMaster.

3. Key Mechanisms & Concepts

EIP20 Methods

All standard EIP20 methods are implemented, such as balanceOf(), transfer(), transferFrom(), approve(), totalSupply(), etc.
The implementation of these methods is derived from OpenZeppelin's library.

User Available External Functions to Burn Stablecoins Without Redeeming Collateral

burnNoRedeem

1
function burnNoRedeem(uint256 amount, address poolManager) external;
Copied!
Destroys amount token for the caller without giving collateral back. When calling this function, people should specify the poolManager for which they want to decrease the stocksUsers: this a way for the protocol to maintain healthy accounting variables.
Parameters
  • amount: Amount to burn
  • poolManager: Reference to the PoolManager contract for which the stocksUsers will need to be updated

burnFromNoRedeem

1
function burnFromNoRedeem(address account, uint256 amount, address poolManager) external;
Copied!
Burns the amount of agToken on behalf of another account without redeeming collateral back. This function is for instance to be used by governance to burn the tokens accumulated by the BondingCurve contract.
Parameters
  • account: Account to burn on behalf of
  • amount: Amount to burn
  • poolManager: Reference to the PoolManager contract for which the stocksUsers will need to be updated

burnStablecoin

1
function burnStablecoin(uint256 amount) external;
Copied!
Burns the amount of agToken on behalf of another account without redeeming collateral back and without changing any variable in a PoolManager contract.
Parameters
  • amount: Amount to burn

StableMaster Functions

The following functions can only be called by the StableMaster contract. The StableMaster will call these functions after having been requested to do so by a user

mint

1
function mint(address account, uint256 amount) external;
Copied!
Lets the StableMaster contract mint agTokens, a VaultManager, if initialized the FlashLoan contract or a whitelisted address mint agTokens
Parameters:
  • account: Address to mint to
  • amount: Amount to mint

burnSelf

1
function burnSelf(uint256 amount, address burner) external;
Copied!
Burns amount tokens from a burner address. This method is to be called by any contract with a minting right on the AgToken after being requested to do so by an address willing to burn tokens from its address
Parameters:
  • amount: Amount of tokens to burn
  • burner: Address to burn from

burnFrom

1
function burnFrom(uint256 amount, address burner, address sender) external;
Copied!
Burns amount tokens from a burner address after being asked to by sender. This method is to be called by the StableMaster contract or any contract with a minting right on the token after being requested to do so by a msg.sender address willing to burn tokens from another sender address
The method checks the allowance between the sender and the burner.
Parameters:
  • amount: Amount of tokens to burn
  • burner: Address to burn from
  • sender: Address which requested the burn from burner

EIP2612 Methods

permit()

1
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public;
Copied!
Allows a user to permit another account (or contract) to use their funds using a signed message. This enables gas-less transactions and single approval/transfer transactions.
Parameters:
  • owner: The owner of the funds
  • spender: The spender of the funds
  • value: The amount the spender is permitted to use
  • deadline: The deadline timestamp that the permit is valid. Use type(uint256).max for no deadline
  • v: Signature Parameter
  • r: Signature Parameter
  • s: Signature Parameter

Governance Methods

For the AgTokens that support Angle Borrowing Module, there are some functions which are available to the Treasury contract to perform some governance actions. Generally, the Treasury will do so after being requested by governance.
  • addMinter: to grant the minter right to an address.
  • removeMinter: to remove the minter right to an address. A minter can self-revoke itself and the Treasury cannot revoke the stableMaster
  • setTreasury: to change the reference to the treasury contract