Arcadia Finance
Search
K
Comment on page

Main Registry

The Main-registry stores basic information for each token that can, or could at some point, be deposited in the vaults.

State Variables

_this

address immutable _this;

assetsUpdatable

bool public assetsUpdatable = true;

baseCurrencyCounter

uint256 public baseCurrencyCounter;

factoryAddress

address public factoryAddress;

pricingModules

address[] private pricingModules;

assetsInMainRegistry

address[] public assetsInMainRegistry;

baseCurrencies

address[] public baseCurrencies;

inMainRegistry

mapping(address => bool) public inMainRegistry;

isPricingModule

mapping(address => bool) public isPricingModule;

isBaseCurrency

mapping(address => bool) public isBaseCurrency;

assetToBaseCurrency

mapping(address => uint256) public assetToBaseCurrency;

assetToPricingModule

mapping(address => address) public assetToPricingModule;

baseCurrencyToInformation

mapping(uint256 => BaseCurrencyInformation) public baseCurrencyToInformation;

isActionAllowed

mapping(address => bool) public isActionAllowed;

Functions

onlyPricingModule

Only Sub-registries can call functions marked by this modifier.
modifier onlyPricingModule();

onlyVault

modifier onlyVault();

noDelegate

modifier noDelegate();

constructor

The Main Registry must always be initialised with the BaseCurrency USD
Since the BaseCurrency USD has no native token, baseCurrencyDecimals should be set to 0 and assetAddress to the null address.
constructor(BaseCurrencyInformation memory baseCurrencyInformation);
Parameters
Name
Type
Description
baseCurrencyInformation
BaseCurrencyInformation
A Struct with information about the BaseCurrency USD - baseCurrencyToUsdOracleUnit: Since there is no price oracle for usd to USD, this is 0 by default for USD - baseCurrencyUnit: Since there is no native token for USD, this is 0 by default for USD - assetAddress: Since there is no native token for usd, this is 0 address by default for USD - baseCurrencyToUsdOracle: Since there is no price oracle for usd to USD, this is 0 address by default for USD - baseCurrencyLabel: The symbol of the baseCurrency (only used for readability purpose)

setFactory

Sets the Factory address
function setFactory(address _factoryAddress) external onlyOwner;
Parameters
Name
Type
Description
_factoryAddress
address
The address of the Factory

setAllowedAction

Sets an allowed action handler
Can only be called by owner.
function setAllowedAction(address action, bool allowed) public onlyOwner;
Parameters
Name
Type
Description
action
address
The address of the action handler
allowed
bool
Bool to indicate its status

addBaseCurrency

Add a new baseCurrency (a unit in which price is measured, like USD or ETH) to the Main Registry, or overwrite an existing one
*If the BaseCurrency has no native token, baseCurrencyDecimals should be set to 0 and assetAddress to the null address. Tokens pegged to the native token do not count as native tokens
  • USDC is not a native token for USD as BaseCurrency
  • WETH is a native token for ETH as BaseCurrency*
The list of Risk Variables (Collateral Factor and Liquidation Threshold) should either be set through the pricing modules!
Risk variable have 2 decimals precision
function addBaseCurrency(BaseCurrencyInformation calldata baseCurrencyInformation) external onlyOwner;
Parameters
Name
Type
Description
baseCurrencyInformation
BaseCurrencyInformation
A Struct with information about the BaseCurrency - baseCurrencyToUsdOracleUnit: The unit of the oracle, equal to 10 to the power of the number of decimals of the oracle - baseCurrencyUnit: The unit of the baseCurrency, equal to 10 to the power of the number of decimals of the baseCurrency - assetAddress: The contract address of the baseCurrency, - baseCurrencyToUsdOracle: The contract address of the price oracle of the baseCurrency in USD - baseCurrencyLabel: The symbol of the baseCurrency (only used for readability purpose)

addPricingModule

