Papaya Finance Protocol
SDKProtocol
  • Introduction
  • Interaction
  • Getting Started
    • Initial Setup
    • Integration Steps
    • Go Live
  • Features
    • Real-Time Payment Streaming
    • Supported Networks
    • Business Dashboard
  • Use Cases
    • For Enterprises
    • For Financial Services
    • For Digital Economy
  • FAQ
  • Glossary
  • Future Development
  • Protocol
    • Common Methods
    • Recurring Payments
    • Subscription Methods
    • Auto Top-up
    • Liquidations
    • Fees
    • Advanced Section
      • Events
      • Subscriptions
      • Projects
      • Signatures
  • SDK
    • Installation
    • Quick Start
    • API
      • PapayaGetter
      • PapayaInteraction
      • PapayaBySigInteraction
Powered by GitBook
On this page
  • constructor
  • allSubscriptions
  • balanceOf
  • getUserSettings
  • getAllProjectOwners
  • getUser
  • FLOOR
  • MAX_PROTOCOL_FEE
  • APPROX_LIQUIDATE_GAS
  • APPROX_SUBSCRIPTION_GAS
  • SUBSCRIPTION_THRESHOLD
  • COIN_PRICE_FEED
  • TOKEN_PRICE_FEED
  • TOKEN
  • DECIMALS_SCALE
  1. SDK
  2. API

PapayaGetter

Class for using read-only methods of Papaya Contract

PreviousAPINextPapayaInteraction

Last updated 8 months ago


constructor

constructor({papayaAddress: string, provider?: JsonRpcProvider })

parameters

  • papayaAddress(`0x{string}`) - smart-contract address

  • provider( JsonRpcProvider ) - jsonRpc blockchain provider from

usage

import { PapayaGetter } from "@papaya-metaverse/papaya-sdk"

const papayaGetter = new PapayaGetter({
    papayaAddress: "0x1c3E45F2D9Dd65ceb6a644A646337015119952ff",
    provider:  new JsonRpcProvider("https://polygon.infura.io/v3/${INFURA_API_KEY}")
})

When using in browser, there is no need to specify rpcUrl since the window.ethereum provider is taken internally.

const papayaGetter = new PapayaGetter({
    papayaAddress: "0x1c3E45F2D9Dd65ceb6a644A646337015119952ff"
})

allSubscriptions

description

To know the subscriptions of a particular user, use the allSubscription method, which returns arrays of addresses and encoded subscription data (cost, author’s share, project number).

allSubscriptions(user: string): Promise<{ address: string[]; encodedRates: BigInt[] }>

parameters

  • user(string) - address of certain user

usage

//...

(async () => {
    const allSubscriptions = await papayaGetter.allSubscriptions(
        "0x1234567890123456789012345678901234567890"
    )
})()

balanceOf

description

The standard method for ERC 20 shows the balance, but with some changes. Due to the fact that streams change the balance every second, this method will show the current balance, even if there was no synchronization

balanceOf(projectId: number): Promise<BigInt>

parameters

  • projectId(number) - unique number of project

usage

//...

(async () => {
    const balance = await papayaGetter.balanceOf(
        "0x1234567890123456789012345678901234567890"
    )
})()

getUserSettings

description

If the settings of a specific user are set, you can familiarize yourself with them using this method

getUserSettings(projectId: number, user: string): Promise<{ initialized: boolean; projectFee: BigInt }>

parameters

  • projectId(number) - number of certain projectId

  • user(string) - address of certain user

usage

//...

(async () => {
    const userSettings = await papayaGetter.getUserSettings(
        "0",
        "0x1234567890123456789012345678901234567890"
    )
})()

getAllProjectOwners

description

This method returns an array of addresses that are the owners of the projects

getAllProjectOwners(): Promise<string[]>

usage

//...

(async () => {
    const allProjectOwners = await papayaGetter.getAllProjectOwners()
})()

getUser

description

This method returns four fields: balance, incoming stream, outgoing stream, last synchronization timestamp. Note: Since user balance synchronization occurs on request, balance data may be outdated.

getUser(user: string): Promise<{ balance: BigInt; incomeRate: BigInt; outgoingRate: BigInt; updated: BigInt; }>

parameters

  • user(string) - address of certain user

usage

//...

(async () => {
    const user = await papayaGetter.getUser(
        "0x1234567890123456789012345678901234567890"
    )
})()

FLOOR

description

This method returns the floor of every calculation, it is necessary to calculate the value of assets and fees

FLOOR(): Promise<BigInt>

MAX_PROTOCOL_FEE

description

This method returns the maximum possible fee value

MAX_PROTOCOL_FEE(): Promise<BigInt>

APPROX_LIQUIDATE_GAS

description

This method returns the approximate cost of completing the liquidation if the person does not have subscriptions.

APPROX_LIQUIDATE_GAS(): Promise<BigInt>

APPROX_SUBSCRIPTION_GAS

description

This method returns the approximate cost of performing liquidation for each subscription

APPROX_SUBSCRIPTION_GAS(): Promise<BigInt>

SUBSCRIPTION_THRESHOLD

description

This method returns the maximum possible count of subcriptions per user

SUBSCRIPTION_THRESHOLD(): Promise<BigInt>

COIN_PRICE_FEED

description

This method returns address of coin price feed, that used in smart-contract

COIN_PRICE_FEED(): Promise<string>

TOKEN_PRICE_FEED

description

This method returns address of token price feed, that used in smart-contract

TOKEN_PRICE_FEED(): Promise<string>

TOKEN

description

This method returns address of underlying token, because we masked it into pp*, where * is an asset name

TOKEN(): Promise<string>

DECIMALS_SCALE

description

This method returns the number for which the token was needed to be converted to the form 1e18

DECIMALS_SCALE(): Promise<BigInt>
ethers.js