Contract Interaction Examples

This section shows how developers interact with PLX vault contracts directly — either through the SDK or Solana’s Anchor framework.


Example 1: Minting a Leveraged Token (SOL2X)

POST https://api.plx.fi/v1/actions/mint

Payload

{
  "wallet": "B3kPq...x7xA",
  "symbol": "SOL2X",
  "amount": 25.0,
  "signature": "5q9NQhC8bX..."
}

Response

{
  "status": "success",
  "tx_hash": "2WfxZ...kLB7",
  "new_balance": 25.0,
  "vault_ratio": 2.03
}

Example 2: Claiming Rewards Automatically

POST https://api.plx.fi/v1/rewards/claim

Response

{
  "wallet": "F9Y...xRz",
  "claimed": 3.94,
  "token": "SOL",
  "tx": "7kgFhS...Zp2k"
}

Example 3: Subscribing to Rebalance Events (WebSocket)

const socket = new WebSocket("wss://stream.plx.fi/rebalance");
socket.onmessage = (msg) => console.log(JSON.parse(msg.data));

Event Example

{
  "event": "rebalance",
  "symbol": "PUMP2X",
  "old_ratio": 1.96,
  "new_ratio": 2.00,
  "timestamp": 1734514921
}

These examples mirror the actual Anchor program interactions, making it possible for developers to simulate transactions without deploying on-chain code.

Last updated