๐Ÿ’ฐ Balance

Learn how to retrieve user wallet balances with ForkastSDK, including USDC, USDT, and CGPC balances via the getBalances function.

This section documents the core interfaces used when working with user balances in ForkastSDK.

๐Ÿ› ๏ธ Functions

๐Ÿ’ฐ Get Balance

import { ForkastSDK, Network, BalanceResponse } from "@forkastgg/client";

const sdk = new ForkastSDK(Network.MAINNET, "YOUR_API_KEY");
const accountService = sdk.getAccountService();
const balanceService = sdk.getBalanceService();

const { accessToken } = await accountService.loginWithPrivateKey(
  "YOUR_PRIVATE_KEY"
);

const balances:BalanceResponse = await balanceService.getBalances(accessToken);

console.log(balances);

Parameters

FieldTypeRequiredDescription
accessTokenstringYesAccess Token received from login response

๐Ÿงฉ Types

๐Ÿ’ฐ Balance

Represents a user's wallet and proxy wallet balances across different stablecoins and platform tokens.

interface BalanceResponse {
  id: string;
  createdAt: string;
  updatedAt: string;
  deletedAt: string;
  userId: number;
  balanceUSDC: string;
  lockBalanceUSDC: string;
  balanceUSDT: string;
  lockBalanceUSDT: string;
  balanceCGPC: string;
  lockBalanceCGPC: string;
  walletProxyAddress: string;
  walletAddress: string;
}

Key Fields

FieldTypeDescription
idstring
createdAtstringISO timestamp of when the balance record was created
uppdatedAtstringISO timestamp of last update
deletedAtstringISO timestamp if the record is soft-deleted
userIdnumberID of the user
balanceUSDCnumber- 1 = Yes outcome
  • 0 = No outcome | | lockBalanceUSDC | number | Price per unit of outcome token | | balanceCGPC | number | Number of shares to buy/sell | | lockBalanceCGPC | number | Total value (price * amount) |