Skip to main content

Exchange

Struct Exchange 

Source
pub struct Exchange {
Show 119 fields pub id: Value, pub name: Value, pub countries: Value, pub version: Value, pub alias: Value, pub certified: Value, pub pro: Value, pub hostname: Value, pub apiKey: Value, pub secret: Value, pub password: Value, pub uid: Value, pub walletAddress: Value, pub privateKey: Value, pub twofa: Value, pub token: Value, pub login: Value, pub accountId: Value, pub requiredCredentials: Value, pub timeout: Value, pub rateLimit: Value, pub enableRateLimit: Value, pub rateLimiterAlgorithm: Value, pub rollingWindowSize: Value, pub tokenBucket: Value, pub userConfig: Value, pub verbose: Value, pub isSandboxModeEnabled: Value, pub proxy: Value, pub proxyUrl: Value, pub proxy_url: Value, pub proxyUrlCallback: Value, pub proxy_url_callback: Value, pub httpProxy: Value, pub http_proxy: Value, pub httpProxyCallback: Value, pub http_proxy_callback: Value, pub httpsProxy: Value, pub https_proxy: Value, pub httpsProxyCallback: Value, pub https_proxy_callback: Value, pub socksProxy: Value, pub socks_proxy: Value, pub socksProxyCallback: Value, pub socks_proxy_callback: Value, pub wsProxy: Value, pub ws_proxy: Value, pub wssProxy: Value, pub wss_proxy: Value, pub wsSocksProxy: Value, pub ws_socks_proxy: Value, pub markets: Value, pub markets_by_id: Value, pub currencies: Value, pub currencies_by_id: Value, pub commonCurrencies: Value, pub baseCurrencies: Value, pub quoteCurrencies: Value, pub symbols: Value, pub ids: Value, pub codes: Value, pub timeframes: Value, pub precision: Value, pub limits: Value, pub fees: Value, pub features: Value, pub has: Value, pub exceptions: Value, pub urls: Value, pub api: Value, pub options: Value, pub headers: Value, pub accounts: Value, pub accountsById: Value, pub orderbooks: Value, pub orders: Value, pub trades: Value, pub myTrades: Value, pub positions: Value, pub newUpdates: Value, pub tickers: Value, pub bidsasks: Value, pub ohlcvs: Value, pub clients: Value, pub balance: Value, pub liquidations: Value, pub myLiquidations: Value, pub fundingRates: Value, pub triggerOrders: Value, pub transactions: Value, pub reloadingMarkets: Value, pub marketsLoading: Value, pub last_request_url: Value, pub last_request_headers: Value, pub last_request_body: Value, pub last_http_response: Value, pub last_response_headers: Value, pub mock_response: Value, pub mock_response_by_url: Value, pub last_json_response: Value, pub lastRestRequestTimestamp: Value, pub fetchHistoryCache: Value, pub fetchHistoryCacheSize: Value, pub paddingMode: Value, pub precisionMode: Value, pub substituteCommonCurrencyCodes: Value, pub reduceFees: Value, pub minFundingAddressLength: Value, pub networkAliases: Value, pub MAX_VALUE: Value, pub returnResponseHeaders: Value, pub httpExceptions: Value, pub status: Value, pub userAgent: Value, pub user_agent: Value, pub userAgents: Value, pub describe_data: Value, pub derived_describe: Option<Arc<dyn Fn() -> Value + Sync + Send>>, pub internals: Internals,
}

Fields§

§id: Value§name: Value§countries: Value§version: Value§alias: Value§certified: Value§pro: Value§hostname: Value§apiKey: Value§secret: Value§password: Value§uid: Value§walletAddress: Value§privateKey: Value§twofa: Value§token: Value§login: Value§accountId: Value§requiredCredentials: Value§timeout: Value§rateLimit: Value§enableRateLimit: Value§rateLimiterAlgorithm: Value§rollingWindowSize: Value§tokenBucket: Value§userConfig: Value

The raw constructor config, kept so initialize_properties can merge it over describe() the way Go’s InitParent does (deepExtend(describe, userConfig)) instead of relying on per-field precedence guards in each Core’s generated init().

§verbose: Value§isSandboxModeEnabled: Value§proxy: Value§proxyUrl: Value§proxy_url: Value§proxyUrlCallback: Value§proxy_url_callback: Value§httpProxy: Value§http_proxy: Value§httpProxyCallback: Value§http_proxy_callback: Value§httpsProxy: Value§https_proxy: Value§httpsProxyCallback: Value§https_proxy_callback: Value§socksProxy: Value§socks_proxy: Value§socksProxyCallback: Value§socks_proxy_callback: Value§wsProxy: Value§ws_proxy: Value§wssProxy: Value§wss_proxy: Value§wsSocksProxy: Value§ws_socks_proxy: Value§markets: Value

Plain dict-or-null container – see PLAIN_DICT_FIELDS.

