-
Notifications
You must be signed in to change notification settings - Fork 8
PegStabilityModuleBase
Used to mint ZAI with collateral at a pre-defined rate
https://docs.maha.xyz/mechanics/peg-mechanics/peg-stablility-module-psm
bytes32 PAUSER_ROLEbytes32 FEE_COLLECTOR_ROLEcontract IStablecoin zaiReturns the Zai stablecoin
contract IERC20 collateralReturns the collateral token
uint256 supplyCapReturns the supply cap
uint256 debtCapReturns the debt cap
uint256 debtReturns the current debt held in this vault
uint256 mintFeeBpsThe mint fee in BPS
uint256 redeemFeeBpsThe redeem fee in BPS
address feeDestinationThe address where fees are sent
uint256 MAX_FEE_BPSThe maximum fee that can be charged
function __PegStabilityModule_init(address _zai, address _collateral, address _governance, uint256 _supplyCap, uint256 _debtCap, uint256 _mintFeeBps, uint256 _redeemFeeBps, address _feeDestination) internalfunction mint(address dest, uint256 shares) externalMints ZAI with collateral
This contract calculates how much collateral should be taken
| Name | Type | Description |
|---|---|---|
| dest | address | |
| shares | uint256 | The amount of zai to mint |
function redeem(address dest, uint256 shares) externalRedeems ZAI for collateral
This contract calculates how much collateral should be given
| Name | Type | Description |
|---|---|---|
| dest | address | |
| shares | uint256 | The amount of zai to redeem |
function rate() public view virtual returns (uint256)Returns the current rate of ZAI/Collateral
function sweepFees() externalCollects fees from the collateral pool
function togglePause() externalPauses the contract
function updateCaps(uint256 _supplyCap, uint256 _debtCap) externalUpdates the supply and debt caps
Only callable by the admin
| Name | Type | Description |
|---|---|---|
| _supplyCap | uint256 | How much collateral can be taken |
| _debtCap | uint256 | How much debt can be held |
function updateFees(uint256 _mintFeeBps, uint256 _redeemFeeBps) externalUpdates the mint and redeem fees
| Name | Type | Description |
|---|---|---|
| _mintFeeBps | uint256 | The new mint fee in BPS |
| _redeemFeeBps | uint256 | The new redeem fee in BPS |
function updateFeeDestination(address _feeDestination) externalUpdates the fee destination
Only callable by the admin
| Name | Type | Description |
|---|---|---|
| _feeDestination | address | The new fee destination |
function toCollateralAmount(uint256 _shares) public view returns (uint256)Converts ZAI amount to collateral
| Name | Type | Description |
|---|---|---|
| _shares | uint256 |
| Name | Type | Description |
|---|---|---|
| [0] | uint256 |
function mintAmountIn(uint256 amountAssetsIn) external view returns (uint256 shares)Calculates how much ZAI should be minted for a given amount of collateral
| Name | Type | Description |
|---|---|---|
| amountAssetsIn | uint256 | The amount of collateral |
function redeemAmountOut(uint256 amountAssetsOut) external view returns (uint256 shares)Calculates how much ZAI should be redeemed for a given amount of collateral
| Name | Type | Description |
|---|---|---|
| amountAssetsOut | uint256 | The amount of collateral |
function toCollateralAmountWithFee(uint256 _amount, uint256 _fee) public view returns (uint256)Converts ZAI amount to collateral with fee added
Fee is calculated as (amount * (MAX_FEE_BPS + fee)) / MAX_FEE_BPS
| Name | Type | Description |
|---|---|---|
| _amount | uint256 | The amount of ZAI |
| _fee | uint256 | The fee to be charged in BPS |
function toCollateralAmountWithFeeInverse(uint256 _amount, uint256 _fee) public view returns (uint256)Converts ZAI amount to collateral with fee removed
Fee is calculated as (amount * (MAX_FEE_BPS - fee)) / MAX_FEE_BPS
| Name | Type | Description |
|---|---|---|
| _amount | uint256 | The amount of ZAI |
| _fee | uint256 | The fee to be charged in BPS |
function feesCollected() public view virtual returns (uint256)How much fees has been collected by the protocol
| Name | Type | Description |
|---|---|---|
| [0] | uint256 |
function _updateCaps(uint256 _supplyCap, uint256 _debtCap) internalfunction _updateFeeDestination(address _feeDestination) internalUpdates the fee destination
| Name | Type | Description |
|---|---|---|
| _feeDestination | address | the new fee destination |
function _updateFees(uint256 _mintFeeBps, uint256 _redeemFeeBps) internalUpdates the mint and redeem fees
| Name | Type | Description |
|---|---|---|
| _mintFeeBps | uint256 | the new mint fee in BPS |
| _redeemFeeBps | uint256 | the new redeem fee in BPS |