Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
284 changes: 284 additions & 0 deletions src/bin/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,36 @@ async fn main() {
query_order_by_oid_example(&info_client).await;
query_referral_state_example(&info_client).await;
historical_orders_example(&info_client).await;
frontend_open_orders_example(&info_client).await;
user_fills_by_time_example(&info_client).await;
user_twap_slice_fills_example(&info_client).await;
portfolio_example(&info_client).await;
user_role_example(&info_client).await;
user_rate_limit_example(&info_client).await;
sub_accounts_example(&info_client).await;
vault_details_example(&info_client).await;
user_vault_equities_example(&info_client).await;
max_builder_fee_example(&info_client).await;
delegations_example(&info_client).await;
delegator_summary_example(&info_client).await;
delegator_history_example(&info_client).await;
delegator_rewards_example(&info_client).await;
borrow_lend_user_state_example(&info_client).await;
borrow_lend_reserve_state_example(&info_client).await;
all_borrow_lend_reserve_states_example(&info_client).await;
user_dex_abstraction_example(&info_client).await;
aligned_quote_token_info_example(&info_client).await;
perp_dexs_example(&info_client).await;
user_non_funding_ledger_updates_example(&info_client).await;
predicted_fundings_example(&info_client).await;
perps_at_open_interest_cap_example(&info_client).await;
perp_deploy_auction_status_example(&info_client).await;
perp_dex_limits_example(&info_client).await;
perp_dex_status_example(&info_client).await;
all_perp_metas_example(&info_client).await;
spot_deploy_state_example(&info_client).await;
spot_pair_deploy_auction_status_example(&info_client).await;
token_details_example(&info_client).await;
}

fn address() -> Address {
Expand Down Expand Up @@ -205,3 +235,257 @@ async fn historical_orders_example(info_client: &InfoClient) {
info_client.historical_orders(user).await.unwrap()
);
}

async fn frontend_open_orders_example(info_client: &InfoClient) {
let user = address();
info!(
"Frontend open orders for {user}: {:?}",
info_client.frontend_open_orders(user).await.unwrap()
);
}

async fn user_fills_by_time_example(info_client: &InfoClient) {
let user = address();
let start_timestamp = 1690540602225;
let end_timestamp = 1690569402225;
info!(
"User fills by time for {user} between {start_timestamp} and {end_timestamp}: {:?}",
info_client
.user_fills_by_time(user, start_timestamp, Some(end_timestamp), None)
.await
.unwrap()
);
}

async fn user_twap_slice_fills_example(info_client: &InfoClient) {
let user = address();
info!(
"User TWAP slice fills for {user}: {:?}",
info_client.user_twap_slice_fills(user).await.unwrap()
);
}

async fn portfolio_example(info_client: &InfoClient) {
let user = address();
info!(
"Portfolio for {user}: {:?}",
info_client.portfolio(user).await.unwrap()
);
}

async fn user_role_example(info_client: &InfoClient) {
let user = address();
info!(
"User role for {user}: {:?}",
info_client.user_role(user).await.unwrap()
);
}

async fn user_rate_limit_example(info_client: &InfoClient) {
let user = address();
info!(
"User rate limit for {user}: {:?}",
info_client.user_rate_limit(user).await.unwrap()
);
}

async fn sub_accounts_example(info_client: &InfoClient) {
let user = address();
info!(
"Sub accounts for {user}: {:?}",
info_client.sub_accounts(user).await.unwrap()
);
}

async fn vault_details_example(info_client: &InfoClient) {
// Example vault address (you may need to replace with a valid vault address)
let vault_address: Address = "0x1234567890123456789012345678901234567890"
.parse()
.unwrap();
let user = address();
match info_client.vault_details(vault_address, Some(user)).await {
Ok(details) => info!(
"Vault details for {vault_address} (user: {user}): {:?}",
details
),
Err(e) => info!("Vault details error (expected if vault doesn't exist): {e}"),
}
}

async fn user_vault_equities_example(info_client: &InfoClient) {
let user = address();
info!(
"User vault equities for {user}: {:?}",
info_client.user_vault_equities(user).await.unwrap()
);
}

async fn max_builder_fee_example(info_client: &InfoClient) {
let user = address();
let builder: Address = "0x1234567890123456789012345678901234567890"
.parse()
.unwrap();
info!(
"Max builder fee for user {user} and builder {builder}: {:?}",
info_client.max_builder_fee(user, builder).await.unwrap()
);
}

async fn delegations_example(info_client: &InfoClient) {
let user = address();
info!(
"Delegations for {user}: {:?}",
info_client.delegations(user).await.unwrap()
);
}

