@totalis/hip4-client 0.123.0 → 0.125.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 +391 -0
- package/README.md +9 -5
- package/dist/api-keys.d.ts +21 -2
- package/dist/api-keys.js +12 -10
- package/dist/audience-contract.d.ts +1 -2
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/flow-errors.d.ts +1 -1
- package/dist/flow-errors.js +1 -1
- package/dist/generated/account-read.d.ts +150 -126
- package/dist/generated/api-keys.d.ts +19 -10
- package/dist/generated/browse.d.ts +12 -12
- package/dist/generated/client.d.ts +5 -2
- package/dist/generated/errors.d.ts +15 -8
- package/dist/generated/errors.js +47 -35
- package/dist/generated/maker.d.ts +3 -4
- package/dist/generated/openapi.d.ts +828 -892
- package/dist/generated/realtime.d.ts +68 -93
- package/dist/generated/vault-abi.d.ts +57 -0
- package/dist/generated/vault-abi.js +77 -0
- package/dist/generated/version.d.ts +16 -16
- package/dist/generated/version.js +20 -18
- package/dist/maker.d.ts +134 -54
- package/dist/maker.js +257 -147
- package/dist/money.d.ts +8 -6
- package/dist/money.js +7 -7
- package/dist/partner.d.ts +2 -0
- package/dist/partner.js +2 -1
- package/dist/request.d.ts +11 -2
- package/dist/request.js +7 -2
- package/dist/totalis.d.ts +147 -232
- package/dist/totalis.js +290 -269
- package/dist/typed-data.d.ts +6 -0
- package/dist/typed-data.js +8 -0
- package/dist/ui.d.ts +6 -10
- package/dist/ui.js +15 -13
- package/dist/vault-reads.d.ts +46 -0
- package/dist/vault-reads.js +72 -0
- package/examples/browser-wallet.mjs +1 -1
- package/examples/node-bot.mjs +15 -12
- package/package.json +1 -1
package/dist/money.js
CHANGED
|
@@ -15,7 +15,7 @@ const bps = 10000n;
|
|
|
15
15
|
export function spendableCash(balance) {
|
|
16
16
|
const component = (kind) => {
|
|
17
17
|
const entry = balance.components.find((candidate) => candidate.kind === kind);
|
|
18
|
-
return entry === undefined || entry.
|
|
18
|
+
return entry === undefined || entry.freshness !== "CURRENT" || entry.amount === null ? null : BigInt(entry.amount);
|
|
19
19
|
};
|
|
20
20
|
const walletUsdc = component("WALLET_USDC");
|
|
21
21
|
// As the venue computes it: reservations beyond the wallet leave nothing available, never less.
|
|
@@ -23,7 +23,7 @@ export function spendableCash(balance) {
|
|
|
23
23
|
return {
|
|
24
24
|
vault: component("VAULT_FREE"),
|
|
25
25
|
wallet: wallet === null ? null : wallet > 0n ? wallet : 0n,
|
|
26
|
-
total: balance.
|
|
26
|
+
total: balance.freshness === "CURRENT" && balance.amount !== null ? BigInt(balance.amount) : null,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
@@ -76,15 +76,15 @@ export function netStake(terms) {
|
|
|
76
76
|
* 9.18 USDC at 100 bps profit fee nets 9.118140 USDC.
|
|
77
77
|
*/
|
|
78
78
|
export function netPayout(quote) {
|
|
79
|
-
const terms = "
|
|
79
|
+
const terms = "signing" in quote ? quote.signing.entry : quote;
|
|
80
80
|
return netOfProfitFee(terms.payout, netStake(terms), terms.fee_bps);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* What the owner receives from a sell-back: its price less the position's
|
|
84
|
-
* profit fee on the price above its net stake. `position` is the position
|
|
85
|
-
* (`GET /v1/me/positions/{position_id}`
|
|
86
|
-
* unknown.
|
|
84
|
+
* profit fee on the price above its net stake. `position` is the `position`
|
|
85
|
+
* of Get position's read (`GET /v1/me/positions/{position_id}` returns
|
|
86
|
+
* `{ context, position }`); `null` when its `net_stake` is unknown.
|
|
87
87
|
*/
|
|
88
88
|
export function netCashout(bid, position) {
|
|
89
|
-
return position.net_stake === null ? null : netOfProfitFee(bid.
|
|
89
|
+
return position.net_stake === null ? null : netOfProfitFee(bid.price, position.net_stake, position.fee_bps);
|
|
90
90
|
}
|
package/dist/partner.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ApiClientOptions, type PublicEnvironment } from "./base.js";
|
|
2
2
|
import type { components } from "./generated/client.js";
|
|
3
|
+
import { rfqLegsInOrder } from "./request.js";
|
|
4
|
+
export { rfqLegsInOrder };
|
|
3
5
|
import { type SignerInput } from "./signer.js";
|
|
4
6
|
export type WalletAdmission = components["schemas"]["WalletAdmission"];
|
|
5
7
|
/** Your partner's fees, terms, balance and payouts (TT-2420). Amounts are atomic USDC strings. */
|
package/dist/partner.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { audienceClient } from "./base.js";
|
|
2
|
-
import { unwrap, uuidv7 } from "./request.js";
|
|
2
|
+
import { rfqLegsInOrder, unwrap, uuidv7 } from "./request.js";
|
|
3
|
+
export { rfqLegsInOrder };
|
|
3
4
|
import { runtime } from "./runtime.js";
|
|
4
5
|
import { toTotalisSigner } from "./signer.js";
|
|
5
6
|
/** The key environment a consent names, from the SDK's environment. */
|
package/dist/request.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export declare function uuidv7(now?: number): string;
|
|
|
4
4
|
/** 32 random bytes as 0x-hex, for salts and nonces. */
|
|
5
5
|
export declare function randomBytes32(): `0x${string}`;
|
|
6
6
|
/**
|
|
7
|
-
* The envelope
|
|
8
|
-
*
|
|
7
|
+
* The command envelope venues before contract 277 took a core exit or a
|
|
8
|
+
* run-off claim in. No current route takes one: every command is sent bare.
|
|
9
|
+
* Build it once and resend it unchanged.
|
|
9
10
|
*/
|
|
10
11
|
export declare function envelope<Command>(command: Command, requestId?: string): {
|
|
11
12
|
schema_version: 1;
|
|
@@ -130,4 +131,12 @@ export declare function unwrap<Data>(result: {
|
|
|
130
131
|
* serialized as JSON.
|
|
131
132
|
*/
|
|
132
133
|
export declare function rawBody<Body extends Blob | ArrayBuffer | Uint8Array>(body: Body): Body;
|
|
134
|
+
/** Legs in the order `openPosition` sends them: by increasing numeric `outcome_id`. */
|
|
135
|
+
export declare function rfqLegsInOrder<Leg extends {
|
|
136
|
+
readonly outcome_id: string;
|
|
137
|
+
readonly side: "YES" | "NO";
|
|
138
|
+
}>(legs: readonly Leg[]): {
|
|
139
|
+
outcome_id: string;
|
|
140
|
+
side: "YES" | "NO";
|
|
141
|
+
}[];
|
|
133
142
|
export {};
|
package/dist/request.js
CHANGED
|
@@ -15,8 +15,9 @@ export function randomBytes32() {
|
|
|
15
15
|
return `0x${Array.from(randomBytes(32), (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* The envelope
|
|
19
|
-
*
|
|
18
|
+
* The command envelope venues before contract 277 took a core exit or a
|
|
19
|
+
* run-off claim in. No current route takes one: every command is sent bare.
|
|
20
|
+
* Build it once and resend it unchanged.
|
|
20
21
|
*/
|
|
21
22
|
export function envelope(command, requestId = uuidv7()) {
|
|
22
23
|
return { schema_version: 1, request_id: requestId, sent_at: new Date().toISOString(), command };
|
|
@@ -201,3 +202,7 @@ export function unwrap(result) {
|
|
|
201
202
|
export function rawBody(body) {
|
|
202
203
|
return body;
|
|
203
204
|
}
|
|
205
|
+
/** Legs in the order `openPosition` sends them: by increasing numeric `outcome_id`. */
|
|
206
|
+
export function rfqLegsInOrder(legs) {
|
|
207
|
+
return [...legs].sort((a, b) => Number(a.outcome_id) - Number(b.outcome_id)).map(({ outcome_id, side }) => ({ outcome_id, side }));
|
|
208
|
+
}
|