@audren-xyz/sdk 1.3.0 → 1.3.2
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 +24 -1
- package/dist/aggregators.d.ts +284 -0
- package/dist/aggregators.js +1245 -0
- package/dist/index.d.ts +14 -13
- package/dist/index.js +1 -0
- package/dist/instructions.d.ts +1 -1
- package/dist/prover-entry.d.ts +1 -1
- package/dist/prover.d.ts +1 -1
- package/dist/prover.js +2 -10
- package/dist/relayer.d.ts +18 -1
- package/dist/relayer.js +14 -2
- package/dist/scanner.d.ts +3 -3
- package/dist/store.d.ts +3 -3
- package/dist/swap.js +11 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ For maintainer, npm publishing, and WASM rebuild rules, see [`AGENTS.md`](AGENTS
|
|
|
6
6
|
|
|
7
7
|
## Package Entrypoints (`package.json` `exports`)
|
|
8
8
|
|
|
9
|
-
- **`@audren-xyz/sdk`** (`.`): Zero-WASM, `"sideEffects": false` tree-shakeable core for Node.js, Browsers, and Cloudflare Workers — pure-TS Circom BN254 Poseidon (backed by per-width tree-shakeable `POSEIDON_PARAMS_2..6` constants in `src/poseidon-constants.ts`), BIP-350 Bech32m `aud1...` stealth addresses (rejecting non-canonical `spend_pk`, whitespace, and low-order X25519 `view_pk` points), RFC 8439 ChaCha20-Poly1305 versioned `106 B` SoA memos (`34 B` header/AAD + `72 B` ciphertext containing `56 B` plaintext with `14 B` encrypted `paymentId` + `16 B` Poly1305 tag, with X25519 low-order rejection), all 12 canonical PDAs (`audren_*`, including `GlobalRootHistory` `audren_roots`), zero-copy account decoders (`decodeGlobalRootHistory` + `selectRootSnapshotForNotes`), zero-indexer `CompactWalletStore` (bidirectional Rust <-> TS JSON compatible) + Rendezvous (HRW) privacy-first ordinary Solana RPC `getMultipleAccounts` scanner (`syncCompactStoreWithRpc`, default `privacyMode: 'strict'`), `finalized`-first / `confirmed`-fallback `fetchGlobalRootHistory` & batched witness reconstruction (`reconstructWitnessesForNotes` for multi-input spends; `reconstructWitness` for single notes), all 9 instruction builders (`InitPool`, `InitLane`, `OpenPage`, `Deposit`, `InitRootHistory`, `Transact`, `ExecViaEscrow` with `extraWritablePubkeys`, `SetPaused`, `UpdatePool`), zero-crank Auto-`OpenPage` planner (`planAutoOpenPages` / `buildAutoOpenPageInstructions`), bump-aware tight CU limit helpers (`CU_LIMIT_*`, `recommendedOpenPageCuLimit`, `recommendedDepositCuLimit`, `recommendedTransactCuLimit`, `recommendedExecViaEscrowCuLimit`, `computeBumpCuMargin`), Token-2022 helpers (`parseToken2022TransferFeeConfig`, `computeToken2022NetAmount`, `inspectToken2022UnsafeSelfPay`), Solana Transaction v1 (`0x81`) compiler, and the Audren Gateway v1 (`audren-gateway/v1`) / Relayer client (`AudrenRelayClient`, `AudrenRelayError`, `AudrenGatewayClient`, `AudrenGatewayError`, `AUDREN_DEFAULT_RELAY_URL`, `DEFAULT_DEVNET_RELAY_URL`, `AUDREN_DEFAULT_DEVNET_RELAY_URL`, `AUDREN_AUDITED_SWAP_ROUTERS`,
|
|
9
|
+
- **`@audren-xyz/sdk`** (`.`): Zero-WASM, `"sideEffects": false` tree-shakeable core for Node.js, Browsers, and Cloudflare Workers — pure-TS Circom BN254 Poseidon (backed by per-width tree-shakeable `POSEIDON_PARAMS_2..6` constants in `src/poseidon-constants.ts`), BIP-350 Bech32m `aud1...` stealth addresses (rejecting non-canonical `spend_pk`, whitespace, and low-order X25519 `view_pk` points), RFC 8439 ChaCha20-Poly1305 versioned `106 B` SoA memos (`34 B` header/AAD + `72 B` ciphertext containing `56 B` plaintext with `14 B` encrypted `paymentId` + `16 B` Poly1305 tag, with X25519 low-order rejection), all 12 canonical PDAs (`audren_*`, including `GlobalRootHistory` `audren_roots`), zero-copy account decoders (`decodeGlobalRootHistory` + `selectRootSnapshotForNotes`), zero-indexer `CompactWalletStore` (bidirectional Rust <-> TS JSON compatible) + Rendezvous (HRW) privacy-first ordinary Solana RPC `getMultipleAccounts` scanner (`syncCompactStoreWithRpc`, default `privacyMode: 'strict'`), `finalized`-first / `confirmed`-fallback `fetchGlobalRootHistory` & batched witness reconstruction (`reconstructWitnessesForNotes` for multi-input spends; `reconstructWitness` for single notes), all 9 instruction builders (`InitPool`, `InitLane`, `OpenPage`, `Deposit`, `InitRootHistory`, `Transact`, `ExecViaEscrow` with `extraWritablePubkeys`, `SetPaused`, `UpdatePool`), zero-crank Auto-`OpenPage` planner (`planAutoOpenPages` / `buildAutoOpenPageInstructions`), bump-aware tight CU limit helpers (`CU_LIMIT_*`, `recommendedOpenPageCuLimit`, `recommendedDepositCuLimit`, `recommendedTransactCuLimit`, `recommendedExecViaEscrowCuLimit`, `computeBumpCuMargin`), Token-2022 helpers (`parseToken2022TransferFeeConfig`, `computeToken2022NetAmount`, `inspectToken2022UnsafeSelfPay`), Solana Transaction v1 (`0x81`) compiler, plug-and-play multi-aggregator swap routing (`AudrenSwapRouter`, `AudrenSwapRouter.fromEnv()`, `createJupiterSwapAdapter`, `createDFlowSwapAdapter`, `createOkxSwapAdapter`, `createTitanSwapAdapter`, `createBedrockSwapAdapter`, `findExcludedCpiVenue`, `computeAggregatorExecCuLimit`, `'auto'` parallel best-price racing, custom `register()`, and 1-call `planPrivateSwap()`), and the optional Audren Gateway v1 (`audren-gateway/v1`) / Relayer client (`AudrenRelayClient`, `AudrenRelayError`, `AudrenGatewayClient`, `AudrenGatewayError`, `AUDREN_DEFAULT_RELAY_URL`, `DEFAULT_DEVNET_RELAY_URL`, `AUDREN_DEFAULT_DEVNET_RELAY_URL`, `AUDREN_AUDITED_SWAP_ROUTERS`, supporting `apiKey` / `bearerToken` / custom `headers`, `targetProgramId`, `innocenceProof`, and HTTP `202 sent_unconfirmed`; legacy `quoteSwap` / `buildSwapInstructions` / `getAggregators` proxy methods are `@deprecated` in favor of `AudrenSwapRouter`).
|
|
10
10
|
- **`@audren-xyz/sdk/idl`** (`./idl`): Generated `AUDREN_CODAMA_IDL` and `AUDREN_ANCHOR_IDL` TypeScript constants (kept off the root `.` barrel so Cloudflare Workers and edge gateways stay lightweight).
|
|
11
11
|
- **`@audren-xyz/sdk/prover`** (`./prover`): Exact Rust-compiled WASM BN254 Groth16 prover (`audren_circuits.wasm`, `17,861` R1CS, 4-ary Depth-20 global MASP, `192 B` proof) running natively in Node.js and Browser Web Workers. `AudrenWasmProver.init()` verifies both `CANONICAL_WASM_SHA256` and `CANONICAL_PK_SHA256` by default (`verifyWasmHash: true`, `verifyPkHash: true`), auto-derives sibling `audren_joinsplit.pk` if only `wasmUrl` is passed, and exposes `prover.dispose()` to zeroize WASM linear memory.
|
|
12
12
|
- **Static asset & raw JSON IDL subpaths:** `@audren-xyz/sdk/wasm/audren_circuits.wasm`, `@audren-xyz/sdk/wasm/audren_joinsplit.pk`, `@audren-xyz/sdk/idl/codama.json`, `@audren-xyz/sdk/idl/anchor.json`.
|
|
@@ -93,6 +93,29 @@ const prover = await AudrenWasmProver.init();
|
|
|
93
93
|
// Call prover.dispose() when done to zeroize WASM linear memory.
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
## Plug-and-Play Multi-Aggregator Private Swaps (`AudrenSwapRouter`)
|
|
97
|
+
|
|
98
|
+
`AudrenSwapRouter` abstracts Jupiter, DFlow, OKX (WebCrypto HMAC-SHA256), Titan, Bedrock, and custom adapters behind one uniform API for `ExecViaEscrow` (`Tag 6`), handling quote-time `escrow` PDA binding, ATA vs. owner-wallet fee accounts, wrapper-instruction stripping, PDA-CPI venue filtering, fail-closed `AUDREN_AUDITED_SWAP_ROUTERS` validation, and `'auto'` best-price racing:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { AudrenSwapRouter, WSOL_MINT } from '@audren-xyz/sdk';
|
|
102
|
+
|
|
103
|
+
const router = AudrenSwapRouter.fromEnv(process.env); // Jupiter, DFlow, OKX, Titan, Bedrock
|
|
104
|
+
const plan = await router.planPrivateSwap({
|
|
105
|
+
poolId: 0,
|
|
106
|
+
shardId: 0,
|
|
107
|
+
provider: 'auto', // or 'jupiter' | 'dflow' | 'okx' | 'titan' | 'bedrock'
|
|
108
|
+
inputMint: WSOL_MINT,
|
|
109
|
+
outputMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
110
|
+
amount: '10000000',
|
|
111
|
+
slippageBps: 50,
|
|
112
|
+
});
|
|
113
|
+
// Ready for buildExecViaEscrowInstruction():
|
|
114
|
+
// plan.provider, plan.quote.outAmount, plan.instructions.swapInstruction, plan.prepared.accounts
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Gateways are strictly optional: submit your proven instruction directly via your own Solana wallet or a one-time burner wallet funded from inside Audren, or pass it to any `audren-gateway/v1` operator via `AudrenGatewayClient`.
|
|
118
|
+
|
|
96
119
|
## Verify Locally
|
|
97
120
|
|
|
98
121
|
```bash
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { type RelayAggregatorId } from './relayer.js';
|
|
2
|
+
import { type PreparedEscrowAccounts, type RouterSwapInstruction } from './swap.js';
|
|
3
|
+
/**
|
|
4
|
+
* Plug-and-Play Multi-Aggregator Swap Router for Audren `ExecViaEscrow` (`Tag 6`).
|
|
5
|
+
*
|
|
6
|
+
* Abstracts away provider-specific authentication (API keys, Bearer tokens, OKX WebCrypto
|
|
7
|
+
* HMAC-SHA256 signing), endpoint paths, quote-time vs. instruction-time `escrow` PDA binding,
|
|
8
|
+
* fee account styles (ATA vs. owner wallet), wrapper-instruction stripping, PDA-CPI excluded
|
|
9
|
+
* venue filtering, calibrated Compute Unit budgets, and `'auto'` parallel best-price racing
|
|
10
|
+
* across Jupiter, DFlow, OKX, Titan, Bedrock, and custom operator adapters.
|
|
11
|
+
*
|
|
12
|
+
* Zero runtime dependencies; uses `redirect: 'manual'` everywhere for full Cloudflare Workers
|
|
13
|
+
* (`workerd`), Node.js 22+, Bun, Deno, and browser compatibility.
|
|
14
|
+
*/
|
|
15
|
+
export type SwapAggregatorId = RelayAggregatorId;
|
|
16
|
+
export type SwapAggregatorSelection = SwapAggregatorId | 'auto' | (string & {});
|
|
17
|
+
export declare const SINGLE_HOP_ROUTER_CU_HEADROOM = 350000;
|
|
18
|
+
export declare const MULTI_HOP_ROUTER_CU_HEADROOM = 550000;
|
|
19
|
+
export declare const MAX_AGGREGATOR_TX_CU_LIMIT = 1400000;
|
|
20
|
+
export interface SwapAggregatorCapabilities {
|
|
21
|
+
supportsPlatformFeeBps: boolean;
|
|
22
|
+
supportsSwapInstructions: boolean;
|
|
23
|
+
/** True when the provider binds `escrowPubkey` at quote time (Titan, OKX). */
|
|
24
|
+
quoteRequiresUserPubkey: boolean;
|
|
25
|
+
/** Fee side charged by this aggregator in ExactIn mode. */
|
|
26
|
+
feeSide: 'output' | 'input' | 'either';
|
|
27
|
+
/** Whether `feeAccount` expects the token ATA (Jupiter/DFlow/Titan) or owner wallet (OKX/Bedrock). */
|
|
28
|
+
feeAccountStyle: 'ata' | 'owner_wallet';
|
|
29
|
+
}
|
|
30
|
+
export interface SwapRouteLegSummary {
|
|
31
|
+
label: string;
|
|
32
|
+
ammKey?: string;
|
|
33
|
+
inputMint: string;
|
|
34
|
+
outputMint: string;
|
|
35
|
+
inAmount: string;
|
|
36
|
+
outAmount: string;
|
|
37
|
+
percent?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface NormalizedSwapQuote {
|
|
40
|
+
provider: string;
|
|
41
|
+
inputMint: string;
|
|
42
|
+
outputMint: string;
|
|
43
|
+
inAmount: string;
|
|
44
|
+
outAmount: string;
|
|
45
|
+
otherAmountThreshold: string;
|
|
46
|
+
slippageBps: number;
|
|
47
|
+
priceImpactPct?: string | null;
|
|
48
|
+
platformFee?: {
|
|
49
|
+
amount: string;
|
|
50
|
+
feeBps: number;
|
|
51
|
+
mint: string;
|
|
52
|
+
} | null;
|
|
53
|
+
routePlan: Array<{
|
|
54
|
+
swapInfo: SwapRouteLegSummary;
|
|
55
|
+
percent?: number;
|
|
56
|
+
}>;
|
|
57
|
+
contextSlot?: number | null;
|
|
58
|
+
latencyMs: number;
|
|
59
|
+
rawQuote: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
export interface NormalizedSwapInstructions {
|
|
62
|
+
provider: string;
|
|
63
|
+
swapInstruction: RouterSwapInstruction;
|
|
64
|
+
addressLookupTableAddresses: string[];
|
|
65
|
+
computeUnitLimit: number;
|
|
66
|
+
feeAccount: string | null;
|
|
67
|
+
}
|
|
68
|
+
export interface SwapAdapterQuoteRequest {
|
|
69
|
+
inputMint: string;
|
|
70
|
+
outputMint: string;
|
|
71
|
+
amount: string;
|
|
72
|
+
slippageBps: number;
|
|
73
|
+
onlyDirectRoutes?: boolean;
|
|
74
|
+
maxAccounts?: number;
|
|
75
|
+
excludeDexes?: readonly string[];
|
|
76
|
+
platformFeeBps?: number;
|
|
77
|
+
/** Fee collector owner wallet (for `feeAccountStyle: 'owner_wallet'`, e.g. OKX/Bedrock). */
|
|
78
|
+
feeOwnerWallet?: string;
|
|
79
|
+
/** Fee collector token ATA (for `feeAccountStyle: 'ata'`, e.g. Jupiter/DFlow/Titan). */
|
|
80
|
+
feeAccountAta?: string;
|
|
81
|
+
/** Isolated Audren `escrow` PDA (required at quote time for Titan & OKX). */
|
|
82
|
+
escrowPubkey?: string;
|
|
83
|
+
timeoutMs?: number;
|
|
84
|
+
signal?: AbortSignal;
|
|
85
|
+
}
|
|
86
|
+
export interface SwapAdapterInstructionsRequest {
|
|
87
|
+
quoteResponse: Record<string, unknown>;
|
|
88
|
+
escrowPubkey: string;
|
|
89
|
+
inputMint: string;
|
|
90
|
+
outputMint: string;
|
|
91
|
+
feeAccountAta?: string;
|
|
92
|
+
feeOwnerWallet?: string;
|
|
93
|
+
platformFeeBps?: number;
|
|
94
|
+
timeoutMs?: number;
|
|
95
|
+
signal?: AbortSignal;
|
|
96
|
+
}
|
|
97
|
+
export interface SwapAggregatorAdapter {
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly name: string;
|
|
100
|
+
readonly capabilities: SwapAggregatorCapabilities;
|
|
101
|
+
isConfigured(): boolean;
|
|
102
|
+
quote(req: SwapAdapterQuoteRequest): Promise<NormalizedSwapQuote>;
|
|
103
|
+
swapInstructions(req: SwapAdapterInstructionsRequest): Promise<NormalizedSwapInstructions>;
|
|
104
|
+
}
|
|
105
|
+
export interface SwapProviderStatus {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
enabled: boolean;
|
|
109
|
+
configured: boolean;
|
|
110
|
+
isDefault: boolean;
|
|
111
|
+
capabilities: SwapAggregatorCapabilities;
|
|
112
|
+
}
|
|
113
|
+
export interface SwapQuoteCandidate {
|
|
114
|
+
provider: string;
|
|
115
|
+
outAmount?: string;
|
|
116
|
+
latencyMs?: number;
|
|
117
|
+
error?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface AudrenSwapQuoteRequest extends SwapAdapterQuoteRequest {
|
|
120
|
+
/** Specific provider id or `'auto'` to race all active providers for best `outAmount`. */
|
|
121
|
+
provider?: SwapAggregatorSelection;
|
|
122
|
+
/** Used to derive `escrowPubkey` automatically if omitted (defaults to pool 0, shard 0). */
|
|
123
|
+
poolId?: number;
|
|
124
|
+
shardId?: number;
|
|
125
|
+
programId?: string;
|
|
126
|
+
}
|
|
127
|
+
export interface AudrenSwapQuoteResult {
|
|
128
|
+
winner: NormalizedSwapQuote;
|
|
129
|
+
candidates: SwapQuoteCandidate[];
|
|
130
|
+
escrowPubkey: string;
|
|
131
|
+
}
|
|
132
|
+
export interface AudrenBuildSwapInstructionsRequest {
|
|
133
|
+
provider: string;
|
|
134
|
+
quoteResponse: Record<string, unknown>;
|
|
135
|
+
escrowPubkey: string;
|
|
136
|
+
inputMint: string;
|
|
137
|
+
outputMint: string;
|
|
138
|
+
feeAccountAta?: string;
|
|
139
|
+
feeOwnerWallet?: string;
|
|
140
|
+
platformFeeBps?: number;
|
|
141
|
+
allowedRouterPrograms?: readonly string[];
|
|
142
|
+
allowUnverifiedRouter?: boolean;
|
|
143
|
+
timeoutMs?: number;
|
|
144
|
+
signal?: AbortSignal;
|
|
145
|
+
}
|
|
146
|
+
export interface AudrenPlanPrivateSwapRequest {
|
|
147
|
+
poolId: number;
|
|
148
|
+
shardId: number;
|
|
149
|
+
inputMint: string;
|
|
150
|
+
outputMint: string;
|
|
151
|
+
amount: string;
|
|
152
|
+
slippageBps: number;
|
|
153
|
+
provider?: SwapAggregatorSelection;
|
|
154
|
+
inputTokenProgram?: string;
|
|
155
|
+
outputTokenProgram?: string;
|
|
156
|
+
onlyDirectRoutes?: boolean;
|
|
157
|
+
maxAccounts?: number;
|
|
158
|
+
excludeDexes?: readonly string[];
|
|
159
|
+
platformFeeBps?: number;
|
|
160
|
+
feeAccountAta?: string;
|
|
161
|
+
feeOwnerWallet?: string;
|
|
162
|
+
extraWritablePubkeys?: readonly string[];
|
|
163
|
+
allowedRouterPrograms?: readonly string[];
|
|
164
|
+
allowUnverifiedRouter?: boolean;
|
|
165
|
+
programId?: string;
|
|
166
|
+
timeoutMs?: number;
|
|
167
|
+
signal?: AbortSignal;
|
|
168
|
+
}
|
|
169
|
+
export interface AudrenPlannedPrivateSwap {
|
|
170
|
+
provider: string;
|
|
171
|
+
quote: NormalizedSwapQuote;
|
|
172
|
+
candidates: SwapQuoteCandidate[];
|
|
173
|
+
instructions: NormalizedSwapInstructions;
|
|
174
|
+
prepared: PreparedEscrowAccounts;
|
|
175
|
+
}
|
|
176
|
+
export interface JupiterAdapterConfig {
|
|
177
|
+
apiKey?: string;
|
|
178
|
+
/** Defaults to `https://api.jup.ag` (appends `/swap/v1` if omitted). */
|
|
179
|
+
apiUrl?: string;
|
|
180
|
+
fetchImpl?: typeof fetch;
|
|
181
|
+
}
|
|
182
|
+
export interface DFlowAdapterConfig {
|
|
183
|
+
apiKey?: string;
|
|
184
|
+
/** Defaults to `https://quote-api.dflow.net`. */
|
|
185
|
+
apiUrl?: string;
|
|
186
|
+
fetchImpl?: typeof fetch;
|
|
187
|
+
}
|
|
188
|
+
export interface OkxAdapterConfig {
|
|
189
|
+
apiKey?: string;
|
|
190
|
+
secretKey?: string;
|
|
191
|
+
passphrase?: string;
|
|
192
|
+
/** Defaults to `https://web3.okx.com`. */
|
|
193
|
+
apiUrl?: string;
|
|
194
|
+
fetchImpl?: typeof fetch;
|
|
195
|
+
}
|
|
196
|
+
export interface TitanAdapterConfig {
|
|
197
|
+
apiKey?: string;
|
|
198
|
+
/** Defaults to `https://api.titan.exchange/api/v1` when `apiKey` is provided. */
|
|
199
|
+
apiUrl?: string;
|
|
200
|
+
fetchImpl?: typeof fetch;
|
|
201
|
+
}
|
|
202
|
+
export interface BedrockAdapterConfig {
|
|
203
|
+
apiUrl?: string;
|
|
204
|
+
apiKey?: string;
|
|
205
|
+
fetchImpl?: typeof fetch;
|
|
206
|
+
}
|
|
207
|
+
export interface AudrenSwapRouterConfig {
|
|
208
|
+
jupiter?: JupiterAdapterConfig;
|
|
209
|
+
dflow?: DFlowAdapterConfig;
|
|
210
|
+
okx?: OkxAdapterConfig;
|
|
211
|
+
titan?: TitanAdapterConfig;
|
|
212
|
+
bedrock?: BedrockAdapterConfig;
|
|
213
|
+
customAdapters?: readonly SwapAggregatorAdapter[];
|
|
214
|
+
/** Restrict active adapters to this allowlist (defaults to all registered adapters). */
|
|
215
|
+
enabledProviders?: readonly string[];
|
|
216
|
+
/** Default selection when `provider` is omitted in `quote()` / `planPrivateSwap()` (defaults to `'auto'`). */
|
|
217
|
+
defaultProvider?: SwapAggregatorSelection;
|
|
218
|
+
/** Default HTTP timeout in ms (defaults to `10_000`). */
|
|
219
|
+
timeoutMs?: number;
|
|
220
|
+
/** Default router program allowlist (defaults to `AUDREN_AUDITED_SWAP_ROUTERS`). */
|
|
221
|
+
allowedRouterPrograms?: readonly string[];
|
|
222
|
+
/** Disable fail-closed `AUDREN_AUDITED_SWAP_ROUTERS` validation by default (use with caution). */
|
|
223
|
+
allowUnverifiedRouter?: boolean;
|
|
224
|
+
/** Optional custom `fetch` implementation for testing or proxying. */
|
|
225
|
+
fetchImpl?: typeof fetch;
|
|
226
|
+
}
|
|
227
|
+
export declare function computeAggregatorExecCuLimit(params: {
|
|
228
|
+
reportedRouterCu?: number;
|
|
229
|
+
routeHopCount?: number | null;
|
|
230
|
+
forceMultiHopHeadroom?: boolean;
|
|
231
|
+
}): number;
|
|
232
|
+
/**
|
|
233
|
+
* Returns the first PDA-CPI-hostile venue label present in `quote.routePlan`, or `null`
|
|
234
|
+
* if every leg is safe to execute through Audren's `ExecViaEscrow` (`Tag 6`) PDA CPI.
|
|
235
|
+
*/
|
|
236
|
+
export declare function findExcludedCpiVenue(quote: Pick<NormalizedSwapQuote, 'routePlan'>, excludedDexes?: readonly string[]): string | null;
|
|
237
|
+
export declare function createJupiterSwapAdapter(config?: JupiterAdapterConfig): SwapAggregatorAdapter;
|
|
238
|
+
export declare function createDFlowSwapAdapter(config?: DFlowAdapterConfig): SwapAggregatorAdapter;
|
|
239
|
+
export declare function createOkxSwapAdapter(config?: OkxAdapterConfig): SwapAggregatorAdapter;
|
|
240
|
+
export declare function createTitanSwapAdapter(config?: TitanAdapterConfig): SwapAggregatorAdapter;
|
|
241
|
+
export declare function createBedrockSwapAdapter(config?: BedrockAdapterConfig): SwapAggregatorAdapter;
|
|
242
|
+
export interface SwapRouterEnvLike {
|
|
243
|
+
JUPITER_API_KEY?: string;
|
|
244
|
+
JUPITER_API_URL?: string;
|
|
245
|
+
DFLOW_API_KEY?: string;
|
|
246
|
+
DFLOW_API_URL?: string;
|
|
247
|
+
OKX_API_KEY?: string;
|
|
248
|
+
OKX_SECRET_KEY?: string;
|
|
249
|
+
OKX_PASSPHRASE?: string;
|
|
250
|
+
OKX_API_URL?: string;
|
|
251
|
+
TITAN_API_KEY?: string;
|
|
252
|
+
TITAN_API_URL?: string;
|
|
253
|
+
BEDROCK_API_URL?: string;
|
|
254
|
+
BEDROCK_API_KEY?: string;
|
|
255
|
+
ENABLED_AGGREGATORS?: string;
|
|
256
|
+
DEFAULT_AGGREGATOR?: string;
|
|
257
|
+
/** Optional comma-separated list of approved swap router program IDs (defaults to `AUDREN_AUDITED_SWAP_ROUTERS`). */
|
|
258
|
+
AUDITED_SWAP_ROUTER_PROGRAMS?: string;
|
|
259
|
+
}
|
|
260
|
+
export declare class AudrenSwapRouter {
|
|
261
|
+
private readonly adapters;
|
|
262
|
+
private readonly enabledProviders;
|
|
263
|
+
private readonly defaultProvider;
|
|
264
|
+
private readonly defaultTimeoutMs;
|
|
265
|
+
private readonly allowedRouterPrograms;
|
|
266
|
+
private readonly allowUnverifiedRouter;
|
|
267
|
+
constructor(config?: AudrenSwapRouterConfig);
|
|
268
|
+
/** Construct a router directly from Worker/Node environment variables. */
|
|
269
|
+
static fromEnv(env: SwapRouterEnvLike, overrides?: Partial<AudrenSwapRouterConfig>): AudrenSwapRouter;
|
|
270
|
+
/** Register or override a custom aggregator adapter at runtime. */
|
|
271
|
+
register(adapter: SwapAggregatorAdapter): this;
|
|
272
|
+
getAdapter(id: string): SwapAggregatorAdapter | undefined;
|
|
273
|
+
private isEnabled;
|
|
274
|
+
listProviders(): SwapProviderStatus[];
|
|
275
|
+
private resolveActiveAdapters;
|
|
276
|
+
quote(req: AudrenSwapQuoteRequest): Promise<AudrenSwapQuoteResult>;
|
|
277
|
+
buildSwapInstructions(req: AudrenBuildSwapInstructionsRequest): Promise<NormalizedSwapInstructions>;
|
|
278
|
+
/**
|
|
279
|
+
* 1-call turnkey planner: derives the sharded `escrow` PDA, quotes (single or `'auto'` race),
|
|
280
|
+
* builds normalized instructions, verifies router allowlist, strips the external `escrow` signer
|
|
281
|
+
* bit, and promotes Solana transaction-wide writability for `ExecViaEscrow` (`Tag 6`).
|
|
282
|
+
*/
|
|
283
|
+
planPrivateSwap(req: AudrenPlanPrivateSwapRequest): Promise<AudrenPlannedPrivateSwap>;
|
|
284
|
+
}
|