npx hardhat test
npx hardhat run scripts/ledger/deploy.impl.js
npx hardhat run scripts/ledger/deploy.proxy.js
- A user calls
mintfunction to deposit ETH into the vault. (The vault swaps it into BlurPool tokens). - The manager calls
refinanceAuctionfunction to take an auction by paying of the owed debt to the auctioned lien and start a new lien where the vault acts as lender. - The manager calls
startAuctionto start an auction for the lien it owns. If someone takes up the auction, the vault's owned debt is paid by the taker is becomes part of the vault's passive balance. - The manager calls
seizefunction to seize an NFT whose auction has expired. This will transfer the NFT from Blend contract to the vault. - Any user can call
liquidateNFTfunction to purchase the NFT from the vault by paying the amount of ETH specified asamountin the order. The order and its content is signed off-chain by the vault manager and is verified on-chain. - A minter or vault shareholder can call
burnfunction to burn their vault shares and redeem the underlying ETH amount. - A service would periodically call
cleanUpLiensArrayfunction to reduce the liens tracking array size which would result in reduce gas costs for the mint and burn functions.
-
initialize(bytes memory data)
This function initializes the vaults state. It is called as delegate call from within the proxy contract. It accepts an arbitrary length bytes array that is decoded to retrieve the initialization data. Currently, it contains the following data.address _manager, address _blurPool, address _blend, string memory _name, string memory _symbol -
mint(uint256 amount)
This function allows users to provide Ether to the vault and in returns receive vault shares. The vault shares represent ownership of the user in the vault. -
burn(uint256 shares)
This function burns shares for the user and return them the corresponding underlying ETH amount to them. If the vault does not have enough asset amount to respond to user request, the transaction is reverted. -
refinanceAuction(Lien calldata lien, uint256 lienId, uint256 rate)
This function is called by the manager to take up an auction. It pays of the debt owed to the old lender of the lien and makes vault the lender of new lien. -
startAuction(Lien calldata lien, uint256 lienId)
This function is called by the manager to start an auction for the lien. -
seize(LienPointer[] calldata lienPointers)
This function is called by the manager to seize an NFT from a lien for which the auction has expired. -
cleanUpLiensArray()
This function is publicly callable to clean up in-active liens from the array of all liens owned by the vault. This effectively reduces the length of liens array and results in has savings when the liens array is looped over to calculate underlying asset amount of the vault. -
liquidateNFT( address collection, uint256 tokenId, uint256 amount, address recipient, uint256 deadline, bytes calldata signature )
This function liquidates/sells off the NFT owned by the vault after it has been seized. The function can be called by anyone with the right order signed by the vault manager. The caller must be therecipientin the function parameter. Thesignatureparameter passed to the function must evaluate to have to been signed the vaultmanager. The amount is taken from the user in the form of Ether and the NFT is transferred to the user. -
getUnderlyingBalance()
This function returns the underlying balance of the Blur vault. The underlying balance comprises the passive BlurPool balance and the sum of all debts owned by the vault for all of its liens. -
getCurrentlyOwnedDebt
This function returns the sum of all debt currently owned by the vault across all of its lien. -
getCurrentDebtByLien
This function returns the debt incurred by a lien. If the call to this function reverts then it means the lien is no longer active.
Some parameters of a Lien change when it is refinanced by the Blur vault. Similarly, the parameters of a Lien change again when it is put up for an auction, so retrieve latest parameters of a lien, the function getLiensByIndex should be called to retrieve the latest parameters of a Lien.