GM Vaults

If properly configured in the GM Lending/Looping Pool contract, each asset is associated with an ERC-4626 Vault. The Tokenized Vault standard assigns shares to depositors, which represent a claim to ownership on a fraction of the Vault's underlying assets. Shares can be converted to deposited asset tokens at any time. The following list of functions only include those that differ from the base ERC-4626 specification:

constructor

constructor(
        ERC20 underlying,
        string memory name,
        string memory symbol,
        address _lendingPool,
        address _manager
    ) ERC4626(underlying, name, symbol) 

At deployment, the constructor takes in token variables (underlying, name, and symbol) and passes them to the ERC-4626 constructor. It also stores the manager and lendingPool addresses and the GM Token's ERC20 instance. Lastly, the contract approves the owner (the Lending Pool) to be able to spend the maximum allowed tokens (type(uint256).max) on its behalf.

Parameters:

pause

function pause() external onlyManager

Pauses functions with the whenNotPaused modifier. Only the Vault manager can call.

unpause

function unpause() external onlyManager

Unpauses functions with the whenNotPaused modifier. Only the Vault manager can call.

totalAssets

function totalAssets(uint256 _amount) public view override

Returns the total token balance of the vault.

Returns:

migrate

function migrate(address newVault, uint256 amount) external

Transfers tokens of the existing Vault contract to a new Vault contract. This function can only be called by the manager while the contract is paused. If amount is greater than the Vault balance, then the call with revert. The amount argument allows for a migration "test" transfer before transferring the entire balance.

Parameters:

Other Functions

function deposit(uint256 assets, address receiver) public override whenNotPaused onlyPool returns (uint256);
function mint(uint256 shares, address receiver) public override whenNotPaused onlyPool returns (uint256);
function withdraw(uint256 assets, address receiver, address owner) public override whenNotPaused onlyPool returns (uint256);
function redeem(uint256 sares, address receiver, address owner) public override whenNotPaused onlyPool returns (uint256);

The above functions are all overridden so that only the lendingPool address can call these functions. This is to ensure that the depositing and withdrawing of assets only happens via the Lending Pool contract, so that internal variables (balances, debt, and exchange rates) are properly tracked and collateral is properly enabled.

Last updated