CollateralManager

Git Source

Inherits: ICollateralManager, Ownable

Author: Sperax Foundation

This contract manages the addition and removal of collateral, configuration of collateral strategies, and allocation percentages.

Collateral Manager interacts with the Vault and various strategies for collateral management.

State Variables

collateralCompositionUsed

uint16 public collateralCompositionUsed;

VAULT

address public immutable VAULT;

collaterals

address[] private collaterals;

collateralInfo

mapping(address => CollateralData) public collateralInfo;

collateralStrategyInfo

mapping(address => mapping(address => StrategyData)) private collateralStrategyInfo;

collateralStrategies

mapping(address => address[]) private collateralStrategies;

Functions

constructor

Constructor to initialize the Collateral Manager

constructor(address _vault);

Parameters

addCollateral

Register a collateral for mint & redeem in USDs

function addCollateral(address _collateral, CollateralBaseData memory _data) external onlyOwner;

Parameters

updateCollateralData

Update existing collateral configuration

function updateCollateralData(address _collateral, CollateralBaseData memory _updateData) external onlyOwner;

Parameters

removeCollateral

Un-list a collateral

function removeCollateral(address _collateral) external onlyOwner;

Parameters

addCollateralStrategy

Add a new strategy to collateral

function addCollateralStrategy(address _collateral, address _strategy, uint16 _allocationCap) external onlyOwner;

Parameters

updateCollateralStrategy

Update existing strategy for collateral

function updateCollateralStrategy(address _collateral, address _strategy, uint16 _allocationCap) external onlyOwner;

Parameters

removeCollateralStrategy

Remove an existing strategy from collateral

Ensure all the collateral is removed from the strategy before calling this Otherwise it will create error in collateral accounting

function removeCollateralStrategy(address _collateral, address _strategy) external onlyOwner;

Parameters

updateCollateralDefaultStrategy

function updateCollateralDefaultStrategy(address _collateral, address _strategy) external onlyOwner;

validateAllocation

Validate allocation for a collateral

function validateAllocation(address _collateral, address _strategy, uint256 _amount) external view returns (bool);

Parameters

Returns

getFeeCalibrationData

Get the required data for mint

function getFeeCalibrationData(address _collateral) external view returns (uint16, uint16, uint16, uint256);

Parameters

Returns

getMintParams

Get the required data for mint

function getMintParams(address _collateral) external view returns (CollateralMintData memory mintData);

Parameters

Returns

getRedeemParams

Get the required data for USDs redemption

function getRedeemParams(address _collateral) external view returns (CollateralRedeemData memory redeemData);

Parameters

Returns

getAllCollaterals

Gets a list of all listed collaterals

function getAllCollaterals() external view returns (address[] memory);

Returns

getCollateralStrategies

Gets a list of all strategies linked to a collateral

function getCollateralStrategies(address _collateral) external view returns (address[] memory);

Parameters

Returns

isValidStrategy

Verifies if a strategy is linked to a collateral

function isValidStrategy(address _collateral, address _strategy) external view returns (bool);

Parameters

Returns

getCollateralInStrategies

Get the amount of collateral in all Strategies

function getCollateralInStrategies(address _collateral) public view returns (uint256 amountInStrategies);

Parameters

Returns

getCollateralInVault

Get the amount of collateral in vault

function getCollateralInVault(address _collateral) public view returns (uint256 amountInVault);

Parameters

Returns

getCollateralInAStrategy

Get the amount of collateral allocated in a strategy

function getCollateralInAStrategy(address _collateral, address _strategy) public view returns (uint256 allocatedAmt);

Parameters

Returns

Events

CollateralAdded

event CollateralAdded(address collateral, CollateralBaseData data);

CollateralRemoved

event CollateralRemoved(address collateral);

CollateralInfoUpdated

event CollateralInfoUpdated(address collateral, CollateralBaseData data);

CollateralStrategyAdded

event CollateralStrategyAdded(address collateral, address strategy);

CollateralStrategyUpdated

event CollateralStrategyUpdated(address collateral, address strategy);

CollateralStrategyRemoved

event CollateralStrategyRemoved(address collateral, address strategy);

Errors

CollateralExists

error CollateralExists();

CollateralDoesNotExist

error CollateralDoesNotExist();

CollateralStrategyExists

error CollateralStrategyExists();

CollateralStrategyMapped

error CollateralStrategyMapped();

CollateralStrategyNotMapped

error CollateralStrategyNotMapped();

CollateralNotSupportedByStrategy

error CollateralNotSupportedByStrategy();

CollateralAllocationPaused

error CollateralAllocationPaused();

CollateralStrategyInUse

error CollateralStrategyInUse();

AllocationPercentageLowerThanAllocatedAmt

error AllocationPercentageLowerThanAllocatedAmt();

IsDefaultStrategy

error IsDefaultStrategy();

Structs

CollateralData

struct CollateralData {
    bool mintAllowed;
    bool redeemAllowed;
    bool allocationAllowed;
    bool exists;
    address defaultStrategy;
    uint16 baseMintFee;
    uint16 baseRedeemFee;
    uint16 downsidePeg;
    uint16 desiredCollateralComposition;
    uint16 collateralCapacityUsed;
    uint256 conversionFactor;
}

StrategyData

struct StrategyData {
    uint16 allocationCap;
    bool exists;
}

Last updated