§markets_by_id: Value§currencies: Value§currencies_by_id: Value§commonCurrencies: Value§baseCurrencies: Value§quoteCurrencies: Value§symbols: Value§ids: Value§codes: Value§timeframes: Value§precision: Value§limits: Value§fees: Value§features: Value§has: Value§exceptions: Value§urls: Value§api: Value§options: Value

Plain dict-or-null container – see PLAIN_DICT_FIELDS.

§headers: Value§accounts: Value§accountsById: Value§orderbooks: Value§orders: Value§trades: Value§myTrades: Value§positions: Value§newUpdates: Value§tickers: Value§bidsasks: Value§ohlcvs: Value§clients: Value§balance: Value

Plain dict-or-null container – see PLAIN_DICT_FIELDS.

§liquidations: Value§myLiquidations: Value§fundingRates: Value§triggerOrders: Value§transactions: Value§reloadingMarkets: Value§marketsLoading: Value§last_request_url: Value§last_request_headers: Value§last_request_body: Value§last_http_response: Value§last_response_headers: Value§mock_response: Value

Canned HTTP response for static response tests — when set, fetch_typed returns it without hitting the network so the exchange’s parser runs against fixture data. Mirrors Go’s MockResponse field. Reused for all requests in a fixture; the test dispatcher replaces or clears it before the next REST dispatch.

§mock_response_by_url: Value

Response-test mock keyed by url fragment, for methods that call several endpoints: one shared body cannot cover two endpoints of different declared shapes. Consulted before mock_response.

§last_json_response: Value§lastRestRequestTimestamp: Value§fetchHistoryCache: Value

Rolling cache of recent fetch results, capped at fetchHistoryCacheSize. Mirrors Exchange.ts fetchHistoryCache / fetchHistoryCacheSize (hand-written, above the transpile marker).

§fetchHistoryCacheSize: Value§paddingMode: Value§precisionMode: Value§substituteCommonCurrencyCodes: Value§reduceFees: Value§minFundingAddressLength: Value§networkAliases: Value§MAX_VALUE: Value§returnResponseHeaders: Value§httpExceptions: Value§status: Value§userAgent: Value§user_agent: Value§userAgents: Value§describe_data: Value§derived_describe: Option<Arc<dyn Fn() -> Value + Sync + Send>>§internals: Internals

Implementations§

Source§

impl Exchange

Source

pub fn new(config: Option<Value>) -> Exchange

Source

pub fn initialize_properties(&mut self, described: Value)

Apply a merged describe() + constructor-config map onto the typed fields. The Rust counterpart of Go’s initializeProperties (go/v4/exchange_options.go) and of the TS constructor’s deepExtend(this, describe(), userConfig) — which Rust cannot do directly because Exchange is a struct, not a dynamic object.

Each Core’s generated init() used to inline ~84 lines of this, which is why every field carried its own precedence guard: config was applied in new() BEFORE describe() ran, so describe() had to be stopped from clobbering it. Here the config is merged over describe() first (Go’s deepExtend(describe, userConfig)), so last-write-wins is the precedence rule and no guards are needed.

Absent keys leave the base default in place — the equivalent of Go’s SafeString(props, key, default).

Source

pub fn urlencode_kv(&self, params: &Value) -> String

Source

pub fn implode_params(&self, path: Value, params: Value) -> Value

Source

pub fn json_str(&self, v: &Value) -> String

Source

pub fn hmac( &self, data: Value, secret: Value, hash: Value, optional_args: &[Value], ) -> Value

Source

pub fn hmac_typed( &self, data: &[u8], secret: &[u8], hash: &str, digest: &str, ) -> Result<String, ExchangeError>

Source

pub fn hash(&self, data: Value, algo: Value, optional_args: &[Value]) -> Value

Source

pub fn hash_typed(&self, data: &[u8], algo: &str, digest: &str) -> String

Source

pub fn binary_to_base64(&self, data: Value, _optional_args: &[Value]) -> Value

Source

pub fn base64_to_binary(&self, s: Value, _optional_args: &[Value]) -> Value

Source

pub fn binary_to_base16(&self, data: Value, _optional_args: &[Value]) -> Value

Source

pub fn base16_to_binary(&self, s: Value, _optional_args: &[Value]) -> Value

Source

pub fn milliseconds(&self) -> Value

Source

pub fn seconds(&self) -> Value

Source

pub fn microseconds(&self) -> Value

Source

pub fn iso8601(&self, ts: Value) -> Value

Source

pub fn parse8601(&self, s: Value) -> Value

Source§

impl Exchange

Source

pub fn dispatch_guard_enter(&mut self, method: &str) -> bool

Enter the guard for method. Returns false if method is already on the dispatch stack (re-entry — caller should fall through to the base body); otherwise pushes it and returns true.

Source

pub fn dispatch_guard_exit(&mut self)

Leave the guard (pop the most-recently entered method).

Source§

impl Exchange

Source

pub fn build_implicit_api(&mut self)

Builds the name → (path, scope, verb) dispatch table by walking the self.api Value::Map. Called lazily on first dynamic call.

The api block layout is: { : { : [path, path, …] } } { : { : { : [path, …] } } } — arbitrary nesting before the verb level. The verb is one of get/post/put/delete/patch (any case). All path components before the verb concatenate into the scope (joined by _).

