Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/output/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub fn print_supported_assets(
println!("{table}");
}
OutputFormat::Json => {
let data: Vec<_> = response
let assets: Vec<_> = response
.supported_assets
.iter()
.map(|a| {
Expand All @@ -88,6 +88,10 @@ pub fn print_supported_assets(
})
})
.collect();
let data = json!({
"supported_assets": assets,
"note": response.note,
});
super::print_json(&data)?;
}
}
Expand Down
27 changes: 21 additions & 6 deletions src/output/clob/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,28 @@ pub fn print_notifications(
.map(|n| {
json!({
"type": n.r#type,
"question": n.payload.question,
"side": n.payload.side.to_string(),
"price": n.payload.price.to_string(),
"outcome": n.payload.outcome,
"owner": n.owner.to_string(),
"asset_id": n.payload.asset_id.to_string(),
"condition_id": n.payload.condition_id.to_string(),
"event_slug": n.payload.event_slug,
"icon": n.payload.icon,
"image": n.payload.image,
"market": n.payload.market.to_string(),
"market_slug": n.payload.market_slug,
"matched_size": n.payload.matched_size.to_string(),
"original_size": n.payload.original_size.to_string(),
"order_id": n.payload.order_id,
"original_size": n.payload.original_size.to_string(),
"outcome": n.payload.outcome,
"outcome_index": n.payload.outcome_index,
"owner_payload": n.payload.owner.to_string(),
"price": n.payload.price.to_string(),
"question": n.payload.question,
"remaining_size": n.payload.remaining_size.to_string(),
"series_slug": n.payload.series_slug,
"side": n.payload.side.to_string(),
"trade_id": n.payload.trade_id,
"market": n.payload.market.to_string(),
"transaction_hash": n.payload.transaction_hash.to_string(),
"order_type": n.payload.order_type.to_string(),
})
})
.collect();
Expand Down Expand Up @@ -293,6 +306,7 @@ pub fn print_user_earnings_markets(
"question": e.question,
"market_slug": e.market_slug,
"event_slug": e.event_slug,
"image": e.image,
"earning_percentage": e.earning_percentage.to_string(),
"rewards_max_spread": e.rewards_max_spread.to_string(),
"rewards_min_size": e.rewards_min_size.to_string(),
Expand Down Expand Up @@ -467,6 +481,7 @@ pub fn print_market_reward(
"question": r.question,
"market_slug": r.market_slug,
"event_slug": r.event_slug,
"image": r.image,
"rewards_max_spread": r.rewards_max_spread.to_string(),
"rewards_min_size": r.rewards_min_size.to_string(),
"market_competitiveness": r.market_competitiveness.to_string(),
Expand Down
19 changes: 19 additions & 0 deletions src/output/clob/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ pub fn print_orders(result: &Page<OpenOrderResponse>, output: &OutputFormat) ->
json!({
"id": o.id,
"status": o.status.to_string(),
"owner": o.owner.to_string(),
"maker_address": o.maker_address.to_string(),
"market": o.market.to_string(),
"asset_id": o.asset_id.to_string(),
"side": o.side.to_string(),
"price": o.price.to_string(),
"original_size": o.original_size.to_string(),
"size_matched": o.size_matched.to_string(),
"associate_trades": o.associate_trades,
"outcome": o.outcome,
"order_type": o.order_type.to_string(),
"created_at": o.created_at.to_rfc3339(),
Expand Down Expand Up @@ -273,9 +276,25 @@ pub fn print_trades(result: &Page<TradeResponse>, output: &OutputFormat) -> anyh
"fee_rate_bps": t.fee_rate_bps.to_string(),
"status": t.status.to_string(),
"match_time": t.match_time.to_rfc3339(),
"last_update": t.last_update.to_rfc3339(),
"outcome": t.outcome,
"bucket_index": t.bucket_index,
"owner": t.owner.to_string(),
"maker_address": t.maker_address.to_string(),
"maker_orders": t.maker_orders.iter().map(|m| json!({
"order_id": m.order_id,
"owner": m.owner.to_string(),
"maker_address": m.maker_address.to_string(),
"matched_amount": m.matched_amount.to_string(),
"price": m.price.to_string(),
"fee_rate_bps": m.fee_rate_bps.to_string(),
"asset_id": m.asset_id.to_string(),
"outcome": m.outcome,
"side": m.side.to_string(),
})).collect::<Vec<_>>(),
"trader_side": format!("{:?}", t.trader_side),
"transaction_hash": t.transaction_hash.to_string(),
"error_msg": t.error_msg,
})
})
.collect();
Expand Down
58 changes: 58 additions & 0 deletions src/output/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,30 @@ pub fn print_positions(positions: &[Position], output: &OutputFormat) -> anyhow:
json!({
"title": p.title,
"slug": p.slug,
"icon": p.icon,
"event_slug": p.event_slug,
"event_id": p.event_id,
"outcome": p.outcome,
"outcome_index": p.outcome_index,
"opposite_outcome": p.opposite_outcome,
"opposite_asset": p.opposite_asset.to_string(),
"asset": p.asset.to_string(),
"size": p.size.to_string(),
"avg_price": p.avg_price.to_string(),
"initial_value": p.initial_value.to_string(),
"current_value": p.current_value.to_string(),
"cash_pnl": p.cash_pnl.to_string(),
"percent_pnl": p.percent_pnl.to_string(),
"total_bought": p.total_bought.to_string(),
"realized_pnl": p.realized_pnl.to_string(),
"percent_realized_pnl": p.percent_realized_pnl.to_string(),
"cur_price": p.cur_price.to_string(),
"condition_id": p.condition_id.to_string(),
"proxy_wallet": p.proxy_wallet.to_string(),
"redeemable": p.redeemable,
"mergeable": p.mergeable,
"end_date": p.end_date.to_string(),
Comment thread
cursor[bot] marked this conversation as resolved.
"negative_risk": p.negative_risk,
})
})
.collect();
Expand Down Expand Up @@ -122,15 +132,21 @@ pub fn print_closed_positions(
json!({
"title": p.title,
"slug": p.slug,
"icon": p.icon,
"event_slug": p.event_slug,
"outcome": p.outcome,
"outcome_index": p.outcome_index,
"opposite_outcome": p.opposite_outcome,
"opposite_asset": p.opposite_asset.to_string(),
"asset": p.asset.to_string(),
"avg_price": p.avg_price.to_string(),
"total_bought": p.total_bought.to_string(),
"realized_pnl": p.realized_pnl.to_string(),
"cur_price": p.cur_price.to_string(),
"condition_id": p.condition_id.to_string(),
"proxy_wallet": p.proxy_wallet.to_string(),
"timestamp": p.timestamp,
"end_date": p.end_date.to_rfc3339(),
})
})
.collect();
Expand Down Expand Up @@ -228,15 +244,23 @@ pub fn print_trades(trades: &[Trade], output: &OutputFormat) -> anyhow::Result<(
json!({
"title": t.title,
"slug": t.slug,
"icon": t.icon,
"event_slug": t.event_slug,
"side": t.side.to_string(),
"outcome": t.outcome,
"outcome_index": t.outcome_index,
"asset": t.asset.to_string(),
"size": t.size.to_string(),
"price": t.price.to_string(),
"timestamp": t.timestamp,
"condition_id": t.condition_id.to_string(),
"proxy_wallet": t.proxy_wallet.to_string(),
"transaction_hash": t.transaction_hash.to_string(),
"name": t.name,
"pseudonym": t.pseudonym,
"bio": t.bio,
"profile_image": t.profile_image,
"profile_image_optimized": t.profile_image_optimized,
})
})
.collect();
Expand All @@ -259,6 +283,12 @@ pub fn print_activity(activity: &[Activity], output: &OutputFormat) -> anyhow::R
activity_type: String,
#[tabled(rename = "Market")]
title: String,
#[tabled(rename = "Side")]
side: String,
#[tabled(rename = "Outcome")]
outcome: String,
#[tabled(rename = "Price")]
price: String,
#[tabled(rename = "Size")]
size: String,
#[tabled(rename = "USDC")]
Expand All @@ -271,6 +301,9 @@ pub fn print_activity(activity: &[Activity], output: &OutputFormat) -> anyhow::R
.map(|a| Row {
activity_type: a.activity_type.to_string(),
title: truncate(a.title.as_deref().unwrap_or(DASH), 35),
side: a.side.as_ref().map(|s| s.to_string()).unwrap_or_default(),
outcome: a.outcome.as_deref().unwrap_or(DASH).into(),
price: a.price.map(|p| format!("{:.4}", p)).unwrap_or_default(),
size: format!("{:.2}", a.size),
usdc_size: format_decimal(a.usdc_size),
tx: truncate(&a.transaction_hash.to_string(), 14),
Expand All @@ -286,11 +319,25 @@ pub fn print_activity(activity: &[Activity], output: &OutputFormat) -> anyhow::R
json!({
"activity_type": a.activity_type.to_string(),
"title": a.title,
"slug": a.slug,
"icon": a.icon,
"event_slug": a.event_slug,
"side": a.side.as_ref().map(|s| s.to_string()),
"outcome": a.outcome,
"outcome_index": a.outcome_index,
"price": a.price.map(|p| p.to_string()),
"asset": a.asset.map(|a| a.to_string()),
"condition_id": a.condition_id.map(|c| c.to_string()),
"size": a.size.to_string(),
"usdc_size": a.usdc_size.to_string(),
"timestamp": a.timestamp,
"transaction_hash": a.transaction_hash.to_string(),
"proxy_wallet": a.proxy_wallet.to_string(),
"name": a.name,
"pseudonym": a.pseudonym,
"bio": a.bio,
"profile_image": a.profile_image,
"profile_image_optimized": a.profile_image_optimized,
})
})
.collect();
Expand Down Expand Up @@ -349,8 +396,14 @@ pub fn print_holders(meta_holders: &[MetaHolder], output: &OutputFormat) -> anyh
"proxy_wallet": h.proxy_wallet.to_string(),
"name": h.name,
"pseudonym": h.pseudonym,
"bio": h.bio,
"asset": h.asset.to_string(),
"amount": h.amount.to_string(),
"outcome_index": h.outcome_index,
"display_username_public": h.display_username_public,
"profile_image": h.profile_image,
"profile_image_optimized": h.profile_image_optimized,
"verified": h.verified,
})
})
.collect();
Expand Down Expand Up @@ -487,6 +540,9 @@ pub fn print_leaderboard(
"user_name": e.user_name,
"pnl": e.pnl.to_string(),
"volume": e.vol.to_string(),
"profile_image": e.profile_image,
"x_username": e.x_username,
"verified_badge": e.verified_badge,
})
})
.collect();
Expand Down Expand Up @@ -539,6 +595,7 @@ pub fn print_builder_leaderboard(
"volume": e.volume.to_string(),
"active_users": e.active_users,
"verified": e.verified,
"builder_logo": e.builder_logo,
})
})
.collect();
Expand Down Expand Up @@ -591,6 +648,7 @@ pub fn print_builder_volume(
json!({
"date": e.dt.to_rfc3339(),
"builder": e.builder,
"builder_logo": e.builder_logo,
"volume": e.volume.to_string(),
"active_users": e.active_users,
"rank": e.rank,
Expand Down
Loading