Integrate your NFT lending protocol with the Wasabi liquidity layer.
Requirements
A new smart contract that allows Wasabi to interact with your lending protocol,
API (or an SDK) that allows fetching for loan offers and any related variables & metadata (signature, nonce, etc.) required to borrow.
Part 1: Implementing the INFTLending Interface
We created an NFT lending interface that can make borrow and repay loans. Implement this interface which will call your protocol's smart contracts.
/// @notice NFTLending Interfaceinterface INFTLending{/// @notice Loan Details struct/// @paramborrowAmount Borrow amount/// @paramrepayAmount Repay amount/// @paramloanExpiration Loan expiration/// @paramnftAddress The collateral NFT address/// @paramtokenId The collateral NFT IDstructLoanDetails{uint256 borrowAmount;uint256 repayAmount;uint256 loanExpiration;address nftAddress;uint256 tokenId;}/// @notice Get loan details for given loan id/// @param_loanId The loan idfunctiongetLoanDetails(uint256_loanId)externalviewreturns(LoanDetailsmemory);/// @notice Borrow WETH from the protocol/// @param_inputData Encoded input parameters/// @return_loanId The loan idfunctionborrow(bytescalldata_inputData)externalpayablereturns(uint256_loanId);/// @notice Repay the loan/// @param_loanId The if of loan to repay/// @param_receiver The address that should receive the collateral NFTfunctionrepay(uint256_loanId,address_receiver)externalpayable;}
Create a Solidity contract This contract should serve as the core component representing your lending protocol and must include the following functions:
getLoanDetails(uint256 _loanId): Implement this function to retrieve comprehensive loan details based on a specified loan ID. It should return a LoanDetails object.
The repayAmount should be the principal + max interest. So if the lending protocol accrues interest, repayAmount should be returned as the fully accrued interest amount.
borrow(bytes calldata _inputData): Develop this function to enable Wasabi to request and receive ETH loans from your protocol.
Related borrow request data that will be passed to the lending protocol will be appropriately encoded off-chain and should be decoded here. The decoded parameters should be used to call the lending protocol functions. The following snippet is from ArcadeLending.sol
repay(uint256 _loanId, address _receiver): Implement this function to facilitate loan repayments initiated by Wasabi. Ensure the collateral NFTs are returned to the designated address.
Create an API or SDK that the Wasabi team will be able to use to fetch collection loan offers from your protocol.
We require 2 endpoints,
A collection offer list endpoint,
A collection offer transaction data endpoint.
Collection Loan Offer List Endpoint
Create an endpoint that should return a list of collection-wide loan offers. This endpoint should take in a NFT collection address and filter offers with that address. For each offer, we need the following variables:
id A unique ID that points to the loan offer
loanAmount The amount that the borrower will receive
duration The duration for the loan in seconds
upfrontFee Any fee that is paid to the protocol when a user borrows, 0 otherwise
totalAvailableSize The total available size for this offer.
For individual offers, it should match the loanAmount
If the offer can be taken up multiple times, then the total committed amount for the offer
Example:
Offer Transaction Data Endpoint
Create an endpoint that will return the variables that should be used when borrowing from your protocol. These variables will be encoded and then sent for a transaction submission. Once the transaction is submitted, the data will be decoded and sent to your protocol. An example can be found here: