Developers
Search…
πŸ€
SanToken - SLP Tokens
Angle's Standard Liquidity Providers contracts
SanToken.json
9KB
Code
SanToken ABI

1. Introduction

sanTokens are the tokens that are given to SLPs contributing to a collateral pool. There is one different sanToken per collateral/stablecoin pair, meaning that every time a new collateral is deployed for a given stablecoin, a new sanToken contract should be deployed.
These tokens are interest-bearing tokens. From a SLP perspective, these tokens are minted/burnt upon calling deposit() or withdraw() in a StableMaster contract and specifying a collateral. The StableMaster contract then calls the SanToken contract corresponding to the collateral to issue or burn the sanTokens.
The exchange rate between sanTokens and the corresponding collateral evolves over time as interests accrue for SLPs.
When a new collateral is launched the sanRate (sanToken exchange rate that is how much of collateral one sanToken is worth) begins at 1 (BASE_TOKENS), and increases at a rate depending on the transaction fees accumulated and the yield obtained from reserves given to SLPs. For example, after one year the exchange rate might equal 1.1. Each SLP has the same sanRate and can thus get more collateral out of the same number of sanTokens.
Like any ERC-20 token, sanTokens can be transferred to any address. They can for instance be staked in Angle's staking contracts to get governance tokens in exchange. sanTokens are regular ERC-20 tokens based on the OpenZeppelin ERC20PermitUpgradeable and on the ERC20BurnableUpgradeable code.
The SanToken contract is never interacted directly with by SLPs for mint operations.
The SanToken contract is very similar to the AgToken contract.

2. Contract Details

Interfaces

Implements ISanToken, ERC20PermitUpgradeable, ERC20BurnableUpgradeable . The contract is upgradeable.
This means that the reference to a SanToken contract in another contract will never change even though the code in the contract may change.

Parameters

  • stableMaster: Reference to the StableMaster contract associated to this sanToken
  • poolManager: Address of the corresponding PoolManager contract. Although it is not used in the functions of the contract, this address is stored in order to make sure that there cannot be a shared sanToken for multiple PoolManager contracts
  • decimal: Number of decimals used for this ERC20. The number of decimals of sanTokens is equal to the number of decimals of the collateral token that corresponds to it

Access Control

There is no specific access control logic in this contract. A custom onlyStableMaster modifier was defined to protect functions which can only be called by 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.
Since this contract implements OpenZeppelin's ERC20BurnableUpgradeable library, owners of sanTokens have the power to completely burn their tokens without getting anything in return.

StableMaster Functions

The following function can only be called by the StableMaster contract. Note that they are not pausable as the functions in the StableMaster which trigger calls to these contracts can be paused.

mint

1
function mint(address account, uint256 amount) external;
Copied!
Lets the StableMaster contract mint sanTokens. Only the StableMaster contract can issue sanTokens, it will typically do so after being requested by a collateral manager receiving collateral through the function deposit() reserved to SLPs.
Parameters:
  • account: Address to mint to
  • amount: Amount to mint

burnSelf

1
function burnSelf(uint256 amount, address burner) external;
Copied!
Lets an address burn sanTokens and redeem collateral for this address. This can only be called by the StableMaster which performs all the security checks to see for instance if the burner was the initial msg.sender
Parameters:
  • amount: Amount of sanTokens to burn from caller
  • burner: Address to burn from

burnFrom

1
function burnFrom(uint256 amount, address burner, address sender) external;
Copied!
Lets an address burn sanTokens on behalf of another address and redeem collateral that will go to this other address. Only the StableMaster can call this function.
Parameters:
  • burner: Address to burn from and to redeem collateral to
  • sender: Address which requested the burn from burner
  • amount: Amount of sanTokens to burn

EIP2612 Methods

Like in the AgToken contrat, the SanToken contract also has a permit() function.