Source§

impl Exchange

Source

pub fn exception_message(&self, exc: Value, _optional_args: &[Value]) -> Value

Coerce a caught panic payload into the [ClassName] message shape TS uses (see Exchange.exceptionMessage). Truncates to 100k chars to match. Rust panics carry just a string in Value, so we trust it as the formatted message and trim it. Used by exchanges that re-throw with a contextual prefix in their catch arms (grvt.transfer is the canonical case).

Source

pub fn get_ccxt_version(&self) -> Value

Port of Exchange.getCcxtVersion(). The TS reads the static Exchange.ccxtVersion (a class member the release process bumps); the transpiler can’t lower that (Exchange as any).ccxtVersion static access, so getCcxtVersion is dropped from exchange_generated.rs and lives here as a hand-written stub instead. Value mirrors ts/src/base/Exchange.ts’s static ccxtVersion (== package.json “version”); only foxbit consumes it (the X-FB-CLIENT-VERSION request header), and no static fixture asserts the header, so a version bump can’t break the suites.

Source

pub fn safe_value_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_k_opt( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Option<String>

safe_string_k without the box: same lookup, empty-string and default rules, None where the boxed helper yields Value::Null.

Source

pub fn safe_string_opt( &self, obj: Value, key: Value, optional_args: &[Value], ) -> Option<String>

safe_string without the box (Value key): same lookup and default rules.

Source

pub fn safe_integer_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

Source

pub fn safe_float_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

Source

pub fn safe_number_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

Source

pub fn safe_bool_k_opt( &self, obj: Value, key: &str, _optional_args: &[Value], ) -> Option<bool>

safe_bool_k without the box: Some only for an actual boolean, else None.

Source

pub fn safe_bool_opt( &self, obj: Value, key: Value, _optional_args: &[Value], ) -> Option<bool>

safe_bool without the box (Value key): same lookup rule as safe_bool_k_opt.

Source

pub fn safe_bool2_opt( &self, obj: Value, k1: Value, k2: Value, _optional_args: &[Value], ) -> Option<bool>

safe_bool2 without the box: first key holding a real boolean wins, else None.

Source

pub fn safe_bool_n_opt( &self, obj: Value, keys: Value, _optional_args: &[Value], ) -> Option<bool>

safe_bool_n without the box: Some only for an actual boolean, else None.

Source

pub fn safe_string2_opt( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Option<String>

safe_string2 without the box: first key whose safe_string is non-null, then the default; None where the boxed helper yields Value::Null.

Source

pub fn safe_string_n_opt( &self, obj: Value, keys: Value, optional_args: &[Value], ) -> Option<String>

safe_string_n without the box: first key whose safe_string is non-null, then the default; None where the boxed helper yields Value::Null.

Source

pub fn safe_number2_opt( &self, obj: Value, k1: Value, k2: Value, _optional_args: &[Value], ) -> Option<f64>

safe_number2 without the box (no default): first key whose string form parses as f64.

Source

pub fn safe_bool_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

Source

pub fn safe_dict_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

Source

pub fn safe_list_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

Source

pub fn safe_value( &self, obj: Value, key: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_value2( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_value_n( &self, obj: Value, keys: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string( &self, obj: Value, key: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string2( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_n( &self, obj: Value, keys: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_upper( &self, obj: Value, key: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_upper_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

safe_string_upper with a &str key — the safe_*_k twin.

Source

pub fn safe_string_upper_k_opt( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Option<String>

safe_string_upper_k without the box: the found value is upper-cased, a default is returned verbatim (None where the boxed helper yields Null).

Source

pub fn safe_string_lower_n( &self, obj: Value, keys: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_upper_n( &self, obj: Value, keys: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_lower( &self, obj: Value, key: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_lower_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

safe_string_lower with a &str key — the safe_*_k twin of the lookup above (same get_value_k path as the rest of the family).

Source

pub fn safe_string_lower_k_opt( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Option<String>

safe_string_lower_k without the box: the found value is lower-cased, a default is returned verbatim (None where the boxed helper yields Null).

Source

pub fn safe_string_lower2( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_string_upper2( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

Source

pub fn super_currency(&self, _code: Value) -> Value

super.X(...) from derived exchanges — routes back to the base Exchange impl. These stubs return Value::Null; they exist so transpiled self.super_X() calls type-check.

Source

pub fn super_handle_errors( &self, _code: Value, _reason: Value, _url: Value, _method: Value, _headers: Value, _body: Value, _response: Value, _request_headers: Value, _request_body: Value, ) -> Value

Source

pub fn set_last_rest_request_timestamp(&self)

Source

pub fn set_last_request(&self, request: Value)

Source

pub fn get_fetch_cache(&self) -> Value

Source

pub fn add_fetch_cache(&self, data: Value)

Source

pub fn client(&mut self, args: &[Value]) -> Value

Source

pub fn spawn(&self, args: &[Value]) -> Value

Source

pub async fn delay(&mut self, ms: Value, args: &[Value]) -> Value

Source

pub fn order_book(&self, args: &[Value]) -> Value

Source

pub fn indexed_order_book(&self, args: &[Value]) -> Value

Source

pub fn counted_order_book(&self, args: &[Value]) -> Value

Source

pub fn safe_order_tracker(&self, _args: &[Value]) -> Value

Source

pub async fn un_watch(&mut self, _topic: Value, _args: &[Value]) -> Value

Source

pub fn send(&self, _payload: Value) -> Value

Source

pub fn lock_id(&self, _args: &[Value]) -> Value

Source

pub fn unlock_id(&self, _args: &[Value]) -> Value

Source

pub fn lock_last_nonce(&self, _args: &[Value]) -> Value

Source

pub fn unlock_last_nonce(&self, _args: &[Value]) -> Value

Source

pub fn extend_exchange_options(&self, _args: &[Value]) -> Value

Source

pub fn on_error(&self, _args: &[Value]) -> Value

Source

pub fn on_close(&self, _args: &[Value]) -> Value

Source

pub fn on_pong(&self, _args: &[Value]) -> Value

Source

pub fn crc32(&self, args: &[Value]) -> Value

CRC-32 checksum — used by a few WS order-book reconcilers (bitget, bitfinex, independentreserve). Stub returns 0; will be replaced with the real algorithm when those order books need it.

Source

pub fn decode_proto_msg(&self, args: &[Value]) -> Value

decode_proto_msg(message) — exchange-specific protobuf decoder (mexc). message is the binary frame carried as a byte array; decode it into mexc’s PushDataV3ApiWrapper shape (matching protobufjs .toJSON()) so the ported handlers consume it unchanged.

Source

pub async fn load_order_book(&mut self, _args: &[Value]) -> Value

loadOrderBook — WS helper used by some bookkeeping methods. Stubbed identically to the unwatch flow.

Source

pub fn remove0x_prefix(&self, hex_data: Value) -> Value

remove0xPrefix(hexData) — strips a leading 0x/0X if present.

Source

pub fn handle_http_status_code( &self, code: Value, reason: Value, url: Value, method: Value, body: Value, )

handleHttpStatusCode(code, reason, url, method, body) — throws the httpExceptions class for the status; a status outside the table passes.

Source

pub fn check_required_dependencies(&self) -> Value

checkRequiredDependencies() — a no-op in Rust; all crypto deps are compiled in.

Source

pub fn rand_number(&self, size: Value) -> Value

randNumber(size) — a random integer with size decimal digits.

Source

pub fn random_bytes(&self, length: Value) -> Value

randomBytes(length) — length random bytes as a hex string.

Source

pub fn convert_to_big_int(&self, value: Value) -> Value

convertToBigInt(value) — the Value-bag has no distinct bigint type, so coerce to a 64-bit integer.

Source

pub fn fix_stringified_json_members(&self, content: Value) -> Value

fixStringifiedJsonMembers(content) — un-escapes a JSON string whose members are themselves stringified JSON (used by bingx).

Source

pub fn binary_concat_array(&self, arr: Value) -> Value

binaryConcatArray(arrayOfChunks) — concatenates hex-string chunks.

Source

pub fn uuid5(&self, namespace: Value, name: Value) -> Value

uuid5(namespace, name) — RFC-4122 v5 (SHA-1 based) UUID.

Source

pub fn eth_abi_encode(&self, types: Value, values: Value) -> Value

ethAbiEncode(types, values) — Solidity abi.encode of a head-only (all-static) tuple: every element becomes one 32-byte word. Supports the static types the callers use (address, bytesN, uint*/int*, bool). Dynamic types (bytes, string, arrays) are not needed (polymarket ERC-7739) and return Null. Values arrive as: bytesN → binary Value::Arr (or 0x-hex string); uint/int → Value::Int or a decimal/0x-hex string (big uint256 like tokenId exceed i64, so string form is preserved by convert_to_big_int); address → 0x-hex string. Result is a binary Value::Arr that hash(...) consumes via value_to_bytes.

Source

pub fn set_property(&self, _property: Value, _optional_args: &[Value]) -> Value

setProperty(this, key, value) — dynamic field setter. The typed Exchange struct has no Value-shaped dynamic field store, so this is currently a no-op (the receiver arg is dropped by the transpiler).

Source

pub fn axolotl( &self, _payload: Value, _hex_key: Value, _ed25519: Value, ) -> Value

axolotl(payload, hexKey, ed25519) — curve25519 signing (Waves exchange).

Source

pub fn retrieve_stark_account( &self, _signature: Value, _class_hash: Value, _proxy_hash: Value, ) -> Value

retrieveStarkAccount(signature, accountClassHash, accountProxyClassHash).

Source

pub fn starknet_encode_structured_data( &self, _domain: Value, _types: Value, _data: Value, _address: Value, ) -> Value

starknetEncodeStructuredData(domain, messageTypes, messageData, address).

Source

pub fn starknet_sign(&self, _msg_hash: Value, _pri: Value) -> Value

starknetSign(msgHash, pri).

Source

pub fn extended_starknet_sign(&self, _msg_hash: Value, _pri: Value) -> Value

extendedStarknetSign(msgHash, pri) — starknet-curve signing for the extended exchange. Stub: starknet crypto (poseidon/stark-curve) is not ported to Rust yet, matching starknet_sign above.

Source

pub fn extended_starknet_get_selector_from_name(&self, _name: Value) -> Value

extendedStarknetGetSelectorFromName(name).

Source

pub fn extended_starknet_compute_poseidon_hash_on_elements( &self, _data: Value, ) -> Value

extendedStarknetComputePoseidonHashOnElements(data).

Source

pub fn to_dydx_long(&self, _num_str: Value) -> Value

toDydxLong(numStr).

Source

pub fn retrieve_dydx_credentials(&self, _entropy: Value) -> Value

retrieveDydxCredentials(entropy).

Source

pub async fn load_dydx_protos(&self) -> Value

loadDydxProtos().

Source

pub fn encode_dydx_tx_raw(&self, _sign_doc: Value, _signature: Value) -> Value

encodeDydxTxRaw(signDoc, signature).

Source

pub fn encode_dydx_tx_for_simulation( &self, _message: Value, _memo: Value, _sequence: Value, _public_key: Value, ) -> Value

encodeDydxTxForSimulation(message, memo, sequence, publicKey).

Source

pub fn encode_dydx_tx_for_signing( &self, _message: Value, _memo: Value, _chain_id: Value, _account: Value, _authenticators: Value, _optional_args: &[Value], ) -> Value

encodeDydxTxForSigning(message, memo, chainId, account, authenticators, fee?).

Source

pub async fn load_lighter_library( &self, _library_path: Value, _chain_id: Value, _private_key: Value, _api_key_index: Value, _account_index: Value, _optional_args: &[Value], ) -> Value

loadLighterLibrary(libraryPath, chainId, privateKey, apiKeyIndex, accountIndex, createClient?).

Source

pub fn lighter_create_client( &self, _signer: Value, _chain_id: Value, _private_key: Value, _api_key_index: Value, _account_index: Value, ) -> Value

lighterCreateClient(signer, chainId, privateKey, apiKeyIndex, accountIndex).

Source

pub fn lighter_generate_api_key(&self, _signer: Value) -> Value

lighterGenerateApiKey(signer).

Source

pub async fn get_zk_transfer_signature_obj( &self, _seeds: Value, _optional_args: &[Value], ) -> Value

getZKTransferSignatureObj(seeds, order) — apex StarkEx signing.

Source

pub async fn get_zk_contract_signature_obj( &self, _seeds: Value, _optional_args: &[Value], ) -> Value

getZKContractSignatureObj(seeds, order) — apex StarkEx signing.

Source

pub async fn futures_transfer( &self, _code: Value, _amount: Value, _transfer_type: Value, _optional_args: &[Value], ) -> Value

futuresTransfer(code, amount, type, params?) — binance futures wallet transfer; inherited by binancecoinm / binanceusdm.

Source

pub fn lighter_sign_create_order( &self, _signer: Value, _request: Value, ) -> Value

lighterSign*(signer, request) — lighter zk-proof signing helpers.

Source

pub fn lighter_sign_create_grouped_orders( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_sign_cancel_order( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_sign_cancel_all_orders( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_sign_withdraw(&self, _signer: Value, _request: Value) -> Value

Source

pub fn lighter_sign_create_sub_account( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_sign_modify_order( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_sign_transfer(&self, _signer: Value, _request: Value) -> Value

Source

pub fn lighter_sign_update_leverage( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_sign_update_margin( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_sign_approve_integrator( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_sign_change_pubkey( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn lighter_create_auth_token( &self, _signer: Value, _request: Value, ) -> Value

Source

pub fn urlencode_with_array_repeat(&self, params: Value) -> Value

urlencodeWithArrayRepeat(params) — qs.stringify(object, { arrayFormat: 'repeat' }): array values repeat the key (a=1&a=2); scalars encode normally.

Source

pub fn safe_integer( &self, obj: Value, key: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_integer2( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_integer_n( &self, obj: Value, keys: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_integer2_opt( &self, obj: Value, k1: Value, k2: Value, _optional_args: &[Value], ) -> Option<i64>

safe_integer2 without the box (no default): first key yielding an integer.

Source

pub fn safe_integer_n_opt( &self, obj: Value, keys: Value, _optional_args: &[Value], ) -> Option<i64>

safe_integer_n without the box (no default): first key in keys yielding an integer.

Source

pub fn safe_integer_product( &self, obj: Value, key: Value, factor: Value, optional_args: &[Value], ) -> Value

Reads obj[key] as a number, multiplies by factor, and casts to i64. Used to convert seconds → milliseconds for timestamps.

Source

pub fn safe_integer_product_k( &self, obj: Value, key: &str, factor: Value, optional_args: &[Value], ) -> Value

safe_integer_product with a &str key — the safe_*_k twin.

Source

pub fn safe_integer_product2( &self, obj: Value, k1: Value, k2: Value, factor: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_integer_product_n( &self, obj: Value, keys: Value, factor: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_timestamp2( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_timestamp_n( &self, obj: Value, keys: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_float( &self, obj: Value, key: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_timestamp( &self, obj: Value, key: Value, optional_args: &[Value], ) -> Value

safeTimestamp(o, k) — parseInt(asFloat(value) * 1000). The value is read as a float (seconds, possibly fractional) and converted to integer milliseconds.

Source

pub fn safe_timestamp_k( &self, obj: Value, key: &str, optional_args: &[Value], ) -> Value

safe_timestamp with a &str key — the safe_*_k twin.

Source

pub fn is_empty(&self, v: Value) -> Value

isEmpty(value) — true when an array/dict is empty, or the value is null/undefined. Scalars (strings, numbers, bools) are never considered empty — mirrors functions/generic.ts.

Source

pub fn value_is_defined(&self, v: Value) -> Value

Source

pub fn extend(&self, a: Value, optional_args: &[Value]) -> Value

Source

pub fn deep_extend(&self, a: Value, optional_args: &[Value]) -> Value

Source

pub fn omit(&self, obj: Value, keys: Value, _optional_args: &[Value]) -> Value

Source

pub fn omit_zero(&self, v: Value) -> Value

Source

pub fn to_array(&self, v: Value) -> Value

Source

pub fn array_concat(&self, a: Value, b: Value) -> Value

Source

pub fn array_slice( &self, v: Value, start: Value, optional_args: &[Value], ) -> Value

Source

pub fn in_array(&self, needle: Value, haystack: Value) -> Value

Source

pub fn unique(&self, v: Value) -> Value

Source

pub fn index_by(&self, arr: Value, key: Value) -> Value

Source

pub fn index_by_safe(&self, arr: Value, key: Value) -> Value

Source

pub fn group_by( &self, arr: Value, key: Value, _optional_args: &[Value], ) -> Value

Source

pub fn filter_by( &self, arr: Value, key: Value, value: Value, _optional_args: &[Value], ) -> Value

Source

pub fn sort_by(&self, arr: Value, key: Value, optional_args: &[Value]) -> Value

sortBy(array, key, descending=false) — stable sort of an array of objects by obj[key]. Mirrors functions/generic.ts.

Source

pub fn sort_by2( &self, arr: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

sortBy2(array, key1, key2, descending=false) — sort by key1, then key2 as a tiebreaker. Mirrors functions/generic.ts.

Source

pub fn keysort(&self, obj: Value, _optional_args: &[Value]) -> Value

Source

pub fn aggregate(&self, arr: Value) -> Value

aggregate(bidasks) — groups [price, volume] rows by price, summing volume and dropping zero-volume rows. Preserves the first-occurrence order of prices. Mirrors functions/misc.ts.

Source

pub fn map_to_safe_map(&self, v: Value) -> Value

Source

pub fn create_safe_dictionary(&self, _optional_args: &[Value]) -> Value

Source

pub fn check_option_string( &self, _method_name: Value, _option_name: Value, value: Value, ) -> Value

Source

pub fn check_option_bool( &self, method_name: Value, option_name: Value, value: Value, ) -> Value

Source

pub fn check_option_integer( &self, _method_name: Value, _option_name: Value, value: Value, ) -> Value

Source

pub fn clone_value(&self, v: Value) -> Value

clone(value) — CCXT’s deep clone, distinct from Rust’s Clone trait. We disambiguate by name; the transpiler emits self.clone(x).

Source

pub fn sum(&self, optional_args: &[Value]) -> Value

sum(...) — variadic numeric sum. Pure variadic (0 fixed args) so single-arg sum(x) (e.g. from test.sum) also works.

Source

pub fn parse_json_value(&self, v: Value) -> Value

parse_json(text) — JSON parse. Mirrors CCXT parseJson, which runs onJsonResponse first: when quoteJsonNumbers is on (default), every object number VALUE is wrapped in quotes before parsing so big integer ids (e.g. bingx’s 18-digit orderId) and precise decimals survive as strings instead of lossy f64/i64.

Source

pub fn clone_self(&self) -> Exchange

Test helper: tests sometimes call exchange.clone() to deep-copy state. We don’t implement structural clone (the trait pointer can’t be cloned safely) — return a fresh empty Exchange so the call compiles and tests can move on. No-arg exchange.clone() form — a structural copy of every Value field. The copy gets a fresh Internals (no shared http client / derived pointers), which is all the transpiled tests need.

Source

pub fn clone(&self, v: Value) -> Value

clone(v) — deep-clone a Value. Matches TS exchange.clone(x). Note: keep this name even though it shadows the (manual) clone_self, because the transpiled tests call exchange.clone(value). Empty-arg calls exchange.clone() get post-processed to clone_self().

Source

pub fn prop(&self, key: &Value) -> Value

Dynamic-property lookup for transpiled base tests. The TS code does exchange['options'], exchange['markets'], etc. — this reads from the unified to_value() view so both access paths (exchange.prop(k) and testSharedMethods.exchangeProp) agree.

Source

pub fn to_value(&self) -> Value

Full Value::Map snapshot of every transpiler-visible field — the Rust analogue of indexing a JS object by property name. Used by prop() and by the base-test exchangeProp shim.

Source

pub fn base16ToBinary(&self, hex: Value, optional_args: &[Value]) -> Value

Source

pub fn base58_to_binary(&self, s: Value, _optional_args: &[Value]) -> Value

Source

pub fn binary_to_base58(&self, b: Value, _optional_args: &[Value]) -> Value

Source

pub fn binary_length(&self, b: Value, _optional_args: &[Value]) -> Value

Source

pub fn is_binary_message(&self, v: Value, _optional_args: &[Value]) -> Value

isBinaryMessage — in this port a binary buffer is a Value::Array of byte-valued ints (see base16_to_binary, string_to_binary). instanceof Uint8Array can’t transpile.

Source

pub fn number_to_be(&self, n: Value, optional_args: &[Value]) -> Value

numberToBE(n, padding) — big-endian byte array of width padding.

Source

pub fn parse_date(&self, s: Value, _optional_args: &[Value]) -> Value

parseDate(x) — ports functions/time.ts. Parses an ISO-8601 timestamp (with T/Z or a plain YYYY-MM-DD HH:MM:SS form, treated as UTC) into epoch milliseconds. Invalid → Null.

Source

pub fn is_binary_message_var(&self, v: Value, _optional_args: &[Value]) -> Value

Source

pub fn ymd(&self, ts: Value, optional_args: &[Value]) -> Value

ymd(timestamp, infix='') — like yyyymmdd but the infix defaults to empty (TS functions/time.ts).

Source

pub fn safe_float_n( &self, obj: Value, keys: Value, optional_args: &[Value], ) -> Value

Source

pub fn safe_float2( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

Source

pub fn safeString2( &self, obj: Value, k1: Value, k2: Value, optional_args: &[Value], ) -> Value

Source

pub fn binary_concat(&self, first: Value, optional_args: &[Value]) -> Value

binaryConcat(a, b, ...) — concatenates byte buffers. The variadic call-site wrap folds the tail args into optional_args.

Source

pub fn stringToBase64(&self, s: Value, optional_args: &[Value]) -> Value

Source

pub fn binary_to_string(&self, b: Value, _optional_args: &[Value]) -> Value

binaryToString(buffer) — decodes a byte buffer as UTF-8.

Source

pub fn string_to_binary(&self, s: Value, _optional_args: &[Value]) -> Value

Source

pub fn urlencode_base64(&self, v: Value, _optional_args: &[Value]) -> Value

urlencodeBase64(payload) — url-safe base64 with +/ → -_ and trailing = padding stripped. Accepts a string or a byte buffer (Value::Array).

Source

pub fn urlencode_nested(&self, v: Value, _optional_args: &[Value]) -> Value

urlencodeNested(object) — qs.stringify(object, { encodeValuesOnly: true }): nested maps → parent[child], arrays → parent[index], only values are percent-encoded.

Source

pub fn is_json_encoded_object(&self, optional_args: &[Value]) -> Value

Source

pub fn strip(&self, s: Value, _optional_args: &[Value]) -> Value

Source

pub fn sort(&self, v: Value, _optional_args: &[Value]) -> Value

Source

pub fn round_timeframe(&self, tf: Value, ts: Value, direction: Value) -> Value

roundTimeframe(timeframe, timestamp, direction) — snap a timestamp to the timeframe boundary (down by default, up for ROUND_UP).

Source

pub async fn sleep(&self, ms: Value) -> Value

Source

pub fn eth_get_address_from_private_key( &self, pk: Value, _optional_args: &[Value], ) -> Value

ethGetAddressFromPrivateKey(pk) — derive the Ethereum address (keccak256 of the uncompressed secp256k1 public key, last 20 bytes).

Source

pub fn ensure_whitelisted_file(&self, p: &Value)

ensures the file path has a whitelisted extension, so users are safeguarded from arbitrary file access

Source

pub fn exists_file(&self, p: Value) -> Value

Source

pub fn read_file(&self, p: Value) -> Value

Source

pub fn write_file(&self, p: Value, content: Value) -> Value

Source

pub fn get_temp_dir(&self) -> Value

Source

pub fn get_property(&self, obj: Value, key: Value) -> Value

Source

pub fn yymmdd(&self, ts: Value, optional_args: &[Value]) -> Value

Source

pub fn yyyymmdd(&self, ts: Value, optional_args: &[Value]) -> Value

Source

pub fn ymdhms(&self, ts: Value, optional_args: &[Value]) -> Value

ymdhms(timestamp, infix=' ') — UTC YYYY-MM-DD<infix>HH:MM:SS.

Source

pub fn rawencode(&self, params: Value, _optional_args: &[Value]) -> Value

rawencode(params, [doSeq]) — URL-encode without sorting. rawencode(object) — qs.stringify(object, { encode: false }): flat key=value pairs with no percent-encoding.

Source

pub fn int_to_base16(&self, n: Value, _optional_args: &[Value]) -> Value

intToBase16(n) — int → lowercase hex string.

Source

pub fn packb(&self, action: Value, _optional_args: &[Value]) -> Value

packb(action) — MessagePack pack stub. Hyperliquid signs the packed bytes of an action. Returning empty bytes here is enough to make the call compile; live signing won’t be correct. packb(value) — MessagePack-encode a Value into a byte array.

Source

pub fn eth_encode_structured_data( &self, domain: Value, types: Value, message: Value, ) -> Value

ethEncodeStructuredData(domain, types, message) — EIP-712 encoding: returns the \x19\x01 || domainSeparator || structHash preimage that the caller keccak-hashes before signing.

Source

pub fn uuid22(&self, _optional_args: &[Value]) -> Value

uuid22() — pseudo-random 22-char hex id.

Source

pub fn uuid16(&self, _optional_args: &[Value]) -> Value

uuid16() — pseudo-random 16-char hex id.

Source

pub fn uuid(&self, _optional_args: &[Value]) -> Value

uuid() — pseudo-random UUID v4: xxxxxxxx-xxxx-4xxx-[89ab]xxx-xxxxxxxxxxxx.

Source

pub fn urlencode(&self, params: Value, _optional_args: &[Value]) -> Value

urlencode(params) — wraps the typed urlencode_kv for Value args.

Source

pub fn json(&self, v: Value) -> Value

json(value) — JSON-stringify.

Source

pub fn encode(&self, s: Value) -> Value

encode(s) — UTF-8 encode string to bytes (as Value::Array of ints).

Source

pub fn decode(&self, b: Value) -> Value

decode(bytes) — decode bytes to a UTF-8 string.

Source

pub fn log(&self, msg: Value)

log(msg) — debug print.

Source

pub fn number_to_string(&self, n: Value) -> Value

Source

pub fn parse_number(&self, v: Value, optional_args: &[Value]) -> Value

Source

pub fn parse_timeframe(&self, tf: Value) -> Value

Source

pub fn precision_from_string(&self, s: Value) -> Value

precisionFromString(str) — ports functions/number.ts. Scientific notation (1e-4 → 4, 1e4 → -4); otherwise the number of fractional digits after stripping trailing zeros.

Source

pub fn decimal_to_precision( &self, n: Value, rounding: Value, precision: Value, optional_args: &[Value], ) -> Value

decimalToPrecision(n, roundingMode, numPrecisionDigits, [countingMode], [paddingMode]) — faithful port of _decimalToPrecision from functions/number.ts.

Source

pub fn capitalize(&self, s: Value) -> Value

Source

pub fn encode_uri_component(&self, s: Value) -> Value

Source

pub fn string_to_chars_array(&self, s: Value) -> Value

Source

pub fn string_to_base64(&self, s: Value, _optional_args: &[Value]) -> Value

Source

pub fn extract_params(&self, path: Value) -> Value

extract_params(path) — pulls {name} placeholders from a URL template. Returns a Value::Array of names.

Source

pub fn proxy_fn( &self, _url: Value, _method: Value, _headers: Value, _body: Value, ) -> Value

Source

pub fn proxy_url_callback_fn( &self, _url: Value, _method: Value, _headers: Value, _body: Value, ) -> Value

Source

pub fn http_proxy_callback_fn( &self, _url: Value, _method: Value, _headers: Value, _body: Value, ) -> Value

Source

pub fn https_proxy_callback_fn( &self, _url: Value, _method: Value, _headers: Value, _body: Value, ) -> Value

Source

pub fn socks_proxy_callback_fn( &self, _url: Value, _method: Value, _headers: Value, _body: Value, ) -> Value

Source

pub fn ws_proxy_callback_fn( &self, _url: Value, _method: Value, _headers: Value, _body: Value, ) -> Value

Source

pub fn wss_proxy_callback_fn( &self, _url: Value, _method: Value, _headers: Value, _body: Value, ) -> Value

Source

pub fn ws_socks_proxy_callback_fn( &self, _url: Value, _method: Value, _headers: Value, _body: Value, ) -> Value

Source

pub fn init_throttler(&mut self)

Source

pub async fn throttle(&self, cost: &[Value]) -> Value

Leaky-bucket rate limiter, mirroring ts/src/base/functions/throttle.ts. rateLimit is milliseconds-per-token, so refillRate = 1/rateLimit tokens/ms; tokens may go negative (a request proceeds when tokens >= 0 and then subtracts its cost), and the next request waits until the bucket refills back to zero. The bucket is owned by one task, so concurrent calls on one instance serialize by queuing there (the TS single queue). A no-op when enableRateLimit is false or the rate is effectively unlimited.

Source

pub fn resolve<T>(&self, v: T) -> T

Source

pub fn reject(&self, err: ExchangeError) -> ExchangeError

Trait Implementations§

Source§

impl Clone for Exchange

Source§

fn clone(&self) -> Exchange

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Exchange

Source§

fn default() -> Exchange

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more