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
  • allSubscriptions
  • subscriptions
  • users
  1. Protocol
  2. Advanced Section

Subscriptions


allSubscriptions

To retrieve the subscriptions of a specific user, use the allSubscriptions method. It returns arrays containing addresses and encoded subscription data (cost, author’s share, project number).

function allSubscriptions(address from) external view returns(address[] memory to, uint256[] memory encodedRates)

subscriptions

To obtain encoded data for a specific subscription, use the subscriptions method. It returns two values: a flag indicating presence and encoded data if the subscription exists.

function subscriptions(address from, address to) external view returns (bool, uint256 encodedRates)
bool - success flag:
    - true subscription exists
    - false in another way
    
uint256 encodedRates - compressed data that stores:
    - uint96 incomeRate
    - uint96 outgoingRate 
    - uint96 projectId 

Note: incomeRate is a rate that incoming to the author, and outgoingRate is a rate that incoming from the subscriber


users

To get information about a user, use the users method. This returns four fields: balance, incoming stream, outgoing stream, and the last synchronization timestamp.

function users(address) public view returns (User calldata user)
struct User {
  int256 balance;
  int256 incomeRate; // changes to this field requires _syncBalance() call
  int256 outgoingRate; // changes to this field requires _syncBalance() call
  uint256 updated;
}

Note that balance synchronization occurs on request, so the balance data may be outdated.

To calculate the balance yourself, determine the difference between incoming and outgoing streams and multiply by the time elapsed since the last synchronization timestamp. Alternatively, use the balanceOf method for up-to-date data.

PreviousEventsNextProjects

Last updated 8 months ago