Skip to content

Commit 47fb2b6

Browse files
authored
Fix response for loan rpcs (#3795)
* Continue in case of unknownOid * udpate * Add missing fields * more logs
1 parent f0e4924 commit 47fb2b6

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

tee-worker/omni-executor/rpc-server/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::result_large_err)]
2+
13
mod auth_token_key_store;
24
mod auth_utils;
35
mod config;

tee-worker/omni-executor/rpc-server/src/methods/omni/common.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ pub struct PumpxRpcError {
2121
pub struct PumpxRpcErrorData {
2222
#[serde(skip_serializing_if = "Option::is_none")]
2323
pub backend_response: Option<PumpxRpcErrorBackendResponse>,
24+
#[serde(skip_serializing_if = "Option::is_none")]
25+
pub field: Option<String>,
26+
#[serde(skip_serializing_if = "Option::is_none")]
27+
pub expected: Option<String>,
28+
#[serde(skip_serializing_if = "Option::is_none")]
29+
pub received: Option<String>,
30+
#[serde(skip_serializing_if = "Option::is_none")]
31+
pub reason: Option<String>,
32+
#[serde(skip_serializing_if = "Option::is_none")]
33+
pub suggestion: Option<String>,
2434
}
2535

2636
#[derive(Serialize, Debug)]
@@ -50,6 +60,11 @@ impl PumpxRpcError {
5060
code: api_response.code as i32,
5161
message: api_response.message,
5262
}),
63+
field: None,
64+
expected: None,
65+
received: None,
66+
reason: None,
67+
suggestion: None,
5368
}),
5469
}
5570
}
@@ -66,7 +81,14 @@ impl From<DetailedError> for PumpxRpcError {
6681
Self {
6782
code: error.code,
6883
message: error.message,
69-
data: Some(PumpxRpcErrorData { backend_response: None }),
84+
data: Some(PumpxRpcErrorData {
85+
backend_response: None,
86+
field: error.details.field,
87+
expected: error.details.expected,
88+
received: error.details.received,
89+
reason: error.details.reason,
90+
suggestion: error.details.suggestion,
91+
}),
7092
}
7193
}
7294
}

tee-worker/omni-executor/rpc-server/src/methods/omni/payback_loan_test.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,6 @@ async fn handle_payback_loan_impl<
464464
initial_margin.min(withdrawable_usdc)
465465
};
466466

467-
info!("Transferring {} USDC from perp to spot", transfer_amount);
468-
469467
// Get initial spot balance BEFORE submitting the transfer
470468
let initial_spot_usdc = hypercore_client
471469
.get_spot_balance(smart_wallet_address_str, "USDC")
@@ -496,7 +494,10 @@ async fn handle_payback_loan_impl<
496494
)
497495
.await?;
498496

499-
info!("Action 2: USD transfer submitted with tx_hash: {:?}", usd_transfer_tx_hash);
497+
info!(
498+
"Action 2: USD transfer submitted, size: {}, tx_hash: {:?}",
499+
transfer_amount, usd_transfer_tx_hash
500+
);
500501
current_nonce += 1;
501502

502503
hypercore_client

tee-worker/omni-executor/rpc-server/src/methods/omni/request_loan_test.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ async fn handle_request_loan_impl<
381381
encode_send_raw_action(usd_transfer_action),
382382
);
383383

384-
let _usd_transfer_tx_hash = submit_corewriter_userop(
384+
let usd_transfer_tx_hash = submit_corewriter_userop(
385385
ctx.clone(),
386386
&omni_account,
387387
&prepare_skeleton_with_nonce(&skeleton_user_op, current_nonce),
@@ -392,7 +392,10 @@ async fn handle_request_loan_impl<
392392
)
393393
.await?;
394394

395-
info!("Action 2: USD class transfer submitted");
395+
info!(
396+
"Action 2: USD class transfer submitted, size: {}, tx_hash: {:?}",
397+
usdc_for_perp, usd_transfer_tx_hash
398+
);
396399

397400
// Wait for USD transfer to complete
398401
let _actual_perp_balance = hypercore_client
@@ -439,8 +442,8 @@ async fn handle_request_loan_impl<
439442
let hedge_size = (usdc_for_perp * effective_leverage) / target_hedge_price;
440443

441444
info!(
442-
"Perp hedge open pricing - markPx: {}, midPx: {}, ask (lowest sell): {}, target (with {}x buffer): {}",
443-
perp_mark_price, perp_mid_price, perp_ask_price, PERP_ENTRY_PRICE_RATIO, target_hedge_price
445+
"Perp hedge open pricing - markPx: {}, midPx: {}, ask (lowest sell): {}, target (with {}x buffer): {}, hedge_size: {}",
446+
perp_mark_price, perp_mid_price, perp_ask_price, PERP_ENTRY_PRICE_RATIO, target_hedge_price, hedge_size
444447
);
445448

446449
let clamped_hedge_size = clamp_size(hedge_size, validation_result.perp_sz_decimals);

0 commit comments

Comments
 (0)