Add a Sub-registry Address to the list of Sub-Registries
function addPricingModule(address subAssetRegistryAddress) external onlyOwner;
Parameters
Name
Type
Description
subAssetRegistryAddress
address
Address of the Sub-Registry

setAssetsToNonUpdatable

Disables the updatability of assets. In the disabled states, asset properties become immutable
function setAssetsToNonUpdatable() external onlyOwner;

addAsset

Add a new asset to the Main Registry, or overwrite an existing one (if assetsUpdatable is True)
The list of Risk Variables (Collateral Factor and Liquidation Threshold) should either be as long as the number of assets added to the Main Registry,or the list must have length 0. If the list has length zero, the risk variables of the baseCurrency for all assets is initiated as default (safest lowest rating).
Risk variable are variables with 2 decimals precision
By overwriting existing assets, the contract owner can temper with the value of assets already used as collateral (for instance by changing the oracle address to a fake price feed) and poses a security risk towards protocol users. This risk can be mitigated by setting the boolean "assetsUpdatable" in the MainRegistry to false, after which assets are no longer updatable.
function addAsset(address assetAddress) external onlyPricingModule returns (bool);
Parameters
Name
Type
Description
assetAddress
address
The address of the asset

batchProcessDeposit

Batch process multiple assets
processDeposit in the pricing module checks whehter it's allowlisted and updates the maxExposure
function batchProcessDeposit(address[] calldata assetAddresses, uint256[] calldata assetIds, uint256[] calldata amounts)
public
onlyVault
noDelegate;
Parameters
Name
Type
Description
assetAddresses
address[]
An array of addresses of the assets
assetIds
uint256[]
An array of asset ids
amounts
uint256[]
An array of amounts to be deposited

batchProcessWithdrawal

Process a withdrawal for different assets
batchProcessWithdrawal in the pricing module updates the maxExposure
function batchProcessWithdrawal(address[] calldata assetAddresses, uint256[] calldata amounts)
public
onlyVault
noDelegate;
Parameters
Name
Type
Description
assetAddresses
address[]
An array of addresses of the assets
amounts
uint256[]
An array of amounts to be withdrawn

getTotalValue

Calculate the total value of a list of assets denominated in a given BaseCurrency
For each token address, a corresponding id at the same index should be present, for tokens without Id (ERC20 for instance), the Id should be set to 0
function getTotalValue(
address[] calldata assetAddresses,
uint256[] calldata assetIds,
uint256[] calldata assetAmounts,
address baseCurrency
) public view returns (uint256 valueInBaseCurrency);
Parameters
Name
Type
Description
assetAddresses
address[]
The List of token addresses of the assets
assetIds
uint256[]
The list of corresponding token Ids that needs to be checked
assetAmounts
uint256[]
The list of corresponding amounts of each Token-Id combination
baseCurrency
address
The contract address of the BaseCurrency
Returns
Name
Type
Description
valueInBaseCurrency
uint256
The total value of the list of assets denominated in BaseCurrency

getTotalValue

Calculate the total value of a list of assets denominated in a given BaseCurrency
For each token address, a corresponding id at the same index should be present, for tokens without Id (ERC20 for instance), the Id should be set to 0
ToDo: value sum unchecked. Cannot overflow on 1e18 decimals
function getTotalValue(
address[] calldata assetAddresses,
uint256[] calldata assetIds,
uint256[] calldata assetAmounts,
uint256 baseCurrency
) public view returns (uint256 valueInBaseCurrency);
Parameters
Name
Type
Description
assetAddresses
address[]
The List of token addresses of the assets
assetIds
uint256[]
The list of corresponding token Ids that needs to be checked
assetAmounts
uint256[]
The list of corresponding amounts of each Token-Id combination
baseCurrency
uint256
An identifier (uint256) of the BaseCurrency
Returns
Name
Type
Description
valueInBaseCurrency
uint256
The total value of the list of assets denominated in BaseCurrency

getListOfValuesPerAsset

