User selects the loan option returned from pricer step 1, user should pass selected option to pricer 2 and gets the data required to create a plan.

Pricing Step 2: Build the plan creation datas with provided loan option

priceBnplsStep2 is an asynchronous method that performs the second step in pricing the plans. It processes the selected loan options from the first step to build the required data for the plan creation.

Parameters

  • wallet (string): The address of the wallet that will be used to execute the plan creation.

  • items (Array<IItemWithSelectedLoanOption>): An array of items with selected loan option.

  • currencyAddress (string): The address of the currency to be financed for the loan.

  • autoRepayStatus (AutoRepayStatus): The status of auto-repay for the plan. This indicates how the plan will handle automatic repayments.

Returns

  • Promise<Array<IPricedItemWithPlan>>: A promise that resolves to an array of objects, each containing the finalized plan details and pricing information for the items.

Example Usage

const option = optionsFromStep1Response.find((o) => {
  return o.loanRate === userSelectedLoanRate &&
         o.term * o.totalNumberOfPayments === userSelectedDuration
}); // Find the user-selected option from the possible options.

const args = {
  wallet: '0x123...', // Wallet address to execute the plan
  items: [
    {
      address: '0xabc...', // Item contract address
      tokenId: '1', // NFT or token ID
      itemType: ItemType.ERC721, // Item type (e.g., ERC721, ERC1155)
      amount: 0, // Quantity of the token
      price: BigNumber.from(1000), // Item price / appraisal
      option,
    },
  ],
  currencyAddress: '0x456...', // Address of the currency to be financed for the loan
  autoRepayStatus: AutoRepayStatus.FromMainWallet, // Auto-repay status (from main wallet)
};

// call pricer step 2 based on plan type
// BNPL - sdk.priceBnplsStep2()
// Pawn - sdk.pricePawnsStep2()

const result = await sdk.priceBnplsStep2(args);
console.log(result);

🚧

Call pricer step 2 based on plan type

  • For BNPL: Use sdk.priceBnplsStep2()
  • For Pawn: Use sdk.pricePawnsStep2()

Notes

  • The items array should include accurate loan option details for each item.
  • Verify that the currencyAddress corresponds to a valid and supported currency for the loan.
  • The autoRepayStatus should be set based on the intended repayment method, as it affects how automatic payments are handled.