PapayaGetter
Class for using read-only methods of Papaya Contract
constructor
constructor({papayaAddress: string, provider?: JsonRpcProvider })
parameters
papayaAddress(
`0x{string}`
)
- smart-contract addressprovider( JsonRpcProvider )
- jsonRpc blockchain provider from ethers.js
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}")
})
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 projectIduser(
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>
Last updated