Instantiate a lender object through the module, providing the lender wallet as a parameter.
const unibridgeLender = new UnibridgeCollateralized(lenderWallet, "<optional_address_to_fill>");
To initiate the lend() function, it is necessary to construct the suitable payload object containing the requisite fields and values. Once the payload object is prepared, it can be supplied as an argument while calling the lend() function, as demonstrated below.
// your erc721 address to be lent out
const E721_ADDR = ['<your_erc721_address>'];
// your erc721 token to be lent out
const E721_TOKENID = [BigNumber.from('<your_erc721_token_id>')];
// amount of token being lent out
const lendAmount = [1];
// maximum duration being able to be rented (in days)
const maxRentDuration = [1];
// daily price
const dailyRentPrice = [1.1];
// set nft price to be collateralized
const nftPrice = [2.2];
// payment token. please see PaymentToken object for supported list
const paymentToken = [PaymentToken.WETH];
// your onchain lending id, where it can be found in "Lent" event
const lendingID = [1];
// duration to rent (in days)
const rentDuration = [1];
// -------------------- LEND ----------------------
// Collateral Free Lend Transaction
// IMPORTANT: BE SURE TO APPROVE LENDER'S NFT TOKEN TOWARD RENTAL CONTRACT ITSELF
txn = await unibridgeLender.lend(
E721_ADDR,
E721_TOKENID,
lendAmount,
maxRentDuration,
dailyRentPrice,
nftPrice,
paymentToken,
{ gasLimit: 400_000, gasPrice: "400000000000" }
);
receipt = await txn.wait();
console.log(`Lend Success: ${receipt.transactionHash}`);
UniBridge Collateral Free
Import the UnibridgeCollateralFree and PaymentToken modules from the SDK.
Instantiate a lender object through the module, providing the lender wallet as a parameter.
const unibridgeLender = new UnibridgeCollateralFree(lenderWallet, "<optional_address_to_fill>");
To initiate the lend() function, it is necessary to construct the suitable payload object containing the requisite fields and values. Once the payload object is prepared, it can be supplied as an argument while calling the lend() function, as demonstrated below.
// your erc721 address to be lent out
const E721_ADDR = ['<your_erc721_address>'];
// your erc721 token to be lent out
const E721_TOKENID = [BigNumber.from('<your_erc721_token_id>')];
// amount of token being lent out
const lendAmount = [1];
// maximum duration being able to be rented (in days)
const maxRentDuration = [1];
// daily price
const dailyRentPrice = [1.1];
// payment token. please see PaymentToken object for supported list
const paymentToken = [PaymentToken.WETH];
// your onchain lending id, where it can be found in "Lent" event
const lendingID = [1];
// duration to rent (in days)
const rentDuration = [1];
// -------------------- LEND ----------------------
// Collateral Free Lend Transaction
txn = await unibridgeLender.lend(
E721_ADDR,
E721_TOKENID,
lendAmount,
maxRentDuration,
dailyRentPrice,
paymentToken,
{ gasLimit: 400_000, gasPrice: "400000000000" }
);
receipt = await txn.wait();
console.log(`Lend Success: ${receipt.transactionHash}`);