0.0.3 • Published 5 months ago
@crystalizefi/crystalize-sdk v0.0.3
Crystalize SDK
The Crystalize SDK library provides a simple pre-packaged API to communicate with the Crystalize protocol. It simplifies the process of retrieving pool data from a specific contract.
Features
- Simplified method to fetch pool data.
- Utilizes ethers.js for efficient Ethereum communication.
- Supports multiple Ethereum networks.
Installation
npm install @crystalizefi/crystalize-sdk
Or if you prefer using Yarn:
yarn add @crystalizefi/crystalize-sdk
Usage
To use the Crystalize SDK library, start by importing it into your Javascript project:
import { Crystalize } from '@crystalizefi/crystalize-sdk';
Setting Up
Initialize the library by specifying the RPC URL and chain ID:
const crystalize = new Crystalize({
rpcUrl: 'YOUR_RPC_URL',
chainId: YOUR_CHAIN_ID,
});
Fetching Pool Data
You can fetch pool data by calling the getPools
method:
async function fetchPools() {
const pools = await crystalize.getPools({
pending: false,
user: 'OPTIONAL_USER_ADDRESS',
});
console.log(pools);
}
API Reference
getPools({ pending, user })
Fetches pool data.
- pending:
boolean
- Indicates whether to fetch pending pools. - user: `string
(optional) - User address.
Types
The PoolData
type represents the structure of data for a pool. It includes the following fields:
- address: string - The address of the pool.
- status: PoolStatus - The current status of the pool.
- totalAmountStaked: number - The total current amount staked in the pool.
- totalAmountStakedMax: number - The maximum total amount staked in the pool.
- maxStakePerAddress: number - The maximum amount that a single address can stake.
- capacity: number - The capacity of the pool.
- seedParticipants: number - The number of participants seeding the pool.
- seedingStart: number - The start time of the seeding period.
- seedingEnd: number - The end time of the seeding period.
- lockedEnd: number - The time when the pool gets unlocked.
- user: UserData | null - User-specific data, if available.
The UserData
type represents specific information about a user's interaction with a pool:
- stakedBalance: number - The amount of currency the user has staked.
- maxStakedBalance: number - The maximum balance the user can stake.
- earned: number - The amount earned by the user.
- claimed: number - The amount claimed by the user.