@totalis/hip4-client 0.130.0 → 0.131.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +114 -0
- package/README.md +13 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.js +2 -1
- package/dist/generated/client.d.ts +3 -1
- package/dist/generated/errors.d.ts +3 -1
- package/dist/generated/errors.js +17 -2
- package/dist/generated/maker.d.ts +2 -1
- package/dist/generated/openapi.d.ts +258 -59
- package/dist/generated/realtime.d.ts +12 -1
- package/dist/generated/version.d.ts +7 -7
- package/dist/generated/version.js +8 -5
- package/dist/hypercore.d.ts +6 -0
- package/dist/hypercore.js +7 -1
- package/dist/single-orders.d.ts +223 -0
- package/dist/single-orders.js +277 -0
- package/dist/singles.d.ts +4 -1
- package/dist/singles.js +4 -1
- package/dist/totalis.d.ts +6 -0
- package/dist/totalis.js +34 -0
- package/package.json +2 -1
package/dist/totalis.js
CHANGED
|
@@ -9,6 +9,8 @@ import { abortReason, anySignal, timeoutSignal } from "./runtime.js";
|
|
|
9
9
|
import { toTotalisSigner } from "./signer.js";
|
|
10
10
|
import { TotalisStream } from "./stream.js";
|
|
11
11
|
import { items } from "./pagination.js";
|
|
12
|
+
import { orderHistoryCursor, outcomeOf, proofWindow } from "./single-orders.js";
|
|
13
|
+
import { outcomeCoin, readSingleOrder } from "./singles.js";
|
|
12
14
|
import { address, agentGrantTypedData, exitTypedData, receiveWithAuthorizationTypedData, sellBackTypedData, takerAcceptTypedData, payoutNonce, transferWithAuthorizationTypedData, walletPermitTypedData, } from "./typed-data.js";
|
|
13
15
|
/** The approval asked when the approval left falls short: 10,000 USDC, or the shortfall when it is larger. */
|
|
14
16
|
export const defaultWalletApproval = 10000000000n;
|
|
@@ -467,6 +469,36 @@ export function createTotalis(options) {
|
|
|
467
469
|
offeredCore: offered, allowance: comboAllowance({ vault: venue.vault, wallet: venue.wallet, core: offered }),
|
|
468
470
|
};
|
|
469
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Where the node order history that proves IOCs stands for this session's
|
|
474
|
+
* account on this deployment's network (`GET /v1/hypercore/order-history`).
|
|
475
|
+
* Read it in the background and keep the latest for `placeSingleIoc`'s
|
|
476
|
+
* `history`, never on the way to signing; drop it when the account or
|
|
477
|
+
* network changes.
|
|
478
|
+
*/
|
|
479
|
+
async function readOrderHistory(signal) {
|
|
480
|
+
const [chain, cursor] = await Promise.all([deployment(), client.GET("/v1/hypercore/order-history", signal === undefined ? {} : { signal }).then(unwrap)]);
|
|
481
|
+
return orderHistoryCursor(cursor, chain.chain_id);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Settle a saved IOC by evidence, signing and sending nothing: the venue's
|
|
485
|
+
* proof from its node order history, then Hyperliquid's `orderStatus` by
|
|
486
|
+
* its cloid (through `info`), read after it so that a lookup counted after
|
|
487
|
+
* the deadline was made after it (`singleOrderOutcome`). The session must
|
|
488
|
+
* be the record's account. Throws when neither read answered.
|
|
489
|
+
*/
|
|
490
|
+
async function settleSingleOrder(record, options = {}) {
|
|
491
|
+
if ((await deployment()).chain_id !== String(record.chainId))
|
|
492
|
+
throw new Error(`this order was placed on chain ${record.chainId}, not this deployment's`);
|
|
493
|
+
const signal = options.signal === undefined ? {} : { signal: options.signal };
|
|
494
|
+
const { nonce, afterHeight } = proofWindow(record);
|
|
495
|
+
const query = { coin: outcomeCoin(record.outcomeId, record.side), nonce, expires_after: record.expiresAfter, ...(afterHeight === null ? {} : { after_height: afterHeight }) };
|
|
496
|
+
const proof = await client.GET("/v1/hypercore/orders/{cloid}", { params: { path: { cloid: record.cloid }, query }, ...signal }).then(unwrap).then((value) => ({ value }), (error) => ({ error }));
|
|
497
|
+
const status = await readSingleOrder(hyperliquidNetwork(record.chainId), record.account, record.cloid, options.info, options.signal).then((value) => ({ value }), (error) => ({ error }));
|
|
498
|
+
if ("error" in proof && "error" in status)
|
|
499
|
+
throw proof.error;
|
|
500
|
+
return outcomeOf(record, { ...("value" in status ? { status: status.value } : {}), ...("value" in proof ? { proof: proof.value } : {}) }, "value" in status);
|
|
501
|
+
}
|
|
470
502
|
/** The wallet's USDC authorization of `value` into the vault; the venue fills `account` and `from` with the same wallet. */
|
|
471
503
|
/** The body names the signed ReceiveWithAuthorization's `value` `amount`. */
|
|
472
504
|
async function depositAuthorization(chain, account, value) {
|
|
@@ -1608,6 +1640,8 @@ export function createTotalis(options) {
|
|
|
1608
1640
|
/** What the account holds at Totalis, every amount read at one block (`GET /v1/me/account-value`). */
|
|
1609
1641
|
accountValue: readAccountValue,
|
|
1610
1642
|
readComboCash,
|
|
1643
|
+
readOrderHistory,
|
|
1644
|
+
settleSingleOrder,
|
|
1611
1645
|
openPosition,
|
|
1612
1646
|
cashOut,
|
|
1613
1647
|
prepareEntryFunding,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totalis/hip4-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.131.0",
|
|
4
4
|
"description": "Totalis HIP-4 SDK: typed HTTP clients, signer-agnostic typed data, a retrying request layer, pagination, a realtime stream and taker/maker flows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"directory": "clients/typescript"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
+
"@noble/curves": "1.9.7",
|
|
88
89
|
"@noble/hashes": "1.8.0",
|
|
89
90
|
"openapi-fetch": "0.17.0"
|
|
90
91
|
},
|