function add(uint128 x, int128 y) internal pure returns (uint128 z)
Add a number (which might be negative) to a positive, and revert if the result is negative.
event AssetAdded(bytes6 assetId, address asset)
event SeriesAdded(bytes6 seriesId, bytes6 baseId, address fyToken)
event IlkAdded(bytes6 seriesId, bytes6 ilkId)
event SpotOracleAdded(bytes6 baseId, bytes6 ilkId, address oracle, uint32 ratio)
event RateOracleAdded(bytes6 baseId, address oracle)
event DebtLimitsSet(bytes6 baseId, bytes6 ilkId, uint96 max, uint24 min, uint8 dec)
event VaultBuilt(bytes12 vaultId, address owner, bytes6 seriesId, bytes6 ilkId)
event VaultTweaked(bytes12 vaultId, bytes6 seriesId, bytes6 ilkId)
event VaultDestroyed(bytes12 vaultId)
event VaultGiven(bytes12 vaultId, address receiver)
event VaultPoured(bytes12 vaultId, bytes6 seriesId, bytes6 ilkId, int128 ink, int128 art)
event VaultStirred(bytes12 from, bytes12 to, uint128 ink, uint128 art)
event VaultRolled(bytes12 vaultId, bytes6 seriesId, uint128 art)
event SeriesMatured(bytes6 seriesId, uint256 rateAtMaturity)
mapping(bytes6 => address) assets
mapping(bytes6 => struct DataTypes.Series) series
mapping(bytes6 => mapping(bytes6 => bool)) ilks
mapping(bytes6 => contract IOracle) lendingOracles
mapping(bytes6 => mapping(bytes6 => struct DataTypes.SpotOracle)) spotOracles
mapping(bytes6 => mapping(bytes6 => struct DataTypes.Debt)) debt
mapping(bytes6 => uint256) ratesAtMaturity
mapping(bytes12 => struct DataTypes.Vault) vaults
mapping(bytes12 => struct DataTypes.Balances) balances
function addAsset(bytes6 assetId, address asset) external
Add a new Asset.
function setDebtLimits(bytes6 baseId, bytes6 ilkId, uint96 max, uint24 min, uint8 dec) external
Set the maximum and minimum debt for an underlying and ilk pair. Can be reset.
function setLendingOracle(bytes6 baseId, contract IOracle oracle) external
Set a rate oracle. Can be reset.
function setSpotOracle(bytes6 baseId, bytes6 ilkId, contract IOracle oracle, uint32 ratio) external
Set a spot oracle and its collateralization ratio. Can be reset.
function addSeries(bytes6 seriesId, bytes6 baseId, contract IFYToken fyToken) external
Add a new series
function addIlks(bytes6 seriesId, bytes6[] ilkIds) external
Add a new Ilk (approve an asset as collateral for a series).
function build(address owner, bytes12 vaultId, bytes6 seriesId, bytes6 ilkId) external returns (struct DataTypes.Vault vault)
Create a new vault, linked to a series (and therefore underlying) and a collateral
function destroy(bytes12 vaultId) external
Destroy an empty vault. Used to recover gas costs.
function _tweak(bytes12 vaultId, bytes6 seriesId, bytes6 ilkId) internal returns (struct DataTypes.Vault vault)
Change a vault series and/or collateral types. We can change the series if there is no debt, or assets if there are no assets
function tweak(bytes12 vaultId, bytes6 seriesId, bytes6 ilkId) external returns (struct DataTypes.Vault vault)
Change a vault series and/or collateral types. We can change the series if there is no debt, or assets if there are no assets
function _give(bytes12 vaultId, address receiver) internal returns (struct DataTypes.Vault vault)
Transfer a vault to another user.
function give(bytes12 vaultId, address receiver) external returns (struct DataTypes.Vault vault)
Transfer a vault to another user.
function vaultData(bytes12 vaultId, bool getSeries) internal view returns (struct DataTypes.Vault vault_, struct DataTypes.Series series_, struct DataTypes.Balances balances_)
function debtFromBase(bytes6 seriesId, uint128 base) external returns (uint128 art)
Think about rounding up if using, since we are dividing.
Convert a debt amount for a series from base to fyToken terms.
function debtToBase(bytes6 seriesId, uint128 art) external returns (uint128 base)
Convert a debt amount for a series from fyToken to base terms
function stir(bytes12 from, bytes12 to, uint128 ink, uint128 art) external returns (struct DataTypes.Balances, struct DataTypes.Balances)
Move collateral and debt between vaults.
function _pour(bytes12 vaultId, struct DataTypes.Vault vault_, struct DataTypes.Balances balances_, struct DataTypes.Series series_, int128 ink, int128 art) internal returns (struct DataTypes.Balances)
Add collateral and borrow from vault, pull assets from and push borrowed asset to user Or, repay to vault and remove collateral, pull borrowed asset from and push assets to user
function pour(bytes12 vaultId, int128 ink, int128 art) external virtual returns (struct DataTypes.Balances)
Manipulate a vault, ensuring it is collateralized afterwards. To be used by debt management contracts.
function slurp(bytes12 vaultId, uint128 ink, uint128 art) external returns (struct DataTypes.Balances)
Reduce debt and collateral from a vault, ignoring collateralization checks. To be used by liquidation engines.
function roll(bytes12 vaultId, bytes6 newSeriesId, int128 art) external returns (struct DataTypes.Vault, struct DataTypes.Balances)
Change series and debt of a vault. The module calling this function also needs to buy underlying in the pool for the new series, and sell it in pool for the old series.
function level(bytes12 vaultId) external returns (int256)
Return the collateralization level of a vault. It will be negative if undercollateralized.
function mature(bytes6 seriesId) external
Record the borrowing rate at maturity for a series
function _mature(bytes6 seriesId, struct DataTypes.Series series_) internal
Record the borrowing rate at maturity for a series
function accrual(bytes6 seriesId) external returns (uint256)
Retrieve the rate accrual since maturity, maturing if necessary.
function _accrual(bytes6 seriesId, struct DataTypes.Series series_) private returns (uint256 accrual_)
Retrieve the rate accrual since maturity, maturing if necessary. Note: Call only after checking we are past maturity
function _level(struct DataTypes.Vault vault_, struct DataTypes.Balances balances_, struct DataTypes.Series series_) internal returns (int256)
Return the collateralization level of a vault. It will be negative if undercollateralized.