Skip to content

PegStabilityModuleBase

senamakel edited this page Nov 27, 2024 · 2 revisions

Solidity API

PegStabilityModuleBase

Used to mint ZAI with collateral at a pre-defined rate

https://docs.maha.xyz/mechanics/peg-mechanics/peg-stablility-module-psm

PAUSER_ROLE

bytes32 PAUSER_ROLE

FEE_COLLECTOR_ROLE

bytes32 FEE_COLLECTOR_ROLE

zai

contract IStablecoin zai

Returns the Zai stablecoin

collateral

contract IERC20 collateral

Returns the collateral token

supplyCap

uint256 supplyCap

Returns the supply cap

debtCap

uint256 debtCap

Returns the debt cap

debt

uint256 debt

Returns the current debt held in this vault

mintFeeBps

uint256 mintFeeBps

The mint fee in BPS

redeemFeeBps

uint256 redeemFeeBps

The redeem fee in BPS

feeDestination

address feeDestination

The address where fees are sent

MAX_FEE_BPS

uint256 MAX_FEE_BPS

The maximum fee that can be charged

__PegStabilityModule_init

function __PegStabilityModule_init(address _zai, address _collateral, address _governance, uint256 _supplyCap, uint256 _debtCap, uint256 _mintFeeBps, uint256 _redeemFeeBps, address _feeDestination) internal

mint

function mint(address dest, uint256 shares) external

Mints ZAI with collateral

This contract calculates how much collateral should be taken

Parameters

Name Type Description
dest address
shares uint256 The amount of zai to mint

redeem

function redeem(address dest, uint256 shares) external

Redeems ZAI for collateral

This contract calculates how much collateral should be given

Parameters

Name Type Description
dest address
shares uint256 The amount of zai to redeem

rate

function rate() public view virtual returns (uint256)

Returns the current rate of ZAI/Collateral

sweepFees

function sweepFees() external

Collects fees from the collateral pool

togglePause

function togglePause() external

Pauses the contract

updateCaps

function updateCaps(uint256 _supplyCap, uint256 _debtCap) external

Updates the supply and debt caps

Only callable by the admin

Parameters

Name Type Description
_supplyCap uint256 How much collateral can be taken
_debtCap uint256 How much debt can be held

updateFees

function updateFees(uint256 _mintFeeBps, uint256 _redeemFeeBps) external

Updates the mint and redeem fees

Parameters

Name Type Description
_mintFeeBps uint256 The new mint fee in BPS
_redeemFeeBps uint256 The new redeem fee in BPS

updateFeeDestination

function updateFeeDestination(address _feeDestination) external

Updates the fee destination

Only callable by the admin

Parameters

Name Type Description
_feeDestination address The new fee destination

toCollateralAmount

function toCollateralAmount(uint256 _shares) public view returns (uint256)

Converts ZAI amount to collateral

Parameters

Name Type Description
_shares uint256

Return Values

Name Type Description
[0] uint256

mintAmountIn

function mintAmountIn(uint256 amountAssetsIn) external view returns (uint256 shares)

Calculates how much ZAI should be minted for a given amount of collateral

Parameters

Name Type Description
amountAssetsIn uint256 The amount of collateral

redeemAmountOut

function redeemAmountOut(uint256 amountAssetsOut) external view returns (uint256 shares)

Calculates how much ZAI should be redeemed for a given amount of collateral

Parameters

Name Type Description
amountAssetsOut uint256 The amount of collateral

toCollateralAmountWithFee

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

Parameters

Name Type Description
_amount uint256 The amount of ZAI
_fee uint256 The fee to be charged in BPS

toCollateralAmountWithFeeInverse

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

Parameters

Name Type Description
_amount uint256 The amount of ZAI
_fee uint256 The fee to be charged in BPS

feesCollected

function feesCollected() public view virtual returns (uint256)

How much fees has been collected by the protocol

Return Values

Name Type Description
[0] uint256

_updateCaps

function _updateCaps(uint256 _supplyCap, uint256 _debtCap) internal

_updateFeeDestination

function _updateFeeDestination(address _feeDestination) internal

Updates the fee destination

Parameters

Name Type Description
_feeDestination address the new fee destination

_updateFees

function _updateFees(uint256 _mintFeeBps, uint256 _redeemFeeBps) internal

Updates the mint and redeem fees

Parameters

Name Type Description
_mintFeeBps uint256 the new mint fee in BPS
_redeemFeeBps uint256 the new redeem fee in BPS

Clone this wiki locally