UNPKG

@solace-fi/sdk-nightly

Version:

Note - Unstable nightly build, documentation not up-to-date for nightly build

147 lines (146 loc) 7.06 kB
import { BigNumber as BN, providers, Wallet, Contract, utils, BigNumberish } from 'ethers'; import { GasConfiguration } from '../types'; export declare class Coverage { chainID: number; walletOrProviderOrSigner: Wallet | providers.JsonRpcSigner | providers.Provider; solaceCoverProduct: Contract; constructor(chainID: number, walletOrProviderOrSigner?: Wallet | providers.JsonRpcSigner | providers.Provider); /************************************************************* METHODS - SOLACECOVERPRODUCT EXTERNAL MUTATOR FUNCTION WRAPPERS *************************************************************/ /** * Activates policy for `policyholder` * @param policyholder The address of the intended policyholder. * @param coverLimit The maximum value to cover in **USD**. * @param amount The deposit amount in **USD** to fund the policyholder's account. * @param referralCode The referral code. * @param chains_ The chain ids. * @return policyID The ID of the newly minted policy. */ activatePolicy(policyholder: string, coverLimit: BigNumberish, amount: BigNumberish, referralCode: utils.BytesLike, chains?: BigNumberish[], gasConfig?: GasConfiguration): Promise<providers.TransactionResponse>; /** * @notice Updates the cover limit of a user's policy. * @notice This will reset the cooldown. * @param newCoverLimit_ The new maximum value to cover in **USD**. * @param referralCode_ The referral code. */ updateCoverLimit(newCoverLimit: BigNumberish, referralCode: utils.BytesLike, gasConfig?: GasConfiguration): Promise<providers.TransactionResponse>; /** * @notice Deposits funds into the `policyholder` account. * @param policyholder The policyholder. * @param amount The amount to deposit in **USD**. */ deposit(policyholder: string, amount: BigNumberish, gasConfig?: GasConfiguration): Promise<providers.TransactionResponse>; /** * Withdraw funds from user's account. * If cooldown has passed, the user will withdraw their entire account balance. * If cooldown has not started, or has not passed, the user will not be able to withdraw their entire account. A minimum required account balance (one epoch's fee) will be left in the user's account. */ withdraw(gasConfig?: GasConfiguration): Promise<providers.TransactionResponse>; /** * Deactivate a user's policy. * This will set a user's cover limit to 0, and begin the cooldown timer. Read comments for [`cooldownPeriod()`](#cooldownperiod) for more information on the cooldown mechanic. */ deactivatePolicy(gasConfig?: GasConfiguration): Promise<providers.TransactionResponse>; /************************************************************* METHODS - SOLACECOVERPRODUCT EXTERNAL VIEW FUNCTION WRAPPERS *************************************************************/ /** * @returns The active cover limit in **USD** to 18 decimal places. In other words, the total cover that has been sold at the current time. */ activeCoverLimit(): Promise<BN>; /** * @returns The amount of available remaining capacity for new cover. */ availableCoverCapacity(): Promise<BN>; /** * @returns The maximum amount of cover that can be sold in **USD** to 18 decimals places. */ maxCover(): Promise<BN>; /** * @returns The policy count (amount of policies that have been purchased, includes inactive policies). */ policyCount(): Promise<BN>; /** * @param policyholder The policyholder address. * @returns The policyholder's account balance in **USD**. */ accountBalanceOf(policyholder: string): Promise<BN>; /** * @param policyID The policy ID. * @returns The cover limit for the given policy ID. */ coverLimitOf(policyID: BigNumberish): Promise<BN>; /** * @param coverLimit Cover limit. * @returns The minimum required account balance for a given cover limit. Equals the maximum chargeable fee for one epoch. */ minRequiredAccountBalance(coverLimit: BN): Promise<BN>; /** * @param policyID The policy ID. * @returns True if policy is active. False if policy is inactive, or does not exist. */ policyStatus(policyID: BigNumberish): Promise<boolean>; /** * @param policyID The policy ID. * @returns The policy chain information */ getPolicyChainInfo(policyID: BigNumberish): Promise<boolean>; /** * @param policyID The policy ID. * @returns The chain at the given index */ getChain(chainIndex: BigNumberish): Promise<boolean>; /** * @param policyID The policy ID. * @returns The number of supported chains */ numSupportedChains(): Promise<boolean>; /** * TO-DO Decide if need to decode return value from BN hex. * @param policyholder The policyholder address. * @returns policyID The policy ID. */ policyOf(policyholder: string): Promise<BN>; /** * @param policyholder The policyholder address. * @returns The reward points for the policyholder. */ rewardPointsOf(policyholder: string): Promise<BN>; /** * @param policyholder The policyholder address. * @returns The total premium paid for the policyholder. */ premiumsPaidOf(policyholder: string): Promise<BN>; /** * @param policyholder The policyholder address. * @returns The cooldown period start expressed as Unix timestamp */ cooldownStart(policyholder: string): Promise<BN>; /** * @param policyholder The policyholder address. * @returns True if the policyholder has previously used a valid referral code, false if not. */ isReferralCodeUsed(policyholder: string): Promise<boolean>; /** * @param referralCode The referral code. * @returns The referrer address, returns 0 address if invalid referral code. */ getReferrerFromReferralCode(referralCode: utils.BytesLike): Promise<string>; /** * @param referralCode The referral code. * @returns True if valid referral code, false otherwise. */ isReferralCodeValid(referralCode: utils.BytesLike): Promise<boolean>; /** * Generates a referral code for the given Signer (dependent on private key). * @returns 65-byte (or 130 hex-character) referral code. * Note that this is an Ethereum ECDSA signature. * * Note Ledger generated signatures appear to have an issue where the last 2 characters (or 1 byte) of the signature is '00' or '01'. * Valid Ethereum ECDSA signatures have the last 2 characters as '0b' or '0c'. This is the v part of the signature. * To fix this issue, if the last two characters of the signature are '00', replace with '0b'. * If the last two characters of the signature are '01', replace with '0c'. */ getReferralCode(): Promise<string>; }