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

NameTypeDescription

_vault

address

Address of the Vault contract

addCollateral

Register a collateral for mint & redeem in USDs

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

_data

CollateralBaseData

Collateral configuration data

updateCollateralData

Update existing collateral configuration

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

_updateData

CollateralBaseData

Updated configuration for the collateral

removeCollateral

Un-list a collateral

function removeCollateral(address _collateral) external onlyOwner;

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

addCollateralStrategy

Add a new strategy to collateral

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

_strategy

address

Address of the strategy

_allocationCap

uint16

Allocation capacity

updateCollateralStrategy

Update existing strategy for collateral

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

_strategy

address

Address of the strategy

_allocationCap

uint16

Allocation capacity

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

NameTypeDescription

_collateral

address

Address of the collateral

_strategy

address

Address of the strategy

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

NameTypeDescription

_collateral

address

Address of the collateral

_strategy

address

Address of the desired strategy

_amount

uint256

Amount to be allocated.

Returns

NameTypeDescription

bool

True for valid allocation request.

getFeeCalibrationData

Get the required data for mint

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

Returns

NameTypeDescription

uint16

Base fee config for collateral (baseMintFee, baseRedeemFee, composition, totalCollateral)

uint16

uint16

uint256

getMintParams

Get the required data for mint

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

Returns

NameTypeDescription

mintData

CollateralMintData

mintData

getRedeemParams

Get the required data for USDs redemption

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

Returns

NameTypeDescription

redeemData

CollateralRedeemData

redeemData

getAllCollaterals

Gets a list of all listed collaterals

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

Returns

NameTypeDescription

address[]

List of addresses representing all listed collaterals

getCollateralStrategies

Gets a list of all strategies linked to a collateral

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

Returns

NameTypeDescription

address[]

List of addresses representing available strategies for the collateral

isValidStrategy

Verifies if a strategy is linked to a collateral

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

_strategy

address

Address of the strategy

Returns

NameTypeDescription

bool

True if the strategy is linked to the collateral, otherwise False

getCollateralInStrategies

Get the amount of collateral in all Strategies

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

Returns

NameTypeDescription

amountInStrategies

uint256

amountInStrategies

getCollateralInVault

Get the amount of collateral in vault

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

Returns

NameTypeDescription

amountInVault

uint256

amountInVault

getCollateralInAStrategy

Get the amount of collateral allocated in a strategy

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

Parameters

NameTypeDescription

_collateral

address

Address of the collateral

_strategy

address

Address of the strategy

Returns

NameTypeDescription

allocatedAmt

uint256

Allocated amount

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