Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
33e6637
init
Kailai-Wang Oct 23, 2025
ea305c1
update
Kailai-Wang Oct 23, 2025
c6c4403
init
Kailai-Wang Oct 23, 2025
35bcf4c
update
Kailai-Wang Oct 23, 2025
afeb0c2
update oa type check
Kailai-Wang Oct 23, 2025
abb18e9
remove unneeded
Kailai-Wang Oct 23, 2025
5ea7f47
fix tests
Kailai-Wang Oct 23, 2025
bfba4bf
fix tests
Kailai-Wang Oct 23, 2025
df3bf45
Merge branch 'dev' into payback-loan
Kailai-Wang Oct 23, 2025
a31a6ea
Merge branch 'p-1733-dismiss-to_hex-in-oe' into payback-loan
Kailai-Wang Oct 23, 2025
f107fd3
small refactoring
Kailai-Wang Oct 23, 2025
c5bfca6
fix
Kailai-Wang Oct 23, 2025
d3cd95a
Merge branch 'dev' into payback-loan
Kailai-Wang Oct 24, 2025
ffa076d
update
Kailai-Wang Oct 24, 2025
ffa2024
Merge branch 'dev' into payback-loan
Kailai-Wang Oct 24, 2025
85701f8
update
Kailai-Wang Oct 24, 2025
f19113d
add equity param
Kailai-Wang Oct 24, 2025
22e6504
add comment
Kailai-Wang Oct 24, 2025
091111b
Merge branch 'dev' into payback-loan
Kailai-Wang Oct 24, 2025
92dc142
Try to fix the clearinghouseState response struct
Kailai-Wang Oct 24, 2025
9fa0b67
fix price calculation
Kailai-Wang Oct 27, 2025
4d26db1
Merge branch 'dev' into payback-loan
Kailai-Wang Oct 27, 2025
8616fa5
fix compile
Kailai-Wang Oct 27, 2025
c3ee36e
fix calculations
Kailai-Wang Oct 27, 2025
b882521
fix bug
Kailai-Wang Oct 27, 2025
3534f5c
bug fix
Kailai-Wang Oct 27, 2025
302cad9
fix bugs
Kailai-Wang Oct 28, 2025
5057439
Merge branch 'dev' into payback-loan
Kailai-Wang Oct 28, 2025
5e195eb
fix bugs regarding pricing
Kailai-Wang Oct 28, 2025
81a188b
check spot buy size
Kailai-Wang Oct 28, 2025
57172cc
clippy
Kailai-Wang Oct 28, 2025
ab18312
try to debug
Kailai-Wang Oct 28, 2025
dc141dd
Revert "try to debug"
Kailai-Wang Oct 28, 2025
add8e1a
fix position size
Kailai-Wang Oct 28, 2025
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
361 changes: 180 additions & 181 deletions tee-worker/omni-executor/Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tee-worker/omni-executor/executor-storage/src/loan_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub struct LoanRecord {
pub usdc_loaned: String,
pub spot_sell_cloid: String,
pub hedge_open_cloid: String,
/// Actual position size that was opened for this loan (filled or partially filled)
/// This should be set after the hedge order completes in request_loan
pub position_size: String,
}

pub struct LoanRecordStorage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ mod tests {
use super::*;
use chrono::{Days, Utc};
use executor_primitives::{utils::hex::hex_encode, Identity, Web2IdentityType};
use parity_scale_codec::Encode;
use rsa::{pkcs1::EncodeRsaPrivateKey, RsaPrivateKey};

#[derive(PartialEq, Debug, Serialize, Deserialize)]
Expand Down
54 changes: 54 additions & 0 deletions tee-worker/omni-executor/hyperliquid/src/corewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,57 @@ pub fn encode_usd_class_transfer_action(ntl: u64, to_perp: bool) -> Vec<u8> {
pub fn build_usd_class_transfer_to_perp(ntl: u64) -> Vec<u8> {
encode_usd_class_transfer_action(ntl, true)
}

pub fn build_usd_class_transfer_to_spot(ntl: u64) -> Vec<u8> {
encode_usd_class_transfer_action(ntl, false)
}

pub fn build_perp_close_order(asset_id: u32, size: u64, price: u64, cloid: u128) -> Vec<u8> {
// Close position by selling (is_buy = false) with reduce_only = true
// Note: For long positions, we need to sell to close
// The size should match the position size we want to close
encode_limit_order_action_with_reduce_only(asset_id, false, price, size, cloid, true)
}

pub fn build_spot_buy_order(asset_id: u32, size: u64, price: u64, cloid: u128) -> Vec<u8> {
let is_buy = true;
encode_limit_order_action(asset_id, is_buy, price, size, cloid)
}

pub fn build_cancel_order_by_cloid(asset_id: u32, cloid: u128) -> Vec<u8> {
let encoded =
ethabi::encode(&[ethabi::Token::Uint(asset_id.into()), ethabi::Token::Uint(cloid.into())]);

let mut data = Vec::new();
data.push(0x01); // version
data.extend_from_slice(&[0x00, 0x00, 0x0b]); // action_id = 11 (cancel order by cloid)
data.extend_from_slice(&encoded);
data
}

fn encode_limit_order_action_with_reduce_only(
asset: u32,
is_buy: bool,
limit_px: u64,
sz: u64,
cloid: u128,
reduce_only: bool,
) -> Vec<u8> {
let encoded_tif: u8 = 2; // Gtc

let encoded = ethabi::encode(&[
ethabi::Token::Uint(asset.into()),
ethabi::Token::Bool(is_buy),
ethabi::Token::Uint(limit_px.into()),
ethabi::Token::Uint(sz.into()),
ethabi::Token::Bool(reduce_only),
ethabi::Token::Uint(encoded_tif.into()),
ethabi::Token::Uint(cloid.into()),
]);

let mut data = Vec::new();
data.push(0x01); // version
data.extend_from_slice(&[0x00, 0x00, 0x01]); // action_id = 1
data.extend_from_slice(&encoded);
data
}
Loading