๐Ÿ”” User Updates

Connect to the socket server as an authenticated user to receive real-time updates on your positions, activities, and TC balance.

To receive real-time updates about your positions, activities, and TC balance, you must connect to the socket server as an authenticated user.

import { io } from "socket.io-client";

const url = "{{BASE_URL}}";
const opts = {
  transports: ["websocket"],
  reconnection: true,
  auth: { token: "YOUR_TOKEN_HERE" }, // Set your JWT or session token here
};

const socket = io(url, opts);

socket.on("connect", () => {
  console.log("connected", socket.id);
  // Optionally join a room if needed
  // socket.emit("joinRoom", "user_123"); // Example: join a user-specific room
});

socket.on("disconnect", (reason) => {
  console.log("disconnected", reason);
});

socket.on("connect_error", (err) => {
  console.error("Connection error:", err.message);
});

// Listen for user-specific events
socket.on("update_position", (data) => {
  console.log("Received update_position:", data);
});

socket.on("update_activity", (data) => {
  console.log("Received update_activity:", data);
});

socket.on("update_cgpc_balance", (data) => {
  console.log("Received update_cgpc_balance:", data);
});

๐Ÿ’ฐ Get TC Balance Updates

Sent when your TC/USDC token balance or related wallet information changes.

Event: update_cgpc_balance

FieldTypeDescription
idstringBalance record ID
createdAtstringRecord creation ISO timestamp
updatedAtstringLast update ISO timestamp
deletedAtstring | nullDeletion timestamp (if deleted)
userIdnumberUser identifier
balanceUSDCstringUSDC balance
lockBalanceUSDCstringLocked USDC balance
balanceUSDTstringUSDT balance
lockBalanceUSDTstringLocked USDT balance
balanceCGPCnumberTC token balance
lockBalanceCGPCstringLocked CGPC balance
walletProxyAddressstringProxy wallet address
walletAddressstringUserโ€™s wallet address
tradeGapstringTrade gap value
lastRewardClaimedAtstringLast reward claim ISO timestamp

๐Ÿ“ˆ Get New Positions

Sent when your position in a market is updated.

Event: update_position

FieldTypeDescription
idstringPosition ID
marketIdstringMarket identifier
amountnumberNumber of shares held
outcomeIdstringOutcome identifier
outcomeTitlestringOutcome name (e.g., "yes", "no")
eventIdnumberEvent identifier
marketQuestionstringThe marketโ€™s question
marketStatusenumMarket status (ACTIVE, CLOSED, etc.)
marketImagestringImage URL for the market
avgPricenumberAverage price paid
latestPricenumberMost recent price
currentValuenumberCurrent value of your position
betValuenumberTotal amount youโ€™ve bet
pnlnumberProfit and loss (decimal)
winValuenumberValue if your outcome wins

๐Ÿ“œ Get Activity of the user

Sent when a new activity (trade) is recorded for your account.

Event: update_activity

FieldTypeDescription
idstringActivity ID
amountnumberAmount traded
pricenumberPrice per unit
totalnumberTotal value of the trade
typeenumActivity type (buy, sell, etc.)
createdAtstringISO timestamp of the activity
txHashstringBlockchain transaction hash
marketIdstringMarket identifier
marketTitlestringMarket title
marketQuestionstringMarketโ€™s question
marketImagestringImage URL for the market
eventIdnumberEvent identifier
outcomeIdstringOutcome identifier
outcomeTitlestringOutcome name
outcomeTypenumberOutcome type (numeric)
abbreviationstring|nullAbbreviation (if any)
slugstringSlug for the event/market
rewardTokenstring | nullReward token (if any)

๐Ÿ’ผ Get Outcome Balance

Sent when your balance or locked balance for a specific outcome token is updated. This event notifies you of changes to your holdings for a particular outcome in a market.

Event: update_outcome_balance

FieldTypeDescription
idstringOutcome balance record ID
createdAtstringRecord creation ISO timestamp
updatedAtstringLast update ISO timestamp
deletedAtstring|nullDeletion timestamp (if deleted)
userIdnumberUser identifier
outcomeIdnumberOutcome identifier
tokenIdstringToken identifier for the outcome
balancenumberCurrent balance for this outcome
lockedBalancestringLocked balance for this outcome

๐Ÿงพ Get Open Orders

Emitted to provide the list of open orders for a user in a specific market.

FieldTypeDescription
idstringOrder ID
market_idnumberMarket ID
orders_addressstringAddress associated with the order
orders_amountstringTotal order amount
orders_filled_amountstringAmount already filled
orders_outcome_typenumberOutcome type (e.g., 0 = No, 1 = Yes)
orders_pricestringOrder price
orders_remaining_amountstringRemaining amount to be filled
orders_sidenumberOrder side (0 = buy, 1 = sell)
orders_statusnumberStatus code of the order
orders_expirednull/numberExpiry timestamp or null
orders_typenumberType of order
outcome_idnumberOutcome ID
outcome_titlestringOutcome title
orders_totalstringTotal value of the order
market_imagestringURL to market image