import { BigNumber, ContractTransaction } from 'ethers'; import { CyanFactory, PaymentPlanV2, CyanWallet } from './contracts'; import { IPlan, ICyanSDKConstructor, ICreatePlanParams, IConfigs, ISdkPricerStep1, ISdkPricerStep2, IItem, IItemWithPrice, IOffer, ItemType, IGetCollectionsMaxLtvs } from './types'; export declare class CyanSDK { private signer; private api; private configs; constructor({ host, apiKey, provider }: ICyanSDKConstructor); /** * Initiates Cyan SDK. */ static initiate(args: ICyanSDKConstructor): Promise; /** * Downloads and stores configs from Cyan API. * You should call this method before using any other methods. */ configure(): Promise; /** * Performs the first step of pricing BNPLs and generating options from the response. * @param {string} currencyAddress The currency to use for BNPL. * @param {Array} items An array of objects representing the items to price. * @returns {Promise} A Promise that resolves to an object containing the priced items and pricing options. */ priceBnplsStep1(currencyAddress: string, items: Array): Promise; /** * Performs the second step of pricing BNPLs. * @param {ISdkPricerStep2['params']} args - The pricing parameters * @returns {Promise} The pricing result */ priceBnplsStep2(args: ISdkPricerStep2['params']): Promise; /** * Performs the first step of pricing Pawns and generating options from the response. * @param {string} currencyAddress The currency to use for BNPL. * @param {Array} items An array of objects representing the items to price. * @returns {Promise} A Promise that resolves to an object containing the priced items and pricing options. */ pricePawnsStep1(currencyAddress: string, items: Array): Promise; /** * Performs the second step of pricing Pawns. * @param {ISdkPricerStep2['params']} args - The pricing parameters * @returns {Promise} The pricing result */ pricePawnsStep2(args: ISdkPricerStep2['params']): Promise; /** * Accepts payment plans by signing a typed data message and sending it to the API. * @param {ICreatePlanParams[]} plans - Array of payment plan objects to accept. * @throws {CyanError} PaymentPlanContract not found. Please try reconfiguring the SDK. * @returns {Promise} */ acceptPlans(plans: ICreatePlanParams[]): Promise; /** * Creates BNPL (Buy Now Pay Later) plans by calling the createBNPL function of the payment plan contract. * @param {string} currencyAddress The address of the currency to use for the BNPL plans. * @param {ICreatePlanParams[]} plans An array of objects containing the parameters for each plan to create. * @param {boolean} payFromCyanWallet Whether to pay the downpayment using the Cyan Wallet or not (only works for native currency) * @returns {Promise} A Promise that resolves to a ContractTransaction object. */ createBnpls(currencyAddress: string, plans: ICreatePlanParams[], payFromCyanWallet?: boolean): Promise; /** * Creates pawn plans by calling the createPawn function of the payment plan contract. * @param {ICreatePlanParams[]} plans An array of objects containing the parameters for each plan to create. * @returns {Promise} A Promise that resolves to a ContractTransaction object representing the transaction hash of the contract invocation. */ createPawns(plans: ICreatePlanParams[]): Promise; /** * Checks if the user has allowed the Payment Plan Contract to spend the specified amount of the given currency, and approves it if not. * @param currencyAddress The address of the currency to be checked and allowed. * @param amount The amount of currency to be checked and allowed. * @returns Promise that resolves when the approval transaction has been confirmed. * @throws CyanError if PaymentPlanContract is not found. */ checkAndAllowCurrencyForPlan(currencyAddress: string, amount: BigNumber): Promise; /** * Approve Payment Plan Contract to spend a specific ERC721 or ERC1155 token on behalf of the signer. * @param {string} address - The address of the ERC721 or ERC1155 contract. * @param {string} tokenId - The ID of the token to approve. * @returns {Promise} - A Promise that resolves when the transaction is confirmed. * @throws {Error} - Throws an error if the PaymentPlan contract is not found or if the transaction fails. */ getApproval(address: string, tokenId: string, tokenType?: ItemType): Promise; /** * Get the following payment information for a payment plan * @param {IPlan} plan - The payment plan object * @param {boolean} [isEarlyRepayment=false] - Optional flag to indicate if this is early repayment or not * @returns {Promise} An object containing payment information * @throws {Error} Throws an error if the payment plan contract cannot be found or if there is an issue getting payment information */ getPaymentInfo(plan: { planId: number; paymentPlanContractAddress: string; }, isEarlyRepayment?: boolean): Promise<{ payAmountForCollateral: string; payAmountForInterest: string; payAmountForService: string; currentPayment: string; dueDate?: Date; }>; /** * Pays the next payment for a payment plan * @param {IPlan} plan - The payment plan object * @returns {Promise} A Promise that resolves to a ContractTransaction object. */ pay(plan: IPlan): Promise; /** * Pays the remaining payment for a payment plan * @param {IPlan} plan - The payment plan object * @returns {Promise} A Promise that resolves to a ContractTransaction object. */ payEarly(plan: IPlan): Promise; /** * Retrieve BNPL or Pawn plans, by user, which are Activated, Funded or in Pending status. * @param address User wallet address * @returns Array of IPlan */ getUserPlans(address: string): Promise; /** * Retrieves the PaymentPlanV2 contract instance for the current chain. * Throws a CyanError if the contract cannot be found for the current chain. * @returns {Promise} The PaymentPlanV2 contract instance. * @throws {CyanError} If the PaymentPlan contract is not found for the current chain. */ getPaymentPlanContract(): Promise; /** * Retrieves the Cyan Factory contract instance for the current chain. * Throws a CyanError if the contract cannot be found for the current chain. * @returns {Promise} The Cyan Factory contract instance. * @throws {CyanError} If the Cyan Factory contract is not found for the current chain. */ getFactoryContract(): Promise; /** * Returns an instance of the CyanWallet contract for the current user. * @throws {NoWalletError} if no wallet is associated with the current user. * @returns {Promise} An instance of the CyanWallet contract. */ getCyanWallet(): Promise; /** * Creates a new CyanWallet for the current user if it does not exist, or returns the existing one. * @returns {Promise} A promise that resolves with a ContractTransaction representing the transaction that deploys or retrieves the CyanWallet contract. */ createCyanWallet(): Promise; /** * Retrieves top bids of the specific collection or token * @param {string} collectionAddress - The collection address * @param {string} tokenId - The token id * @returns {Promise} The top bid result */ getTopBids(collectionAddress: string, tokenId?: string): Promise; /** * Retrieve the maximum LTVs for the given plan type across all supported collections * @param {string} planType - The plan type * @returns {Promise} The maximum LTVs by currency address */ getMaxLtvs(planType: 'bnpl' | 'pawn'): Promise; /** * Fulfill bid offer of the plan * @param {IPlan} plan - Plan object to sell * @param {IOffer} offer - Offer objects to accept * @returns {Promise} */ fulfillOffer(plan: IPlan, offer: IOffer): Promise; /** * Pays the payment for payment plans * @param {Array} plans - The payment plan objects * @param {boolean} isEarlyPayment - The flag to indicate if this is early payment or not * @param {string} releaseWallet - The wallet address to release the token * @returns {Promise} A Promise that resolves to a ContractTransaction object. */ payBulk(plans: IPlan[], isEarlyPayment: boolean, releaseWallet?: string): Promise; getOrCreateCyanWallet(): Promise; _setConfigs(configs: IConfigs): void; private _pay; private _buildStep2Request; private _buildStep2Result; private _getChain; private _getConduitAddress; } export default CyanSDK;