Comment on page
Liquidator
Ensure your total value denomination remains above the liquidation threshold, or risk being liquidated!
contact: dev at arcadia.finance
uint256 public constant hourlyBlocks = 300;
uint256 public breakevenTime = 6;
address public factory;
address public registry;
address public reserveFund;
address public protocolTreasury;
mapping(address => mapping(uint256 => auctionInformation)) public auctionInfo;
mapping(address => mapping(uint256 => uint256)) public claimableBitmap;
claimRatios public claimRatio;
modifier elevated();
constructor(address factory_, address registry_);
Sets the factory address on the liquidator.
The factory is used to fetch the isVault bool in elevated().
function setFactory(address factory_) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
factory_ | address | the factory address. |
Sets the protocol treasury address on the liquidator.
The protocol treasury is used to receive liquidation rewards.
function setProtocolTreasury(address protocolTreasury_) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
protocolTreasury_ | address | the protocol treasury. |
Sets the reserve fund address on the liquidator.
The reserve fund is used to pay liquidation keepers should the liquidation surplus be insufficient.
function setReserveFund(address reserveFund_) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
reserveFund_ | address | the reserve fund address. |
Sets the breakeven time on the liquidator.
The breakeven time is the time from starting an auction duration to the moment the price of the auction has decreased to the open debt. The breakevenTime controls the speed of decrease of the auction price.
function setBreakevenTime(uint256 breakevenTime_) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
breakevenTime_ | uint256 | the new breakeven time address. |
Starts an auction of a vault. Called by the vault itself.
function startAuction(
address vaultAddress,
uint256 life,
address liquidationKeeper,
address originalOwner,
uint128 openDebt,
uint8 baseCurrency
) public elevated returns (bool success);
Parameters
Name | Type | Description |
---|---|---|
vaultAddress | address | the vault address that undergoes the auction. |
life | uint256 | the life of the vault represents the amount of times a vault has been liquidated. |
liquidationKeeper | address | the keeper who triggered the auction. Gets a reward! |
originalOwner | address | the original owner of this vault, at life . |
openDebt | uint128 | the open debt taken by originalOwner at life . |
baseCurrency | uint8 | the baseCurrency in which the vault is denominated. |
Returns
Name | Type | Description |
---|---|---|
success | bool | auction has started -> true. |
Function to check what the current price of the vault being auctioned of is.
Returns whether the vault is on sale or not. Always check the forSale bool!
function getPriceOfVault(address vaultAddress, uint256 life)
public
view
returns (uint256 totalPrice, uint8 baseCurrencyOfVault, bool forSale);
Parameters
Name | Type | Description |
---|---|---|
vaultAddress | address | the vaultAddress. |
life | uint256 | the life of the vault for which the price has to be fetched. |
Returns
Name | Type | Description |
---|---|---|
totalPrice | uint256 | the total price for which the vault can be purchased. |
baseCurrencyOfVault | uint8 | the baseCurrency in which the vault (and totalPrice) is denominaetd. |
forSale | bool | returns false when the vault is not for sale. |
Function a user calls to buy the vault during the auction process. This ends the auction process
Ensure the vault is for sale before calling this function.
function buyVault(address vaultAddress, uint256 life) public;
Parameters
Name | Type | Description |
---|---|---|
vaultAddress | address | the vaultAddress of the vault the user want to buy. |
life | uint256 | the life of the vault for which the price has to be fetched. |
Function to buy only a certain asset of a vault in the liquidation process
function buyPart(address[] memory assetAddresses, uint256[] memory assetIds, uint256[] memory assetAmounts) public;
Parameters
Name | Type | Description |
---|---|---|
assetAddresses | address[] | the vaultAddress |
assetIds | uint256[] | the vaultAddress |
assetAmounts | uint256[] | the vaultAddress //todo |
Function to check what the value of the items in the vault is.
Only used for partial liquidations.
function getValueOfAssets(
address[] memory assetAddresses,
uint256[] memory assetIds,
uint256[] memory assetAmounts,
uint8 baseCurrencyOfDebt
) public view returns (uint256 totalValue);
Parameters
Name | Type | Description |
---|---|---|
assetAddresses | address[] | array of asset addresses |
assetIds | uint256[] | array of assets ids. For assets without Id's (erc20's), Id can be set to 0. |
assetAmounts | uint256[] | amounts of each asset. For assets without amounts (erc721's), amount can be set to 0. |
baseCurrencyOfDebt | uint8 | |
Returns
Name | Type | Description |
---|---|---|
totalValue | uint256 | the total value of all assets. |
Function a a user can call to check who is eligbile to claim what from an auction vault.
Although only 3 bits are needed per claim in claimableBitmap, we keep it per 4. This saves some gas on calculations, and would only require writing a new bitmap after 65 liquidations instead of 85. We're looking forward to the first vault that gets liquidated 65 times!
function claimable(auctionInformation memory auction, address vaultAddress, uint256 life)
public
view
returns (uint256[] memory claimables, address[] memory claimableBy);
Parameters
Name | Type | Description |
---|---|---|
auction | auctionInformation | the auction |
vaultAddress | address | the vaultAddress of the vault the user want to buy. |
life | uint256 | the lifeIndex of vault, the keeper wants to claim their reward from |
Returns
Name | Type | Description |
---|---|---|
claimables | uint256[] | The amounts claimable for a certain auction (in the baseCurrency of the vault). |
claimableBy | address[] | The user that can claim the liquidation reward or surplus. |
Function a eligeble claimer can call to claim the proceeds of the vault they are entitled to.
vaultAddresses and lives form a combination. Claiming for combinations at vaultAddress[i] && lives[i] if multiple lives of the same vault address are to be claimed, the vault address must be repeated! Although only 3 bits are needed per claim in claimableBitmap, we keep it per 4. This saves some gas on calculations, and would only require writing a new bitmap after 65 liquidations instead of 85. We're looking forward to the first vault that gets liquidated 65 times!
function claimProceeds(address claimer, address[] calldata vaultAddresses, uint256[] calldata lives) public;
Parameters
Name | Type | Description |
---|---|---|
claimer | address | the address for which (and to which) the claims are requested. |
vaultAddresses | address[] | vault addresses the caller want to claim the proceeds from. |
lives | uint256[] | the lives for which the caller wants to claim for. //todo: make view function showing available addresses & lives for a claimer |
function _doTransfers(uint256 baseCurrencyCounter, uint256[] memory totalClaimable, address claimer) internal;
The ratios in which the liquidation fee is divided
ratio's have 2 decimals precision (50 equals 0,5 or 50%)
struct claimRatios {
uint64 protocol;
uint64 liquidationKeeper;
}
struct auctionInformation {
uint128 openDebt;
uint128 startBlock;
uint8 baseCurrency;
uint128 assetPaid;
bool stopped;
address liquidationKeeper;
address originalOwner;
}
Last modified 8mo ago