Platform: Code4rena
Start Date: 27/04/2022
End Date: 01/05/2022
Period: 5 days
Status: Completed
Reporters: itsmetechjay, liveactionllama
Pot Size: $50,000 MIM
Participants: 59
Reporters: itsmetechjay, liveactionllama
Judge: 0xean
Id: 113
League: ETH
Auditor per page
Name | Description |
---|---|
Abracadabra | Abracadabra the Lending platform |
SPELL | Governance token Abracadabra |
MIM | Stablecoin minted by the DeFi protocol |
Cauldron | Smart Contract handling the Lending Logic |
Private Pool | Version of the Cauldron where the collateral is an NFT |
NFTs | Non-Fungible Tokens, ERC721s. |
CDP / Collateralized Debt Position | A loan backed by some form of collateral |
LTV / Loan to Value | Ratio of the debt position to the value of the collateral deposited |
Share | A share is a Bentobox share. |
Collateral | The ERC721 (NFT) being used as collateral |
Asset | The ERC20 Token that is borrowed |
The scope of the contest is contracts/NFTPair.sol, a Private Pool that allows two parties to create a private loan with a NFT as collateral, and contracts/NFTPairWithOracle.sol, which is largely similar, but allows the option of early liquidation if the price drops below a floor set by an oracle.
The test cases in test/NFTPair.test.ts furnish examples of how to interact with the contract. Versions have also been deployed to Ropsten, using and entirely mocked environment that allows freely minting ERC-20 tokens, NFTs, and messing with the BentoBox balance, simulating vault gains/losses.
Tests can be run with
yarn hardhat test
You may have to run
yarn hardhat typechain
once before doing this.
Abracadabra.money is a lending platform that uses interest-bearing tokens (ibTKNs) or NFTs as collateral to borrow a USD pegged stablecoin (Magic Internet Money - MIM), that can be used as any other traditional stablecoin. The protocol is governed by the SPELL token, that manages the parameters of the protocol, the use of the Treasury, the tokenomics.
Abracadabra is built upon the Bentobox, and uses a custom version of the KASHI technology.
Bentobox, KASHI and Cauldrons as listed for context only, as the scope is the NFT Pair.
One NFTPair is deployed as a MasterContract, to be cloned into actual lending markets via the deploy() function of bentobox.
This contract allows a lender and a borrower to do an OTC loan with an ERC721 as collateral and an ERC20 as borrowed asset. The parameters (valuation, duration and interests) are set by the users.
This contract uses the following libraries and interfaces:
The contract has multiple functions (eg: requestLoan, removeCollateral, lend) that each have an action ID and that can be called either directly or via the cook() function, passing actions ID, value and data as arrays. This function allows for the execution of several actions within the same transaction, which is core to how abracadabra works.
The NFTPair contract and all it's dependencies are deployed on the Ropsten Ethereum testnet:
BentoBox: https://ropsten.etherscan.io/address/0x9a5620779fef1928ef87c1111491212efc2c3cb8
master contract NFT Pair: https://ropsten.etherscan.io/address/0x3a341f5474aac54829a587ce6ab13c86af6b1e29#code The MasterContract is already whitelisted in the mock BentoBox.
Two mock ERC721 tokens, public mint() (but with sequential IDs)
Mock ERC20 with public mint() ("free money") https://ropsten.etherscan.io/address/0xed79a29ce9f7e285be23e8fc32f74e5289713b86
NFT Pair deployments using either contract, and the "free money":