⚖️AgToken - Stablecoin Contracts

Angle's Protocol Stablecoins

1. Introduction

agTokens are Angle's protocol stablecoins. Depending on the stablecoin, different smart contracts may have minting rights on agTokens.

For some tokens, the FlashLoan contract may have minting right on the token, just like some VaultManager contracts associated to the Borrowing Module.

The implementation described here is specific to Ethereum mainnet. agToken implementations on sidechains have a different implementation, such that the ABI of their corresponding contract is the following:

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. This is no longer used and was useful when the protocol's Core module was still being used.

  • 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.

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

burnStablecoin

function burnStablecoin(uint256 amount) external;

Burns the amount of agToken on behalf of another account without redeeming collateral back anywhere

Parameters

  • amount: Amount to burn

Minter only Functions

The following functions can only be called by approved minter contracts.

mint

function mint(address account, uint256 amount) external;

Lets a VaultManager, if initialized the FlashLoan contract or a whitelisted address mint agTokens

Parameters:

  • account: Address to mint to

  • amount: Amount to mint

burnSelf

function burnSelf(uint256 amount, address burner) external;

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

function burnFrom(uint256 amount, address burner, address sender) external;

Burns amount tokens from a burner address after being asked to by sender. This method is to be called by 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()

function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public;

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

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.

  • setTreasury: to change the reference to the treasury contract

Last updated