@audren-xyz/sdk 1.3.2 → 1.3.3
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/aggregators.d.ts +4 -0
- package/dist/aggregators.js +31 -0
- package/dist/relayer.js +2 -1
- package/package.json +1 -1
package/dist/aggregators.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export type SwapAggregatorSelection = SwapAggregatorId | 'auto' | (string & {});
|
|
|
17
17
|
export declare const SINGLE_HOP_ROUTER_CU_HEADROOM = 350000;
|
|
18
18
|
export declare const MULTI_HOP_ROUTER_CU_HEADROOM = 550000;
|
|
19
19
|
export declare const MAX_AGGREGATOR_TX_CU_LIMIT = 1400000;
|
|
20
|
+
/** On-chain `ExecViaEscrow` (`program/src/lib.rs`) hard ceiling for CPI router account metas. */
|
|
21
|
+
export declare const MAX_EXEC_ROUTER_CPI_ACCOUNTS = 64;
|
|
22
|
+
/** Safe unique router account ceiling leaving headroom for Audren's fixed `ExecViaEscrow` accounts inside Solana Tx v1's 64-key cap. */
|
|
23
|
+
export declare const MAX_TX_V1_UNIQUE_ROUTER_ACCOUNTS = 46;
|
|
20
24
|
export interface SwapAggregatorCapabilities {
|
|
21
25
|
supportsPlatformFeeBps: boolean;
|
|
22
26
|
supportsSwapInstructions: boolean;
|
package/dist/aggregators.js
CHANGED
|
@@ -5,6 +5,10 @@ import { JUPITER_CPI_EXCLUDED_DEXES, prepareEscrowAccounts, } from './swap.js';
|
|
|
5
5
|
export const SINGLE_HOP_ROUTER_CU_HEADROOM = 350_000;
|
|
6
6
|
export const MULTI_HOP_ROUTER_CU_HEADROOM = 550_000;
|
|
7
7
|
export const MAX_AGGREGATOR_TX_CU_LIMIT = 1_400_000;
|
|
8
|
+
/** On-chain `ExecViaEscrow` (`program/src/lib.rs`) hard ceiling for CPI router account metas. */
|
|
9
|
+
export const MAX_EXEC_ROUTER_CPI_ACCOUNTS = 64;
|
|
10
|
+
/** Safe unique router account ceiling leaving headroom for Audren's fixed `ExecViaEscrow` accounts inside Solana Tx v1's 64-key cap. */
|
|
11
|
+
export const MAX_TX_V1_UNIQUE_ROUTER_ACCOUNTS = 46;
|
|
8
12
|
const COMPUTE_BUDGET_PROGRAM = 'ComputeBudget111111111111111111111111111111';
|
|
9
13
|
const ATA_PROGRAM = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
10
14
|
const SYSTEM_PROGRAM = '11111111111111111111111111111111';
|
|
@@ -147,6 +151,20 @@ function isValidRouterInstruction(v) {
|
|
|
147
151
|
typeof a.isSigner === 'boolean' &&
|
|
148
152
|
typeof a.isWritable === 'boolean');
|
|
149
153
|
}
|
|
154
|
+
function validatePrebuiltEscrowInstructionBounds(ixs, escrowPubkey, providerLabel) {
|
|
155
|
+
const swapIx = ixs.find((ix) => !WRAPPER_PROGRAMS.has(ix.programId) &&
|
|
156
|
+
ix.accounts.some((a) => a.pubkey === escrowPubkey));
|
|
157
|
+
if (!swapIx) {
|
|
158
|
+
throw new Error(`${providerLabel} did not include an escrow-signed swap instruction`);
|
|
159
|
+
}
|
|
160
|
+
if (swapIx.accounts.length > MAX_EXEC_ROUTER_CPI_ACCOUNTS) {
|
|
161
|
+
throw new Error(`${providerLabel} route requires ${swapIx.accounts.length} router accounts (exceeds ExecViaEscrow max ${MAX_EXEC_ROUTER_CPI_ACCOUNTS})`);
|
|
162
|
+
}
|
|
163
|
+
const uniquePubkeys = new Set(swapIx.accounts.map((a) => a.pubkey)).size;
|
|
164
|
+
if (uniquePubkeys > MAX_TX_V1_UNIQUE_ROUTER_ACCOUNTS) {
|
|
165
|
+
throw new Error(`${providerLabel} route requires ${uniquePubkeys} unique router accounts (exceeds Tx v1 safe budget ${MAX_TX_V1_UNIQUE_ROUTER_ACCOUNTS})`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
150
168
|
export function createJupiterSwapAdapter(config = {}) {
|
|
151
169
|
const fetchImpl = config.fetchImpl ?? globalThis.fetch.bind(globalThis);
|
|
152
170
|
const apiKey = config.apiKey?.trim() ?? '';
|
|
@@ -532,6 +550,10 @@ export function createOkxSwapAdapter(config = {}) {
|
|
|
532
550
|
throw new Error(`OKX API returned no valid route${body.msg ? `: ${body.msg}` : ''}`);
|
|
533
551
|
}
|
|
534
552
|
const rr = entry.routerResult;
|
|
553
|
+
const prebuiltIxs = Array.isArray(entry.instructionLists)
|
|
554
|
+
? entry.instructionLists.filter(isValidRouterInstruction)
|
|
555
|
+
: [];
|
|
556
|
+
validatePrebuiltEscrowInstructionBounds(prebuiltIxs, req.escrowPubkey, 'OKX');
|
|
535
557
|
const outAmount = outBi.toString();
|
|
536
558
|
const minOut = ((outBi * BigInt(10_000 - req.slippageBps)) / 10000n).toString();
|
|
537
559
|
const routePlan = [];
|
|
@@ -763,6 +785,12 @@ export function createTitanSwapAdapter(config = {}) {
|
|
|
763
785
|
if (!route || routeOut === null) {
|
|
764
786
|
throw new Error('Titan returned no valid quotes');
|
|
765
787
|
}
|
|
788
|
+
if (Array.isArray(route.instructions)) {
|
|
789
|
+
const prebuiltIxs = route.instructions
|
|
790
|
+
.map(normalizeTitanInstruction)
|
|
791
|
+
.filter((x) => x !== null);
|
|
792
|
+
validatePrebuiltEscrowInstructionBounds(prebuiltIxs, req.escrowPubkey, 'Titan');
|
|
793
|
+
}
|
|
766
794
|
const outAmount = routeOut.toString();
|
|
767
795
|
const minOut = ((routeOut * BigInt(10_000 - req.slippageBps)) / 10000n).toString();
|
|
768
796
|
const steps = Array.isArray(route.steps)
|
|
@@ -1174,6 +1202,9 @@ export class AudrenSwapRouter {
|
|
|
1174
1202
|
timeoutMs: req.timeoutMs ?? this.defaultTimeoutMs,
|
|
1175
1203
|
signal: req.signal,
|
|
1176
1204
|
});
|
|
1205
|
+
if (built.swapInstruction.accounts.length > MAX_EXEC_ROUTER_CPI_ACCOUNTS) {
|
|
1206
|
+
throw new Error(`Aggregator "${adapter.id}" returned ${built.swapInstruction.accounts.length} router accounts (exceeds ExecViaEscrow max ${MAX_EXEC_ROUTER_CPI_ACCOUNTS})`);
|
|
1207
|
+
}
|
|
1177
1208
|
const allowUnverified = req.allowUnverifiedRouter ?? this.allowUnverifiedRouter;
|
|
1178
1209
|
if (!allowUnverified) {
|
|
1179
1210
|
const allowed = req.allowedRouterPrograms ?? this.allowedRouterPrograms;
|
package/dist/relayer.js
CHANGED
|
@@ -15,8 +15,9 @@ export const AUDREN_DEFAULT_RELAY_TIMEOUT_MS = 45_000;
|
|
|
15
15
|
export const AUDREN_AUDITED_SWAP_ROUTERS = [
|
|
16
16
|
'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4', // Jupiter Swap v1
|
|
17
17
|
'DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH', // DFlow Trading API
|
|
18
|
-
'6m2CDdhRgxpH4WjvdzxAYbGxwdGUz5MziiL5jek2kBma', // OKX DEX
|
|
18
|
+
'6m2CDdhRgxpH4WjvdzxAYbGxwdGUz5MziiL5jek2kBma', // OKX DEX Router (v1)
|
|
19
19
|
'T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT', // Titan Meta-Aggregator
|
|
20
|
+
'proVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u', // OKX DEX Aggregation Router V2/V6
|
|
20
21
|
];
|
|
21
22
|
export class AudrenRelayError extends Error {
|
|
22
23
|
status;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@audren-xyz/sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "TypeScript SDK for Audren — zero-indexer BN254 Groth16 global MASP core (PDAs, Poseidon, layouts, CompactWalletStore, gateway/relayer client, tx v1) plus WASM Groth16 prover (@audren-xyz/sdk/prover) and IDLs (@audren-xyz/sdk/idl)",
|