@augustdigital/sdk 8.17.0 → 8.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/adapters/evm/index.js +4 -2
- package/lib/adapters/stellar/soroban.d.ts +8 -3
- package/lib/adapters/stellar/soroban.js +9 -4
- package/lib/core/analytics/constants.d.ts +1 -1
- package/lib/core/analytics/constants.js +1 -1
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/attribution.d.ts +111 -0
- package/lib/core/attribution.js +142 -0
- package/lib/core/base.class.d.ts +17 -1
- package/lib/core/base.class.js +6 -1
- package/lib/core/fetcher.js +10 -1
- package/lib/core/helpers/chain-error.d.ts +140 -0
- package/lib/core/helpers/chain-error.js +412 -0
- package/lib/core/helpers/signer.d.ts +21 -0
- package/lib/core/helpers/signer.js +52 -0
- package/lib/core/helpers/web3.d.ts +152 -2
- package/lib/core/helpers/web3.js +307 -45
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js +1 -0
- package/lib/evm/methods/crossChainVault.js +4 -0
- package/lib/modules/vaults/getters.js +6 -2
- package/lib/modules/vaults/write.actions.d.ts +41 -1
- package/lib/modules/vaults/write.actions.js +302 -86
- package/lib/sdk.d.ts +438 -3
- package/lib/services/subgraph/vaults.js +85 -14
- package/package.json +1 -1
package/lib/sdk.d.ts
CHANGED
|
@@ -15015,6 +15015,21 @@ export declare const ADAPTER_ABIS: {
|
|
|
15015
15015
|
*/
|
|
15016
15016
|
export declare function allowance(signer: IContractRunner, options: IAllowanceOptions): Promise<bigint>;
|
|
15017
15017
|
|
|
15018
|
+
/**
|
|
15019
|
+
* Append the active attribution suffix to calldata.
|
|
15020
|
+
*
|
|
15021
|
+
* No-ops (returns `data` unchanged) when attribution is off, the chain is
|
|
15022
|
+
* excluded, `data` is empty/absent (plain value transfers are never
|
|
15023
|
+
* attributed), or `data` already ends with the ERC-8021 marker (guards
|
|
15024
|
+
* against double-appending when an upstream layer — e.g. a wagmi config
|
|
15025
|
+
* `dataSuffix` — already attributed the transaction).
|
|
15026
|
+
*
|
|
15027
|
+
* @param data `0x`-prefixed calldata of the outgoing transaction.
|
|
15028
|
+
* @param chainId EVM chain ID of the transaction, when known.
|
|
15029
|
+
* @returns Calldata with the suffix appended, or the input unchanged.
|
|
15030
|
+
*/
|
|
15031
|
+
export declare function appendAttributionSuffix(data: string | undefined | null, chainId?: number): string | undefined | null;
|
|
15032
|
+
|
|
15018
15033
|
/**
|
|
15019
15034
|
* Same approval logic as {@link vaultApprove} but returns a discriminated
|
|
15020
15035
|
* union so callers can tell `sent` apart from `sufficient` and `native`
|
|
@@ -15486,7 +15501,7 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
15486
15501
|
* @throws If `appName` is missing, malformed, or out of the allowed
|
|
15487
15502
|
* length range — see {@link IAugustBase.appName}.
|
|
15488
15503
|
*/
|
|
15489
|
-
constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, }: IAugustBase);
|
|
15504
|
+
constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, attribution, }: IAugustBase);
|
|
15490
15505
|
/**
|
|
15491
15506
|
* Verify API keys and authorize SDK usage.
|
|
15492
15507
|
* TODO: initialize class with appropriate keys and verify august key
|
|
@@ -16977,6 +16992,26 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
16977
16992
|
*/
|
|
16978
16993
|
export declare function balanceOf(signer: IContractRunner, options: IBalanceOfOptions): Promise<bigint>;
|
|
16979
16994
|
|
|
16995
|
+
/**
|
|
16996
|
+
* Build an ERC-8021 schema-0 attribution suffix from builder codes.
|
|
16997
|
+
*
|
|
16998
|
+
* Layout (appended to calldata, read back-to-front by parsers):
|
|
16999
|
+
* `ascii(codes.join(','))` ∥ codesLength (1 byte) ∥ schemaId `0x00` ∥
|
|
17000
|
+
* 16-byte marker `0x80218021802180218021802180218021`.
|
|
17001
|
+
*
|
|
17002
|
+
* @param codes Builder codes as printable-ASCII strings (e.g. `bc_abc123`),
|
|
17003
|
+
* each 1–64 chars, no commas; the comma-joined list must be ≤ 255 bytes.
|
|
17004
|
+
* @returns `0x`-prefixed hex suffix ready to concatenate onto calldata.
|
|
17005
|
+
* @throws Error when `codes` is empty, a code contains a comma or
|
|
17006
|
+
* non-printable/non-ASCII characters, or the joined list exceeds 255 bytes.
|
|
17007
|
+
* @example
|
|
17008
|
+
* ```typescript
|
|
17009
|
+
* buildAttributionSuffix(['baseapp', 'morpho']);
|
|
17010
|
+
* // '0x626173656170702c6d6f7270686f0e0080218021802180218021802180218021'
|
|
17011
|
+
* ```
|
|
17012
|
+
*/
|
|
17013
|
+
export declare function buildAttributionSuffix(codes: string[]): string;
|
|
17014
|
+
|
|
16980
17015
|
/**
|
|
16981
17016
|
* Build a base IVault from backend data, shared across non-EVM adapters (Solana, Stellar).
|
|
16982
17017
|
* Chain-specific fields (chainId, version, name, totalAssets, totalSupply, depositAssets, receipt)
|
|
@@ -17426,6 +17461,13 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
17426
17461
|
*/
|
|
17427
17462
|
export declare const determineSecondsPerBlock: (chain: number) => number;
|
|
17428
17463
|
|
|
17464
|
+
/**
|
|
17465
|
+
* The 16-byte ERC-8021 suffix terminator. The last 16 bytes of an attributed
|
|
17466
|
+
* transaction's calldata are always this marker; parsers read backwards from
|
|
17467
|
+
* it to recover the schema ID and builder codes.
|
|
17468
|
+
*/
|
|
17469
|
+
export declare const ERC8021_MARKER = "80218021802180218021802180218021";
|
|
17470
|
+
|
|
17429
17471
|
export declare const ERC_20_PERMIT_HASH = "0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9";
|
|
17430
17472
|
|
|
17431
17473
|
declare function error(options: {
|
|
@@ -18143,6 +18185,19 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
18143
18185
|
/** Classify an address by chain family (evm / solana / stellar / sui). */
|
|
18144
18186
|
export declare function getAddressChainType(address: string): ChainType;
|
|
18145
18187
|
|
|
18188
|
+
/**
|
|
18189
|
+
* Return the active ERC-8021 suffix for a write on the given chain, or
|
|
18190
|
+
* `undefined` when attribution is off or the chain is excluded.
|
|
18191
|
+
*
|
|
18192
|
+
* @param chainId EVM chain ID of the transaction, when the call site knows
|
|
18193
|
+
* it. When omitted and a `chains` restriction is configured, the suffix is
|
|
18194
|
+
* returned anyway (over-attribution is harmless; see
|
|
18195
|
+
* {@link IAttributionConfig.chains}).
|
|
18196
|
+
* @returns `0x`-prefixed hex suffix, or `undefined` when nothing should be
|
|
18197
|
+
* appended.
|
|
18198
|
+
*/
|
|
18199
|
+
export declare function getAttributionSuffix(chainId?: number): string | undefined;
|
|
18200
|
+
|
|
18146
18201
|
/**
|
|
18147
18202
|
* Get all chain IDs that a vault supports (hub + all spokes).
|
|
18148
18203
|
*/
|
|
@@ -18180,12 +18235,86 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
18180
18235
|
/**
|
|
18181
18236
|
* Fetch token decimals from contract or Solana mint.
|
|
18182
18237
|
* Results are cached to minimize RPC calls.
|
|
18238
|
+
*
|
|
18239
|
+
* **Never throws** — a failed read logs at error level and resolves
|
|
18240
|
+
* `undefined`. Callers that must not silently proceed on an unknown scale (any
|
|
18241
|
+
* path that encodes an amount) should use {@link getDecimalsOrThrow} instead:
|
|
18242
|
+
* feeding `undefined` into `toNormalizedBn` silently defaults to 18 decimals.
|
|
18243
|
+
*
|
|
18183
18244
|
* @param provider Web3 provider
|
|
18184
18245
|
* @param address Token contract address or Solana mint
|
|
18185
|
-
* @
|
|
18246
|
+
* @param isVault Resolve `address` as a vault (evm-2 vaults redirect to the
|
|
18247
|
+
* receipt token) rather than reading it as a plain ERC-20. Defaults to `true`.
|
|
18248
|
+
* @returns Number of decimals for the token, or `undefined` when the read failed.
|
|
18186
18249
|
*/
|
|
18187
18250
|
export declare const getDecimals: (provider: IContractRunner, address: IAddress, isVault?: boolean) => Promise<number>;
|
|
18188
18251
|
|
|
18252
|
+
/**
|
|
18253
|
+
* Read a token's `decimals()` with the **same cache and stampede protection as
|
|
18254
|
+
* {@link getDecimals}**, but surfacing failures instead of swallowing them, and
|
|
18255
|
+
* retrying the transient ones.
|
|
18256
|
+
*
|
|
18257
|
+
* Two reasons this exists rather than a flag on `getDecimals`:
|
|
18258
|
+
*
|
|
18259
|
+
* 1. **`getDecimals` must keep returning `undefined` on failure** — a dozen
|
|
18260
|
+
* read paths depend on that. Amount-encoding paths need the opposite: an
|
|
18261
|
+
* `undefined` reaching `toNormalizedBn` silently means 18 decimals, which
|
|
18262
|
+
* misencodes the transaction. Here the original error propagates, so the
|
|
18263
|
+
* caller's `AugustSDKError` keeps its cause and its Sentry grouping.
|
|
18264
|
+
* 2. **Retry.** Providers intermittently return an empty response to
|
|
18265
|
+
* `decimals()`, which ethers reports as
|
|
18266
|
+
* `missing revert data (action="call", data="0x313ce567", …)` — a shape a
|
|
18267
|
+
* deployed ERC-20 cannot legitimately produce, since `decimals()` takes no
|
|
18268
|
+
* arguments. That is retried here via {@link isEmptyViewResponse} scoped to
|
|
18269
|
+
* this exact selector, alongside ordinary transport faults
|
|
18270
|
+
* ({@link isRetryableRpcError}). The empty-view widening applies **only**
|
|
18271
|
+
* here; everywhere else the strict transport definition stands. A genuine
|
|
18272
|
+
* revert (`CALL_EXCEPTION` carrying revert data) is never retried.
|
|
18273
|
+
*
|
|
18274
|
+
* Cache is shared with `getDecimals`, so a read-then-write flow against the
|
|
18275
|
+
* same token costs one `decimals()` RPC in total, and N concurrent callers for
|
|
18276
|
+
* an uncached token collapse to one.
|
|
18277
|
+
*
|
|
18278
|
+
* **Exception — an unresolvable chain scope bypasses the cache entirely.** When
|
|
18279
|
+
* {@link resolveProviderScope} cannot determine the chain (a runner with no
|
|
18280
|
+
* resolved network and no connection URL, e.g. a browser provider before its
|
|
18281
|
+
* first request), the only available key is the shared `unknown` bucket. Read
|
|
18282
|
+
* paths happily use that bucket, and this function deliberately does not: the
|
|
18283
|
+
* two paths have different blast radii. A wrong cached `decimals` on a read
|
|
18284
|
+
* renders a wrong number on screen; on a write it misencodes an amount the user
|
|
18285
|
+
* then *signs*. The collision needed — the same address being a different token
|
|
18286
|
+
* with different decimals on two chains, within one process, across a
|
|
18287
|
+
* mid-session chain switch — is narrow, but "no worse than the read path" is
|
|
18288
|
+
* not the bar for a value that ends up in a transaction. In that case the read
|
|
18289
|
+
* is neither served from nor written to the cache, and it also skips the
|
|
18290
|
+
* in-flight dedup map, since joining another caller under an untrusted key
|
|
18291
|
+
* would reintroduce exactly the collision being avoided. Retries still apply;
|
|
18292
|
+
* the only thing forgone is the RPC saving.
|
|
18293
|
+
*
|
|
18294
|
+
* RPC cost: 1 on a cache miss, 0 on a hit, up to 3 on a miss that keeps
|
|
18295
|
+
* faulting (~750ms of added latency in the worst case before it gives up).
|
|
18296
|
+
* Always ≥1 when the chain scope is unresolvable.
|
|
18297
|
+
*
|
|
18298
|
+
* @param runner - Provider or signer to read through. A signer is unwrapped to
|
|
18299
|
+
* its provider for cache scoping, so it shares entries with reads on the
|
|
18300
|
+
* same chain.
|
|
18301
|
+
* @param address - Token address. Read directly as an ERC-20 — pass the
|
|
18302
|
+
* receipt-token address yourself for an `evm-2` vault's share scale.
|
|
18303
|
+
* @param tag - Low-cardinality label for retry breadcrumbs (e.g.
|
|
18304
|
+
* `'vaultDeposit:poolDecimals'`).
|
|
18305
|
+
* @returns The token's decimals.
|
|
18306
|
+
* @throws The underlying read error once retries are exhausted, or immediately
|
|
18307
|
+
* when the failure is neither a transport fault nor an empty view response.
|
|
18308
|
+
*
|
|
18309
|
+
* @example
|
|
18310
|
+
* ```ts
|
|
18311
|
+
* // Amount encoding must not proceed on a guessed scale.
|
|
18312
|
+
* const decimals = await getDecimalsOrThrow(signer, token, 'deposit:decimals');
|
|
18313
|
+
* const amount = toNormalizedBn(userInput, decimals);
|
|
18314
|
+
* ```
|
|
18315
|
+
*/
|
|
18316
|
+
export declare const getDecimalsOrThrow: (runner: IContractRunner, address: IAddress, tag: string) => Promise<number>;
|
|
18317
|
+
|
|
18189
18318
|
/**
|
|
18190
18319
|
* Previously fabricated a Goldsky subgraph URL from the chain name and vault
|
|
18191
18320
|
* symbol. That guess is unreliable and produced dead endpoints:
|
|
@@ -18384,12 +18513,90 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
18384
18513
|
/**
|
|
18385
18514
|
* Fetch receipt token address from tokenized vault contract.
|
|
18386
18515
|
* Results are cached to minimize RPC calls.
|
|
18516
|
+
*
|
|
18517
|
+
* **Never throws** — a failed read logs at error level and resolves
|
|
18518
|
+
* `undefined`, which several read paths depend on. The underlying
|
|
18519
|
+
* `lpTokenAddress()` call is made through
|
|
18520
|
+
* {@link getReceiptTokenAddressOrThrow}, so a transient provider blip is
|
|
18521
|
+
* absorbed by a bounded retry before that happens; a deterministic failure (a
|
|
18522
|
+
* vault that has no `lpTokenAddress()` because it is not `evm-2`) still resolves
|
|
18523
|
+
* `undefined` after the attempts are spent, exactly as before. Callers on a
|
|
18524
|
+
* money path must use {@link getReceiptTokenAddressOrThrow} directly instead —
|
|
18525
|
+
* an `undefined` receipt-token address there would silently mis-address a
|
|
18526
|
+
* `decimals()` read.
|
|
18527
|
+
*
|
|
18387
18528
|
* @param provider Web3 provider
|
|
18388
18529
|
* @param address Tokenized vault contract address
|
|
18389
|
-
* @returns Receipt token address
|
|
18530
|
+
* @returns Receipt token address, or `undefined` when the read failed.
|
|
18390
18531
|
*/
|
|
18391
18532
|
export declare const getReceiptTokenAddress: (provider: IContractRunner, address: IAddress) => Promise<`0x${string}`>;
|
|
18392
18533
|
|
|
18534
|
+
/**
|
|
18535
|
+
* Read an `evm-2` vault's receipt (LP) token address via `lpTokenAddress()`,
|
|
18536
|
+
* retrying only the transient transport faults and surfacing everything else
|
|
18537
|
+
* unchanged.
|
|
18538
|
+
*
|
|
18539
|
+
* Why this exists: `lpTokenAddress()` sits immediately before the receipt-token
|
|
18540
|
+
* `decimals()` read on every `evm-2` write path (approve / deposit / request
|
|
18541
|
+
* redeem / swap-router deposit). Those `decimals()` reads were hardened against
|
|
18542
|
+
* provider blips ({@link getDecimalsOrThrow}); the `lpTokenAddress()` read one
|
|
18543
|
+
* line above them was not, so a single truncated `eth_call` response still
|
|
18544
|
+
* failed the whole write with
|
|
18545
|
+
* `missing revert data (action="call", data="0xf5ae497a", …)` — observed in
|
|
18546
|
+
* production against a mainnet vault whose `lpTokenAddress()` demonstrably
|
|
18547
|
+
* returns a real address when the provider is healthy.
|
|
18548
|
+
*
|
|
18549
|
+
* **This must never hide a misrouted vault, and does not.** `lpTokenAddress()`
|
|
18550
|
+
* exists *only* on `evm-2` vaults. A vault wrongly classified as `evm-2` returns
|
|
18551
|
+
* empty returndata for it, deterministically and forever, and that empty
|
|
18552
|
+
* response is byte-identical to the transient one — it is the *only* signal the
|
|
18553
|
+
* SDK gets that its version routing was wrong. So the retry here is deliberately
|
|
18554
|
+
* shaped to preserve that signal:
|
|
18555
|
+
*
|
|
18556
|
+
* - it is **bounded** (3 attempts, ~750ms of backoff in total — see
|
|
18557
|
+
* `retryOnTransientRpc`), never open-ended;
|
|
18558
|
+
* - on exhaustion it **rethrows the original error object**, with its identity,
|
|
18559
|
+
* message, `code` and `transaction.data` intact, so the caller's
|
|
18560
|
+
* `AugustSDKError` cause and Sentry grouping are exactly what they are today;
|
|
18561
|
+
* - it has **no fallback**: it never substitutes another address, never resolves
|
|
18562
|
+
* the vault address itself, and never resolves `null`/`undefined`. It either
|
|
18563
|
+
* returns a real receipt-token address or throws.
|
|
18564
|
+
*
|
|
18565
|
+
* Net effect: a blip costs a retry, a misroute costs three `eth_call`s and then
|
|
18566
|
+
* fails exactly as loudly as before.
|
|
18567
|
+
*
|
|
18568
|
+
* **Deliberately not cached.** Unlike `decimals()`, the vault→receipt-token
|
|
18569
|
+
* mapping is not memoized here. Caching it would make a misroute's first
|
|
18570
|
+
* (failed) probe and every subsequent one diverge, and would put a
|
|
18571
|
+
* vault-identity mapping in the cache on the money path. The lenient, cached
|
|
18572
|
+
* reader is {@link getReceiptTokenAddress} — use that on read paths that can
|
|
18573
|
+
* tolerate `undefined`.
|
|
18574
|
+
*
|
|
18575
|
+
* RPC cost: exactly 1 `eth_call` on success; at most 3 when the provider keeps
|
|
18576
|
+
* faulting.
|
|
18577
|
+
*
|
|
18578
|
+
* @param runner - Provider or signer to read through.
|
|
18579
|
+
* @param vault - Address of the `evm-2` tokenized vault.
|
|
18580
|
+
* @param tag - Low-cardinality label for retry breadcrumbs (e.g.
|
|
18581
|
+
* `'vaultRequestRedeem:receiptToken'`).
|
|
18582
|
+
* @returns The vault's receipt (LP) token address. Never `null`/`undefined`.
|
|
18583
|
+
* @throws The underlying read error, unmodified, once the bounded retries are
|
|
18584
|
+
* exhausted — or immediately when the failure is neither a transport fault nor
|
|
18585
|
+
* an empty response to this exact selector (e.g. a genuine revert carrying
|
|
18586
|
+
* revert data).
|
|
18587
|
+
*
|
|
18588
|
+
* @example
|
|
18589
|
+
* ```ts
|
|
18590
|
+
* const receiptToken = await getReceiptTokenAddressOrThrow(
|
|
18591
|
+
* signer,
|
|
18592
|
+
* vault,
|
|
18593
|
+
* 'vaultRequestRedeem:receiptToken',
|
|
18594
|
+
* );
|
|
18595
|
+
* const decimals = await getDecimalsOrThrow(signer, receiptToken, 'tag');
|
|
18596
|
+
* ```
|
|
18597
|
+
*/
|
|
18598
|
+
export declare const getReceiptTokenAddressOrThrow: (runner: IContractRunner, vault: IAddress, tag: string) => Promise<IAddress>;
|
|
18599
|
+
|
|
18393
18600
|
/**
|
|
18394
18601
|
* Fetches the remaining allocation for an address on a whitelist contract
|
|
18395
18602
|
* @param signer - signer / provider object
|
|
@@ -19293,6 +19500,37 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
19293
19500
|
is_show_compound_apy?: boolean;
|
|
19294
19501
|
}
|
|
19295
19502
|
|
|
19503
|
+
/**
|
|
19504
|
+
* Configuration for ERC-8021 calldata-suffix attribution (Base Builder Codes).
|
|
19505
|
+
*
|
|
19506
|
+
* @example
|
|
19507
|
+
* ```typescript
|
|
19508
|
+
* const sdk = new AugustSDK({
|
|
19509
|
+
* appName: 'my-app',
|
|
19510
|
+
* providers: { 8453: 'https://...' },
|
|
19511
|
+
* keys: { august: '...' },
|
|
19512
|
+
* attribution: { builderCodes: ['bc_abc123'] },
|
|
19513
|
+
* });
|
|
19514
|
+
* ```
|
|
19515
|
+
*/
|
|
19516
|
+
export declare interface IAttributionConfig {
|
|
19517
|
+
/**
|
|
19518
|
+
* Builder codes to embed in the suffix, e.g. from base.dev registration
|
|
19519
|
+
* (`bc_…`). ASCII strings of 1–64 characters each; the comma-joined list
|
|
19520
|
+
* must fit in 255 bytes (schema 0 length prefix is a single byte).
|
|
19521
|
+
*/
|
|
19522
|
+
builderCodes: string[];
|
|
19523
|
+
/**
|
|
19524
|
+
* EVM chain IDs to attribute. Omit to attribute writes on every EVM chain
|
|
19525
|
+
* (the suffix is inert on chains without an ERC-8021 indexer and costs
|
|
19526
|
+
* ~16 gas per non-zero byte). When set, writes on other chains are sent
|
|
19527
|
+
* without the suffix; call sites that cannot determine their chain ID
|
|
19528
|
+
* append the suffix regardless, since over-attribution is harmless and
|
|
19529
|
+
* under-attribution loses data.
|
|
19530
|
+
*/
|
|
19531
|
+
chains?: number[];
|
|
19532
|
+
}
|
|
19533
|
+
|
|
19296
19534
|
export declare interface IAugustBase {
|
|
19297
19535
|
/**
|
|
19298
19536
|
* Identifier-shaped name for the integrating application. Required.
|
|
@@ -19366,6 +19604,21 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
19366
19604
|
* a stale cross-environment base is higher blast-radius than a stale timeout.)
|
|
19367
19605
|
*/
|
|
19368
19606
|
publicApiBaseUrl?: string;
|
|
19607
|
+
/**
|
|
19608
|
+
* ERC-8021 calldata-suffix attribution (Base Builder Codes). When set,
|
|
19609
|
+
* every EVM write sent through the SDK — ethers vault writes and the
|
|
19610
|
+
* cross-chain (OVault) viem writes — carries the attribution suffix so
|
|
19611
|
+
* offchain indexers (base.dev) can credit the transaction to your app.
|
|
19612
|
+
* Omit to send unattributed transactions (the default).
|
|
19613
|
+
*
|
|
19614
|
+
* Note: this is a process-global override applied on EVERY construction —
|
|
19615
|
+
* the last `AugustSDK` instantiated is authoritative, and one that omits
|
|
19616
|
+
* `attribution` RESETS it (same semantics as `publicApiBaseUrl`).
|
|
19617
|
+
*
|
|
19618
|
+
* @throws Throws synchronously from the constructor when the builder codes
|
|
19619
|
+
* are malformed — see {@link IAttributionConfig}.
|
|
19620
|
+
*/
|
|
19621
|
+
attribution?: IAttributionConfig;
|
|
19369
19622
|
}
|
|
19370
19623
|
|
|
19371
19624
|
/** Options for {@link balanceOf}. */
|
|
@@ -20725,6 +20978,54 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
20725
20978
|
|
|
20726
20979
|
export declare function isEarlierThanNow(startTime: Date): boolean;
|
|
20727
20980
|
|
|
20981
|
+
/**
|
|
20982
|
+
* Is this error an **empty RPC response to an argument-free view call** —
|
|
20983
|
+
* i.e. a transport artefact wearing a revert's clothes?
|
|
20984
|
+
*
|
|
20985
|
+
* Why this is separate from {@link isRetryableRpcError}: when a provider
|
|
20986
|
+
* truncates or 500s a response to `eth_call`, ethers reports
|
|
20987
|
+
* `missing revert data (action="call", data="0x313ce567", …)` with a `null`
|
|
20988
|
+
* `data` field. That is byte-for-byte the shape of a genuine revert with no
|
|
20989
|
+
* reason string, so a general "transport" predicate cannot safely claim it —
|
|
20990
|
+
* doing so would retry every data-less `CALL_EXCEPTION` in the SDK. This
|
|
20991
|
+
* predicate narrows the claim to the one case where the ambiguity resolves:
|
|
20992
|
+
* a **deployed ERC-20's `decimals()`/`symbol()`/`name()`/`totalSupply()` cannot
|
|
20993
|
+
* legitimately revert**, because it takes no arguments and returns state fixed
|
|
20994
|
+
* at deployment. An empty response there is the provider's fault, full stop.
|
|
20995
|
+
*
|
|
20996
|
+
* A match requires all of:
|
|
20997
|
+
* 1. no revert evidence ({@link hasRevertEvidence}) — anything carrying real
|
|
20998
|
+
* revert `data`, an `execution reverted` message, or a failed receipt is out;
|
|
20999
|
+
* 2. a `missing revert data` message;
|
|
21000
|
+
* 3. an `action` of `call` or `staticCall` — a read, never a state change;
|
|
21001
|
+
* 4. **when a selector is derivable** from the error, that it is
|
|
21002
|
+
* `expectedSelector` (if given) or one of
|
|
21003
|
+
* {@link ARGUMENT_FREE_VIEW_SELECTORS}. When no selector can be recovered,
|
|
21004
|
+
* conditions 1–3 stand on their own.
|
|
21005
|
+
*
|
|
21006
|
+
* Note the cost of a false positive is bounded and small: the caller retries an
|
|
21007
|
+
* idempotent read a couple of times before surfacing the same error. The cost
|
|
21008
|
+
* of a false negative is the production flood this predicate exists to stop.
|
|
21009
|
+
*
|
|
21010
|
+
* @param error - The caught value, of unknown type.
|
|
21011
|
+
* @param expectedSelector - Optional `0x`-prefixed 4-byte selector the caller
|
|
21012
|
+
* knows it invoked (e.g. `'0x313ce567'` for `decimals()`). When supplied, the
|
|
21013
|
+
* error's own selector must match it — this stops a `decimals()` retry from
|
|
21014
|
+
* firing on an unrelated view call that happened to fail the same way.
|
|
21015
|
+
* @returns `true` when the failure is an empty provider response to a view call
|
|
21016
|
+
* that cannot revert, and is therefore safe to retry.
|
|
21017
|
+
*
|
|
21018
|
+
* @example
|
|
21019
|
+
* ```ts
|
|
21020
|
+
* try { return Number(await erc20.decimals()); }
|
|
21021
|
+
* catch (e) {
|
|
21022
|
+
* if (!isEmptyViewResponse(e, '0x313ce567')) throw e; // real problem
|
|
21023
|
+
* return Number(await erc20.decimals()); // provider blip
|
|
21024
|
+
* }
|
|
21025
|
+
* ```
|
|
21026
|
+
*/
|
|
21027
|
+
export declare function isEmptyViewResponse(error: unknown, expectedSelector?: string): boolean;
|
|
21028
|
+
|
|
20728
21029
|
/**
|
|
20729
21030
|
* Is this error a routine on-chain read revert rather than a real failure?
|
|
20730
21031
|
*
|
|
@@ -20886,6 +21187,51 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
20886
21187
|
*/
|
|
20887
21188
|
export declare function isRetryableError(error: Error): boolean;
|
|
20888
21189
|
|
|
21190
|
+
/**
|
|
21191
|
+
* Is this error a transient RPC **transport** failure that is safe to retry,
|
|
21192
|
+
* rather than a decision the chain made?
|
|
21193
|
+
*
|
|
21194
|
+
* Why this exists: the SDK's write paths poll `eth_getTransactionReceipt` to
|
|
21195
|
+
* confirm a broadcast transaction. When the provider hiccups mid-poll, ethers
|
|
21196
|
+
* surfaces `could not coalesce error (error={ "code": -32603, … "method":
|
|
21197
|
+
* "eth_getTransactionReceipt" … })`. Historically that propagated out of
|
|
21198
|
+
* `safeWaitForTx` and the SDK reported the write as **failed** — even though
|
|
21199
|
+
* the transaction was broadcast, its hash was known, and it mined fine. Users
|
|
21200
|
+
* then retried and hit `ERC20InsufficientBalance` because the first attempt had
|
|
21201
|
+
* in fact succeeded. Classifying the failure as transport-level lets callers
|
|
21202
|
+
* re-poll instead of lying to the user.
|
|
21203
|
+
*
|
|
21204
|
+
* Matches, in order of precedence:
|
|
21205
|
+
* 1. **Veto** — anything with revert evidence ({@link hasRevertEvidence}:
|
|
21206
|
+
* `CALL_EXCEPTION` carrying revert `data`, an `execution reverted` message,
|
|
21207
|
+
* or an attached `receipt.status === 0`) returns `false`. Nodes reuse
|
|
21208
|
+
* `-32603`/`-32000` for real reverts, so the veto must come first.
|
|
21209
|
+
* 2. JSON-RPC / ethers transport codes — see `RETRYABLE_RPC_CODES`.
|
|
21210
|
+
* 3. HTTP `429` and any `5xx` carried on the error.
|
|
21211
|
+
* 4. Transport message fragments — see `RETRYABLE_RPC_PHRASES`.
|
|
21212
|
+
*
|
|
21213
|
+
* Retrying is only safe for **idempotent** work: re-reading an immutable value
|
|
21214
|
+
* (`decimals()`) or re-polling a receipt for a hash that is already on the
|
|
21215
|
+
* wire. Never use this to re-send a transaction.
|
|
21216
|
+
*
|
|
21217
|
+
* @param error - The caught value, of unknown type.
|
|
21218
|
+
* @returns `true` when the failure is a transient transport fault worth
|
|
21219
|
+
* retrying with backoff; `false` for chain-level decisions (reverts) and for
|
|
21220
|
+
* anything unrecognised — the safe default is to surface the error.
|
|
21221
|
+
*
|
|
21222
|
+
* @example
|
|
21223
|
+
* ```ts
|
|
21224
|
+
* try {
|
|
21225
|
+
* return await provider.waitForTransaction(hash, 1, 120_000);
|
|
21226
|
+
* } catch (e) {
|
|
21227
|
+
* if (!isRetryableRpcError(e)) throw e; // real revert — surface it
|
|
21228
|
+
* await sleep(250);
|
|
21229
|
+
* return await provider.waitForTransaction(hash, 1, 120_000);
|
|
21230
|
+
* }
|
|
21231
|
+
* ```
|
|
21232
|
+
*/
|
|
21233
|
+
export declare function isRetryableRpcError(error: unknown): boolean;
|
|
21234
|
+
|
|
20889
21235
|
/**
|
|
20890
21236
|
* Check if a string is a valid Solana base58 address (including PDAs).
|
|
20891
21237
|
* Returns `false` for EVM hex addresses.
|
|
@@ -23023,6 +23369,14 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
23023
23369
|
*/
|
|
23024
23370
|
export declare function lookupSelector(selector: string): Promise<string[]>;
|
|
23025
23371
|
|
|
23372
|
+
/**
|
|
23373
|
+
* `lpTokenAddress()` — `keccak256("lpTokenAddress()")[0..4]`. The August `evm-2`
|
|
23374
|
+
* tokenized vault's receipt-token getter, exported so the readers that invoke it
|
|
23375
|
+
* can scope {@link isEmptyViewResponse} to exactly this call instead of
|
|
23376
|
+
* duplicating the literal.
|
|
23377
|
+
*/
|
|
23378
|
+
export declare const LP_TOKEN_ADDRESS_SELECTOR = "0xf5ae497a";
|
|
23379
|
+
|
|
23026
23380
|
/**
|
|
23027
23381
|
* Map composability integrations from backend format to vault format.
|
|
23028
23382
|
* Shared across all chain adapters.
|
|
@@ -23528,6 +23882,49 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
23528
23882
|
|
|
23529
23883
|
/* Excluded from this release type: resolveSpender */
|
|
23530
23884
|
|
|
23885
|
+
/**
|
|
23886
|
+
* Run an **idempotent** RPC read, retrying with exponential backoff while the
|
|
23887
|
+
* failure classifies as a transient transport fault
|
|
23888
|
+
* ({@link isRetryableRpcError}).
|
|
23889
|
+
*
|
|
23890
|
+
* Lives next to the classifiers it consumes so there is exactly one retry
|
|
23891
|
+
* implementation in the SDK: both the receipt-poll fallback in the vault write
|
|
23892
|
+
* paths and the cached `decimals()` reader in `core/helpers/web3.ts` call this.
|
|
23893
|
+
*
|
|
23894
|
+
* Only safe for operations that can be repeated without side effects: polling
|
|
23895
|
+
* `eth_getTransactionReceipt` for an already-broadcast hash, or re-reading an
|
|
23896
|
+
* immutable value such as `decimals()`. **Never wrap a transaction send in
|
|
23897
|
+
* this.**
|
|
23898
|
+
*
|
|
23899
|
+
* Anything that is not a transport fault (a genuine revert, a user rejection,
|
|
23900
|
+
* an insufficient-funds rejection) is rethrown on the first attempt with no
|
|
23901
|
+
* delay, so real failures still fail fast.
|
|
23902
|
+
*
|
|
23903
|
+
* @param tag - Low-cardinality log label for the retry breadcrumb.
|
|
23904
|
+
* @param operation - The idempotent async read to run.
|
|
23905
|
+
* @param context - Extra structured context for the retry breadcrumb (e.g.
|
|
23906
|
+
* `{ hash }`). Sanitized by the logger before transport.
|
|
23907
|
+
* @param isRetryable - Predicate deciding whether a caught error warrants
|
|
23908
|
+
* another attempt. Defaults to the strict transport definition
|
|
23909
|
+
* ({@link isRetryableRpcError}); pass a wider one only where the call site
|
|
23910
|
+
* can prove the extra shape is also a provider artefact — the only such case
|
|
23911
|
+
* today is the selector-scoped {@link isEmptyViewResponse} used by
|
|
23912
|
+
* `getDecimalsOrThrow`.
|
|
23913
|
+
* @returns Whatever `operation` resolves to on the first successful attempt.
|
|
23914
|
+
* @throws The last error thrown by `operation` once retries are exhausted, or
|
|
23915
|
+
* immediately when the error is not retryable.
|
|
23916
|
+
*
|
|
23917
|
+
* @example
|
|
23918
|
+
* ```ts
|
|
23919
|
+
* const receipt = await retryOnTransientRpc(
|
|
23920
|
+
* 'safeWaitForTx:transport-retry',
|
|
23921
|
+
* () => provider.waitForTransaction(hash, 1, 120_000),
|
|
23922
|
+
* { hash },
|
|
23923
|
+
* );
|
|
23924
|
+
* ```
|
|
23925
|
+
*/
|
|
23926
|
+
export declare function retryOnTransientRpc<T>(tag: string, operation: () => Promise<T>, context?: Record<string, unknown>, isRetryable?: (error: unknown) => boolean): Promise<T>;
|
|
23927
|
+
|
|
23531
23928
|
export declare const REWARD_DISTRIBUTOR_ADDRESS: (chainId: number) => string[];
|
|
23532
23929
|
|
|
23533
23930
|
/**
|
|
@@ -24378,6 +24775,22 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
24378
24775
|
vault: IAddress;
|
|
24379
24776
|
}): Promise<IAddress | undefined>;
|
|
24380
24777
|
|
|
24778
|
+
/**
|
|
24779
|
+
* Set (or clear) the process-global attribution config.
|
|
24780
|
+
*
|
|
24781
|
+
* Called unconditionally on every `AugustSDK` construction — an instance
|
|
24782
|
+
* that omits `attribution` passes `null` and RESETS the state, so a prior
|
|
24783
|
+
* instance's builder codes never leak into a later instance in the same
|
|
24784
|
+
* process (same semantics as `setPublicApiBaseUrl`).
|
|
24785
|
+
*
|
|
24786
|
+
* @param config Attribution config from the SDK constructor, or `null` to
|
|
24787
|
+
* disable attribution.
|
|
24788
|
+
* @throws Error when the config's builder codes fail validation — thrown
|
|
24789
|
+
* synchronously from the constructor so misconfiguration is caught at
|
|
24790
|
+
* init, not on the first write.
|
|
24791
|
+
*/
|
|
24792
|
+
export declare function setAttribution(config: IAttributionConfig | null): void;
|
|
24793
|
+
|
|
24381
24794
|
declare function setDevMode(devMode: boolean): void;
|
|
24382
24795
|
|
|
24383
24796
|
declare function setLogger(customLogger: SDKLogger): void;
|
|
@@ -26139,4 +26552,26 @@ declare function assertNotStellar(address: string, operation: string): void;
|
|
|
26139
26552
|
1: IAddress;
|
|
26140
26553
|
};
|
|
26141
26554
|
|
|
26555
|
+
/**
|
|
26556
|
+
* Wrap an ethers signer so every transaction it sends carries the active
|
|
26557
|
+
* ERC-8021 attribution suffix (Base Builder Codes).
|
|
26558
|
+
*
|
|
26559
|
+
* Every ethers write in the SDK funnels through the wrapped signer's
|
|
26560
|
+
* `sendTransaction`, so this single wrap attributes all vault writes. The
|
|
26561
|
+
* wrapper is a Proxy — the caller's signer object is never mutated, so a
|
|
26562
|
+
* signer reused outside the SDK sends unattributed transactions. Attribution
|
|
26563
|
+
* state is read at send time, not wrap time; when no attribution is
|
|
26564
|
+
* configured (see `IAugustBase.attribution`) the wrapper is a pass-through.
|
|
26565
|
+
*
|
|
26566
|
+
* Plain value transfers (no calldata) are never attributed, and calldata
|
|
26567
|
+
* already ending in the ERC-8021 marker is left untouched. When the
|
|
26568
|
+
* configured `chains` list requires a chain check and the transaction does
|
|
26569
|
+
* not carry a `chainId`, the signer's provider network is consulted (one
|
|
26570
|
+
* cached RPC call).
|
|
26571
|
+
*
|
|
26572
|
+
* @param signer Normalized ethers Signer or Wallet.
|
|
26573
|
+
* @returns A proxied signer with an attribution-aware `sendTransaction`.
|
|
26574
|
+
*/
|
|
26575
|
+
export declare function wrapSignerWithAttribution<T extends Signer | Wallet>(signer: T): T;
|
|
26576
|
+
|
|
26142
26577
|
export { }
|