InvaraINVARA CoreDOCS
Developers

Contract reference

Functions, events and errors of the INVARA Core contracts.

InvaraVault#

solidity
function depositAndMint(bytes32 priceId, uint256 collateralAmount, uint256 mintAmount)
function burnAndWithdraw(bytes32 priceId, uint256 burnAmount, uint256 withdrawAmount)
function liquidatePosition(bytes32 priceId, address borrower, uint256 burnAmount)
function registerSyntheticToken(bytes32 priceId, address tokenAddress, uint256 ceiling)   // deployer only, once per id

function positions(bytes32 priceId, address user) view returns (uint256 collateralAmount, uint256 syntheticMinted)
function syntheticTokens(bytes32 priceId) view returns (address)
function debtCeiling(bytes32 priceId) view returns (uint256)   // max outstanding synthetic, fixed at registration
function totalDebt(bytes32 priceId) view returns (uint256)     // outstanding synthetic
function badDebt(bytes32 priceId) view returns (uint256)       // cumulative debt written off

uint256 constant MCR = 130;                 // %
uint256 constant LIQUIDATION_BONUS = 105;  // %
uint256 constant MIN_COLLATERAL = 100e6;       // minimum collateral for a position with debt

Events

solidity
event VaultDeposited(bytes32 indexed priceId, address indexed user, uint256 collateralAdded, uint256 syntheticMinted)
event VaultWithdrawn(bytes32 indexed priceId, address indexed user, uint256 collateralRemoved, uint256 syntheticBurned)
event PositionLiquidated(bytes32 indexed priceId, address indexed borrower, address indexed liquidator, uint256 debtBurned, uint256 collateralSeized)
event BadDebtWrittenOff(bytes32 indexed priceId, address indexed borrower, uint256 debtWrittenOff)
event SyntheticRegistered(bytes32 indexed priceId, address indexed token, uint256 debtCeiling)

Errors

ZeroAddress ZeroDebtCeiling BelowMCR BelowMinCollateral DebtCeilingExceeded PositionHealthy TokenNotRegistered AlreadyRegistered OnlyDeployer VaultMismatch

InvaraOracleAdapter#

solidity
function getAssetPrice(bytes32 priceId) view returns (uint256 priceNormalized)  // 18 decimals
function updatePriceFeeds(bytes[] priceUpdateData) payable                      // refunds excess fee

uint256 constant MAX_PRICE_AGE = 15;  // seconds

Errors: ZeroAddress HighConfidenceInterval InvalidPrice RefundFailed

InvaraSyntheticToken#

solidity
address public immutable VAULT;
function mint(address to, uint256 amount)          // vault only
function burnFrom(address account, uint256 amount) // vault only