The main sdk API.

import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
import { ethers } from 'ethers';

const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
const exchangeRate = await sdk.convertToBNB(ethers.constants.WeiPerEther); // find how much 1 stkBNB is worth
console.log(`1 stkBNB = ${StkBNBWebSDK.format(exchangeRate)} BNB`); // 1 stkBNB = 1.004202 BNB

Hierarchy

  • StkBNBWebSDK

Constructors

Properties

_numConfirmations: number
_signerOrProvider: Provider | Signer
_stakePool: StakePool
_stkBNB: StkBNB
_subgraphUrl: string

Accessors

Methods

  • Check if a particular claim request for the signer can be claimed instantly.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
    const yesOrNo = await sdk.canBeClaimedInstantly(0); // check the claim request at index 0

    Returns

    A promise that resolves to a boolean value indicating if the claim request can be claimed instantly.

    Parameters

    • index: BigNumberish

      Index of the claim request to be claimed for that specific user.

    Returns Promise<boolean>

  • Claim a particular claim request for the signer.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
    const { transactionHash } = await sdk.claim(0); // claim the request at index 0

    Returns

    A transaction receipt for the interaction with the contract

    Parameters

    • index: BigNumberish

      Index of the claim request to be claimed

    • Optional overrides: Overrides & {
          from?: PromiseOrValue<string>;
      }

    Returns Promise<ContractReceipt>

  • Claims all the claim requests for the signer.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
    const { transactionHash } = await sdk.claimAll();

    Returns

    A transaction receipt for the interaction with the contract

    Parameters

    • Optional overrides: Overrides & {
          from?: PromiseOrValue<string>;
      }

    Returns Promise<ContractReceipt>

  • Converts stkBNB to BNB based on the current exchange rate in the contract.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
    import { ethers } from 'ethers';

    const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
    const exchangeRate = await sdk.convertToBNB(ethers.constants.WeiPerEther); // find how much 1 stkBNB is worth
    console.log(`1 stkBNB = ${StkBNBWebSDK.format(exchangeRate)} BNB`); // 1 stkBNB = 1.004202 BNB

    Returns

    The BNB equivalent of the given amount

    Parameters

    • amount: BigNumberish

      Amount of stkBNB to convert to BNB

    Returns Promise<BigNumber>

  • Converts BNB to stkBNB based on the current exchange rate in the contract.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
    import { ethers } from 'ethers';

    const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
    const exchangeRate = await sdk.convertToStkBNB(ethers.constants.WeiPerEther); // find how much 1 BNB is worth
    console.log(`1 BNB = ${StkBNBWebSDK.format(exchangeRate)} stkBNB`); // 1 BNB = 0.995815 stkBNB

    Returns

    The stkBNB equivalent of the given amount

    Parameters

    • amount: BigNumberish

      Amount of BNB to convert to stkBNB

    Returns Promise<BigNumber>

  • Fetches APR% for n number of days before.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
    const apr = await sdk.getApr(7); // get apr% between current Exchange rate and 7 days before exchange rate.

    Returns

    APR% between current and n days before exchange rate.

    Parameters

    • n: number

      Number of days for calculating APR.

    Returns Promise<number>

  • Get the current unlock period for the claims.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
    const cooldownPeriodInSeconds = await sdk.getClaimUnlockTime(); // how many seconds need to pass for claim to be unlocked

    Returns

    Returns Promise<number>

  • Fetches all the claim requests for the user.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
    const claimRequests = await sdk.getClaims('0xa8E41F290ECfe99488D2F5f6621daf36a592e1D7'); // get all the claim requests for the address 0xa8E41F290ECfe99488D2F5f6621daf36a592e1D7

    Returns

    An array containing all the claim requests for the user

    Parameters

    • user: string

      The address of the user to query

    Returns Promise<ClaimRequestStructOutput[]>

  • Get the number of claims for the current user.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
    const numberOfClaims = await sdk.getClaimsLength(); // you get the number of claims for the current user

    Returns

    A promise that resolves to the number of claims for the current user.

    Returns Promise<number>

  • Get the available amount for instant claim requests.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // provide at least the provider
    const weiAvailable = await sdk.getInstantClaimAvailableAmount();

    Returns

    A promise that resolves to the available wei amount for instant claim requests.

    Returns Promise<BigNumber>

  • Fetches the current TVL (total value locked), aka TVU (total value unlocked)

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
    const tvl = await sdk.getTvl();
    console.log(`TVL = ${StkBNBWebSDK.format(tvl, 2)} BNB`); // TVL = 25229.76 BNB

    Returns

    The current TVL

    Returns Promise<BigNumber>

  • Claim a particular claim request for the signer instantly. Deducts a fee.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
    const { transactionHash } = await sdk.instantClaim(0); // claim the request at index 0

    Returns

    A transaction receipt for the interaction with the contract

    Parameters

    • amount: BigNumberish
    • Optional overrides: Overrides & {
          from?: PromiseOrValue<string>;
      }

    Returns Promise<ContractReceipt>

  • Stake BNB for the signer.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
    import { ethers } from 'ethers';

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
    const { transactionHash } = await sdk.stake(ethers.constants.WeiPerEther); // stake 1 BNB

    Returns

    A transaction receipt for the interaction with the contract

    Parameters

    • amount: BigNumberish

      Amount of BNB to stake

    • Optional overrides: Overrides & {
          from?: PromiseOrValue<string>;
      }

    Returns Promise<ContractReceipt>

  • Unstake BNB for the signer. The unstaked amount will be available to claim after the cooldown period is over.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
    import { ethers } from 'ethers';

    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: ...}); // just provide the signer here
    const { transactionHash } = await sdk.unstake(ethers.constants.WeiPerEther); // unstake 1 stkBNB

    Returns

    A transaction receipt for the interaction with the contract

    Parameters

    • amount: BigNumberish

      Amount of stkBNB to unstake

    • Optional overrides: Overrides & {
          from?: PromiseOrValue<string>;
      }

    Returns Promise<ContractReceipt>

  • Rounds an 18 decimal token balance value to 6 digits of precision to show in the UI.

    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";
    import { ethers } from 'ethers';

    const sdk = StkBNBWebSDK.getInstance(); // get the mainnet instance
    const exchangeRate = await sdk.convertToBNB(ethers.constants.WeiPerEther); // find how much 1 stkBNB is worth
    console.log(`1 stkBNB = ${StkBNBWebSDK.format(exchangeRate)} BNB`); // 1 stkBNB = 1.004202 BNB

    Returns

    The formatted value with 6 digits of precision.

    Parameters

    • value: BigNumberish

      The value to format

    • roundToDecimals: number = 6

      The number of decimals to show in the UI

    Returns string

  • Get a new instance of the sdk. Any transactions initiated by this instance will wait for the transaction to finalize as per the configured opts.numConfirmations.

    // Get the testnet instance:
    import { StkBNBWebSDK, Env } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance({env: Env.Testnet});

    // OR get the mainnet instance for reading the blockchain:
    import { StkBNBWebSDK } from "@persistenceone/stkbnb-web-sdk";

    const sdk = StkBNBWebSDK.getInstance();

    // OR get the mainnet instance for carrying out transactions:
    import { StkBNBWebSDK, MAINNET_CONFIG } from "@persistenceone/stkbnb-web-sdk";
    import { ethers } from 'ethers';

    const provider = MAINNET_CONFIG.defaultProvider; // or use your own JSON RPC provider
    const wallet = ethers.Wallet.fromMnemonic('...').connect(provider); // or use your existing wallet instance
    const sdk = StkBNBWebSDK.getInstance({signerOrProvider: wallet}); // just provide the signer here

    Parameters

    Returns StkBNBWebSDK

Generated using TypeDoc