async fn delegator_summary_example(info_client: &InfoClient) {
let user = address();
info!(
"Delegator summary for {user}: {:?}",
info_client.delegator_summary(user).await.unwrap()
);
}

async fn delegator_history_example(info_client: &InfoClient) {
let user = address();
info!(
"Delegator history for {user}: {:?}",
info_client.delegator_history(user).await.unwrap()
);
}

async fn delegator_rewards_example(info_client: &InfoClient) {
let user = address();
info!(
"Delegator rewards for {user}: {:?}",
info_client.delegator_rewards(user).await.unwrap()
);
}

async fn borrow_lend_user_state_example(info_client: &InfoClient) {
let user = address();
info!(
"Borrow/lend user state for {user}: {:?}",
info_client.borrow_lend_user_state(user).await.unwrap()
);
}

async fn borrow_lend_reserve_state_example(info_client: &InfoClient) {
let token: u32 = 0; // USDC token index
info!(
"Borrow/lend reserve state for token {token}: {:?}",
info_client.borrow_lend_reserve_state(token).await.unwrap()
);
}

async fn all_borrow_lend_reserve_states_example(info_client: &InfoClient) {
info!(
"All borrow/lend reserve states: {:?}",
info_client.all_borrow_lend_reserve_states().await.unwrap()
);
}

async fn user_dex_abstraction_example(info_client: &InfoClient) {
let user = address();
info!(
"User DEX abstraction for {user}: {:?}",
info_client.user_dex_abstraction(user).await.unwrap()
);
}

async fn aligned_quote_token_info_example(info_client: &InfoClient) {
let token: u32 = 0; // USDC token index
info!(
"Aligned quote token info for token {token}: {:?}",
info_client.aligned_quote_token_info(token).await.unwrap()
);
}

async fn perp_dexs_example(info_client: &InfoClient) {
info!(
"Perpetual DEXs: {:?}",
info_client.perp_dexs().await.unwrap()
);
}

async fn user_non_funding_ledger_updates_example(info_client: &InfoClient) {
let user = address();
let start_timestamp = 1690540602225;
let end_timestamp = 1690569402225;
info!(
"User non-funding ledger updates for {user}: {:?}",
info_client
.user_non_funding_ledger_updates(user, start_timestamp, Some(end_timestamp))
.await
.unwrap()
);
}

async fn predicted_fundings_example(info_client: &InfoClient) {
info!(
"Predicted fundings: {:?}",
info_client.predicted_fundings().await.unwrap()
);
}

async fn perps_at_open_interest_cap_example(info_client: &InfoClient) {
info!(
"Perps at open interest cap: {:?}",
info_client.perps_at_open_interest_cap(None).await.unwrap()
);
}

async fn perp_deploy_auction_status_example(info_client: &InfoClient) {
info!(
"Perp deploy auction status: {:?}",
info_client.perp_deploy_auction_status().await.unwrap()
);
}

async fn perp_dex_limits_example(info_client: &InfoClient) {
// Example DEX name - adjust as needed for a valid builder-deployed DEX
let dex = "example_dex";
match info_client.perp_dex_limits(dex.to_string()).await {
Ok(limits) => info!("Perp DEX limits for {dex}: {:?}", limits),
Err(e) => info!("Perp DEX limits error (expected if DEX doesn't exist): {e}"),
}
}

async fn perp_dex_status_example(info_client: &InfoClient) {
info!(
"Perp DEX status: {:?}",
info_client.perp_dex_status(None).await.unwrap()
);
}

async fn all_perp_metas_example(info_client: &InfoClient) {
info!(
"All perp metas: {:?}",
info_client.all_perp_metas().await.unwrap()
);
}

async fn spot_deploy_state_example(info_client: &InfoClient) {
let user = address();
info!(
"Spot deploy state for {user}: {:?}",
info_client.spot_deploy_state(user).await.unwrap()
);
}

async fn spot_pair_deploy_auction_status_example(info_client: &InfoClient) {
info!(
"Spot pair deploy auction status: {:?}",
info_client.spot_pair_deploy_auction_status().await.unwrap()
);
}

async fn token_details_example(info_client: &InfoClient) {
// Example token ID (USDC on testnet - adjust as needed)
let token_id = "0xc1fb593aeffbeb02f85e0308e9956a90";
match info_client.token_details(token_id.to_string()).await {
Ok(details) => info!("Token details for {token_id}: {:?}", details),
Err(e) => info!("Token details error (expected if token doesn't exist): {e}"),
}
}
Loading
Loading