Castle Crush (Reward Share)
This is a guide on how to use reNFT's SDK to interact with the Wildlife contract directly. This tutorial was written for sdk version 5.0.4.
Lend
import { JsonRpcProvider } from '@ethersproject/providers';
import { parseFixed } from '@ethersproject/bignumber';
import { Wallet } from '@ethersproject/wallet';
import { Whoopi, PaymentToken, RESOLVERS, RenftContracts } from '@renft/sdk';
const provider = new JsonRpcProvider('https://api.avax-test.network/ext/bc/C/rpc');
const privKey = '';
let wallet = new Wallet(privKey);
wallet = wallet.connect(provider);
let txn;
let receipt;
const castleCrushNftAddress = "0xeA4E79F0a40A9A468a5159499b738dc6b1332447";
const whoopiAddress = "0x516775e81b0d1fC91Ec326DEd21c33728895Fc6C";
const whoopi = new Whoopi(wallet, whoopiAddress);
const tokenId = [210, 200];
// ! Note that if allowedRenters is empty, you must set upfrontRentFee to
// ! a non zero value.
const upfrontRentFee = [
parseFixed("1", RESOLVERS[RenftContracts.WHOOPI_FUJI][PaymentToken.USDC]).toString(),
parseFixed("1", RESOLVERS[RenftContracts.WHOOPI_FUJI][PaymentToken.USDC]).toString()
];
// ! you can't use SENTINEL as a payment token, even though
// ! you don't want to set an upfront rent fee. Just use any
// ! payment token in such a case.
const paymentToken = [PaymentToken.USDC, PaymentToken.USDC];
const revShareBeneficiaries = [
["0x000000045232fe75A3C7db3e5B03B0Ab6166F425", "0x465DCa9995D6c2a81A9Be80fBCeD5a770dEE3daE"],
["0x465DCa9995D6c2a81A9Be80fBCeD5a770dEE3daE", "0xeA4E79F0a40A9A468a5159499b738dc6b1332447"]
];
// ! portions sum cannot be 100 here. At lend, we don't know who will rent,
// ! and the renter is always a mandatory part in rev share. We are not setting
// ! the renter here at lend time. Therefore, 100 - sum(portions) is what
// ! gets eventually assigned to the renter.
const revSharePortions = [
[50, 40], // 10% is how much the renter will get on this lending
[90, 5] // 5% is how much ther renter will get on this lending
];
// * means 1 and 2 cycles respectively
const maxRentDuration = [1, 2];
txn = await whoopi.lend(
castleCrushNftAddress,
tokenId,
upfrontRentFee,
revShareBeneficiaries,
revSharePortions,
maxRentDuration,
paymentToken,
undefined,
// ! uncomment this if it does not allow you to execute because it predicts that
// ! the transaction will fail
// { gasLimit: 1000000 }
);
receipt = await txn.wait();Rent
Stop Lending
Stop Renting
Pay Rewards
Query On-chain data
Last updated