@totalis/hip4-client 0.87.0 → 0.88.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 +14 -0
- package/dist/audience-contract.d.ts +0 -3
- package/dist/client.d.ts +1 -1
- package/dist/generated/account-read.d.ts +3 -3
- package/dist/generated/openapi.d.ts +15 -86
- package/dist/generated/realtime.d.ts +3 -52
- package/dist/generated/version.d.ts +6 -6
- package/dist/generated/version.js +6 -6
- package/dist/maker.d.ts +1 -5
- package/dist/maker.js +10 -23
- package/dist/money.d.ts +4 -7
- package/dist/money.js +4 -6
- package/dist/totalis.d.ts +4 -7
- package/dist/totalis.js +6 -9
- package/dist/typed-data.d.ts +1 -29
- package/dist/typed-data.js +1 -21
- package/dist/ui.js +1 -1
- package/examples/browser-wallet.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
`@totalis/hip4-client` follows [semantic versioning](https://semver.org).
|
|
4
4
|
The contract version the generated types come from is `sdkVersion` in `./version`.
|
|
5
5
|
|
|
6
|
+
## 0.88.0
|
|
7
|
+
|
|
8
|
+
### Removed
|
|
9
|
+
|
|
10
|
+
- `TRANSFER` cash-out bids (TT-2570). Only the maker that backs a position
|
|
11
|
+
bids on its cash-out, with a sell-back; other makers no longer receive its
|
|
12
|
+
cash-out RFQ. Removed `TransferQuote`, `cashoutTransferTypedData` and the
|
|
13
|
+
`CashoutTransfer` entry of `totalisTypes` and `signedBy`. `CashoutBid` is
|
|
14
|
+
now `SellBackQuote`. `maker.bid` always publishes a sell-back and no longer
|
|
15
|
+
reads `rfq.maker_id`. `netCashout` takes only a sell-back. The quote API no
|
|
16
|
+
longer takes `transfer` terms, quotes and acceptances are never `TRANSFER`,
|
|
17
|
+
and quote history's `cashout_kind` is only `SELL_BACK`. Contract
|
|
18
|
+
`215.0.0-no-transfer-bids`. Breaking.
|
|
19
|
+
|
|
6
20
|
## 0.87.0
|
|
7
21
|
|
|
8
22
|
### Added
|
|
@@ -43,9 +43,6 @@ type QuoteContract = [
|
|
|
43
43
|
} ? true : false>,
|
|
44
44
|
Assert<OpenApiComponents["schemas"]["SellBackTerms"] extends {
|
|
45
45
|
readonly position_id: string;
|
|
46
|
-
} ? true : false>,
|
|
47
|
-
Assert<OpenApiComponents["schemas"]["TransferTerms"] extends {
|
|
48
|
-
readonly position_id: string;
|
|
49
46
|
} ? true : false>
|
|
50
47
|
];
|
|
51
48
|
export type AudienceContract = [ClientContract, MakerContract, OperatorContract, CashoutContract, QuoteContract];
|
package/dist/client.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type { components, operations, paths } from "./generated/client.js";
|
|
|
5
5
|
export type { AccessToken, ApiClientOptions, PublicEnvironment } from "./base.js";
|
|
6
6
|
/** The typed HTTP client for the `client` audience. `createTotalis` adds the flows. */
|
|
7
7
|
export declare function createClient(environment: PublicEnvironment, options?: ApiClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
|
|
8
|
-
export { bestBid, bestQuote, createTotalis, defaultWalletApproval, EntryError, entryFailure, follow, WalletApprovalError, type Acceptance, type AcceptanceResult, type Amount, type ApprovalListener, type BridgeState, type ComboCash, type CashoutBid, type Chooser, type Deployment, type DepositAccepted, type EntryCash, type EntryFailure, type EntryFunding, type EntryQuote, type KnownWalletApproval, type LandedWalletApproval, type SignedWalletApproval, type WalletApproval, type WalletApprovalRequest, type CoreExit, type LegacySignedEntry, type Leg, type PreparedEntryFunding, type NotAdmitted, type RecordListener, type Operation, type Quote, type ResponseOf, type SellBackQuote, type SignedAcceptance, type SignedCashout, type SignedCoreExit, type SignedDeposit, type SignedEntry, type SignedReturnToCore, type Totalis, type TotalisOptions, type
|
|
8
|
+
export { bestBid, bestQuote, createTotalis, defaultWalletApproval, EntryError, entryFailure, follow, WalletApprovalError, type Acceptance, type AcceptanceResult, type Amount, type ApprovalListener, type BridgeState, type ComboCash, type CashoutBid, type Chooser, type Deployment, type DepositAccepted, type EntryCash, type EntryFailure, type EntryFunding, type EntryQuote, type KnownWalletApproval, type LandedWalletApproval, type SignedWalletApproval, type WalletApproval, type WalletApprovalRequest, type CoreExit, type LegacySignedEntry, type Leg, type PreparedEntryFunding, type NotAdmitted, type RecordListener, type Operation, type Quote, type ResponseOf, type SellBackQuote, type SignedAcceptance, type SignedCashout, type SignedCoreExit, type SignedDeposit, type SignedEntry, type SignedReturnToCore, type Totalis, type TotalisOptions, type WalletCall, type Withdrawal, } from "./totalis.js";
|
|
9
9
|
export { bridgeAction, bridgeGasBuffer, classifyHypercoreAnswer, coreSetupFee, hyperevmUsdcBridge, hyperliquidExchange, hyperliquidInfo, hyperliquidNetwork, hypercoreNonce, hypercoreSignature, readCoreCash, sendAssetTypedData, settleHypercore, signSendAsset, submitHypercore, usdcText, type BridgedCash, type CoreAccountMode, type CoreCash, type HypercoreAnswer, type HyperliquidInfo, type HypercoreSignature, type HypercoreTransport, type HyperliquidNetwork, type SendAssetAction, type SignedSendAsset, } from "./hypercore.js";
|
|
10
10
|
export { ApiError, envelope, NetworkError, randomBytes32, retryingFetch, sendOnce, unwrap, uuidv7, type Fetch, type Repaired, type RetryPolicy } from "./request.js";
|
|
11
11
|
export { items, pages, type Page, type PageQuery } from "./pagination.js";
|
|
@@ -930,15 +930,15 @@ export type components = {
|
|
|
930
930
|
*/
|
|
931
931
|
readonly rfq_id: string;
|
|
932
932
|
/**
|
|
933
|
-
* @description ENTRY opens a position; CASHOUT buys one back (SELL_BACK)
|
|
933
|
+
* @description ENTRY opens a position; CASHOUT buys one back (SELL_BACK).
|
|
934
934
|
* @enum {string}
|
|
935
935
|
*/
|
|
936
936
|
readonly kind: "ENTRY" | "CASHOUT";
|
|
937
937
|
/**
|
|
938
|
-
* @description For a CASHOUT quote, SELL_BACK
|
|
938
|
+
* @description For a CASHOUT quote, SELL_BACK: the position's own maker buys it back. null for ENTRY.
|
|
939
939
|
* @enum {string|null}
|
|
940
940
|
*/
|
|
941
|
-
readonly cashout_kind: "SELL_BACK" |
|
|
941
|
+
readonly cashout_kind: "SELL_BACK" | null;
|
|
942
942
|
/** @description Where the quote stands now. OPEN, AWAITING_CONFIRMATION and ACCEPTED can still change; every other status is final. FILLED is the only status in which the quote traded. */
|
|
943
943
|
readonly status: components["schemas"]["QuoteHistoryStatus"];
|
|
944
944
|
/**
|
|
@@ -1200,7 +1200,7 @@ export type paths = {
|
|
|
1200
1200
|
};
|
|
1201
1201
|
/**
|
|
1202
1202
|
* Get my vault agents
|
|
1203
|
-
* @description The authenticated account's vault agents whose latest AgentGrant on chain is still live, by agent address, a page at a time: each agent may sign the account's named TakerAccept, owner-side SellBack
|
|
1203
|
+
* @description The authenticated account's vault agents whose latest AgentGrant on chain is still live, by agent address, a page at a time: each agent may sign the account's named TakerAccept, owner-side SellBack and Exit to the account's own wallet or Core spot until valid_until. copy_agent marks a server-held copy agent (managed under /v1/me/copy-agents) rather than a key one of the account's devices holds. A grant appears once the chain-agent projects it, after its operation completes. nonce is the agent's last grant, which a new grant or revoke must exceed.
|
|
1204
1204
|
*/
|
|
1205
1205
|
readonly get: operations["getVaultAgents"];
|
|
1206
1206
|
readonly put?: never;
|
|
@@ -2938,7 +2938,7 @@ export type components = {
|
|
|
2938
2938
|
readonly opened_at: components["schemas"]["$defs-Timestamp"];
|
|
2939
2939
|
} & components["schemas"]["TraderComboFields"];
|
|
2940
2940
|
/** @description One live, unsigned quote on an RFQ, told apart by `kind`. List quotes, the account snapshot's quotes and `QUOTE_CREATED` carry the same item. */
|
|
2941
|
-
readonly Quote: components["schemas"]["EntryQuote"] | components["schemas"]["SellBackQuote"]
|
|
2941
|
+
readonly Quote: components["schemas"]["EntryQuote"] | components["schemas"]["SellBackQuote"];
|
|
2942
2942
|
/** @description A maker's offer to open a position on an entry RFQ. */
|
|
2943
2943
|
readonly EntryQuote: {
|
|
2944
2944
|
/** @description Quote ID: the EIP-712 digest of `entry` as the `Quote` struct. Accept it with `POST /v1/quotes/{quote_id}/accept`. */
|
|
@@ -2973,23 +2973,7 @@ export type components = {
|
|
|
2973
2973
|
/** @description Sell-back terms the owner accepts by signing `quote_id` as `SellBack`. */
|
|
2974
2974
|
readonly sell_back: components["schemas"]["schemas-SellBackTerms"];
|
|
2975
2975
|
};
|
|
2976
|
-
/** @description
|
|
2977
|
-
readonly TransferQuote: {
|
|
2978
|
-
/** @description Quote ID: the EIP-712 digest of `transfer` as the `CashoutTransfer` struct, which the owner signs to accept. */
|
|
2979
|
-
readonly quote_id: components["schemas"]["Bytes32"];
|
|
2980
|
-
/** @description RFQ this quote answers. */
|
|
2981
|
-
readonly rfq_id: components["schemas"]["Uuid"];
|
|
2982
|
-
/**
|
|
2983
|
-
* @description Always `TRANSFER`: another maker takes over the position.
|
|
2984
|
-
* @constant
|
|
2985
|
-
*/
|
|
2986
|
-
readonly kind: "TRANSFER";
|
|
2987
|
-
/** @description Venue-wide publication sequence number; a higher value was created later. */
|
|
2988
|
-
readonly sequence: number;
|
|
2989
|
-
/** @description Transfer terms the owner accepts by signing `quote_id` as `CashoutTransfer`. */
|
|
2990
|
-
readonly transfer: components["schemas"]["schemas-TransferTerms"];
|
|
2991
|
-
};
|
|
2992
|
-
/** @description Your quote on the RFQ: `quote_id` plus exactly one set of terms. Send `entry` for an entry RFQ, and `sell_back` or `transfer` for a cash-out RFQ. It replaces your live quote on the RFQ. */
|
|
2976
|
+
/** @description Your quote on the RFQ: `quote_id` plus exactly one set of terms. Send `entry` for an entry RFQ, and `sell_back` for a cash-out RFQ, which only the maker that backs the position may quote. It replaces your live quote on the RFQ. */
|
|
2993
2977
|
readonly CreateQuoteCommand: {
|
|
2994
2978
|
/** @description EIP-712 digest of `entry`, as the `Quote` struct. It must match the terms exactly. You sign it when you confirm an acceptance, and it becomes the `position_id` of the position the trade opens. */
|
|
2995
2979
|
readonly quote_id: components["schemas"]["Bytes32"];
|
|
@@ -3000,11 +2984,6 @@ export type components = {
|
|
|
3000
2984
|
readonly quote_id: components["schemas"]["Bytes32"];
|
|
3001
2985
|
/** @description Sell-back terms, only from the maker that backs the position: your maker vault pays the owner `price` and the position closes. `position_id`, `owner` and `leg_state` must match the RFQ, and `expiry` is 25 to 60 seconds ahead. */
|
|
3002
2986
|
readonly sell_back: components["schemas"]["schemas-SellBackTerms"];
|
|
3003
|
-
} | {
|
|
3004
|
-
/** @description EIP-712 digest of `transfer`, as the `CashoutTransfer` struct. It must match the terms exactly; you (the buyer) and the owner (the seller) both sign it. */
|
|
3005
|
-
readonly quote_id: components["schemas"]["Bytes32"];
|
|
3006
|
-
/** @description Transfer terms, from any maker other than the one that backs the position: `buyer`, your quote signer, pays `seller` the `price` and takes the position. `position_id`, `seller` and `leg_state` must match the RFQ, and `expiry` is 25 to 60 seconds ahead. */
|
|
3007
|
-
readonly transfer: components["schemas"]["schemas-TransferTerms"];
|
|
3008
2987
|
};
|
|
3009
2988
|
readonly QuoteList: {
|
|
3010
2989
|
/** @description Live quotes on this RFQ in creation order, at most 100. Rank them yourself. Left out: entry quotes at or after their `accept_before`, cash-out quotes within 22 seconds of expiry, a quote whose acceptance timed out, and every quote on a cash-out RFQ that already has an accepted one. */
|
|
@@ -3021,7 +3000,7 @@ export type components = {
|
|
|
3021
3000
|
};
|
|
3022
3001
|
/** @description The taker's accept of the quote in the path. The `Idempotency-Key` header becomes the `acceptance_id`. */
|
|
3023
3002
|
readonly AcceptQuoteCommand: {
|
|
3024
|
-
/** @description Your EIP-712 signature over the quote. For an entry quote, sign its `entry` terms as `TakerAccept`. For a cash-out quote, the owner signs `quote_id` as `SellBack
|
|
3003
|
+
/** @description Your EIP-712 signature over the quote. For an entry quote, sign its `entry` terms as `TakerAccept`. For a cash-out quote, the owner signs `quote_id` as `SellBack`, the same digest the maker signs. */
|
|
3025
3004
|
readonly taker_signature: components["schemas"]["ContractSignature"];
|
|
3026
3005
|
/** @description Entry quotes only; not allowed on a cash-out. Pays the part of the stake your vault balance is short from your account wallet: `WALLET` with a USDC authorization for the exact shortfall, or `WALLET_APPROVAL` from the wallet's approval to WalletAccept. Omit it when your vault balance covers the stake. The acceptance keeps the route it was admitted with; a replay never switches it. */
|
|
3027
3006
|
readonly funding?: components["schemas"]["WalletFunding"] | components["schemas"]["WalletApprovalFunding"];
|
|
@@ -3048,7 +3027,7 @@ export type components = {
|
|
|
3048
3027
|
* @constant
|
|
3049
3028
|
*/
|
|
3050
3029
|
readonly decision: "CONFIRM";
|
|
3051
|
-
/** @description Your quote signer's EIP-712 signature over the accepted terms: `entry` as `Quote`, `sell_back` as `SellBack
|
|
3030
|
+
/** @description Your quote signer's EIP-712 signature over the accepted terms: `entry` as `Quote`, `sell_back` as `SellBack`. Your capital stays reserved for as long as this signature can execute. */
|
|
3052
3031
|
readonly maker_signature: components["schemas"]["ContractSignature"];
|
|
3053
3032
|
} | {
|
|
3054
3033
|
/**
|
|
@@ -3060,7 +3039,7 @@ export type components = {
|
|
|
3060
3039
|
/** @description The acceptance after your answer. It never includes the taker's `acceptance_id`. */
|
|
3061
3040
|
readonly ConfirmQuoteResult: components["schemas"]["AcceptanceFields"];
|
|
3062
3041
|
/** @description A taker's accept of your quote, waiting for your confirm until `deadline`, told apart by `kind`. `QUOTE_ACCEPTED`, the maker snapshot's `acceptances` and List pending acceptances carry the same item. It never includes the taker's signature or `acceptance_id`. */
|
|
3063
|
-
readonly MakerAcceptance: components["schemas"]["EntryMakerAcceptance"] | components["schemas"]["SellBackMakerAcceptance"]
|
|
3042
|
+
readonly MakerAcceptance: components["schemas"]["EntryMakerAcceptance"] | components["schemas"]["SellBackMakerAcceptance"];
|
|
3064
3043
|
/** @description A taker's accept of your entry quote. */
|
|
3065
3044
|
readonly EntryMakerAcceptance: {
|
|
3066
3045
|
/** @description The accepted quote. Confirm with `POST /v1/quotes/{quote_id}/confirm`. */
|
|
@@ -3093,22 +3072,6 @@ export type components = {
|
|
|
3093
3072
|
/** @description Accepted sell-back terms; sign them as `SellBack`. */
|
|
3094
3073
|
readonly sell_back: components["schemas"]["schemas-SellBackTerms"];
|
|
3095
3074
|
};
|
|
3096
|
-
/** @description An owner's accept of your transfer quote. */
|
|
3097
|
-
readonly TransferMakerAcceptance: {
|
|
3098
|
-
/** @description The accepted quote. Confirm with `POST /v1/quotes/{quote_id}/confirm`. */
|
|
3099
|
-
readonly quote_id: components["schemas"]["Bytes32"];
|
|
3100
|
-
/** @description RFQ this quote answers. */
|
|
3101
|
-
readonly rfq_id: components["schemas"]["Uuid"];
|
|
3102
|
-
/**
|
|
3103
|
-
* @description Always `TRANSFER`: you take over the position.
|
|
3104
|
-
* @constant
|
|
3105
|
-
*/
|
|
3106
|
-
readonly kind: "TRANSFER";
|
|
3107
|
-
/** @description Confirm before this instant, an RFC3339 UTC timestamp. A later answer cannot reopen the acceptance. */
|
|
3108
|
-
readonly deadline: components["schemas"]["$defs-Timestamp"];
|
|
3109
|
-
/** @description Accepted transfer terms; sign them as `CashoutTransfer`. */
|
|
3110
|
-
readonly transfer: components["schemas"]["schemas-TransferTerms"];
|
|
3111
|
-
};
|
|
3112
3075
|
/** @description Acceptances a maker snapshot left out past its cap; the snapshot names this route in `truncated`. Items match the snapshot's `acceptances` and `QUOTE_ACCEPTED`. */
|
|
3113
3076
|
readonly MakerAcceptanceList: {
|
|
3114
3077
|
/** @description Acceptances of your quotes waiting for your confirm on this page, earliest deadline first. One answered or expired since the snapshot is left out; a new one arrives on the stream. */
|
|
@@ -3222,10 +3185,10 @@ export type components = {
|
|
|
3222
3185
|
readonly maker_id: components["schemas"]["NonZeroUInt64String"];
|
|
3223
3186
|
/** @description The position's stake after the taker fee, in atomic USDC (6 decimals): tickets(position_id).stake, which the vault fixes when the position opens, so it is also the value at decision_block. The position's net_stake. */
|
|
3224
3187
|
readonly net_stake: components["schemas"]["$defs-Amount"];
|
|
3225
|
-
/** @description What the position pays if every leg wins, in atomic USDC (6 decimals): tickets(position_id).payout, which the vault fixes when the position opens, so it is also the value at decision_block.
|
|
3188
|
+
/** @description What the position pays if every leg wins, in atomic USDC (6 decimals): tickets(position_id).payout, which the vault fixes when the position opens, so it is also the value at decision_block. The position's payout. */
|
|
3226
3189
|
readonly payout: components["schemas"]["$defs-Amount"];
|
|
3227
3190
|
/**
|
|
3228
|
-
* @description OPEN collects cash-out quotes until expires_at; EXPIRED means that window passed without an accepted quote; CANCELLED means the owner cancelled it or a newer intent generation replaced it; ACCEPTED means a quote was accepted and confirmed; FAILED means the accepted sell-back
|
|
3191
|
+
* @description OPEN collects cash-out quotes until expires_at; EXPIRED means that window passed without an accepted quote; CANCELLED means the owner cancelled it or a newer intent generation replaced it; ACCEPTED means a quote was accepted and confirmed; FAILED means the accepted sell-back failed on chain (see terminal_reason); DECLINED means every maker that could answer declined to quote it before expires_at.
|
|
3229
3192
|
* @enum {string}
|
|
3230
3193
|
*/
|
|
3231
3194
|
readonly status: "OPEN" | "ACCEPTED" | "EXPIRED" | "CANCELLED" | "FAILED" | "DECLINED";
|
|
@@ -3292,23 +3255,6 @@ export type components = {
|
|
|
3292
3255
|
/** @description Random uint256, as a decimal string, that makes each signed quote unique. */
|
|
3293
3256
|
readonly salt: components["schemas"]["Uint256"];
|
|
3294
3257
|
};
|
|
3295
|
-
/** @description Transfer terms: another maker buys the position and becomes its owner. They mirror the signed CashoutTransfer struct. */
|
|
3296
|
-
readonly TransferTerms: {
|
|
3297
|
-
/** @description Position the quote is for; the signed CashoutTransfer names it ticketId. */
|
|
3298
|
-
readonly position_id: components["schemas"]["Hash32"];
|
|
3299
|
-
/** @description Price the buyer pays the seller for the whole position, in atomic USDC (6 decimals). */
|
|
3300
|
-
readonly price: components["schemas"]["$defs-Amount"];
|
|
3301
|
-
/** @description Current position owner, who sells the ticket. */
|
|
3302
|
-
readonly seller: components["schemas"]["LowercaseNonZeroAddress"];
|
|
3303
|
-
/** @description The bidding maker's current quote signer, which becomes the owner and pays from its own vault balance. */
|
|
3304
|
-
readonly buyer: components["schemas"]["LowercaseNonZeroAddress"];
|
|
3305
|
-
/** @description Unix seconds after which the quote can no longer be executed. */
|
|
3306
|
-
readonly expiry: components["schemas"]["UInt64String"];
|
|
3307
|
-
/** @description Random uint256, as a decimal string, that makes each signed quote unique. */
|
|
3308
|
-
readonly salt: components["schemas"]["Uint256"];
|
|
3309
|
-
/** @description Position leg state the quote was priced against; must equal the RFQ's leg_state. */
|
|
3310
|
-
readonly leg_state: components["schemas"]["Hash32"];
|
|
3311
|
-
};
|
|
3312
3258
|
/** @description Sell-back terms: the underwriting maker buys the position back and it closes. They mirror the signed SellBack struct. */
|
|
3313
3259
|
readonly SellBackTerms: {
|
|
3314
3260
|
/** @description Position the quote is for; the signed SellBack names it ticketId. */
|
|
@@ -4798,23 +4744,6 @@ export type components = {
|
|
|
4798
4744
|
/** @description Position leg state the quote was priced against; must equal the RFQ's leg_state. */
|
|
4799
4745
|
readonly leg_state: components["schemas"]["Hash32"];
|
|
4800
4746
|
};
|
|
4801
|
-
/** @description Transfer terms: another maker buys the position and becomes its owner. They mirror the signed CashoutTransfer struct. */
|
|
4802
|
-
readonly "schemas-TransferTerms": {
|
|
4803
|
-
/** @description Position the quote is for; the signed CashoutTransfer names it ticketId. */
|
|
4804
|
-
readonly position_id: components["schemas"]["Hash32"];
|
|
4805
|
-
/** @description Price the buyer pays the seller for the whole position, in atomic USDC (6 decimals). */
|
|
4806
|
-
readonly price: components["schemas"]["$defs-Amount"];
|
|
4807
|
-
/** @description Current position owner, who sells the ticket. */
|
|
4808
|
-
readonly seller: components["schemas"]["LowercaseNonZeroAddress"];
|
|
4809
|
-
/** @description The bidding maker's current quote signer, which becomes the owner and pays from its own vault balance. */
|
|
4810
|
-
readonly buyer: components["schemas"]["LowercaseNonZeroAddress"];
|
|
4811
|
-
/** @description Unix seconds after which the quote can no longer be executed. */
|
|
4812
|
-
readonly expiry: components["schemas"]["UInt64String"];
|
|
4813
|
-
/** @description Random uint256, as a decimal string, that makes each signed quote unique. */
|
|
4814
|
-
readonly salt: components["schemas"]["Uint256"];
|
|
4815
|
-
/** @description Position leg state the quote was priced against; must equal the RFQ's leg_state. */
|
|
4816
|
-
readonly leg_state: components["schemas"]["Hash32"];
|
|
4817
|
-
};
|
|
4818
4747
|
/** Format: uint256-decimal */
|
|
4819
4748
|
readonly Uint: string;
|
|
4820
4749
|
readonly ContractSignature: string;
|
|
@@ -5625,7 +5554,7 @@ export type components = {
|
|
|
5625
5554
|
readonly Operation: {
|
|
5626
5555
|
/** @description Deterministic 32-byte ID of the operation. */
|
|
5627
5556
|
readonly operation_id: components["schemas"]["Bytes32"];
|
|
5628
|
-
/** @description Operation type, named after the contract call: DEPOSIT_USER_AUTHORIZED, WITHDRAW_USER, ACCEPT, SETTLE, CLAIM, SELL_BACK, POSITION_TRANSFER,
|
|
5557
|
+
/** @description Operation type, named after the contract call: DEPOSIT_USER_AUTHORIZED, WITHDRAW_USER, ACCEPT, SETTLE, CLAIM, SELL_BACK, POSITION_TRANSFER, TOTALIS_PAYOUT, CORE_EXIT or ATTEST. Treat unlisted values as opaque. */
|
|
5629
5558
|
readonly kind: string;
|
|
5630
5559
|
/** @description Atomic USDC (6 decimals): the gross stake for ACCEPT, the moved amount for deposits, withdrawals and Core exits; null for kinds without a known amount. */
|
|
5631
5560
|
readonly amount: components["schemas"]["$defs-Amount"] | null;
|
|
@@ -6093,15 +6022,15 @@ export type components = {
|
|
|
6093
6022
|
*/
|
|
6094
6023
|
readonly rfq_id: string;
|
|
6095
6024
|
/**
|
|
6096
|
-
* @description ENTRY opens a position; CASHOUT buys one back (SELL_BACK)
|
|
6025
|
+
* @description ENTRY opens a position; CASHOUT buys one back (SELL_BACK).
|
|
6097
6026
|
* @enum {string}
|
|
6098
6027
|
*/
|
|
6099
6028
|
readonly kind: "ENTRY" | "CASHOUT";
|
|
6100
6029
|
/**
|
|
6101
|
-
* @description For a CASHOUT quote, SELL_BACK
|
|
6030
|
+
* @description For a CASHOUT quote, SELL_BACK: the position's own maker buys it back. null for ENTRY.
|
|
6102
6031
|
* @enum {string|null}
|
|
6103
6032
|
*/
|
|
6104
|
-
readonly cashout_kind: "SELL_BACK" |
|
|
6033
|
+
readonly cashout_kind: "SELL_BACK" | null;
|
|
6105
6034
|
/** @description Where the quote stands now. OPEN, AWAITING_CONFIRMATION and ACCEPTED can still change; every other status is final. FILLED is the only status in which the quote traded. */
|
|
6106
6035
|
readonly status: components["schemas"]["QuoteHistoryStatus"];
|
|
6107
6036
|
/**
|
|
@@ -8988,7 +8917,7 @@ export interface operations {
|
|
|
8988
8917
|
readonly stake: components["schemas"]["$defs-Amount"];
|
|
8989
8918
|
/** @description What the trader's ticket pays if every leg wins. */
|
|
8990
8919
|
readonly payout: components["schemas"]["$defs-Amount"];
|
|
8991
|
-
/** @description The price the trader's cash-out was quoted at; present on an EXIT. A sell-back above the stake pays this less the vault's profit fee
|
|
8920
|
+
/** @description The price the trader's cash-out was quoted at; present on an EXIT. A sell-back above the stake pays this less the vault's profit fee. */
|
|
8992
8921
|
readonly price?: components["schemas"]["$defs-Amount"];
|
|
8993
8922
|
};
|
|
8994
8923
|
/**
|
|
@@ -10045,7 +9974,7 @@ export interface operations {
|
|
|
10045
9974
|
readonly "application/json": components["schemas"]["QuoteCreated"];
|
|
10046
9975
|
};
|
|
10047
9976
|
};
|
|
10048
|
-
/** @description A term no confirm could fill, named in `field_violations`: `quote_id` that is not the digest of `entry`, `maker_id` other than your key's, `legs`, `stake` or `taker` other than the RFQ's, a net stake under the minimum (`stake`), `payout` not above `stake` or over the maximum payout, `fee_bps` or `taker_fee_bps` other than Get deployment's, or `expiry` not more than 14 and at most 30 seconds ahead.
|
|
9977
|
+
/** @description A term no confirm could fill, named in `field_violations`: `quote_id` that is not the digest of `entry`, `maker_id` other than your key's, `legs`, `stake` or `taker` other than the RFQ's, a net stake under the minimum (`stake`), `payout` not above `stake` or over the maximum payout, `fee_bps` or `taker_fee_bps` other than Get deployment's, or `expiry` not more than 14 and at most 30 seconds ahead. */
|
|
10049
9978
|
readonly 400: components["responses"]["Error"];
|
|
10050
9979
|
readonly 401: components["responses"]["Error"];
|
|
10051
9980
|
readonly 403: components["responses"]["Error"];
|
|
@@ -10276,7 +10205,7 @@ export interface operations {
|
|
|
10276
10205
|
readonly 401: components["responses"]["Error"];
|
|
10277
10206
|
readonly 403: components["responses"]["Error"];
|
|
10278
10207
|
readonly 404: components["responses"]["Error"];
|
|
10279
|
-
/** @description Resending the same answer replays the result; a different answer to the same acceptance returns `IDEMPOTENCY_KEY_REUSED`. An answer after the acceptance's `deadline` cannot reopen it. `QUOTE_CAPACITY_EXCEEDED`: your free capital, less the fills you have confirmed that are not yet on chain, does not cover this fill
|
|
10208
|
+
/** @description Resending the same answer replays the result; a different answer to the same acceptance returns `IDEMPOTENCY_KEY_REUSED`. An answer after the acceptance's `deadline` cannot reopen it. `QUOTE_CAPACITY_EXCEEDED`: your free capital, less the fills you have confirmed that are not yet on chain, does not cover this fill. Nothing filled. */
|
|
10280
10209
|
readonly 409: components["responses"]["Error"];
|
|
10281
10210
|
readonly 422: components["responses"]["Error"];
|
|
10282
10211
|
readonly 429: components["responses"]["RateLimited"];
|
|
@@ -20,7 +20,7 @@ export type components = {
|
|
|
20
20
|
readonly OperationUpdatedPayload: {
|
|
21
21
|
/** @description Operation identifier (32-byte hex). Read GET /v1/me/operations/{operation_id} for the full resource. */
|
|
22
22
|
readonly operation_id: components["schemas"]["Bytes32"];
|
|
23
|
-
/** @description Operation type, as the operation's kind: ACCEPT, SELL_BACK,
|
|
23
|
+
/** @description Operation type, as the operation's kind: ACCEPT, SELL_BACK, WITHDRAW_USER and the others GET /v1/me/operations/{operation_id} names. Treat unlisted values as opaque. */
|
|
24
24
|
readonly kind: string;
|
|
25
25
|
/** @description Operation status after this change. QUEUED, IN_FLIGHT, RETRYABLE and UNKNOWN are nonterminal; COMMITTED (on chain), REVERTED and EXPIRED_UNEXECUTED are terminal. */
|
|
26
26
|
readonly status: components["schemas"]["OperationState"];
|
|
@@ -911,41 +911,8 @@ export type components = {
|
|
|
911
911
|
/** @description Sell-back terms the owner accepts by signing `quote_id` as `SellBack`. */
|
|
912
912
|
readonly sell_back: components["schemas"]["SellBackTerms"];
|
|
913
913
|
};
|
|
914
|
-
/** @description Transfer terms: another maker buys the position and becomes its owner. They mirror the signed CashoutTransfer struct. */
|
|
915
|
-
readonly TransferTerms: {
|
|
916
|
-
/** @description Position the quote is for; the signed CashoutTransfer names it ticketId. */
|
|
917
|
-
readonly position_id: components["schemas"]["Hash32"];
|
|
918
|
-
/** @description Price the buyer pays the seller for the whole position, in atomic USDC (6 decimals). */
|
|
919
|
-
readonly price: components["schemas"]["Amount"];
|
|
920
|
-
/** @description Current position owner, who sells the ticket. */
|
|
921
|
-
readonly seller: components["schemas"]["LowercaseNonZeroAddress"];
|
|
922
|
-
/** @description The bidding maker's current quote signer, which becomes the owner and pays from its own vault balance. */
|
|
923
|
-
readonly buyer: components["schemas"]["LowercaseNonZeroAddress"];
|
|
924
|
-
/** @description Unix seconds after which the quote can no longer be executed. */
|
|
925
|
-
readonly expiry: components["schemas"]["UInt64String"];
|
|
926
|
-
/** @description Random uint256, as a decimal string, that makes each signed quote unique. */
|
|
927
|
-
readonly salt: components["schemas"]["Uint256"];
|
|
928
|
-
/** @description Position leg state the quote was priced against; must equal the RFQ's leg_state. */
|
|
929
|
-
readonly leg_state: components["schemas"]["Hash32"];
|
|
930
|
-
};
|
|
931
|
-
/** @description A cash-out offer from another maker: it pays the owner `price` and takes over the position. */
|
|
932
|
-
readonly TransferQuote: {
|
|
933
|
-
/** @description Quote ID: the EIP-712 digest of `transfer` as the `CashoutTransfer` struct, which the owner signs to accept. */
|
|
934
|
-
readonly quote_id: components["schemas"]["Bytes32"];
|
|
935
|
-
/** @description RFQ this quote answers. */
|
|
936
|
-
readonly rfq_id: components["schemas"]["Uuid"];
|
|
937
|
-
/**
|
|
938
|
-
* @description Always `TRANSFER`: another maker takes over the position.
|
|
939
|
-
* @constant
|
|
940
|
-
*/
|
|
941
|
-
readonly kind: "TRANSFER";
|
|
942
|
-
/** @description Venue-wide publication sequence number; a higher value was created later. */
|
|
943
|
-
readonly sequence: number;
|
|
944
|
-
/** @description Transfer terms the owner accepts by signing `quote_id` as `CashoutTransfer`. */
|
|
945
|
-
readonly transfer: components["schemas"]["TransferTerms"];
|
|
946
|
-
};
|
|
947
914
|
/** @description One live, unsigned quote on an RFQ, told apart by `kind`. List quotes, the account snapshot's quotes and `QUOTE_CREATED` carry the same item. */
|
|
948
|
-
readonly Quote: components["schemas"]["EntryQuote"] | components["schemas"]["SellBackQuote"]
|
|
915
|
+
readonly Quote: components["schemas"]["EntryQuote"] | components["schemas"]["SellBackQuote"];
|
|
949
916
|
/** @description A taker's accept of your entry quote. */
|
|
950
917
|
readonly EntryMakerAcceptance: {
|
|
951
918
|
/** @description The accepted quote. Confirm with `POST /v1/quotes/{quote_id}/confirm`. */
|
|
@@ -978,24 +945,8 @@ export type components = {
|
|
|
978
945
|
/** @description Accepted sell-back terms; sign them as `SellBack`. */
|
|
979
946
|
readonly sell_back: components["schemas"]["SellBackTerms"];
|
|
980
947
|
};
|
|
981
|
-
/** @description An owner's accept of your transfer quote. */
|
|
982
|
-
readonly TransferMakerAcceptance: {
|
|
983
|
-
/** @description The accepted quote. Confirm with `POST /v1/quotes/{quote_id}/confirm`. */
|
|
984
|
-
readonly quote_id: components["schemas"]["Bytes32"];
|
|
985
|
-
/** @description RFQ this quote answers. */
|
|
986
|
-
readonly rfq_id: components["schemas"]["Uuid"];
|
|
987
|
-
/**
|
|
988
|
-
* @description Always `TRANSFER`: you take over the position.
|
|
989
|
-
* @constant
|
|
990
|
-
*/
|
|
991
|
-
readonly kind: "TRANSFER";
|
|
992
|
-
/** @description Confirm before this instant, an RFC3339 UTC timestamp. A later answer cannot reopen the acceptance. */
|
|
993
|
-
readonly deadline: components["schemas"]["Timestamp"];
|
|
994
|
-
/** @description Accepted transfer terms; sign them as `CashoutTransfer`. */
|
|
995
|
-
readonly transfer: components["schemas"]["TransferTerms"];
|
|
996
|
-
};
|
|
997
948
|
/** @description A taker's accept of your quote, waiting for your confirm until `deadline`, told apart by `kind`. `QUOTE_ACCEPTED`, the maker snapshot's `acceptances` and List pending acceptances carry the same item. It never includes the taker's signature or `acceptance_id`. */
|
|
998
|
-
readonly MakerAcceptance: components["schemas"]["EntryMakerAcceptance"] | components["schemas"]["SellBackMakerAcceptance"]
|
|
949
|
+
readonly MakerAcceptance: components["schemas"]["EntryMakerAcceptance"] | components["schemas"]["SellBackMakerAcceptance"];
|
|
999
950
|
readonly Withdrawal: {
|
|
1000
951
|
/** @description Server-assigned ID of this withdrawal. */
|
|
1001
952
|
readonly withdrawal_id: components["schemas"]["Uuid"];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const sdkVersion = "
|
|
2
|
-
export declare const openapiSha256 = "
|
|
3
|
-
export declare const realtimeSha256 = "
|
|
1
|
+
export declare const sdkVersion = "215.0.0-no-transfer-bids";
|
|
2
|
+
export declare const openapiSha256 = "997b89a2fb217df2863da685026667a9d5b4db05a57f309392f878ac128cfebb";
|
|
3
|
+
export declare const realtimeSha256 = "32e56c8bb642401f5b03e9c38274087c09bebb73ffe60c0d34432c2e78ce1e15";
|
|
4
4
|
export declare const jsonSchemaSha256: {
|
|
5
|
-
readonly "account.schema.json": "
|
|
5
|
+
readonly "account.schema.json": "c11a94438d5f7b54e08d3b559098ce2671f4c9aad3a79feb684b7a81f77d809a";
|
|
6
6
|
readonly "comments.schema.json": "7cb61352e5a0280fa34951fdcc2d934062bf628da4743f0dc8c763d0b79b7611";
|
|
7
7
|
readonly "common.schema.json": "04f51deb3cbea448e59195e26ede3212598d58a7940fe67eb2123fd9161c5edb";
|
|
8
8
|
readonly "core-exit.schema.json": "c7f617e815225cdcac95c236f8b73fbe288ee5713ff444c3be90eb915fc3a401";
|
|
@@ -14,8 +14,8 @@ export declare const jsonSchemaSha256: {
|
|
|
14
14
|
readonly "maker-telemetry.schema.json": "85b111ce0f4935299d1116071b43de12e775bef4e0c283c12f19046d34374a9c";
|
|
15
15
|
readonly "market-data.schema.json": "85db33fac6a29b0fa87a500bfda947d0ab3913b13f1c26663d4a7c0484c35786";
|
|
16
16
|
readonly "product-metadata.schema.json": "7c8ffbde878a0aedaed16814fcfd2e80038054b140886cc8736bb7b508042631";
|
|
17
|
-
readonly "quote.schema.json": "
|
|
18
|
-
readonly "realtime.schema.json": "
|
|
17
|
+
readonly "quote.schema.json": "52ee1f4708c8b1504e4cd2f2f9279e14c8ec8aeacac1f491441ae0e15ac3c71a";
|
|
18
|
+
readonly "realtime.schema.json": "32e56c8bb642401f5b03e9c38274087c09bebb73ffe60c0d34432c2e78ce1e15";
|
|
19
19
|
};
|
|
20
20
|
export declare const operations: {
|
|
21
21
|
readonly client: readonly ["abandonCoreExit", "acceptQuote", "activeCoreExits", "admitOwnMaker", "admitPartnerWallet", "approveWallet", "bindEmbeddedWallet", "cancelRfq", "confirmComboCopyAgent", "confirmCoreCopyAgent", "createCashout", "createComment", "createCoreExit", "createDeposit", "createGoldenRfq", "createRfq", "createRunOffClaim", "createWalletChallenge", "createWalletSession", "createWithdrawal", "deleteComment", "editComment", "endWalletSession", "followTrader", "getAcceptance", "getAccountActivity", "getAccountPnl", "getAccountPosition", "getBalances", "getCopyAgents", "getCopyBudget", "getCopySettings", "getCopySummary", "getCoreExit", "getDeployment", "getGolden", "getGoldenMarkets", "getGoldenOffer", "getGoldenSuggestions", "getHypercoreBalance", "getHypercorePortfolio", "getHypercoreSettlementCredits", "getIdentity", "getMakerActivity", "getMakerCapital", "getMakerExposure", "getMakerPerformance", "getMakerPosition", "getMakerQuotes", "getMakerTelemetry", "getMakerVaultFundingTransaction", "getMakerWithdrawal", "getMarket", "getMarketDataConfig", "getMarketDefinitions", "getMarketHistory", "getMarketRecurringRound", "getMarketReferenceCloses", "getMarketScoreTimeline", "getMarketStats", "getOperation", "getOwnMaker", "getPartnerReport", "getPerpMarks", "getProfitLeaderboard", "getQuestion", "getQuestionRecurringRound", "getQuestionScoreTimeline", "getRfq", "getSeries", "getSuggestedCombo", "getTaxonomy", "getTrader", "getTraderPnl", "getUsernameAvailability", "getVaultAgents", "getVolumeLeaderboard", "getWalletApproval", "getWithdrawal", "grantComboCopyAgent", "grantVaultAgent", "likeComment", "listAccountActivity", "listAccountPositions", "listComboCopies", "listComboFeed", "listCommentReplies", "listComments", "listControlledMakers", "listCopiedFills", "listCopyTrades", "listDiscovery", "listFollows", "listMakerActivity", "listMakerPositions", "listMakerQuoteHistory", "listMarkets", "listOperations", "listQuotes", "listTraderPositions", "listTraderTrades", "placeGolden", "reactComment", "recordAcquisition", "refreshPicture", "requestComboCopyAgent", "requestCoreCopyAgent", "revokeComboCopyAgent", "searchCatalog", "setAvatar", "setCopyAllocation", "setCopySettings", "setPublicProfile", "setUsername", "setXHandleShown", "stream", "streamMarkets", "switchOffComboCopyAgent", "switchOffCoreCopyAgent", "unfollowTrader", "unlikeComment", "unreactComment"];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Generated by scripts/generate.mjs; do not edit.
|
|
2
|
-
export const sdkVersion = "
|
|
3
|
-
export const openapiSha256 = "
|
|
4
|
-
export const realtimeSha256 = "
|
|
2
|
+
export const sdkVersion = "215.0.0-no-transfer-bids";
|
|
3
|
+
export const openapiSha256 = "997b89a2fb217df2863da685026667a9d5b4db05a57f309392f878ac128cfebb";
|
|
4
|
+
export const realtimeSha256 = "32e56c8bb642401f5b03e9c38274087c09bebb73ffe60c0d34432c2e78ce1e15";
|
|
5
5
|
export const jsonSchemaSha256 = {
|
|
6
|
-
"account.schema.json": "
|
|
6
|
+
"account.schema.json": "c11a94438d5f7b54e08d3b559098ce2671f4c9aad3a79feb684b7a81f77d809a",
|
|
7
7
|
"comments.schema.json": "7cb61352e5a0280fa34951fdcc2d934062bf628da4743f0dc8c763d0b79b7611",
|
|
8
8
|
"common.schema.json": "04f51deb3cbea448e59195e26ede3212598d58a7940fe67eb2123fd9161c5edb",
|
|
9
9
|
"core-exit.schema.json": "c7f617e815225cdcac95c236f8b73fbe288ee5713ff444c3be90eb915fc3a401",
|
|
@@ -15,8 +15,8 @@ export const jsonSchemaSha256 = {
|
|
|
15
15
|
"maker-telemetry.schema.json": "85b111ce0f4935299d1116071b43de12e775bef4e0c283c12f19046d34374a9c",
|
|
16
16
|
"market-data.schema.json": "85db33fac6a29b0fa87a500bfda947d0ab3913b13f1c26663d4a7c0484c35786",
|
|
17
17
|
"product-metadata.schema.json": "7c8ffbde878a0aedaed16814fcfd2e80038054b140886cc8736bb7b508042631",
|
|
18
|
-
"quote.schema.json": "
|
|
19
|
-
"realtime.schema.json": "
|
|
18
|
+
"quote.schema.json": "52ee1f4708c8b1504e4cd2f2f9279e14c8ec8aeacac1f491441ae0e15ac3c71a",
|
|
19
|
+
"realtime.schema.json": "32e56c8bb642401f5b03e9c38274087c09bebb73ffe60c0d34432c2e78ce1e15"
|
|
20
20
|
};
|
|
21
21
|
export const operations = {
|
|
22
22
|
"client": [
|
package/dist/maker.d.ts
CHANGED
|
@@ -116,7 +116,7 @@ export declare function createMaker(options: MakerOptions): {
|
|
|
116
116
|
salt: string;
|
|
117
117
|
};
|
|
118
118
|
}>;
|
|
119
|
-
bid: (rfq: Pick<CashoutRfq, "rfq_id" | "position_id" | "owner" | "leg_state"
|
|
119
|
+
bid: (rfq: Pick<CashoutRfq, "rfq_id" | "position_id" | "owner" | "leg_state">, terms: {
|
|
120
120
|
readonly price: bigint | string;
|
|
121
121
|
readonly lifetimeSeconds?: number;
|
|
122
122
|
readonly salt?: string;
|
|
@@ -124,10 +124,6 @@ export declare function createMaker(options: MakerOptions): {
|
|
|
124
124
|
quote_id: import("./generated/openapi.js").components["schemas"]["Bytes32"];
|
|
125
125
|
sell_back: import("./generated/openapi.js").components["schemas"]["schemas-SellBackTerms"];
|
|
126
126
|
quoteId: string;
|
|
127
|
-
} | {
|
|
128
|
-
quote_id: import("./generated/openapi.js").components["schemas"]["Bytes32"];
|
|
129
|
-
transfer: import("./generated/openapi.js").components["schemas"]["schemas-TransferTerms"];
|
|
130
|
-
quoteId: string;
|
|
131
127
|
}>;
|
|
132
128
|
cancelQuote: (quoteId: string) => Promise<{
|
|
133
129
|
readonly status: "CANCELLED" | "REPLACED" | "ACCEPTED";
|
package/dist/maker.js
CHANGED
|
@@ -4,7 +4,7 @@ import { toTotalisSigner } from "./signer.js";
|
|
|
4
4
|
import { items } from "./pagination.js";
|
|
5
5
|
import { TotalisStream } from "./stream.js";
|
|
6
6
|
import { follow, terminalOperationStatuses } from "./totalis.js";
|
|
7
|
-
import { address,
|
|
7
|
+
import { address, hashTypedData, quoteTypedData, sellBackTypedData } from "./typed-data.js";
|
|
8
8
|
import { calldata, controllerTransactions } from "./controller.js";
|
|
9
9
|
export { controllerTransactions, encodeCall, openMakerVaultTransaction } from "./controller.js";
|
|
10
10
|
export function createMakerClient(environment, options) {
|
|
@@ -176,30 +176,19 @@ export function createMaker(options) {
|
|
|
176
176
|
return { quoteId: quote_id, entry };
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
|
-
* Publish an unsigned cash-out
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* `INVALID_REQUEST` naming `transfer.price`, so bid only on your own
|
|
185
|
-
* positions unless it is funded. The owner signs it before accepting, so
|
|
186
|
-
* confirming it executes it. Throws `AcceptancePendingError` like `quote`.
|
|
179
|
+
* Publish an unsigned sell-back on a cash-out RFQ, on the same route as entry
|
|
180
|
+
* quotes. Only the maker that backs the position receives its cash-out RFQ
|
|
181
|
+
* and may bid; the maker vault pays the owner `price` and the position
|
|
182
|
+
* closes. The owner signs it before accepting, so confirming it executes it.
|
|
183
|
+
* Throws `AcceptancePendingError` like `quote`.
|
|
187
184
|
*/
|
|
188
185
|
async function bid(rfq, terms) {
|
|
189
186
|
await acceptancesKnown();
|
|
190
187
|
refuseWhileAwaiting(rfq.rfq_id);
|
|
191
188
|
const chain = await deployment();
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const sell_back = { ...common, owner: rfq.owner };
|
|
196
|
-
command = { quote_id: hashTypedData(sellBackTypedData(chain, sell_back)), sell_back };
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
const transfer = { ...common, seller: rfq.owner, buyer: await signer.address() };
|
|
200
|
-
command = { quote_id: hashTypedData(cashoutTransferTypedData(chain, transfer)), transfer };
|
|
201
|
-
}
|
|
202
|
-
await publish(rfq.rfq_id, command.quote_id, Number(common.expiry), async () => unwrap(await client.POST("/v1/rfqs/{rfq_id}/quotes", {
|
|
189
|
+
const sell_back = { position_id: rfq.position_id, price: String(terms.price), owner: rfq.owner, expiry: expiryIn(terms.lifetimeSeconds ?? 45), salt: terms.salt ?? randomSalt(), leg_state: rfq.leg_state };
|
|
190
|
+
const command = { quote_id: hashTypedData(sellBackTypedData(chain, sell_back)), sell_back };
|
|
191
|
+
await publish(rfq.rfq_id, command.quote_id, Number(sell_back.expiry), async () => unwrap(await client.POST("/v1/rfqs/{rfq_id}/quotes", {
|
|
203
192
|
params: { path: { rfq_id: rfq.rfq_id }, header: { "Idempotency-Key": uuidv7() } }, body: command,
|
|
204
193
|
})));
|
|
205
194
|
return { quoteId: command.quote_id, ...command };
|
|
@@ -270,9 +259,7 @@ export function createMaker(options) {
|
|
|
270
259
|
/** The exact terms an acceptance asks this maker to sign, checked against the quote ID. */
|
|
271
260
|
async function termsFor(acceptance) {
|
|
272
261
|
const chain = await deployment();
|
|
273
|
-
const typedData = acceptance.kind === "ENTRY" ? quoteTypedData(chain, acceptance.entry)
|
|
274
|
-
: acceptance.kind === "SELL_BACK" ? sellBackTypedData(chain, acceptance.sell_back)
|
|
275
|
-
: cashoutTransferTypedData(chain, acceptance.transfer);
|
|
262
|
+
const typedData = acceptance.kind === "ENTRY" ? quoteTypedData(chain, acceptance.entry) : sellBackTypedData(chain, acceptance.sell_back);
|
|
276
263
|
if (hashTypedData(typedData) !== acceptance.quote_id)
|
|
277
264
|
throw new Error("acceptance terms do not match their quote ID");
|
|
278
265
|
// The quote signer signs only terms this maker published and that are still live.
|
package/dist/money.d.ts
CHANGED
|
@@ -5,9 +5,6 @@ type EntryTerms = Pick<Schemas["schemas-QuoteTerms"], "stake" | "payout" | "fee_
|
|
|
5
5
|
type CashoutTerms = {
|
|
6
6
|
readonly kind: "SELL_BACK";
|
|
7
7
|
readonly sell_back: Pick<Schemas["schemas-SellBackTerms"], "price">;
|
|
8
|
-
} | {
|
|
9
|
-
readonly kind: "TRANSFER";
|
|
10
|
-
readonly transfer: Pick<Schemas["schemas-TransferTerms"], "price">;
|
|
11
8
|
};
|
|
12
9
|
/**
|
|
13
10
|
* Spendable Totalis cash from `GET /v1/me/balances`, in USDC base units, as
|
|
@@ -65,10 +62,10 @@ export declare function netPayout(quote: {
|
|
|
65
62
|
readonly entry: EntryTerms;
|
|
66
63
|
} | EntryTerms): bigint;
|
|
67
64
|
/**
|
|
68
|
-
* What the owner receives from a
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
65
|
+
* What the owner receives from a sell-back: its price less the position's
|
|
66
|
+
* profit fee on the price above its net stake. `position` is the position read
|
|
67
|
+
* (`GET /v1/me/positions/{position_id}`); `null` when its `net_stake` is
|
|
68
|
+
* unknown.
|
|
72
69
|
*/
|
|
73
70
|
export declare function netCashout(bid: CashoutTerms, position: {
|
|
74
71
|
readonly net_stake: string | null;
|
package/dist/money.js
CHANGED
|
@@ -80,13 +80,11 @@ export function netPayout(quote) {
|
|
|
80
80
|
return netOfProfitFee(terms.payout, netStake(terms), terms.fee_bps);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* What the owner receives from a
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
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 read
|
|
85
|
+
* (`GET /v1/me/positions/{position_id}`); `null` when its `net_stake` is
|
|
86
|
+
* unknown.
|
|
87
87
|
*/
|
|
88
88
|
export function netCashout(bid, position) {
|
|
89
|
-
if (bid.kind === "TRANSFER")
|
|
90
|
-
return BigInt(bid.transfer.price);
|
|
91
89
|
return position.net_stake === null ? null : netOfProfitFee(bid.sell_back.price, position.net_stake, position.fee_bps);
|
|
92
90
|
}
|
package/dist/totalis.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ type CoreExitRequest = {
|
|
|
29
29
|
readonly activationFeeAccepted?: boolean;
|
|
30
30
|
};
|
|
31
31
|
export type Deployment = Ok<"/v1/deployment", "get">;
|
|
32
|
-
/** One live unsigned quote, told apart by `kind`: `ENTRY` (`entry`)
|
|
32
|
+
/** One live unsigned quote, told apart by `kind`: `ENTRY` (`entry`) or `SELL_BACK` (`sell_back`). */
|
|
33
33
|
export type Quote = Ok<"/v1/rfqs/{rfq_id}/quotes", "get">["quotes"][number];
|
|
34
34
|
export type EntryQuote = Extract<Quote, {
|
|
35
35
|
readonly kind: "ENTRY";
|
|
@@ -39,11 +39,8 @@ export type SellBackQuote = Extract<Quote, {
|
|
|
39
39
|
readonly kind: "SELL_BACK";
|
|
40
40
|
}>;
|
|
41
41
|
/** A cash-out quote from another maker: it takes over the position. */
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}>;
|
|
45
|
-
/** A cash-out quote: a sell-back or a transfer. */
|
|
46
|
-
export type CashoutBid = SellBackQuote | TransferQuote;
|
|
42
|
+
/** A cash-out quote: a sell-back by the maker that backs the position. */
|
|
43
|
+
export type CashoutBid = SellBackQuote;
|
|
47
44
|
export type Acceptance = Ok<"/v1/quotes/{quote_id}/acceptance", "get">;
|
|
48
45
|
/** An accept whose response was lost and that the venue never admitted: cancel fenced the RFQ first. Nothing traded. */
|
|
49
46
|
export type NotAdmitted = {
|
|
@@ -265,7 +262,7 @@ export type TotalisOptions = Omit<ApiClientOptions, "accessToken"> & {
|
|
|
265
262
|
readonly signer?: SignerInput;
|
|
266
263
|
/**
|
|
267
264
|
* A key the account granted as a vault agent (`grantVaultAgent`). When set,
|
|
268
|
-
* it signs the account's TakerAccept, SellBack
|
|
265
|
+
* it signs the account's TakerAccept, SellBack and Exits to
|
|
269
266
|
* its wallet or HyperCore instead of `signer`, so those need no wallet
|
|
270
267
|
* prompt. `signer` still names the account and signs everything else: USDC
|
|
271
268
|
* authorizations, HyperCore actions, grants and run-off claims. The venue
|
package/dist/totalis.js
CHANGED
|
@@ -8,7 +8,7 @@ import { ApiError, backoffDelay, envelope, NetworkError, randomBytes32, resendab
|
|
|
8
8
|
import { toTotalisSigner } from "./signer.js";
|
|
9
9
|
import { TotalisStream } from "./stream.js";
|
|
10
10
|
import { items } from "./pagination.js";
|
|
11
|
-
import { address, agentGrantTypedData,
|
|
11
|
+
import { address, agentGrantTypedData, exitTypedData, receiveWithAuthorizationTypedData, sellBackTypedData, takerAcceptTypedData, payoutNonce, transferWithAuthorizationTypedData, walletPermitTypedData, } from "./typed-data.js";
|
|
12
12
|
/** The approval asked when the approval left falls short: 10,000 USDC, or the shortfall when it is larger. */
|
|
13
13
|
export const defaultWalletApproval = 10000000000n;
|
|
14
14
|
/**
|
|
@@ -100,7 +100,7 @@ const refreshCodes = new Set(["QUOTE_EXPIRED", "QUOTE_REPLACED"]);
|
|
|
100
100
|
const passedOn = new Set(["DECLINED", "TIMED_OUT"]);
|
|
101
101
|
const timerSlackMs = 250;
|
|
102
102
|
function termsOf(quote) {
|
|
103
|
-
return quote.kind === "ENTRY" ? quote.entry : quote.
|
|
103
|
+
return quote.kind === "ENTRY" ? quote.entry : quote.sell_back;
|
|
104
104
|
}
|
|
105
105
|
/** The highest payout among quotes still before their `accept_before` (ties go to the earliest). */
|
|
106
106
|
export function bestQuote() {
|
|
@@ -917,15 +917,13 @@ export function createTotalis(options) {
|
|
|
917
917
|
function signEntry(request) {
|
|
918
918
|
return signEntryWith(request, "plan", request.funding);
|
|
919
919
|
}
|
|
920
|
-
/** Sign a cash-out quote as the position's owner without sending it: the same SellBack
|
|
920
|
+
/** Sign a cash-out quote as the position's owner without sending it: the same SellBack digest the maker signs. */
|
|
921
921
|
async function signCashout(request) {
|
|
922
922
|
const { quote } = request;
|
|
923
923
|
const { vaultSigner, account, chain, scope } = await recordScope();
|
|
924
|
-
|
|
925
|
-
if (seller.toLowerCase() !== account)
|
|
924
|
+
if (quote.sell_back.owner.toLowerCase() !== account)
|
|
926
925
|
throw new Error("the quote sells another owner's position");
|
|
927
|
-
const
|
|
928
|
-
const taker_signature = await vaultSigner.signTypedData(typedData);
|
|
926
|
+
const taker_signature = await vaultSigner.signTypedData(sellBackTypedData(chain, quote.sell_back));
|
|
929
927
|
return {
|
|
930
928
|
kind: "CASHOUT", acceptanceId: request.acceptanceId ?? uuidv7(), rfqId: quote.rfq_id, quoteId: quote.quote_id, ...scope,
|
|
931
929
|
positionId: termsOf(quote).position_id, command: { taker_signature },
|
|
@@ -1173,8 +1171,7 @@ export function createTotalis(options) {
|
|
|
1173
1171
|
const matches = (quote) => {
|
|
1174
1172
|
if (quote.kind === "ENTRY" || quote.rfq_id !== rfqId)
|
|
1175
1173
|
return false;
|
|
1176
|
-
|
|
1177
|
-
return termsOf(quote).position_id.toLowerCase() === positionId.toLowerCase() && seller === owner;
|
|
1174
|
+
return quote.sell_back.position_id.toLowerCase() === positionId.toLowerCase() && quote.sell_back.owner === owner;
|
|
1178
1175
|
};
|
|
1179
1176
|
const signed = await signedOrCancel(rfqId, async () => {
|
|
1180
1177
|
const bid = await awaitOffer(rfqId, matches, choose, collectMs, quoteTimeoutMs, signal);
|
package/dist/typed-data.d.ts
CHANGED
|
@@ -89,28 +89,6 @@ export declare const totalisTypes: {
|
|
|
89
89
|
readonly name: "legState";
|
|
90
90
|
readonly type: "bytes32";
|
|
91
91
|
}];
|
|
92
|
-
readonly CashoutTransfer: readonly [{
|
|
93
|
-
readonly name: "ticketId";
|
|
94
|
-
readonly type: "bytes32";
|
|
95
|
-
}, {
|
|
96
|
-
readonly name: "price";
|
|
97
|
-
readonly type: "uint128";
|
|
98
|
-
}, {
|
|
99
|
-
readonly name: "seller";
|
|
100
|
-
readonly type: "address";
|
|
101
|
-
}, {
|
|
102
|
-
readonly name: "buyer";
|
|
103
|
-
readonly type: "address";
|
|
104
|
-
}, {
|
|
105
|
-
readonly name: "expiry";
|
|
106
|
-
readonly type: "uint64";
|
|
107
|
-
}, {
|
|
108
|
-
readonly name: "salt";
|
|
109
|
-
readonly type: "uint256";
|
|
110
|
-
}, {
|
|
111
|
-
readonly name: "legState";
|
|
112
|
-
readonly type: "bytes32";
|
|
113
|
-
}];
|
|
114
92
|
readonly Exit: readonly [{
|
|
115
93
|
readonly name: "account";
|
|
116
94
|
readonly type: "address";
|
|
@@ -145,14 +123,13 @@ export type TotalisPrimaryType = Exclude<keyof typeof totalisTypes, "Leg">;
|
|
|
145
123
|
/**
|
|
146
124
|
* Who signs each struct: the maker's signer, the taker's signer, or either
|
|
147
125
|
* side of a cash-out. A vault agent the account granted may sign the taker's
|
|
148
|
-
* TakerAccept
|
|
126
|
+
* TakerAccept and SellBack, and an Exit back to the account;
|
|
149
127
|
* only the account itself signs an AgentGrant.
|
|
150
128
|
*/
|
|
151
129
|
export declare const signedBy: {
|
|
152
130
|
readonly Quote: "maker";
|
|
153
131
|
readonly TakerAccept: "taker";
|
|
154
132
|
readonly SellBack: "maker_and_taker";
|
|
155
|
-
readonly CashoutTransfer: "maker_and_taker";
|
|
156
133
|
readonly Exit: "taker";
|
|
157
134
|
readonly AgentGrant: "taker";
|
|
158
135
|
};
|
|
@@ -207,11 +184,6 @@ export declare function takerAcceptTypedData(deployment: TotalisDeployment, quot
|
|
|
207
184
|
* owner accepts it. `position_id` from the API goes into `ticketId`.
|
|
208
185
|
*/
|
|
209
186
|
export declare function sellBackTypedData(deployment: TotalisDeployment, bid: Schemas["SellBackTerms"]): TotalisTypedData<"SellBack">;
|
|
210
|
-
/**
|
|
211
|
-
* A cash-out transfer of a position to a buying maker; the maker quotes it and
|
|
212
|
-
* the seller accepts it. `position_id` from the API goes into `ticketId`.
|
|
213
|
-
*/
|
|
214
|
-
export declare function cashoutTransferTypedData(deployment: TotalisDeployment, bid: Schemas["TransferTerms"]): TotalisTypedData<"CashoutTransfer">;
|
|
215
187
|
/** The vault leg of a withdrawal: the Exit that moves its shortfall from the vault to the wallet. */
|
|
216
188
|
export declare function exitTypedData(deployment: TotalisDeployment, exit: {
|
|
217
189
|
account: Hex;
|
package/dist/typed-data.js
CHANGED
|
@@ -31,15 +31,6 @@ export const totalisTypes = {
|
|
|
31
31
|
{ name: "salt", type: "uint256" },
|
|
32
32
|
{ name: "legState", type: "bytes32" },
|
|
33
33
|
],
|
|
34
|
-
CashoutTransfer: [
|
|
35
|
-
{ name: "ticketId", type: "bytes32" },
|
|
36
|
-
{ name: "price", type: "uint128" },
|
|
37
|
-
{ name: "seller", type: "address" },
|
|
38
|
-
{ name: "buyer", type: "address" },
|
|
39
|
-
{ name: "expiry", type: "uint64" },
|
|
40
|
-
{ name: "salt", type: "uint256" },
|
|
41
|
-
{ name: "legState", type: "bytes32" },
|
|
42
|
-
],
|
|
43
34
|
Exit: [
|
|
44
35
|
{ name: "account", type: "address" },
|
|
45
36
|
{ name: "to", type: "address" },
|
|
@@ -57,14 +48,13 @@ export const totalisTypes = {
|
|
|
57
48
|
/**
|
|
58
49
|
* Who signs each struct: the maker's signer, the taker's signer, or either
|
|
59
50
|
* side of a cash-out. A vault agent the account granted may sign the taker's
|
|
60
|
-
* TakerAccept
|
|
51
|
+
* TakerAccept and SellBack, and an Exit back to the account;
|
|
61
52
|
* only the account itself signs an AgentGrant.
|
|
62
53
|
*/
|
|
63
54
|
export const signedBy = {
|
|
64
55
|
Quote: "maker",
|
|
65
56
|
TakerAccept: "taker",
|
|
66
57
|
SellBack: "maker_and_taker",
|
|
67
|
-
CashoutTransfer: "maker_and_taker",
|
|
68
58
|
Exit: "taker",
|
|
69
59
|
AgentGrant: "taker",
|
|
70
60
|
};
|
|
@@ -117,16 +107,6 @@ export function sellBackTypedData(deployment, bid) {
|
|
|
117
107
|
message: { ticketId: bid.position_id, price: BigInt(bid.price), owner: bid.owner, expiry: BigInt(bid.expiry), salt: BigInt(bid.salt), legState: bid.leg_state },
|
|
118
108
|
};
|
|
119
109
|
}
|
|
120
|
-
/**
|
|
121
|
-
* A cash-out transfer of a position to a buying maker; the maker quotes it and
|
|
122
|
-
* the seller accepts it. `position_id` from the API goes into `ticketId`.
|
|
123
|
-
*/
|
|
124
|
-
export function cashoutTransferTypedData(deployment, bid) {
|
|
125
|
-
return {
|
|
126
|
-
domain: domain(deployment), types: { CashoutTransfer: totalisTypes.CashoutTransfer }, primaryType: "CashoutTransfer",
|
|
127
|
-
message: { ticketId: bid.position_id, price: BigInt(bid.price), seller: bid.seller, buyer: bid.buyer, expiry: BigInt(bid.expiry), salt: BigInt(bid.salt), legState: bid.leg_state },
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
110
|
/** The vault leg of a withdrawal: the Exit that moves its shortfall from the vault to the wallet. */
|
|
131
111
|
export function exitTypedData(deployment, exit) {
|
|
132
112
|
return {
|
package/dist/ui.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { acceptBefore, bestBid, bestQuote } from "./totalis.js";
|
|
2
2
|
const everyResource = ["BALANCES", "CAPITAL", "ACTIVITY", "POSITIONS", "PERFORMANCE", "TELEMETRY", "QUOTES", "ACCESS"];
|
|
3
|
-
const expiryOf = (quote) => (quote.kind === "ENTRY" ? quote.entry : quote.
|
|
3
|
+
const expiryOf = (quote) => (quote.kind === "ENTRY" ? quote.entry : quote.sell_back).expiry;
|
|
4
4
|
/**
|
|
5
5
|
* A small framework-agnostic bridge from the account stream to a UI: quotes
|
|
6
6
|
* from the subscription, the venue clock, account invalidations for a query
|
|
@@ -47,7 +47,7 @@ export async function openPosition(totalis, { legs, stake, onQuotes }) {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Cash out a position at the best quote. The wallet signs the quote's SellBack
|
|
50
|
-
*
|
|
50
|
+
* before the accept; ACCEPTED means the sale is queued as
|
|
51
51
|
* `operationId`. Any other status (DECLINED, TIMED_OUT, CANCELLED, NOT_ADMITTED)
|
|
52
52
|
* sold nothing.
|
|
53
53
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totalis/hip4-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.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": [
|