API Reference
These docs are for v2.0. Click to read the latest docs for v2.0.1.

Add/Remove Sub Account

The method Set Sub Account allows users to whitelist or delist a wallet address as a sub-account to their wallet address.

You can whitelist, and delist, sub-accounts for each of the Markets, using this method. Only the whitelisted sub-accounts and the parent can perform trade actions on behalf of the parent.

Sub-accounts will only have permission to perform trade actions on the selected Markets for which they have been whitelisted by the Parent.

The method takes the following input params:

  • Public Address: The address of the sub-account to whitelist/delist
  • Market Symbol: Symbol of the market in format "{ASSET_SYMBOL}-PERP" eg: "BTC-PERP", "ETH-PERP"
  • Status: Boolean set to True to whitelist, and False to delist

The response will have the following schema:

type ResponseSchema = {
    ok: boolean; // boolean indicating contract call success/failure
    data: any; // transaction data
    message: string; // success / error message
    code?: number | string; // status code
    stack?: string; // error stack
  };

Example

import { Networks, BluefinClient } from "@bluefin-exchange/bluefin-v2-client";
import { TEST_ACCT_KEY, TEST_SUB_ACCT_KEY } from "./config";

async function main() {

    // account keys
    const parentAccountKey ="" || TEST_ACCT_KEY;
    const childAccountKey = "" || TEST_SUB_ACCT_KEY;

    // initialize the parent account client
    const clientParent = new BluefinClient(
        true,
        Networks.TESTNET_SUI,
        parentAccountKey,
        "ED25519"
    );
    await clientParent.init();

    // initialize the child account client
    const clientChild = new BluefinClient(
        true,
        Networks.TESTNET_SUI,
        childAccountKey,
        "ED25519"
    );
    await clientChild.init();

    // Add child account as subaccount
    const resp1 = await clientParent.setSubAccount(
        clientChild.getPublicAddress(),
        true
    );

    console.log(resp1);

    // Remove child account as subaccount
    const resp2 = await clientParent.setSubAccount(
        clientChild.getPublicAddress(),
        false
    );

    console.log(resp2);
}

main().then().catch(console.warn);

from config import TEST_ACCT_KEY, TEST_SUB_ACCT_KEY, TEST_NETWORK
from bluefin_v2_client import (
    BluefinClient,
    Networks,
)
import asyncio


async def main():
  # initialize the parent account client
  clientParent = BluefinClient(True, Networks[TEST_NETWORK], TEST_ACCT_KEY)
  await clientParent.init(True)

  # initialize the child account client
  clientChild = BluefinClient(True, Networks[TEST_NETWORK], TEST_SUB_ACCT_KEY)
  await clientChild.init(True)

  print("Parent: ", clientParent.get_public_address())
  print("Child: ", clientChild.get_public_address())

  # add child account as subaccount
  status = await clientParent.update_sub_account(
      clientChild.get_public_address(), True
    )
  print("Sub account added: {}\n".format(status))

  # remove child account as subaccount
  status = await clientParent.update_sub_account(
      clientChild.get_public_address(), False
    )
  print("Sub account removed: {}\n".format(status))


if __name__ == "__main__":
  loop = asyncio.new_event_loop()
  loop.run_until_complete(main())
  loop.close()