pub struct Client<H> { /* private fields */ }Expand description
Papertrade client over one transport. Cheap to clone when the transport is.
Implementations§
Source§impl<H: Http + Clone> Client<H>
impl<H: Http + Clone> Client<H>
Sourcepub async fn session(
&self,
store: &impl Store,
owner: Address,
) -> Result<Option<SessionRecord>, Error>
pub async fn session( &self, store: &impl Store, owner: Address, ) -> Result<Option<SessionRecord>, Error>
The session key stored for owner, if readable.
Sourcepub async fn key_state(
&self,
store: &impl Store,
owner: Address,
account: Option<&Account>,
) -> Result<KeyState, Error>
pub async fn key_state( &self, store: &impl Store, owner: Address, account: Option<&Account>, ) -> Result<KeyState, Error>
Where owner’s stored key stands, given the account as last streamed.
Sourcepub async fn new_session(
&self,
store: &impl Store,
owner: Address,
) -> Result<SessionRecord, Error>
pub async fn new_session( &self, store: &impl Store, owner: Address, ) -> Result<SessionRecord, Error>
Makes and stores a session key for owner, unless the stored one is still usable.
Sourcepub async fn register(
&self,
store: &impl Store,
wallet: &impl Wallet,
) -> Result<SessionRecord, Error>
pub async fn register( &self, store: &impl Store, wallet: &impl Wallet, ) -> Result<SessionRecord, Error>
Has the wallet register the stored session key (made first if none is usable) and posts the registration to the relayer once.
Sourcepub async fn enable(
&self,
store: &impl Store,
wallet: &impl Wallet,
account: Option<&Account>,
) -> Result<KeyState, Error>
pub async fn enable( &self, store: &impl Store, wallet: &impl Wallet, account: Option<&Account>, ) -> Result<KeyState, Error>
Enables trading: makes a session key if needed and registers it unless it is ready. At most one wallet prompt.
Sourcepub async fn session_key(
&self,
store: &impl Store,
owner: Address,
account: Option<&Account>,
) -> Result<SessionKey, Error>
pub async fn session_key( &self, store: &impl Store, owner: Address, account: Option<&Account>, ) -> Result<SessionKey, Error>
owner’s session key as a signer, or Error::NeedsKey with the step to take first.
Source§impl<H: Http + Clone> Client<H>
impl<H: Http + Clone> Client<H>
Sourcepub async fn trading_state(&self) -> Result<TradingState, Error>
pub async fn trading_state(&self) -> Result<TradingState, Error>
Every market’s parameters, open interest and caps, and which intents the relayer accepts now.
Sourcepub async fn summary(&self) -> Result<Summary, Error>
pub async fn summary(&self) -> Result<Summary, Error>
TVL, LP, queue, fees, and PAPER’s supply and curve.
Sourcepub async fn volumes(&self) -> Result<Vec<(u32, u128)>, Error>
pub async fn volumes(&self) -> Result<Vec<(u32, u128)>, Error>
Each market’s notional over the last day, by instrument id.
Sourcepub async fn queue(&self) -> Result<QueueSummary, Error>
pub async fn queue(&self) -> Result<QueueSummary, Error>
The payout queue: total owed to queued winners, count, and its largest and front entries.
Sourcepub async fn recent_trades(&self) -> Result<Vec<Trade>, Error>
pub async fn recent_trades(&self) -> Result<Vec<Trade>, Error>
The latest trades across the venue, newest first.
Sourcepub async fn queue_rank(&self, owner: Address) -> Result<QueueRank, Error>
pub async fn queue_rank(&self, owner: Address) -> Result<QueueRank, Error>
Where owner’s queued intents stand in the relayer’s queue.
Sourcepub async fn quote(&self, asset_index: u32) -> Result<Quote, Error>
pub async fn quote(&self, asset_index: u32) -> Result<Quote, Error>
The market’s BBO from the oracle’s on-chain source (asset_index is Hyperliquid’s perp
index). An intent sent now executes at its mid, give or take a block.
Sourcepub async fn deposit_address(&self, owner: Address) -> Result<Address, Error>
pub async fn deposit_address(&self, owner: Address) -> Result<Address, Error>
owner’s deposit address, derived on chain. USDC sent to it on HyperCore is swept into
the venue and credited to owner.
Sourcepub async fn pending_reward(&self, owner: Address) -> Result<u128, Error>
pub async fn pending_reward(&self, owner: Address) -> Result<u128, Error>
USDC staking rewards distributed to owner and not yet paid, in collateral units.
Sourcepub async fn win_fee_rate(&self) -> Result<u128, Error>
pub async fn win_fee_rate(&self) -> Result<u128, Error>
The Exchange contract’s current win fee, an 18-decimal fraction.
Sourcepub fn stream_url(&self, owner: Address) -> String
pub fn stream_url(&self, owner: Address) -> String
URL of owner’s account stream (server-sent events liveness, wallet, heartbeat).
Each wallet event’s data folds into the account with
Account::apply.
Source§impl<H: Http + Clone> Client<H>
impl<H: Http + Clone> Client<H>
Sourcepub async fn open(
&self,
store: &impl Store,
owner: Address,
account: &Account,
open: Open,
mark: Option<u128>,
) -> Result<Accepted, Error>
pub async fn open( &self, store: &impl Store, owner: Address, account: &Account, open: Open, mark: Option<u128>, ) -> Result<Accepted, Error>
Opens a position for owner, signed by the session key, at the BBO mid of the relayer’s
batch. It is first checked against a fresh trading state, account as last streamed, and
mark (the current mid, raw) for the side’s open-interest cap.
Source§impl<H: Http + Clone> Client<H>
impl<H: Http + Clone> Client<H>
Sourcepub async fn stake(
&self,
store: &impl Store,
wallet: &impl Wallet,
amount: u128,
) -> Result<Accepted, Error>
pub async fn stake( &self, store: &impl Store, wallet: &impl Wallet, amount: u128, ) -> Result<Accepted, Error>
Stakes amount PAPER (18 decimals) immediately. The wallet signs.
Source§impl<H: Http + Clone> Client<H>
impl<H: Http + Clone> Client<H>
Sourcepub async fn register_deposit(&self, owner: Address) -> Result<Address, Error>
pub async fn register_deposit(&self, owner: Address) -> Result<Address, Error>
Registers owner’s deposit address with the relayer’s sweeper and returns it.
Sourcepub async fn plan_deposit(
&self,
owner: Address,
usdc: u64,
source: Source,
mode: Mode,
) -> Result<Deposit, Error>
pub async fn plan_deposit( &self, owner: Address, usdc: u64, source: Source, mode: Mode, ) -> Result<Deposit, Error>
Plans a deposit of usdc (6 decimals, at least 10 USDC) from source, after registering
the address and checking it against the one derived on chain. When the address has no
HyperCore account, its first send also pays ACTIVATION_FEE_USDC from the source
balance; a perp balance moves to spot first, fee included.
Sourcepub async fn send_deposit(
&self,
wallet: &impl Wallet,
deposit: &Deposit,
) -> Result<(), Error>
pub async fn send_deposit( &self, wallet: &impl Wallet, deposit: &Deposit, ) -> Result<(), Error>
Has the wallet sign each send in order and posts it to Hyperliquid once. A failed send
leaves the later ones unsent; an HTTP status other than 2xx is
TransportError::Status.