This is a brief workflow of creating a Pawn Plan. A Pawn is a shorthand name for "NFT Loans" on the Cyan Dapp.
To add the Cyan's Pawn feature to your application, follow these few steps.
1. Pricer Step 1
Pawn pricer accepts a currency address and an array of NFT items as input and returns possible loan options.
const pricingOptions = await cyan.pricePawnsStep1(
'0x0000000000000000000000000000000000000000',
[
{
address: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
tokenId: "3758",
itemType: 1,
amount: 0,
price: "10000000000" // Optional price field, if not passed, Cyan will price an item
},
], // NFTs array
);
2. Pricer Step 2
After the user selects the loan option returned from the first step, the user should pass the selected option to pricer 2 and gets the data required to create a Pawn Plan.
const plans = await cyan.pricePawnsStep2({
wallet: '0x8589D5276833407C37d139D3d0007340C7131cd3',
items: [{
address: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
tokenId: '3758',
itemType: 1,
amount: 0,
}], // Array of the IItemsWithPrice object returned from pricer step 1
option: {
loanRate: 5000, // Loaning rate multiplied by 100
duration: 604800, // Loan duration in seconds
}, // User's selected option, must be one of the options returned from step 1.
currencyAddress: '0x0000000000000000000000000000000000000000',
autoRepayStatus: 0,
});
3. Get Approval
Before creating a Pawn Plan, getting Approval is required. This is done by calling the getApproval
method.
const approval = await cyan.getApproval(
'0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d', // Collection address
'3758', // Token ID
);
When your users initiate a deal on Cyan, they automatically agree to the Terms & Conditions of Cyan. We have an optional signable step you may elect to implement on your front end to make it clear to the user what happens if they miss a payment.
4. Create Pawn Plans
Finally, to create a Pawn plan, call the createPawns
method with returned data from the second step of the pricer.
const plans = [...]; // Array of the successfully priced plans from step 2
const result = await cyan.createPawns(plans);
5. Make a payment
To make the next payment in a created Pawn Plan, please follow the steps in Plans.