@owney/sdk 0.7.26-beta.4 → 0.7.26-beta.6
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/dist/index.cjs +842 -116
- package/dist/index.d.cts +328 -34
- package/dist/index.d.ts +328 -34
- package/dist/index.js +845 -115
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -147,12 +147,30 @@ type SwapQuote = {
|
|
|
147
147
|
*/
|
|
148
148
|
permitSupported?: boolean;
|
|
149
149
|
/**
|
|
150
|
-
* True only for a cross-chain swap FROM native ETH, which
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
150
|
+
* True only for a cross-chain swap FROM native ETH, which Fusion+ cannot
|
|
151
|
+
* take as a source: the escrow pulls the maker's funds with `transferFrom`,
|
|
152
|
+
* and no signature can move native value. Left unread, the order signs
|
|
153
|
+
* perfectly well and the relayer refuses it with a bare 502 — after the user
|
|
154
|
+
* has already signed (ROUT-242).
|
|
155
|
+
*
|
|
156
|
+
* So the client wraps first and swaps `wrappedNative` instead. ERC-20
|
|
157
|
+
* sources are signature-only after their one-time approval.
|
|
154
158
|
*/
|
|
155
159
|
requiresOnchainOrder: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* The ERC-20 the source chain's native asset wraps into. Present only
|
|
162
|
+
* alongside `requiresOnchainOrder`.
|
|
163
|
+
*
|
|
164
|
+
* Comes from the routing API rather than a client-side lookup because the
|
|
165
|
+
* wrapper cannot be derived from the symbol: "WETH" on Polygon is bridged
|
|
166
|
+
* Ether, an entirely different asset from wrapped POL. This address receives
|
|
167
|
+
* the user's whole swap amount as msg.value, so guessing it is not an option.
|
|
168
|
+
*/
|
|
169
|
+
wrappedNative?: {
|
|
170
|
+
symbol: string;
|
|
171
|
+
address: string;
|
|
172
|
+
decimals: number;
|
|
173
|
+
};
|
|
156
174
|
/**
|
|
157
175
|
* What the swap costs, as the provider reports it on this quote.
|
|
158
176
|
*
|
|
@@ -202,7 +220,7 @@ type SwapOrderStatus = "pending" | "executed" | "expired" | "cancelled" | "refun
|
|
|
202
220
|
* of the flow and the one place a user would otherwise think nothing is
|
|
203
221
|
* happening.
|
|
204
222
|
*/
|
|
205
|
-
type SwapStage = "withdrawing" | "withdrawn" | "quoting" | "approving" | "signing" | "swapping" | "swapped" | "depositing" | "refunding" | "refunded";
|
|
223
|
+
type SwapStage = "withdrawing" | "withdrawn" | "quoting" | "wrapping" | "wrapped" | "approving" | "signing" | "swapping" | "swapped" | "depositing" | "refunding" | "refunded";
|
|
206
224
|
/**
|
|
207
225
|
* Which way the funds travel, which decides what each side may be.
|
|
208
226
|
*
|
|
@@ -742,6 +760,156 @@ type AgentApyOptions = {
|
|
|
742
760
|
chainId?: number;
|
|
743
761
|
};
|
|
744
762
|
|
|
763
|
+
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "SWAP_DISABLED" | "SWAP_RATE_LIMITED" | "SWAP_REQUEST_FAILED" | "SWAP_QUOTE_FAILED" | "SWAP_UNSUPPORTED_PAIR" | "SWAP_APPROVAL_REQUIRED" | "SWAP_BELOW_DEPOSIT_MINIMUM" | "SWAP_DEPOSIT_PENDING" | "SWAP_WALLET_PROMPT_TIMEOUT" | "SWAP_INSUFFICIENT_GAS" | "SWAP_NATIVE_UNSUPPORTED" | "SWAP_ORDER_EXPIRED" | "SWAP_ORDER_REFUNDED" | "SWAP_ORDER_CANCELLED" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
764
|
+
declare class OwneyError extends Error {
|
|
765
|
+
readonly code: OwneyErrorCode;
|
|
766
|
+
readonly details?: Record<string, unknown>;
|
|
767
|
+
readonly agentId?: string;
|
|
768
|
+
constructor(code: OwneyErrorCode, message: string, details?: Record<string, unknown>, agentId?: string);
|
|
769
|
+
}
|
|
770
|
+
declare class AgentNotFoundError extends OwneyError {
|
|
771
|
+
constructor(agentId: string, available: string[]);
|
|
772
|
+
}
|
|
773
|
+
declare class NotConnectedError extends OwneyError {
|
|
774
|
+
constructor();
|
|
775
|
+
}
|
|
776
|
+
declare class AgentChainIncompatibleError extends OwneyError {
|
|
777
|
+
readonly incompatibleAgents: Array<{
|
|
778
|
+
agentId: string;
|
|
779
|
+
supportedChainIds: readonly number[];
|
|
780
|
+
}>;
|
|
781
|
+
readonly connectedChainId: number;
|
|
782
|
+
constructor(incompatibleAgents: Array<{
|
|
783
|
+
agentId: string;
|
|
784
|
+
supportedChainIds: readonly number[];
|
|
785
|
+
}>, connectedChainId: number);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Withdrawal swaps the user has walked away from, and how they ended.
|
|
790
|
+
*
|
|
791
|
+
* The deposit side has `swap.pending-deposit.ts` for the same shape of
|
|
792
|
+
* problem, but the two are not symmetrical. A pending deposit is a JOB: the
|
|
793
|
+
* money is in the wallet and an ordinary deposit finishes it. This is a
|
|
794
|
+
* WATCH — the funds are in escrow, nothing the user does moves them along,
|
|
795
|
+
* and the only question is where they ended up.
|
|
796
|
+
*
|
|
797
|
+
* That is the whole reason this exists. `withdrawAndSwap` used to hold the
|
|
798
|
+
* screen for the entire escrow lifecycle, which on a slow mainnet fill is
|
|
799
|
+
* minutes of a modal the user cannot leave (ROUT-242). Backgrounding it means
|
|
800
|
+
* the outcome arrives after the UI that started it has gone, so the outcome
|
|
801
|
+
* has to be written down somewhere the next render can find it.
|
|
802
|
+
*
|
|
803
|
+
* Only cross-chain swaps are recorded. A same-chain classic swap is one
|
|
804
|
+
* transaction and resolves in seconds; a same-chain fusion order has no stored
|
|
805
|
+
* preimages, so there would be nothing for a reloaded session to resume and
|
|
806
|
+
* the record would sit at `swapping` for ever.
|
|
807
|
+
*
|
|
808
|
+
* Kept deliberately separate from the secret store. Secrets are retired the
|
|
809
|
+
* moment an order reaches a verdict — that is a safety property, not a display
|
|
810
|
+
* one — and the record has to outlive them so the user can still be told what
|
|
811
|
+
* happened after they come back.
|
|
812
|
+
*/
|
|
813
|
+
/**
|
|
814
|
+
* `swapping` is the only non-terminal state. `unknown` is what a watch that
|
|
815
|
+
* gave up looks like: we stopped polling before the order spoke, so the order
|
|
816
|
+
* may well have filled. It is not a failure, and it must never be shown as
|
|
817
|
+
* one.
|
|
818
|
+
*/
|
|
819
|
+
type WithdrawSwapStatus = "swapping" | "landed" | "refunded" | "unknown";
|
|
820
|
+
type WithdrawSwapRecord = {
|
|
821
|
+
/** Identity. One record per Fusion+ order. */
|
|
822
|
+
orderHash: string;
|
|
823
|
+
status: WithdrawSwapStatus;
|
|
824
|
+
/**
|
|
825
|
+
* What actually left the agent, smallest unit of the SOURCE asset.
|
|
826
|
+
*
|
|
827
|
+
* The measured figure, not the requested one — a "MAX" withdrawal has no
|
|
828
|
+
* requested figure at all, and this is what a refund gives back.
|
|
829
|
+
*/
|
|
830
|
+
withdrawn: string;
|
|
831
|
+
srcSymbol: string;
|
|
832
|
+
srcChainId: number;
|
|
833
|
+
srcDecimals: number;
|
|
834
|
+
/**
|
|
835
|
+
* What the quote expected to arrive, smallest unit of the DESTINATION.
|
|
836
|
+
*
|
|
837
|
+
* `dst.amount` — the auction's start, not its floor. The bar reads "about",
|
|
838
|
+
* and quoting the floor understated every completed withdrawal by half a
|
|
839
|
+
* percent (ROUT-242, comment 16056).
|
|
840
|
+
*/
|
|
841
|
+
expected: string;
|
|
842
|
+
dstSymbol: string;
|
|
843
|
+
dstChainId: number;
|
|
844
|
+
dstDecimals: number;
|
|
845
|
+
/** Measured arrival. Set only on `landed`, and shown in place of `expected`. */
|
|
846
|
+
received?: string;
|
|
847
|
+
/** Epoch ms. */
|
|
848
|
+
createdAt: number;
|
|
849
|
+
/** Epoch ms, set when the status stopped being `swapping`. */
|
|
850
|
+
settledAt?: number;
|
|
851
|
+
};
|
|
852
|
+
declare function subscribeWithdrawSwaps(listener: () => void): () => void;
|
|
853
|
+
/**
|
|
854
|
+
* Write the record as the order is submitted, alongside the secrets.
|
|
855
|
+
*
|
|
856
|
+
* Not after the swap resolves: the point is to survive the gap between submit
|
|
857
|
+
* and settle, which is exactly when the user closes the tab.
|
|
858
|
+
*/
|
|
859
|
+
declare function saveWithdrawSwap(record: WithdrawSwapRecord): void;
|
|
860
|
+
/**
|
|
861
|
+
* Move a record to its outcome.
|
|
862
|
+
*
|
|
863
|
+
* A no-op for an order with no record, which is the normal case for deposit
|
|
864
|
+
* swaps — they share the secret store and so pass through the same resume
|
|
865
|
+
* loop, but they are not withdrawals and were never recorded here.
|
|
866
|
+
*
|
|
867
|
+
* `settledAt` is stamped here rather than by the caller so every writer agrees
|
|
868
|
+
* on what "settled" means: the moment the status stopped being `swapping`.
|
|
869
|
+
*/
|
|
870
|
+
declare function updateWithdrawSwap(orderHash: string, patch: Partial<Omit<WithdrawSwapRecord, "orderHash">>): void;
|
|
871
|
+
/** The user has read the outcome. Only they do this. */
|
|
872
|
+
declare function clearWithdrawSwap(orderHash: string): void;
|
|
873
|
+
/** Every record, newest first, sweeping anything past MAX_AGE_MS. */
|
|
874
|
+
declare function listWithdrawSwaps(now?: number): WithdrawSwapRecord[];
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Swaps that landed but were never deposited.
|
|
878
|
+
*
|
|
879
|
+
* `swapAndDeposit` does two things, and the deposit is the line after the
|
|
880
|
+
* swap. When the swap works and the deposit does not, the user is left holding
|
|
881
|
+
* the swapped asset with the form back on screen and nothing to say why
|
|
882
|
+
* (ROUT-242, comment 15980) — and the error they got said "your funds have not
|
|
883
|
+
* been moved", which is exactly wrong and makes a retry spend them twice.
|
|
884
|
+
*
|
|
885
|
+
* So the outcome is written down. Recovering it needs no order, no secret and
|
|
886
|
+
* no signature: the money is already in the wallet in the right asset, and
|
|
887
|
+
* what is missing is an ordinary deposit. Recording it is what lets the reload
|
|
888
|
+
* the user actually performs pick the job back up.
|
|
889
|
+
*
|
|
890
|
+
* Storage failures are swallowed everywhere here. Losing the note is bad;
|
|
891
|
+
* failing the swap because we could not write the note is worse.
|
|
892
|
+
*/
|
|
893
|
+
type PendingDeposit = {
|
|
894
|
+
/** Stable id so a retry can clear exactly the one it handled. */
|
|
895
|
+
id: string;
|
|
896
|
+
/** What arrived, in the asset's smallest unit. */
|
|
897
|
+
received: string;
|
|
898
|
+
/** The deposit asset. */
|
|
899
|
+
symbol: string;
|
|
900
|
+
/**
|
|
901
|
+
* The chain the funds are ON, which for a cross-chain swap is the
|
|
902
|
+
* DESTINATION — depositing against the source would read an empty wallet.
|
|
903
|
+
*/
|
|
904
|
+
chainId: number;
|
|
905
|
+
/** Narrows the deposit to one agent when the caller asked for one. */
|
|
906
|
+
agentId?: string;
|
|
907
|
+
/** Epoch ms, for the sweep. */
|
|
908
|
+
createdAt: number;
|
|
909
|
+
};
|
|
910
|
+
/** Every record, dismissed ones included, newest first. Sweeps as it goes. */
|
|
911
|
+
declare function listPendingDeposits(now?: number): PendingDeposit[];
|
|
912
|
+
|
|
745
913
|
declare class OwneySDK {
|
|
746
914
|
private agents;
|
|
747
915
|
private activeAgents;
|
|
@@ -929,6 +1097,22 @@ declare class OwneySDK {
|
|
|
929
1097
|
* network has actually changed.
|
|
930
1098
|
*/
|
|
931
1099
|
private ensureSwapChain;
|
|
1100
|
+
/**
|
|
1101
|
+
* Turn a native-source cross-chain quote into an ERC-20 one.
|
|
1102
|
+
*
|
|
1103
|
+
* Fusion+ cannot escrow native value, so the quote arrives with
|
|
1104
|
+
* `requiresOnchainOrder` set and the relayer would refuse the order after
|
|
1105
|
+
* the user signed it (ROUT-242). Wrapping first costs one transaction and
|
|
1106
|
+
* puts the swap back on the ERC-20 rail that already works, rather than
|
|
1107
|
+
* adding a second order type that would need its own escrow handling.
|
|
1108
|
+
*
|
|
1109
|
+
* Re-quoted afterwards rather than patched: the amount wrapped may be less
|
|
1110
|
+
* than the amount quoted (gas has to come out of the same balance), and
|
|
1111
|
+
* every executor dep — allowance, permit, balances — is derived from the
|
|
1112
|
+
* quote's source token. A quote naming ETH would have all of them reading
|
|
1113
|
+
* the wrong asset.
|
|
1114
|
+
*/
|
|
1115
|
+
private wrapNativeSource;
|
|
932
1116
|
/**
|
|
933
1117
|
* Binds the executor's abstract deps to this client's wallet.
|
|
934
1118
|
*
|
|
@@ -936,6 +1120,28 @@ declare class OwneySDK {
|
|
|
936
1120
|
* flow stays testable without a provider — the executor never imports viem.
|
|
937
1121
|
*/
|
|
938
1122
|
private buildSwapDeps;
|
|
1123
|
+
/**
|
|
1124
|
+
* Waits until the WALLET'S OWN node reports at least `amount` of `token`.
|
|
1125
|
+
*
|
|
1126
|
+
* Separate from the swap's arrival measurement on purpose: that one runs on
|
|
1127
|
+
* a pinned HTTP RPC, and what matters here is the view the deposit will
|
|
1128
|
+
* actually use. Returns whether it got there — a courtesy, not a gate, since
|
|
1129
|
+
* the deposit's own check is the authority and refusing to even attempt
|
|
1130
|
+
* would strand funds we might have been able to move.
|
|
1131
|
+
*/
|
|
1132
|
+
private walletSeesBalance;
|
|
1133
|
+
/**
|
|
1134
|
+
* Runs a quoted swap. A named seam rather than an inline `executeSwap` call
|
|
1135
|
+
* so the deposit half of `swapAndDeposit` can be exercised on its own.
|
|
1136
|
+
*/
|
|
1137
|
+
private runSwap;
|
|
1138
|
+
/**
|
|
1139
|
+
* The half of the swap deps that only ever talks to the routing API.
|
|
1140
|
+
*
|
|
1141
|
+
* Split out because resuming an order needs exactly this and nothing else —
|
|
1142
|
+
* no provider, no wallet client, no chain. See `resumePendingSwaps`.
|
|
1143
|
+
*/
|
|
1144
|
+
private swapRunnerDeps;
|
|
939
1145
|
/**
|
|
940
1146
|
* Assets the user may pay with, and what each chain deposits into.
|
|
941
1147
|
*
|
|
@@ -945,6 +1151,82 @@ declare class OwneySDK {
|
|
|
945
1151
|
getSwapTokens(): Promise<{
|
|
946
1152
|
chains: SwapChainTokens[];
|
|
947
1153
|
}>;
|
|
1154
|
+
/**
|
|
1155
|
+
* Swaps that landed but were never deposited, newest first.
|
|
1156
|
+
*
|
|
1157
|
+
* The money is already in the wallet in the right asset — what is missing is
|
|
1158
|
+
* an ordinary deposit, which is why this needs no order and no signature to
|
|
1159
|
+
* describe. See `completePendingDeposit`.
|
|
1160
|
+
*/
|
|
1161
|
+
listPendingDeposits(): ReturnType<typeof listPendingDeposits>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Backgrounded withdrawal swaps and how they ended, newest first.
|
|
1164
|
+
*
|
|
1165
|
+
* Nothing to act on — unlike `listPendingDeposits`, which describes a job the
|
|
1166
|
+
* user can finish. This is a watch: the funds are in escrow and the only
|
|
1167
|
+
* open question is where they land. See `swap.withdraw-swap.ts`.
|
|
1168
|
+
*/
|
|
1169
|
+
listWithdrawSwaps(): WithdrawSwapRecord[];
|
|
1170
|
+
/**
|
|
1171
|
+
* Retire a settled record. The user has read the outcome.
|
|
1172
|
+
*
|
|
1173
|
+
* Only they do this — a record that disappears on its own takes with it the
|
|
1174
|
+
* only thing telling someone where their money went.
|
|
1175
|
+
*/
|
|
1176
|
+
dismissWithdrawSwap(orderHash: string): void;
|
|
1177
|
+
/**
|
|
1178
|
+
* Deposit a swap that already landed.
|
|
1179
|
+
*
|
|
1180
|
+
* Nothing is swapped again: the funds are in the wallet, so this is the
|
|
1181
|
+
* second half of `swapAndDeposit` on its own. Cleared only once the deposit
|
|
1182
|
+
* has actually gone through — a failure here leaves the record in place so it
|
|
1183
|
+
* can be offered again rather than silently dropped.
|
|
1184
|
+
*/
|
|
1185
|
+
completePendingDeposit(id: string): Promise<OwneyDepositResult | OwneyMultiDepositResult>;
|
|
1186
|
+
/**
|
|
1187
|
+
* Pick up cross-chain swaps a previous session left in flight.
|
|
1188
|
+
*
|
|
1189
|
+
* A Fusion+ order is only finished when the client publishes a secret for
|
|
1190
|
+
* each fill, once the escrows exist — so a user who closed the tab mid-swap
|
|
1191
|
+
* leaves an order nobody will ever complete, and it expires and refunds
|
|
1192
|
+
* instead of arriving. The preimages are stored for exactly this (24h sweep,
|
|
1193
|
+
* see the secret store); this is the other half.
|
|
1194
|
+
*
|
|
1195
|
+
* Needs NO wallet, deliberately. The signature already happened and the funds
|
|
1196
|
+
* are already escrowed, so finishing is pure API work — demanding a reconnect
|
|
1197
|
+
* first would strand the people it exists for.
|
|
1198
|
+
*
|
|
1199
|
+
* Every order is attempted even if an earlier one throws: they are unrelated
|
|
1200
|
+
* escrows, and one ending badly must not abandon the next one's secrets.
|
|
1201
|
+
* `unfinished` is not a verdict — the order may still settle, so unless the
|
|
1202
|
+
* chain has said refunded or cancelled its preimages are kept.
|
|
1203
|
+
*/
|
|
1204
|
+
resumePendingSwaps(options?: {
|
|
1205
|
+
onStage?: (orderHash: string, stage: SwapStage) => void;
|
|
1206
|
+
timeoutMs?: number;
|
|
1207
|
+
}): Promise<{
|
|
1208
|
+
orderHash: string;
|
|
1209
|
+
status: "completed" | "unfinished";
|
|
1210
|
+
error?: OwneyError;
|
|
1211
|
+
}[]>;
|
|
1212
|
+
/**
|
|
1213
|
+
* Pick up SAME-CHAIN orders a previous session left in the auction.
|
|
1214
|
+
*
|
|
1215
|
+
* They are not in the secret store and never will be: that store exists to
|
|
1216
|
+
* keep preimages, and a same-chain fill needs none — the resolver takes the
|
|
1217
|
+
* maker's tokens and delivers the taker's in one transaction. So the only
|
|
1218
|
+
* record of one is the withdrawal record itself, which carries the order
|
|
1219
|
+
* hash, and that is all a resume needs here.
|
|
1220
|
+
*
|
|
1221
|
+
* Gentler than the Fusion+ case in the way that matters. Nothing is
|
|
1222
|
+
* escrowed, so an order nobody ever picks up leaves the wallet exactly as it
|
|
1223
|
+
* was — this is catching up on news, not rescuing funds.
|
|
1224
|
+
*
|
|
1225
|
+
* Same-chain is read off the record rather than stored as a rail: a
|
|
1226
|
+
* withdrawal whose source and destination share a chain could not have been
|
|
1227
|
+
* anything else.
|
|
1228
|
+
*/
|
|
1229
|
+
private resumeSameChainSwaps;
|
|
948
1230
|
/**
|
|
949
1231
|
* What the wallet actually holds, across every supported chain, restricted
|
|
950
1232
|
* to tokens a swap could use.
|
|
@@ -976,13 +1258,24 @@ declare class OwneySDK {
|
|
|
976
1258
|
* tokens can share a ticker, and `providers` (how many token lists carry the
|
|
977
1259
|
* address) is the only usable signal for telling them apart. Surface it.
|
|
978
1260
|
*
|
|
979
|
-
*
|
|
1261
|
+
* A blank query WITH a chainId lists that chain's catalogue instead of
|
|
1262
|
+
* searching it — what a picker wants when someone selects a chain before
|
|
1263
|
+
* typing anything. Blank with no chain returns nothing: that would be asking
|
|
1264
|
+
* for the top of every catalogue at once, which is a download, not a list.
|
|
980
1265
|
*/
|
|
981
1266
|
searchSwapTokens(params: {
|
|
982
|
-
/** Omit to search every supported chain. */
|
|
1267
|
+
/** Omit to search every supported chain. Required to list one. */
|
|
983
1268
|
chainId?: number;
|
|
984
|
-
|
|
1269
|
+
/** Omit, with a chainId, to list the chain rather than search it. */
|
|
1270
|
+
query?: string;
|
|
985
1271
|
limit?: number;
|
|
1272
|
+
/**
|
|
1273
|
+
* Which picker is asking. A withdrawal ends in the user's own wallet, so
|
|
1274
|
+
* the "is this something anyone deliberately holds" gate is theirs to
|
|
1275
|
+
* waive; a deposit ends in an agent and stays curated. Omit it for the
|
|
1276
|
+
* curated list.
|
|
1277
|
+
*/
|
|
1278
|
+
direction?: SwapDirection;
|
|
986
1279
|
}): Promise<{
|
|
987
1280
|
tokens: SwapTokenSearchResult[];
|
|
988
1281
|
}>;
|
|
@@ -1078,6 +1371,32 @@ declare class OwneySDK {
|
|
|
1078
1371
|
/** Percent, classic rail only. Fusion+ prices through its auction. */
|
|
1079
1372
|
slippage?: number;
|
|
1080
1373
|
onSwapProgress?: (stage: SwapStage) => void;
|
|
1374
|
+
/**
|
|
1375
|
+
* Fires once the order is with the relayer, before the watch.
|
|
1376
|
+
*
|
|
1377
|
+
* Both resolver-filled rails reach it — cross-chain Fusion+ and the
|
|
1378
|
+
* same-chain auction. Not the classic rail, which is one transaction with
|
|
1379
|
+
* no order behind it and resolves in seconds either way.
|
|
1380
|
+
*
|
|
1381
|
+
* The seam a backgrounded withdrawal hangs off. Up to here the flow needs
|
|
1382
|
+
* the user in front of it; past here it is polling that a later page load
|
|
1383
|
+
* can take over — from the stored preimages on Fusion+, and from the
|
|
1384
|
+
* order hash alone on the same-chain rail. So a caller may stop awaiting
|
|
1385
|
+
* this promise and let the screen go. See `swap.withdraw-swap.ts` for what
|
|
1386
|
+
* the caller should write down when it does.
|
|
1387
|
+
*
|
|
1388
|
+
* Carries the two figures a status bar cannot get anywhere else. The
|
|
1389
|
+
* withdrawal has already happened by this point and `withdrawn` is what
|
|
1390
|
+
* MEASURABLY arrived, which on a "MAX" withdrawal is the only figure that
|
|
1391
|
+
* exists — and it is also what comes back if the order never fills.
|
|
1392
|
+
*/
|
|
1393
|
+
onOrderSubmitted?: (submitted: {
|
|
1394
|
+
orderHash: string;
|
|
1395
|
+
/** Smallest unit of the agent's asset. */
|
|
1396
|
+
withdrawn: string;
|
|
1397
|
+
/** Smallest unit of the destination — the auction's start, not its floor. */
|
|
1398
|
+
expected: string;
|
|
1399
|
+
}) => void;
|
|
1081
1400
|
/** How long to wait for the withdrawal to land before giving up on the swap. */
|
|
1082
1401
|
arrivalTimeoutMs?: number;
|
|
1083
1402
|
}): Promise<{
|
|
@@ -1202,31 +1521,6 @@ declare class OwneySDK {
|
|
|
1202
1521
|
getAllocationApy({ agentId, }?: AllocationApyOptions): Promise<OwneyAllocationApy>;
|
|
1203
1522
|
}
|
|
1204
1523
|
|
|
1205
|
-
type OwneyErrorCode = "NOT_CONNECTED" | "NO_ACTIVE_CHAIN" | "WALLET_NO_ACCOUNTS" | "WALLET_ADDRESS_REQUIRED" | "WALLET_NOT_DEPLOYED" | "AGENT_NOT_FOUND" | "AGENT_CHAIN_INCOMPATIBLE" | "AGENT_EMPTY_LIST" | "AGENT_DISABLED" | "CHAIN_UNSUPPORTED" | "CHAIN_NO_COMPATIBLE_AGENTS" | "CHAIN_MISMATCH" | "ASSET_UNSUPPORTED" | "ASSET_NO_COMPATIBLE_AGENTS" | "DEPOSIT_BALANCE_UNAVAILABLE" | "DEPOSIT_PARTIAL_FAILURE" | "DEPOSIT_AMOUNT_BELOW_MINIMUM" | "DEPOSIT_CALLBACK_REQUIRED" | "DEPOSIT_CALLBACK_INVALID" | "DEPOSIT_NO_PERMITTED_TOKENS" | "DEPOSIT_INSUFFICIENT_BALANCE" | "WITHDRAW_NO_PERMITTED_TOKENS" | "WITHDRAW_INSUFFICIENT_BALANCE" | "WITHDRAW_ALL_FAILED" | "WITHDRAW_PARTIAL_FAILURE" | "WITHDRAW_FAILED" | "AGENT_RATE_LIMITED" | "API_ROUTING_ERROR" | "API_ROUTING_FAILED" | "API_NO_AGENTS" | "SPONSOR_REQUEST_FAILED" | "PERMIT2_APPROVAL_REQUIRED" | "SPONSORED_CALLS_UNSUPPORTED" | "SPONSORED_CALLS_NO_ID" | "SPONSORED_CALLS_NO_RECEIPT" | "SWAP_DISABLED" | "SWAP_RATE_LIMITED" | "SWAP_REQUEST_FAILED" | "SWAP_QUOTE_FAILED" | "SWAP_UNSUPPORTED_PAIR" | "SWAP_APPROVAL_REQUIRED" | "SWAP_BELOW_DEPOSIT_MINIMUM" | "SWAP_ORDER_EXPIRED" | "SWAP_ORDER_REFUNDED" | "SWAP_ORDER_CANCELLED" | "WITHDRAW_ARRIVAL_TIMEOUT" | "WITHDRAW_SWAP_FAILED" | "BALANCE_ALL_FAILED" | "ALLOCATION_ALL_FAILED" | "VALIDATION_INVALID_DAYS";
|
|
1206
|
-
declare class OwneyError extends Error {
|
|
1207
|
-
readonly code: OwneyErrorCode;
|
|
1208
|
-
readonly details?: Record<string, unknown>;
|
|
1209
|
-
readonly agentId?: string;
|
|
1210
|
-
constructor(code: OwneyErrorCode, message: string, details?: Record<string, unknown>, agentId?: string);
|
|
1211
|
-
}
|
|
1212
|
-
declare class AgentNotFoundError extends OwneyError {
|
|
1213
|
-
constructor(agentId: string, available: string[]);
|
|
1214
|
-
}
|
|
1215
|
-
declare class NotConnectedError extends OwneyError {
|
|
1216
|
-
constructor();
|
|
1217
|
-
}
|
|
1218
|
-
declare class AgentChainIncompatibleError extends OwneyError {
|
|
1219
|
-
readonly incompatibleAgents: Array<{
|
|
1220
|
-
agentId: string;
|
|
1221
|
-
supportedChainIds: readonly number[];
|
|
1222
|
-
}>;
|
|
1223
|
-
readonly connectedChainId: number;
|
|
1224
|
-
constructor(incompatibleAgents: Array<{
|
|
1225
|
-
agentId: string;
|
|
1226
|
-
supportedChainIds: readonly number[];
|
|
1227
|
-
}>, connectedChainId: number);
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
1524
|
declare class InvalidHistoryCursorError extends Error {
|
|
1231
1525
|
readonly code: "invalid_cursor";
|
|
1232
1526
|
constructor(message: string);
|
|
@@ -1304,4 +1598,4 @@ type StoredOrder = {
|
|
|
1304
1598
|
*/
|
|
1305
1599
|
declare function listOrders(now?: number): StoredOrder[];
|
|
1306
1600
|
|
|
1307
|
-
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type RebalanceLog, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type WithdrawOptions, createOwneySIWX, listOrders as listPendingSwaps, setOwneyDebug };
|
|
1601
|
+
export { type AccountAgentApy, type AccountApyOptions, type AccountDailyEarnings, type AgentApy, type AgentApyDetails, type AgentBalance, AgentChainIncompatibleError, type AgentEarnings, type AgentHistoryEntry, type AgentHistoryPosition, type AgentId, AgentNotFoundError, type AgentSupportedAsset, type AgentSupportedAssets, type AgentUserProfile, type AgentWithdrawResult, type AgentsApyOptions, type AllocationAgentApy, type AllocationApyOptions, type ApyByChainAndAsset, type ApyHistoryPoint, type Asset, type AssetDailyEarnings, type AvailableAgent, type AvailableAgentsOptions, type ConnectionState, type DailyApyDays, type DailyEarningsOptions, type DailyEarningsPoint, type DepositCallback, type DepositOptions, type HistoryAction, type HistoryFilters, type HistoryOptions, type HistoryTransaction, type IAgent, InvalidHistoryCursorError, type LookbackDays, NotConnectedError, type OwneyAccountApy, type OwneyAgentApy, type OwneyAgentHistory, type OwneyAllocationApy, type OwneyBalances, type OwneyDepositResult, type OwneyEarnings, OwneyError, type OwneyErrorCode, type OwneyMultiDepositResult, type OwneyPosition, OwneySDK, type OwneySDKConfig, type OwneySIWXConfig, type OwneySupportedChainId, type OwneySupportedChains, type OwneySupportedTokens, type OwneyToken, type OwneyUserProfile, type OwneyWithdrawResult, type PendingDeposit, type RebalanceLog, type SwapChainTokens, type SwapDirection, type SwapOrderStatus, type SwapQuote, type SwapQuoteParams, type SwapRail, type SwapStage, type SwapTokenInfo, type SwapTokenSearchResult, type WithdrawOptions, type WithdrawSwapRecord, type WithdrawSwapStatus, clearWithdrawSwap, createOwneySIWX, listPendingDeposits, listOrders as listPendingSwaps, listWithdrawSwaps, saveWithdrawSwap, setOwneyDebug, subscribeWithdrawSwaps, updateWithdrawSwap };
|