put https://trade.api.{env}.bluefin.io/api/v1/trade/accounts/deauthorize
Deauthorizes an account to trade, perform liquidations and more, on behalf of another account.
Client Library
#!/usr/bin/env python
import asyncio
import logging
import time
from bluefin_pro_sdk import BluefinProSdk, Environment, RpcUrl
from crypto_helpers.signature import SuiWallet
# Set up logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)
def now():
"""Return the current time in milliseconds since the Epoch."""
return int(time.time() * 1000)
async def main():
"""
Example showing how to deauthorize a wallet using the Bluefin Pro API
using the PRODUCTION environment.
"""
# Create a wallet with your private key
sui_wallet = SuiWallet(
mnemonic="dilemma salmon lake ceiling moral glide cute that ginger float area aunt vague remind cage mother concert inch dizzy present proud program time urge"
)
log.info(f"Using wallet address: {sui_wallet.sui_address}")
# Initialize the Bluefin Pro SDK client with PRODUCTION environment and RPC
async with BluefinProSdk(
sui_wallet=sui_wallet,
contracts=None, # Not needed for this example
rpc_url=RpcUrl.PROD,
env=Environment.PRODUCTION,
debug=False # Set to True for more verbose output
) as client:
try:
# Initialize the client, which will handle authentication
await client.init()
# ========= Deauthorize a wallet ==========
log.info("Deauthorizing wallet")
await client.deauthorize_account("INSERT_WALLET_ADDRESS_HERE")
except Exception as e:
log.error(f"Error deauthorizing wallet: {e}")
raise
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
log.info("Exiting due to keyboard interrupt")
use bluefin_api::{
apis::{
configuration::Configuration,
trade_api::{put_authorize_account, put_deauthorize_account},
},
models::{AccountAuthorizationRequest, AccountAuthorizationRequestSignedFields},
};
use bluefin_pro::prelude::*;
use chrono::Utc;
use hex::FromHex;
use sui_sdk_types::SignatureScheme;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
/// # Trade Account Authorization Example
///
/// This example demonstrates how to authorize and deauthorize trading accounts
/// using the Bluefin API.
///
/// ## Key Components
///
/// - `AccountAuthorizationRequestExt`: A wrapper around `AccountAuthorizationRequest` that
/// provides signing capabilities. Always use this wrapper instead of using the internal
/// `AccountAuthorizationRequest` directly. The internal request should only be used when
/// constructing the `AccountAuthorizationRequestExt`. To authorize an account, set the
/// `is_authorize` parameter to `true`. To deauthorize an account, set the `is_authorize`
/// parameter to `false`.
///
async fn send_request(
request: AccountAuthorizationRequestExt,
environment: Environment,
) -> Result<()> {
let mut config = Configuration::new();
config.base_path = trade::url(environment).into();
put_deauthorize_account(&config, request.request).await?;
Ok(())
}
#[tokio::main]
async fn main() -> Result<()> {
let environment = Environment::Mainnet;
let time_now = Utc::now().timestamp_millis();
let contracts_info = exchange::info::contracts_config(environment).await?;
// Authorize account
let request = AccountAuthorizationRequestExt::new(
AccountAuthorizationRequest {
signed_fields: AccountAuthorizationRequestSignedFields {
account_address: "INSERT_ACCOUNT_ADDRESS_HERE",
authorized_account_address: "INSERT_WALLET_ADDRESS_TO_AUTHORIZE_HERE",
salt: rand::random::<u64>().to_string(),
ids_id: contracts_info.ids_id.clone(),
signed_at_millis: time_now,
},
..Default::default()
},
false,
);
let request = request.sign(
PrivateKey::from_hex("INSERT_HEX_ENCODED_PRIVATE_KEY_HERE")?,
SignatureScheme::Ed25519,
)?;
send_request(request, environment).await?;
println!("Deauthorized account");
Ok(())
}
HTTPs
Alternatively, call the PUT /trade/accounts/deauthorize endpoint using the integrated editor on the right or locally from any language supporting HTTPs network calls.