Calculate the value per asset of a list of assets denominated in a given BaseCurrency
For each token address, a corresponding id at the same index should be present, for tokens without Id (ERC20 for instance), the Id should be set to 0
function getListOfValuesPerAsset(
address[] calldata assetAddresses,
uint256[] calldata assetIds,
uint256[] calldata assetAmounts,
address baseCurrency
) public view returns (RiskModule.AssetValueAndRiskVariables[] memory valuesAndRiskVarPerAsset);
Parameters
Name
Type
Description
assetAddresses
address[]
The List of token addresses of the assets
assetIds
uint256[]
The list of corresponding token Ids that needs to be checked
assetAmounts
uint256[]
The list of corresponding amounts of each Token-Id combination
baseCurrency
address
The contract address of the BaseCurrency
Returns
Name
Type
Description
valuesAndRiskVarPerAsset
AssetValueAndRiskVariables.RiskModule[]
The list of values per assets denominated in BaseCurrency

getListOfValuesPerAsset

Calculate the value per asset of a list of assets denominated in a given BaseCurrency
For each token address, a corresponding id at the same index should be present, for tokens without Id (ERC20 for instance), the Id should be set to 0
function getListOfValuesPerAsset(
address[] calldata assetAddresses,
uint256[] calldata assetIds,
uint256[] calldata assetAmounts,
uint256 baseCurrency
) public view returns (RiskModule.AssetValueAndRiskVariables[] memory);
Parameters
Name
Type
Description
assetAddresses
address[]
The List of token addresses of the assets
assetIds
uint256[]
The list of corresponding token Ids that needs to be checked
assetAmounts
uint256[]
The list of corresponding amounts of each Token-Id combination
baseCurrency
uint256
An identifier (uint256) of the BaseCurrency
Returns
Name
Type
Description
<none>
AssetValueAndRiskVariables.RiskModule[]
valuesAndRiskVarPerAsset The list of values per assets denominated in BaseCurrency

getCollateralValue

Calculate the collateralValue given the asset details in given baseCurrency
For each token address, a corresponding id at the same index should be present, for tokens without Id (ERC20 for instance), the Id should be set to 0
function getCollateralValue(
address[] calldata assetAddresses,
uint256[] calldata assetIds,
uint256[] calldata assetAmounts,
address baseCurrency
) public view returns (uint256 collateralValue);
Parameters
Name
Type
Description
assetAddresses
address[]
The List of token addresses of the assets
assetIds
uint256[]
The list of corresponding token Ids that needs to be checked
assetAmounts
uint256[]
The list of corresponding amounts of each Token-Id combination
baseCurrency
address
An address of the BaseCurrency contract
Returns
Name
Type
Description
collateralValue
uint256
Collateral value of the given assets denominated in BaseCurrency.

getLiquidationValue

Calculate the getLiquidationValue given the asset details in given baseCurrency
For each token address, a corresponding id at the same index should be present, for tokens without Id (ERC20 for instance), the Id should be set to 0
function getLiquidationValue(
address[] calldata assetAddresses,
uint256[] calldata assetIds,
uint256[] calldata assetAmounts,
address baseCurrency
) public view returns (uint256 liquidationValue);
Parameters
Name
Type
Description
assetAddresses
address[]
The List of token addresses of the assets
assetIds
uint256[]
The list of corresponding token Ids that needs to be checked
assetAmounts
uint256[]
The list of corresponding amounts of each Token-Id combination
baseCurrency
address
An address of the BaseCurrency contract
Returns
Name
Type
Description
liquidationValue
uint256
Liquidation value of the given assets denominated in BaseCurrency.

Structs

BaseCurrencyInformation

struct BaseCurrencyInformation {
uint64 baseCurrencyToUsdOracleUnit;
uint64 baseCurrencyUnitCorrection;
address assetAddress;
address baseCurrencyToUsdOracle;
string baseCurrencyLabel;
}