@dcasegr/amm-client 0.0.0-stage → 0.38.1
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/README.md +107 -2
- package/dist/client.d.ts +534 -0
- package/dist/client.js +1319 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.js +75 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +53 -0
- package/dist/lib/config.d.ts +42 -0
- package/dist/lib/config.js +64 -0
- package/dist/lib/keys.d.ts +42 -0
- package/dist/lib/keys.js +48 -0
- package/dist/lib/overlay.d.ts +190 -0
- package/dist/lib/overlay.js +302 -0
- package/dist/lib/skein.d.ts +82 -0
- package/dist/lib/skein.js +142 -0
- package/dist/lib/tokenId.d.ts +72 -0
- package/dist/lib/tokenId.js +121 -0
- package/dist/lp/amounts.d.ts +12 -0
- package/dist/lp/amounts.js +38 -0
- package/dist/lp/close.d.ts +90 -0
- package/dist/lp/close.js +140 -0
- package/dist/lp/images.d.ts +11 -0
- package/dist/lp/images.js +45 -0
- package/dist/lp/inventory.d.ts +68 -0
- package/dist/lp/inventory.js +84 -0
- package/dist/lp/poolDeploy.d.ts +220 -0
- package/dist/lp/poolDeploy.js +291 -0
- package/dist/lp/poolRows.d.ts +13 -0
- package/dist/lp/poolRows.js +19 -0
- package/dist/lp/positions.d.ts +81 -0
- package/dist/lp/positions.js +144 -0
- package/dist/lp/rebalance.d.ts +101 -0
- package/dist/lp/rebalance.js +168 -0
- package/dist/lp/wallet.d.ts +12 -0
- package/dist/lp/wallet.js +19 -0
- package/dist/market/activeSwap.d.ts +158 -0
- package/dist/market/activeSwap.js +320 -0
- package/dist/market/plan.d.ts +85 -0
- package/dist/market/plan.js +149 -0
- package/dist/market/prices.d.ts +13 -0
- package/dist/market/prices.js +14 -0
- package/dist/market/relay.d.ts +84 -0
- package/dist/market/relay.js +201 -0
- package/dist/market/swapAction.d.ts +306 -0
- package/dist/market/swapAction.js +508 -0
- package/dist/market/swapFlow.d.ts +58 -0
- package/dist/market/swapFlow.js +86 -0
- package/dist/market/view.d.ts +58 -0
- package/dist/market/view.js +63 -0
- package/dist/pool/artifact.d.ts +23 -0
- package/dist/pool/artifact.js +38 -0
- package/dist/pool/index.d.ts +8 -0
- package/dist/pool/index.js +8 -0
- package/dist/pool/oneColor.d.ts +19 -0
- package/dist/pool/oneColor.js +39 -0
- package/dist/pool/pool.artifact.json +5069 -0
- package/dist/pool/runar-ir-schema.d.ts +21 -0
- package/dist/pool/runar-ir-schema.js +18 -0
- package/dist/pool/template.d.ts +295 -0
- package/dist/pool/template.js +715 -0
- package/dist/vendor/runar/LICENSE +21 -0
- package/dist/vendor/runar/NOTICE +15 -0
- package/dist/vendor/runar/runar-ir-schema/src/abi-type-encoding.d.ts +42 -0
- package/dist/vendor/runar/runar-ir-schema/src/abi-type-encoding.js +53 -0
- package/dist/vendor/runar/runar-ir-schema/src/anf-ir.d.ts +221 -0
- package/dist/vendor/runar/runar-ir-schema/src/anf-ir.js +33 -0
- package/dist/vendor/runar/runar-ir-schema/src/artifact.d.ts +288 -0
- package/dist/vendor/runar/runar-ir-schema/src/artifact.js +8 -0
- package/dist/vendor/runar/runar-ir-schema/src/canonical-json.d.ts +43 -0
- package/dist/vendor/runar/runar-ir-schema/src/canonical-json.js +204 -0
- package/dist/vendor/runar/runar-ir-schema/src/input-limits.d.ts +89 -0
- package/dist/vendor/runar/runar-ir-schema/src/input-limits.js +100 -0
- package/dist/vendor/runar/runar-ir-schema/src/stack-ir.d.ts +118 -0
- package/dist/vendor/runar/runar-ir-schema/src/stack-ir.js +8 -0
- package/dist/vendor/runar/runar-ir-schema/src/state-layout.d.ts +56 -0
- package/dist/vendor/runar/runar-ir-schema/src/state-layout.js +145 -0
- package/dist/vendor/runar/runar-ir-schema/src/unknown-anf-kind-error.d.ts +18 -0
- package/dist/vendor/runar/runar-ir-schema/src/unknown-anf-kind-error.js +25 -0
- package/dist/vendor/runar/runar-sdk/src/anf-interpreter.d.ts +160 -0
- package/dist/vendor/runar/runar-sdk/src/anf-interpreter.js +1149 -0
- package/dist/vendor/runar/runar-sdk/src/calling.d.ts +98 -0
- package/dist/vendor/runar/runar-sdk/src/calling.js +209 -0
- package/dist/vendor/runar/runar-sdk/src/contract.d.ts +443 -0
- package/dist/vendor/runar/runar-sdk/src/contract.js +2516 -0
- package/dist/vendor/runar/runar-sdk/src/deployment.d.ts +36 -0
- package/dist/vendor/runar/runar-sdk/src/deployment.js +119 -0
- package/dist/vendor/runar/runar-sdk/src/errors.d.ts +46 -0
- package/dist/vendor/runar/runar-sdk/src/errors.js +59 -0
- package/dist/vendor/runar/runar-sdk/src/oppushtx.d.ts +23 -0
- package/dist/vendor/runar/runar-sdk/src/oppushtx.js +95 -0
- package/dist/vendor/runar/runar-sdk/src/ordinals/envelope.d.ts +31 -0
- package/dist/vendor/runar/runar-sdk/src/ordinals/envelope.js +272 -0
- package/dist/vendor/runar/runar-sdk/src/ordinals/types.d.ts +21 -0
- package/dist/vendor/runar/runar-sdk/src/ordinals/types.js +4 -0
- package/dist/vendor/runar/runar-sdk/src/providers/provider.d.ts +65 -0
- package/dist/vendor/runar/runar-sdk/src/providers/provider.js +59 -0
- package/dist/vendor/runar/runar-sdk/src/providers/wallet-provider.d.ts +94 -0
- package/dist/vendor/runar/runar-sdk/src/providers/wallet-provider.js +297 -0
- package/dist/vendor/runar/runar-sdk/src/script-utils.d.ts +54 -0
- package/dist/vendor/runar/runar-sdk/src/script-utils.js +252 -0
- package/dist/vendor/runar/runar-sdk/src/signers/signer.d.ts +17 -0
- package/dist/vendor/runar/runar-sdk/src/signers/signer.js +4 -0
- package/dist/vendor/runar/runar-sdk/src/spend-safety.d.ts +31 -0
- package/dist/vendor/runar/runar-sdk/src/spend-safety.js +35 -0
- package/dist/vendor/runar/runar-sdk/src/state.d.ts +54 -0
- package/dist/vendor/runar/runar-sdk/src/state.js +584 -0
- package/dist/vendor/runar/runar-sdk/src/types.d.ts +227 -0
- package/dist/vendor/runar/runar-sdk/src/types.js +4 -0
- package/dist/vendor/runar/runar-sdk/src/unsound-primitives.d.ts +30 -0
- package/dist/vendor/runar/runar-sdk/src/unsound-primitives.js +42 -0
- package/dist/vendor/runar/runar-sdk.d.ts +9 -0
- package/dist/vendor/runar/runar-sdk.js +8 -0
- package/dist/wallet/action.d.ts +28 -0
- package/dist/wallet/action.js +42 -0
- package/dist/wallet/brc29.d.ts +83 -0
- package/dist/wallet/brc29.js +80 -0
- package/dist/wallet/color.d.ts +110 -0
- package/dist/wallet/color.js +134 -0
- package/dist/wallet/swapPayouts.d.ts +35 -0
- package/dist/wallet/swapPayouts.js +146 -0
- package/package.json +39 -4
package/README.md
CHANGED
|
@@ -1,3 +1,108 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dcasegr/amm-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Open Exchange client (skein-amm): every read and every action the Open Exchange pages make —
|
|
4
|
+
the token list, prices, quotes and swaps, pool deploy / close / rebalance, Move back, positions,
|
|
5
|
+
the root's settings — over a BRC-100 wallet, bound by `createClient` to one exchange. ESM with
|
|
6
|
+
type declarations; no React, no styles, no wallet provider (connect the wallet yourself and pass
|
|
7
|
+
it in). The source is skein-amm's `web/ui/src` (the pages' own); the matching engine is
|
|
8
|
+
[`@dcasegr/amm-engine`](../engine). Versions follow the skein-amm release.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
npm install @dcasegr/amm-client @bsv/sdk @1sat/templates @bsv/color-permission-module
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`@bsv/sdk` (4), `@1sat/templates` and `@bsv/color-permission-module` are peer dependencies: one
|
|
17
|
+
copy, the wallet's. The wallet must carry the BRC-207 1Color module (`@bsv/color-permission-module`)
|
|
18
|
+
for the token actions.
|
|
19
|
+
|
|
20
|
+
## createClient
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { createClient } from "@dcasegr/amm-client";
|
|
24
|
+
|
|
25
|
+
const client = createClient({
|
|
26
|
+
origin: "https://swap.skein.nexus", // the exchange: an origin (the swap app at <origin>/amm) or the app's base URL
|
|
27
|
+
feeRateSatsPerKb: 100, // the miner fee rate a swap leg's staged sats are sized with (default 100)
|
|
28
|
+
wallet, // a BRC-100 WalletInterface; null or absent: reads only
|
|
29
|
+
fetch, // optional: the plain fetch (default the global one)
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`createClient(opts: ClientOptions): AmmClient`, where `ClientOptions` is `{ origin: string;
|
|
34
|
+
feeRateSatsPerKb?: number; wallet?: WalletInterface | null; fetch?: FetchLike; signedFor?: (base)
|
|
35
|
+
=> Signed; identityKey?: string | null }` (`signedFor`: the wallet's BRC-104 client per instance,
|
|
36
|
+
default one `AuthFetch` session per instance; `identityKey`: default read from the wallet when
|
|
37
|
+
needed). Nothing reads `import.meta.env` or `location`. `client.withWallet(wallet)` is the same
|
|
38
|
+
exchange with another wallet, keeping what was read and quoted.
|
|
39
|
+
|
|
40
|
+
The client (each an async function unless noted):
|
|
41
|
+
|
|
42
|
+
- the exchange: `enabledList`, `registeredTokens`, `tokenBaseOf`, `hostedTokens`,
|
|
43
|
+
`watchHostedPools` / `watchTokenPools` (event streams, sync, return the unsubscribe),
|
|
44
|
+
`claimStatus`, `isRoot`, `claimExchange`, `discoveryBase` (sync), `onDataChange` (sync);
|
|
45
|
+
- swap: `quoteSwap(request, poolsAnswer, {sym, dec})` (sync: the engine's plan over the pools the
|
|
46
|
+
token's pools stream gave), `executeSwap(quote, {onProgress})`, `checkSwapAgain(leg)`,
|
|
47
|
+
`walletSats`;
|
|
48
|
+
- liquidity: `myPositions`, `validatorTerms`, `deployPosition({tokenId, tokens, sats})`,
|
|
49
|
+
`closePosition({outpoint})`, `rebalancePosition({outpoint, tokens, sats})` (the old pool closed
|
|
50
|
+
and a new one deployed in ONE wallet createAction);
|
|
51
|
+
- your tokens: `myTokens`, `settleSwaps` (the silent pass over staged swap legs: the txids taken
|
|
52
|
+
in), `moveBackTokens(tokenId)` (what it did: txid, amount, BEEF, submit), `sendTokens`;
|
|
53
|
+
- settings (root): `deployBeef`, `enableToken`, `tokensToEnable`, `disableToken`, `defaults`,
|
|
54
|
+
`setDefaultTerms`, `clearDefaultTerms`, `setDefaultMarket`, `clearDefaultMarket`, `tokenTerms`,
|
|
55
|
+
`setTokenTerms`, `discoveryState`, `setDiscovery`.
|
|
56
|
+
|
|
57
|
+
Pure helpers beside it: `hostedFrom`, `poolViews`, `poolFees`, `withLeg`, `hasTerms`,
|
|
58
|
+
`enableCandidates`, `topicOf`, `lookupOf`, `ammLookupOf`, `walletDeployBeef`, `exchangeBase`,
|
|
59
|
+
`tokenBase`; the types (`Quote`, `SwapResult`, `LegResult`, `Position`, `WalletToken`, …).
|
|
60
|
+
|
|
61
|
+
## Errors
|
|
62
|
+
|
|
63
|
+
An error of one of `CLIENT_ERROR_KINDS` is a `ClientError` with `kind` and the message the pages
|
|
64
|
+
show: `stale_pool`, `fee_mismatch`, `quote_mismatch`, `slippage`, `pool_spent`, `user_rejected`,
|
|
65
|
+
`no_answer`, `refused`, `network`. A swap leg that did not fill carries its `kind` beside its
|
|
66
|
+
`error` text. `errorKind(e)` classifies any error; other errors stay plain `Error`s.
|
|
67
|
+
|
|
68
|
+
## The shared names
|
|
69
|
+
|
|
70
|
+
What two sites must use to file identical wallet rows: `POOLS_BASKET` (`amm-pools`, the LP's
|
|
71
|
+
position rows), `SWAP_BASKET` (`amm-swap`, what swap legs spend), `SWAP_PROTOCOL` (`[2, "amm
|
|
72
|
+
swap"]`), `SWAP_KEY_PREFIX` + `swapKeyID` (the staged rows' keyIDs), `swapInstructions` /
|
|
73
|
+
`swapSatsInstructions` (their customInstructions), `LP_KEY_PROTOCOL` (BRC-29) + `LP_KEY_MARK` +
|
|
74
|
+
`lpKeyDescription` / `lpKeyIdOfDescription` (the deploy's pool output description naming the LP
|
|
75
|
+
keyID), `POOL_TAG` / `POOL_OP` / `isPoolRow` / `poolCustomInstructions` (an `amm-pools` row),
|
|
76
|
+
`POOL_DEPLOY_LABEL` (`amm-pool-deploy`), `SWAP_TTL_MS` (15 s), `transferPlanLabels` (the `p color
|
|
77
|
+
plan` labels), the receipt helpers `newReceivingKey` / `receiptOutput`, and `xTopics` (the BRC-22
|
|
78
|
+
`x-topics` header: a JSON array).
|
|
79
|
+
|
|
80
|
+
## A swap
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { createClient, ClientError } from "@dcasegr/amm-client";
|
|
84
|
+
|
|
85
|
+
const client = createClient({ origin: "https://swap.skein.nexus", wallet });
|
|
86
|
+
const tokenId = "<txid>_0";
|
|
87
|
+
|
|
88
|
+
// The token's pools route as an event stream: the pools a swap may use, the market.
|
|
89
|
+
const stop = client.watchTokenPools(tokenId, async (pools) => {
|
|
90
|
+
stop();
|
|
91
|
+
const quote = client.quoteSwap({ tokenId, side: "buy", amountIn: 50_000n, maxSlippageBps: 50, allowPartial: false }, pools, { sym: "TOK", dec: 0 });
|
|
92
|
+
try {
|
|
93
|
+
const result = await client.executeSwap(quote, { onProgress: (p) => console.log(p.phase) });
|
|
94
|
+
console.log(result.status, result.legs);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
if (e instanceof ClientError && e.kind === "pool_spent") console.log("quote again");
|
|
97
|
+
else throw e;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Build
|
|
103
|
+
|
|
104
|
+
From skein-amm's `web/`: `npm ci` in `ui` and in `engine`, then `npm pack` here (the build
|
|
105
|
+
compiles `../ui/src/index.ts` with `../ui`'s TypeScript into `dist/`, after building the engine).
|
|
106
|
+
|
|
107
|
+
runar-sdk is vendored inside (`dist/vendor/runar`, MIT: its `LICENSE` and `NOTICE` there): the
|
|
108
|
+
runar-sdk the pool template is built on is not published.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Open Exchange client (skein-amm 0.38.0, D8–D14, agent-env plans/history-api-2026-11-05.md):
|
|
3
|
+
* every read and every action the pages make, bound by `createClient` to one exchange, one miner
|
|
4
|
+
* fee rate, one wallet and one fetch — configuration as arguments (D9): nothing here reads
|
|
5
|
+
* `import.meta.env` or `location`. No React; the pages (src/data/exchange.ts) hold a client and
|
|
6
|
+
* wrap it in their hooks. Published as `@dcasegr/amm-client` (src/index.ts; README "The packages").
|
|
7
|
+
*
|
|
8
|
+
* 0.34.0 (agent-env plans/exchange-api-2026-11-04.md §0, D1–D25; docs/AMM.md "The public read
|
|
9
|
+
* API"): every read is a plain GET of the exchange's public read API (src/lib/overlay.ts), and the
|
|
10
|
+
* client sends `/lookup` nowhere. Where each comes from:
|
|
11
|
+
*
|
|
12
|
+
* - **The token list** (`GET <swap>/tokens`): read ONCE per client (D4; `enabledList`), again
|
|
13
|
+
* only after its own enable or disable changed it.
|
|
14
|
+
* - **Prices** (D6, D22): the host-wide pools route `GET <origin>/amm/pools` (`hostedTokens`,
|
|
15
|
+
* `watchHostedPools`); a token's price is Σsats / Σtokens over its listed pools.
|
|
16
|
+
* - **Swap** (D11–D16): the token's pools route `GET /@<token>/amm/pools` held as an event stream
|
|
17
|
+
* (`watchTokenPools`): the pools whose validator is beating and whose commission meets the
|
|
18
|
+
* market's minimum (the host's filter), the market's commission key hash; a quote is the
|
|
19
|
+
* matching engine's plan over that list (no request); a swap reads ONE `GET
|
|
20
|
+
* /@<token>/amm/pools/beef?lp=` for its legs (freshness, the pools' BEEF), then each leg's relay
|
|
21
|
+
* request (`amm.swap.submit`, held by the host until the relay rests; 15 s expiry); a lost answer
|
|
22
|
+
* is "no answer yet" with "Check again" (`GET /@<token>/amm/swaps?id=`, once).
|
|
23
|
+
* - **Liquidity** (D9, D23): the wallet's pool rows and deploy history, then ONE `GET
|
|
24
|
+
* /@<token>/amm/positions?lp=` per token; a deploy the history has but the basket lacks is
|
|
25
|
+
* filed then; Close and Rebalance read their pool's BEEF by LP key (`/pools/beef?lp=`); the
|
|
26
|
+
* deploy's terms `GET /@<token>/amm/terms`.
|
|
27
|
+
* - **Your tokens** (D17, D18, D19, D24): the wallet's module and the swap basket; the token list
|
|
28
|
+
* once and ONE discovery `GET /@discovery/1color/tokens?ids=` for held tokens the list lacks; a
|
|
29
|
+
* silent pass over the swap basket's staged legs (src/wallet/swapPayouts.ts); Move back submits
|
|
30
|
+
* at the host root.
|
|
31
|
+
* - **Settings** (D20, D21): the claim card (`claimStatus`: swap's identity, the recipient of
|
|
32
|
+
* root's messages), the token list once, discovery's list and ONE `?ids=` read; Enable's deploy
|
|
33
|
+
* BEEF from the wallet's basket else `GET /@discovery/1color/<token>/deploy`.
|
|
34
|
+
*
|
|
35
|
+
* Ids (David, 2026-10-09): every token id is the BRC-207 assetId
|
|
36
|
+
* `<txid>_<vout>`, `_0` included for a 1Color token (src/lib/tokenId.ts);
|
|
37
|
+
* an outpoint is `<txid>.<vout>`. Amounts are bigints in base units; prices
|
|
38
|
+
* are numbers: sats per whole token.
|
|
39
|
+
*/
|
|
40
|
+
import { type WalletInterface } from "@bsv/sdk";
|
|
41
|
+
import { type Send1ColorResult } from "@1sat/actions";
|
|
42
|
+
import { type PoolState, type Plan } from "@dcasegr/amm-engine";
|
|
43
|
+
import { type LiveAnswer, type PoolRow, type PoolsAnswer, type SignedFetch } from "./lib/overlay.js";
|
|
44
|
+
import { type Defaults, type Discovery, type EnabledToken, type ListedToken } from "./lib/skein.js";
|
|
45
|
+
import type { AuthFetchLike } from "./market/relay.js";
|
|
46
|
+
import { type PreparedSwap } from "./market/swapAction.js";
|
|
47
|
+
import { type MovedBack } from "./market/activeSwap.js";
|
|
48
|
+
import { type PositionRow } from "./lp/positions.js";
|
|
49
|
+
import { ClientError, type ClientErrorKind } from "./errors.js";
|
|
50
|
+
/** A token id: the BRC-207 assetId `<txid>_<vout>`, `_0` included (src/lib/tokenId.ts). */
|
|
51
|
+
export type TokenId = string;
|
|
52
|
+
/** What a swap of 2% of the price costs: the sats a buy needs to move the marginal price up by `bps`. */
|
|
53
|
+
export interface Depth {
|
|
54
|
+
bps: number;
|
|
55
|
+
sats: bigint;
|
|
56
|
+
}
|
|
57
|
+
/** A token this overlay hosts (registered here), with its pools summed. */
|
|
58
|
+
export interface HostedToken {
|
|
59
|
+
tokenId: TokenId;
|
|
60
|
+
sym: string;
|
|
61
|
+
dec: number;
|
|
62
|
+
/** An image URL (a data: URL of the deploy's embedded icon, or an ORDFS URL). */
|
|
63
|
+
icon?: string;
|
|
64
|
+
/** Sats per whole token across the token's pools: what the next small swap pays. Null with no open pool. */
|
|
65
|
+
marginalPrice: number | null;
|
|
66
|
+
depth: Depth | null;
|
|
67
|
+
/** Number of open pools. */
|
|
68
|
+
pools: number;
|
|
69
|
+
/** All pools summed. */
|
|
70
|
+
reserves: {
|
|
71
|
+
sats: bigint;
|
|
72
|
+
tokens: bigint;
|
|
73
|
+
};
|
|
74
|
+
/** Price change over 24 h, a fraction (0.018 = +1.8%). Absent when not known. */
|
|
75
|
+
change24h?: number;
|
|
76
|
+
}
|
|
77
|
+
/** One open pool of a token, as a quote routes over it. */
|
|
78
|
+
export interface PoolView {
|
|
79
|
+
/** `<txid>.<vout>` */
|
|
80
|
+
outpoint: string;
|
|
81
|
+
tokenId: TokenId;
|
|
82
|
+
sats: bigint;
|
|
83
|
+
tokens: bigint;
|
|
84
|
+
validator: ValidatorRef;
|
|
85
|
+
}
|
|
86
|
+
export interface ValidatorRef {
|
|
87
|
+
identityKey: string;
|
|
88
|
+
live: boolean;
|
|
89
|
+
}
|
|
90
|
+
/** "buy": pay sats, receive the token. "sell": pay the token, receive sats. */
|
|
91
|
+
export type Side = "buy" | "sell";
|
|
92
|
+
export interface QuoteRequest {
|
|
93
|
+
tokenId: TokenId;
|
|
94
|
+
side: Side;
|
|
95
|
+
/** Base units of what is paid (sats on a buy, token base units on a sell). */
|
|
96
|
+
amountIn: bigint;
|
|
97
|
+
/** Max slippage against the quoted amount out, basis points. */
|
|
98
|
+
maxSlippageBps: number;
|
|
99
|
+
allowPartial: boolean;
|
|
100
|
+
}
|
|
101
|
+
export interface QuoteLeg {
|
|
102
|
+
/** The pool, `<txid>.<vout>`. */
|
|
103
|
+
poolOutpoint: string;
|
|
104
|
+
amountIn: bigint;
|
|
105
|
+
amountOut: bigint;
|
|
106
|
+
/** Share of the amount in, basis points (the legs sum to 10000). */
|
|
107
|
+
shareBps: number;
|
|
108
|
+
/** The pool's reserves before the leg. */
|
|
109
|
+
reserves: {
|
|
110
|
+
sats: bigint;
|
|
111
|
+
tokens: bigint;
|
|
112
|
+
};
|
|
113
|
+
validator: ValidatorRef;
|
|
114
|
+
}
|
|
115
|
+
export interface Quote {
|
|
116
|
+
request: QuoteRequest;
|
|
117
|
+
legs: QuoteLeg[];
|
|
118
|
+
amountOut: bigint;
|
|
119
|
+
/** The least amount out the swap accepts: amountOut less max slippage. */
|
|
120
|
+
minAmountOut: bigint;
|
|
121
|
+
/** Sats per whole token this swap pays (fees included). */
|
|
122
|
+
effectivePrice: number;
|
|
123
|
+
/** Sats per whole token before the swap. */
|
|
124
|
+
marginalPrice: number;
|
|
125
|
+
/** |effective − marginal| / marginal, basis points. */
|
|
126
|
+
impactBps: number;
|
|
127
|
+
/** The validator's fees applied to every leg. */
|
|
128
|
+
fees: Fees;
|
|
129
|
+
}
|
|
130
|
+
export interface LegResult {
|
|
131
|
+
poolOutpoint: string;
|
|
132
|
+
status: "filled" | "failed";
|
|
133
|
+
txid?: string;
|
|
134
|
+
error?: string;
|
|
135
|
+
/** 0.31.1: the leg was refused `pool_spent`, repriced against the pool's newest state and sent again. */
|
|
136
|
+
repriced?: true;
|
|
137
|
+
/** 0.34.0 (D15): no answer yet — the swap's id, for "Check again" (`checkSwapAgain`). */
|
|
138
|
+
checkId?: string;
|
|
139
|
+
/** 0.38.0 (D13): the failure's kind, when it has one (`error` stays the text). */
|
|
140
|
+
kind?: ClientErrorKind;
|
|
141
|
+
}
|
|
142
|
+
export interface SwapResult {
|
|
143
|
+
status: "filled" | "partial" | "failed";
|
|
144
|
+
legs: LegResult[];
|
|
145
|
+
}
|
|
146
|
+
/** The validator's fees, basis points of the amount in. The LP accepts them; there is no fee input. */
|
|
147
|
+
export interface Fees {
|
|
148
|
+
lpBps: number;
|
|
149
|
+
validatorBps: number;
|
|
150
|
+
/** The relay's commission (the pool's CommissionBps); 0: none. */
|
|
151
|
+
commissionBps: number;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* `amm.pool.terms`'s refusal when no terms are set (0.15.0, David Case
|
|
155
|
+
* 2026-10-23: terms are a runtime record root sets; unset, a market only).
|
|
156
|
+
*/
|
|
157
|
+
export declare const NO_VALIDATOR = "no validator here";
|
|
158
|
+
/** What the pages show in place of the terms when none are set. */
|
|
159
|
+
export declare const NO_TERMS_TEXT = "This exchange validates nothing: no terms are set.";
|
|
160
|
+
/** No terms are set on this skein (`amm.pool.terms` answered "no validator here"): a market only. */
|
|
161
|
+
export interface NoTerms {
|
|
162
|
+
none: true;
|
|
163
|
+
}
|
|
164
|
+
/** Whether `t` is a validator's terms (not "none set"). */
|
|
165
|
+
export declare function hasTerms(t: ValidatorTerms | NoTerms | null | undefined): t is ValidatorTerms;
|
|
166
|
+
/** The validator a new position is deployed with, and its fees (read-only on the page). */
|
|
167
|
+
export interface ValidatorTerms {
|
|
168
|
+
validator: ValidatorRef;
|
|
169
|
+
/** "this exchange's" when the validator is this skein. */
|
|
170
|
+
isThisExchange: boolean;
|
|
171
|
+
fees: Fees;
|
|
172
|
+
}
|
|
173
|
+
/** One of the user's pools. A position is only deployed or closed (no add, no partial remove). */
|
|
174
|
+
export interface Position {
|
|
175
|
+
/** The pool, `<txid>.<vout>`. */
|
|
176
|
+
outpoint: string;
|
|
177
|
+
tokenId: TokenId;
|
|
178
|
+
sym: string;
|
|
179
|
+
dec: number;
|
|
180
|
+
icon?: string;
|
|
181
|
+
sats: bigint;
|
|
182
|
+
tokens: bigint;
|
|
183
|
+
/** Fees the pool has earned the LP, when it can be told (0.32.0: the sats-in swaps' LP fees, `ls_amm_<assetId>` `{tokenId, lpPubKey}`). */
|
|
184
|
+
feesEarnedSats?: bigint;
|
|
185
|
+
/** 0.32.0: the token-in swaps' LP fees, token base units; told with `feesEarnedSats`. */
|
|
186
|
+
feesEarnedTokens?: bigint;
|
|
187
|
+
/** 0.32.0: the pool is closed (the LP's Close or a rescind's); kept for its fees, not listed as a card. */
|
|
188
|
+
closed?: boolean;
|
|
189
|
+
validator: ValidatorRef;
|
|
190
|
+
/** The validator rescinded the pool (0.13.0): no swaps; the LP closes it. */
|
|
191
|
+
rescinded?: boolean;
|
|
192
|
+
}
|
|
193
|
+
export interface DeployRequest {
|
|
194
|
+
tokenId: TokenId;
|
|
195
|
+
/** Token base units. */
|
|
196
|
+
tokens: bigint;
|
|
197
|
+
sats: bigint;
|
|
198
|
+
}
|
|
199
|
+
export interface DeployResult {
|
|
200
|
+
/** The new pool, `<txid>.<vout>`. */
|
|
201
|
+
outpoint: string;
|
|
202
|
+
txid: string;
|
|
203
|
+
/** What did not complete after the broadcast (the position row's filing, the page's own submit). */
|
|
204
|
+
warnings?: string[];
|
|
205
|
+
}
|
|
206
|
+
export interface CloseRequest {
|
|
207
|
+
outpoint: string;
|
|
208
|
+
}
|
|
209
|
+
export interface RebalanceRequest {
|
|
210
|
+
/** The position's pool, `<txid>.<vout>`. */
|
|
211
|
+
outpoint: string;
|
|
212
|
+
/** The new pool's tokens, base units. */
|
|
213
|
+
tokens: bigint;
|
|
214
|
+
/** The new pool's sats. */
|
|
215
|
+
sats: bigint;
|
|
216
|
+
}
|
|
217
|
+
export interface RebalanceResult {
|
|
218
|
+
/** The new pool, `<txid>.0`. */
|
|
219
|
+
outpoint: string;
|
|
220
|
+
txid: string;
|
|
221
|
+
/** The old pool's output the same transaction closed. */
|
|
222
|
+
closed: string;
|
|
223
|
+
/** What did not complete after the broadcast (the new position row's filing, the page's own submit). */
|
|
224
|
+
warnings?: string[];
|
|
225
|
+
}
|
|
226
|
+
export interface CloseResult {
|
|
227
|
+
txid: string;
|
|
228
|
+
/** Returned to the wallet. */
|
|
229
|
+
sats: bigint;
|
|
230
|
+
tokens: bigint;
|
|
231
|
+
}
|
|
232
|
+
/** One of the user's own 1Color tokens. */
|
|
233
|
+
export interface WalletToken {
|
|
234
|
+
tokenId: TokenId;
|
|
235
|
+
sym: string;
|
|
236
|
+
dec: number;
|
|
237
|
+
icon?: string;
|
|
238
|
+
/** The wallet's balance: the sum of the token's held value outputs in `p color assets` (0.27.0; was the module's `p color balance`). */
|
|
239
|
+
balance: bigint;
|
|
240
|
+
/** How many wallet outputs hold it. */
|
|
241
|
+
outputs: number;
|
|
242
|
+
/** Held in the exchange's active swap basket (`amm-swap`): spent by swap legs, or moved back. */
|
|
243
|
+
inSwaps: bigint;
|
|
244
|
+
/** Sats staged in `amm-swap` for the token's swap legs (0.29.6): spent by swap legs, or moved back. */
|
|
245
|
+
swapSats: number;
|
|
246
|
+
/** Registered on this exchange. */
|
|
247
|
+
onExchange: boolean;
|
|
248
|
+
}
|
|
249
|
+
/** A token seen on the discovery topic (`tm_color`). */
|
|
250
|
+
export interface DiscoveryToken {
|
|
251
|
+
tokenId: TokenId;
|
|
252
|
+
sym: string;
|
|
253
|
+
dec: number;
|
|
254
|
+
icon?: string;
|
|
255
|
+
/** When discovery first saw it, ms. */
|
|
256
|
+
seenAt?: number;
|
|
257
|
+
}
|
|
258
|
+
/** A token on this exchange's list (the swap instance's enable list), as Settings lists it. */
|
|
259
|
+
export interface RegisteredToken {
|
|
260
|
+
tokenId: TokenId;
|
|
261
|
+
sym: string;
|
|
262
|
+
icon?: string;
|
|
263
|
+
status: EnabledToken["status"];
|
|
264
|
+
}
|
|
265
|
+
export type { EnabledToken, Defaults, Discovery, PoolRow, PoolsAnswer };
|
|
266
|
+
/** A token's symbol, decimals and icon, read off its deploy output. */
|
|
267
|
+
export interface DeployMeta {
|
|
268
|
+
sym?: string;
|
|
269
|
+
dec?: number;
|
|
270
|
+
icon?: string;
|
|
271
|
+
}
|
|
272
|
+
/** A token's deploy as `deployBeef` finds it: its Atomic BEEF, its metadata, and where it came from. */
|
|
273
|
+
export interface DeployFound {
|
|
274
|
+
beef: number[];
|
|
275
|
+
meta: DeployMeta;
|
|
276
|
+
from: "wallet" | "discovery";
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Whether the exchange is claimed, its admin, and swap's identity (0.28.0: swap is born owned by the
|
|
280
|
+
* host's key, so `/.well-known/skein`'s `claimed` is always true; the claim is the swap app's own record,
|
|
281
|
+
* `GET <base>/admin` → `{claimant?, since?}`). `identity` from `/.well-known/skein` (the claim's recipient).
|
|
282
|
+
* A swap with no `/admin` read (pages older than open-exchange 0.5.0): `claimed` as `/.well-known/skein` says.
|
|
283
|
+
*/
|
|
284
|
+
export interface ClaimStatus {
|
|
285
|
+
claimed: boolean;
|
|
286
|
+
identity: string;
|
|
287
|
+
claimant?: string;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* The hosted tokens (the enabled 1Color tokens at output 0), each priced from its rows of the
|
|
291
|
+
* host-wide pools route (D6, D22: P1, the pools whose validator is beating): Σsats / Σtokens.
|
|
292
|
+
* `rows` null: not read yet (no prices). Pure.
|
|
293
|
+
*/
|
|
294
|
+
export declare function hostedFrom(list: EnabledToken[], rows: PoolRow[] | null): HostedToken[];
|
|
295
|
+
/** The pools the Swap page lists (D11, D13): the token's pools route's rows, every validator live (the host lists no other). */
|
|
296
|
+
export declare function poolViews(answer: PoolsAnswer | null, tokenId: TokenId): PoolView[];
|
|
297
|
+
/** The fees a pool's own record names (D13: the Swap page's fee line), basis points. */
|
|
298
|
+
export declare function poolFees(p: Pick<PoolState, "liquidityFeeBps" | "validationFeeBps" | "commissionBps">): Fees;
|
|
299
|
+
/** A swap's result with one leg replaced (after "Check again"). */
|
|
300
|
+
export declare function withLeg(r: SwapResult, leg: LegResult): SwapResult;
|
|
301
|
+
/**
|
|
302
|
+
* wallet-toolbox's `specOpWalletBalance` (`sdk.specOpWalletBalance`, @bsv/wallet-toolbox-client): the listOutputs "basket" of its
|
|
303
|
+
* balance special operation. Written out, not imported: the client package exports it only inside its `sdk` namespace, which
|
|
304
|
+
* pulls ~560 kB into the bundle; test/exchange.test.ts checks it equals the toolbox's.
|
|
305
|
+
*/
|
|
306
|
+
export declare const SPEC_OP_WALLET_BALANCE = "893b7646de0e1c9f741bd6e9169b76a8847ae34adef7bef1e6a285371206d2e8";
|
|
307
|
+
/** The topic a token's pools are admitted under (BRC-207; skein-amm 0.8.0): derived, never typed. */
|
|
308
|
+
export declare function topicOf(tokenId: TokenId): string;
|
|
309
|
+
/** The lookup service of a token (BRC-207): derived, never typed. */
|
|
310
|
+
export declare function lookupOf(tokenId: TokenId): string;
|
|
311
|
+
/** The AMM lookup's service of a token, `ls_amm_<assetId>` (0.21.0): a token instance's config names it, so it beats its prices on `ls_amm_<assetId>-live` (skein-overlay 0.17.0: a configured lookup beats). */
|
|
312
|
+
export declare function ammLookupOf(tokenId: TokenId): string;
|
|
313
|
+
/**
|
|
314
|
+
* A token deploy's BEEF from the connected wallet (0.17.0), as the 1Color tokens page gets it
|
|
315
|
+
* (skein-1color web/src/overlay.ts `walletDeployBeef`): the deploy output in the module's basket
|
|
316
|
+
* `p color <txid>v<vout>` (then its `authority` basket), its transaction as BEEF (`include: "entire
|
|
317
|
+
* transactions"`), as an Atomic BEEF of the deploy. Undefined when the wallet holds it in neither
|
|
318
|
+
* (not the deployer's, or the output spent).
|
|
319
|
+
*/
|
|
320
|
+
export declare function walletDeployBeef(wallet: WalletInterface, tokenId: TokenId): Promise<number[] | undefined>;
|
|
321
|
+
/** What enabling a token reports: where the deploy's BEEF came from (2026-10-31: the wallet's basket or discovery; no paste). */
|
|
322
|
+
export interface EnableSent {
|
|
323
|
+
beefFrom: "wallet" | "discovery";
|
|
324
|
+
}
|
|
325
|
+
/** A token Settings offers to enable (2026-10-31): on discovery, in this wallet, or both; not on the list yet. */
|
|
326
|
+
export interface EnableCandidate {
|
|
327
|
+
tokenId: TokenId;
|
|
328
|
+
sym?: string;
|
|
329
|
+
icon?: string;
|
|
330
|
+
onDiscovery: boolean;
|
|
331
|
+
inWallet: boolean;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* The candidates to enable: discovery's token list (its order, newest first, with its metadata),
|
|
335
|
+
* then the tokens only this wallet holds (in the order held); every token already on the swap
|
|
336
|
+
* instance's list (enabled or disabled) left out. Pure: the reads are `tokensToEnable`'s.
|
|
337
|
+
*/
|
|
338
|
+
export declare function enableCandidates(listed: ListedToken[], walletIds: string[], onList: string[]): EnableCandidate[];
|
|
339
|
+
/** The three fees root sets (basis points, integers 0 to 10 000). */
|
|
340
|
+
export interface TermsInput {
|
|
341
|
+
lpBps: number;
|
|
342
|
+
validatorBps: number;
|
|
343
|
+
commissionBps: number;
|
|
344
|
+
}
|
|
345
|
+
/** What a quote was planned from: kept for its execution. */
|
|
346
|
+
interface Planned {
|
|
347
|
+
plan: Plan;
|
|
348
|
+
pools: PoolRow[];
|
|
349
|
+
live: LiveAnswer;
|
|
350
|
+
market: PoolsAnswer["market"];
|
|
351
|
+
dec: number;
|
|
352
|
+
sym: string;
|
|
353
|
+
}
|
|
354
|
+
/** A plain fetch (the reads, the submits, the BRC-104 transport). */
|
|
355
|
+
export type FetchLike = (url: string, init?: RequestInit) => Promise<Response>;
|
|
356
|
+
/** The wallet's BRC-104 client for one instance base (src/lib/skein.ts `authFetchPerInstance`). */
|
|
357
|
+
export type Signed = SignedFetch & AuthFetchLike;
|
|
358
|
+
export interface ClientOptions {
|
|
359
|
+
/**
|
|
360
|
+
* The exchange: its origin (`https://swap.skein.nexus`: the swap app at `<origin>/amm`) or the
|
|
361
|
+
* swap app's base URL with a path (`http://127.0.0.1:8100/@swap/amm`), as the pages compute it.
|
|
362
|
+
*/
|
|
363
|
+
origin: string;
|
|
364
|
+
/** The miner fee rate the client sizes a swap leg's staged sats with, sats per 1000 bytes. Default 100. */
|
|
365
|
+
feeRateSatsPerKb?: number;
|
|
366
|
+
/** The connected BRC-100 wallet; null or absent: a client for the reads (actions answer "Connect a wallet first"). */
|
|
367
|
+
wallet?: WalletInterface | null;
|
|
368
|
+
/** The plain fetch for every unsigned request and the BRC-104 transport. Default: the global `fetch`, looked up at each call. */
|
|
369
|
+
fetch?: FetchLike;
|
|
370
|
+
/** The wallet's BRC-104 client per instance base. Default: `authFetchPerInstance(wallet, fetch)` (one session per instance). */
|
|
371
|
+
signedFor?: (base: string) => Signed;
|
|
372
|
+
/** The wallet's identity key, when the caller has it (the claim's check). Default: read from the wallet when needed. */
|
|
373
|
+
identityKey?: string | null;
|
|
374
|
+
}
|
|
375
|
+
/** Where a swap is (`executeSwap`'s `onProgress`, D12), in this order; `leg` the pool outpoint (`<txid>.<vout>`) of a leg event. */
|
|
376
|
+
export type SwapProgress = {
|
|
377
|
+
phase: "staging";
|
|
378
|
+
} | {
|
|
379
|
+
phase: "relaying";
|
|
380
|
+
leg: string;
|
|
381
|
+
} | {
|
|
382
|
+
phase: "repricing";
|
|
383
|
+
leg: string;
|
|
384
|
+
} | {
|
|
385
|
+
phase: "done";
|
|
386
|
+
result: SwapResult;
|
|
387
|
+
} | {
|
|
388
|
+
phase: "failed";
|
|
389
|
+
result?: SwapResult;
|
|
390
|
+
error?: ClientError | Error;
|
|
391
|
+
};
|
|
392
|
+
export interface SwapOptions {
|
|
393
|
+
/** Called as the swap moves (D12): `staging` (the swap basket is filled for the legs), `relaying` (per leg), `repricing` (a leg refused `pool_spent`, re-quoted), then `done` (a leg filled) or `failed` (none did, or it threw). */
|
|
394
|
+
onProgress?: (p: SwapProgress) => void;
|
|
395
|
+
}
|
|
396
|
+
/** What a client remembers between calls; shared by `withWallet`'s clients. */
|
|
397
|
+
interface Shared {
|
|
398
|
+
/** The token list read by this client (D4: once; again only after its own enable or disable). */
|
|
399
|
+
listRead: Promise<EnabledToken[]> | null;
|
|
400
|
+
/** swap's claim card read by this client (D21: the identity of the recipient of root's messages). */
|
|
401
|
+
claimRead: ClaimStatus | null;
|
|
402
|
+
/** What each quote was planned from: kept for its execution. */
|
|
403
|
+
planned: WeakMap<Quote, Planned>;
|
|
404
|
+
/** The legs whose answer did not come: their prepared swap, for "Check again" (D15). */
|
|
405
|
+
checks: Map<string, {
|
|
406
|
+
prepared: PreparedSwap;
|
|
407
|
+
base: string;
|
|
408
|
+
af: Signed;
|
|
409
|
+
}>;
|
|
410
|
+
/** The positions last loaded, by the output a Close acts on (`<txid>.<vout>`): the wallet's row (its LP key) and the token. */
|
|
411
|
+
loaded: Map<string, PositionRow>;
|
|
412
|
+
/** `onDataChange`'s listeners. */
|
|
413
|
+
listeners: Set<() => void>;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* The client of one exchange (D9): its reads over `origin` (src/lib/overlay.ts, src/lib/skein.ts),
|
|
417
|
+
* the swap flow, the pool flows (deploy, close, rebalance, move back, positions) and the wallet
|
|
418
|
+
* pieces, bound to `feeRateSatsPerKb`, `wallet` and `fetch`. Errors of the kinds in
|
|
419
|
+
* `CLIENT_ERROR_KINDS` are `ClientError`s (D13), the message as before.
|
|
420
|
+
*/
|
|
421
|
+
export declare function createClient(opts: ClientOptions): AmmClient;
|
|
422
|
+
export type AmmClient = ReturnType<typeof makeClient>;
|
|
423
|
+
declare function makeClient(opts: ClientOptions, s: Shared): {
|
|
424
|
+
/** The swap app's base URL (`origin` as given, or `<origin>/amm`). */
|
|
425
|
+
base: string;
|
|
426
|
+
feeRateSatsPerKb: number;
|
|
427
|
+
wallet: WalletInterface | null;
|
|
428
|
+
withWallet: (wallet: WalletInterface | null, o?: {
|
|
429
|
+
signedFor?: (base: string) => Signed;
|
|
430
|
+
identityKey?: string | null;
|
|
431
|
+
}) => {
|
|
432
|
+
/** The swap app's base URL (`origin` as given, or `<origin>/amm`). */
|
|
433
|
+
base: string;
|
|
434
|
+
feeRateSatsPerKb: number;
|
|
435
|
+
wallet: WalletInterface | null;
|
|
436
|
+
withWallet: /*elided*/ any;
|
|
437
|
+
onDataChange: (fn: () => void) => () => void;
|
|
438
|
+
forgetReads: () => void;
|
|
439
|
+
enabledList: () => Promise<EnabledToken[]>;
|
|
440
|
+
tokenBaseOf: (tokenId: string) => Promise<string>;
|
|
441
|
+
hostRoot: () => string;
|
|
442
|
+
discoveryBase: () => string;
|
|
443
|
+
claimStatus: () => Promise<ClaimStatus>;
|
|
444
|
+
isRoot: (identityKey: string | null) => Promise<boolean>;
|
|
445
|
+
claimExchange: () => Promise<boolean>;
|
|
446
|
+
hostedTokens: () => Promise<HostedToken[]>;
|
|
447
|
+
watchHostedPools: (onRows: (rows: PoolRow[]) => void, onLive?: (live: boolean) => void) => () => void;
|
|
448
|
+
watchTokenPools: (tokenId: TokenId, onAnswer: (a: PoolsAnswer) => void, onError?: (e: unknown) => void) => () => void;
|
|
449
|
+
registeredTokens: () => Promise<RegisteredToken[]>;
|
|
450
|
+
quoteSwap: (req: QuoteRequest, held: PoolsAnswer | null, meta: {
|
|
451
|
+
sym: string;
|
|
452
|
+
dec: number;
|
|
453
|
+
}) => Quote;
|
|
454
|
+
executeSwap: (quote: Quote, o?: SwapOptions) => Promise<SwapResult>;
|
|
455
|
+
checkSwapAgain: (leg: LegResult) => Promise<LegResult>;
|
|
456
|
+
walletSats: () => Promise<bigint>;
|
|
457
|
+
myPositions: () => Promise<Position[]>;
|
|
458
|
+
validatorTerms: (tokenId: string) => Promise<NoTerms | ValidatorTerms>;
|
|
459
|
+
deployPosition: (req: DeployRequest) => Promise<DeployResult>;
|
|
460
|
+
closePosition: (req: CloseRequest) => Promise<CloseResult>;
|
|
461
|
+
rebalancePosition: (req: RebalanceRequest) => Promise<RebalanceResult>;
|
|
462
|
+
myTokens: () => Promise<WalletToken[]>;
|
|
463
|
+
settleSwaps: () => Promise<string[]>;
|
|
464
|
+
moveBackTokens: (tokenId: string) => Promise<MovedBack>;
|
|
465
|
+
sendTokens: (tokenId: string, handle: string, amount: bigint, memo?: string | undefined) => Promise<Send1ColorResult>;
|
|
466
|
+
deployBeef: (tokenId: string, wallet?: WalletInterface | null | undefined) => Promise<DeployFound>;
|
|
467
|
+
enableToken: (tokenId: string) => Promise<EnableSent>;
|
|
468
|
+
tokensToEnable: () => Promise<EnableCandidate[]>;
|
|
469
|
+
disableToken: (tokenId: string) => Promise<void>;
|
|
470
|
+
defaults: () => Promise<Defaults>;
|
|
471
|
+
setDefaultTerms: (t: TermsInput) => Promise<void>;
|
|
472
|
+
tokenTerms: (tokenId: string) => Promise<{
|
|
473
|
+
identity: string;
|
|
474
|
+
peerId: string | null;
|
|
475
|
+
lpFeeBps: number;
|
|
476
|
+
validatorFeeBps: number;
|
|
477
|
+
commissionBps: number;
|
|
478
|
+
} | null>;
|
|
479
|
+
setTokenTerms: (tokenId: string, t: TermsInput | null) => Promise<void>;
|
|
480
|
+
clearDefaultTerms: () => Promise<void>;
|
|
481
|
+
setDefaultMarket: (minCommissionBps: number) => Promise<void>;
|
|
482
|
+
clearDefaultMarket: () => Promise<void>;
|
|
483
|
+
discoveryState: () => Promise<Discovery>;
|
|
484
|
+
setDiscovery: (on: boolean) => Promise<void>;
|
|
485
|
+
};
|
|
486
|
+
onDataChange: (fn: () => void) => () => void;
|
|
487
|
+
forgetReads: () => void;
|
|
488
|
+
enabledList: () => Promise<EnabledToken[]>;
|
|
489
|
+
tokenBaseOf: (tokenId: string) => Promise<string>;
|
|
490
|
+
hostRoot: () => string;
|
|
491
|
+
discoveryBase: () => string;
|
|
492
|
+
claimStatus: () => Promise<ClaimStatus>;
|
|
493
|
+
isRoot: (identityKey: string | null) => Promise<boolean>;
|
|
494
|
+
claimExchange: () => Promise<boolean>;
|
|
495
|
+
hostedTokens: () => Promise<HostedToken[]>;
|
|
496
|
+
watchHostedPools: (onRows: (rows: PoolRow[]) => void, onLive?: (live: boolean) => void) => () => void;
|
|
497
|
+
watchTokenPools: (tokenId: TokenId, onAnswer: (a: PoolsAnswer) => void, onError?: (e: unknown) => void) => () => void;
|
|
498
|
+
registeredTokens: () => Promise<RegisteredToken[]>;
|
|
499
|
+
quoteSwap: (req: QuoteRequest, held: PoolsAnswer | null, meta: {
|
|
500
|
+
sym: string;
|
|
501
|
+
dec: number;
|
|
502
|
+
}) => Quote;
|
|
503
|
+
executeSwap: (quote: Quote, o?: SwapOptions) => Promise<SwapResult>;
|
|
504
|
+
checkSwapAgain: (leg: LegResult) => Promise<LegResult>;
|
|
505
|
+
walletSats: () => Promise<bigint>;
|
|
506
|
+
myPositions: () => Promise<Position[]>;
|
|
507
|
+
validatorTerms: (tokenId: string) => Promise<NoTerms | ValidatorTerms>;
|
|
508
|
+
deployPosition: (req: DeployRequest) => Promise<DeployResult>;
|
|
509
|
+
closePosition: (req: CloseRequest) => Promise<CloseResult>;
|
|
510
|
+
rebalancePosition: (req: RebalanceRequest) => Promise<RebalanceResult>;
|
|
511
|
+
myTokens: () => Promise<WalletToken[]>;
|
|
512
|
+
settleSwaps: () => Promise<string[]>;
|
|
513
|
+
moveBackTokens: (tokenId: string) => Promise<MovedBack>;
|
|
514
|
+
sendTokens: (tokenId: string, handle: string, amount: bigint, memo?: string | undefined) => Promise<Send1ColorResult>;
|
|
515
|
+
deployBeef: (tokenId: string, wallet?: WalletInterface | null | undefined) => Promise<DeployFound>;
|
|
516
|
+
enableToken: (tokenId: string) => Promise<EnableSent>;
|
|
517
|
+
tokensToEnable: () => Promise<EnableCandidate[]>;
|
|
518
|
+
disableToken: (tokenId: string) => Promise<void>;
|
|
519
|
+
defaults: () => Promise<Defaults>;
|
|
520
|
+
setDefaultTerms: (t: TermsInput) => Promise<void>;
|
|
521
|
+
tokenTerms: (tokenId: string) => Promise<{
|
|
522
|
+
identity: string;
|
|
523
|
+
peerId: string | null;
|
|
524
|
+
lpFeeBps: number;
|
|
525
|
+
validatorFeeBps: number;
|
|
526
|
+
commissionBps: number;
|
|
527
|
+
} | null>;
|
|
528
|
+
setTokenTerms: (tokenId: string, t: TermsInput | null) => Promise<void>;
|
|
529
|
+
clearDefaultTerms: () => Promise<void>;
|
|
530
|
+
setDefaultMarket: (minCommissionBps: number) => Promise<void>;
|
|
531
|
+
clearDefaultMarket: () => Promise<void>;
|
|
532
|
+
discoveryState: () => Promise<Discovery>;
|
|
533
|
+
setDiscovery: (on: boolean) => Promise<void>;
|
|
534
|
+
};
|