@sodax/sdk 2.2.0-rc.5 → 2.2.0-rc.7
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 +11 -5
- package/dist/index.cjs +2567 -420
- package/dist/index.d.cts +1272 -60
- package/dist/index.d.ts +1272 -60
- package/dist/index.mjs +2562 -430
- package/package.json +8 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SodaxFeature, ISwapsApiV2, Result, SwapsApiConfig, SodaxLogger, GetSwapTokensResponseV2, GetSwapTokensByChainResponseV2, QuoteRequestV2, QuoteQueryV2, QuoteResponseV2, DeadlineQueryV2, DeadlineResponseV2, CreateIntentParamsV2, AllowanceCheckResponseV2, ApproveResponseV2, CreateIntentResponseV2, SubmitIntentRequestV2, SubmitIntentResponseV2, StatusRequestV2, StatusResponseV2, CancelIntentRequestV2, CancelIntentResponseV2, IntentHashRequestV2, IntentHashResponseV2, IntentPacketRequestV2, IntentPacketResponseV2, IntentExtraDataRequestV2, IntentExtraDataResponseV2, IntentStateV2, GetIntentResponseV2, CreateLimitOrderParamsV2, CreateLimitOrderResponseV2, GasEstimateRequestV2, GasEstimateResponseV2, FeeQueryV2, FeeResponseV2, SubmitTxRequestV2, SubmitTxResponseV2, SubmitTxStatusQueryV2, SubmitTxStatusResponseV2, IStellarSponsoringApi, SponsoringApiConfig, StellarSponsorConfig, StellarSponsoredAccountRequest, StellarSponsoredAccountResponse, IBridgeApiV2, BaseApiConfig, GetBridgeTokensResponseV2, GetBridgeTokensByChainResponseV2, CreateBridgeIntentParamsV2, BridgeAllowanceCheckResponseV2, BridgeApproveResponseV2, CreateBridgeIntentResponseV2, BridgeSubmitTxRequestV2, BridgeSubmitTxResponseV2, BridgeSubmitTxStatusQueryV2, BridgeSubmitTxStatusResponseV2, BridgeFeeRequestV2, BridgeFeeResponseV2, BridgeQuoteRequestV2, BridgeableAmountResponseV2, BridgeableCheckResponseV2, BitcoinBoundExtrasV2, PartnerFeeV2, ILeverageYieldApiV2, GetLeverageVaultsResponseV2, GetLeverageVaultResponseV2, VaultQueryV2, VaultAssetResponseV2, LeverageYieldPositionV2, LeverageYieldAprV2, LeverageYieldEffectiveAprV2, LeverageYieldLsdAprV2, VaultTotalAssetsResponseV2, VaultAssetsQueryV2, PreviewDepositResponseV2, PreviewWithdrawResponseV2, VaultSharesQueryV2, PreviewRedeemResponseV2, VaultOwnerQueryV2, ShareBalanceResponseV2, MaxWithdrawResponseV2, LeverageYieldDepositQuoteRequestV2, LeverageYieldWithdrawQuoteRequestV2, CreateDepositIntentParamsV2, CreateWithdrawIntentParamsV2, LeverageYieldSubmitTxRequestV2, IConfigApiV1, ApiConfig, Address, GetAllConfigApiResponse, GetChainsApiResponse, GetSwapTokensApiResponse, SpokeChainKey, GetSwapTokensByChainIdApiResponse, GetMoneyMarketTokensApiResponse, GetMoneyMarketReserveAssetsApiResponse, GetMoneyMarketTokensByChainIdApiResponse, GetRelayChainIdMapApiResponse, GetSpokeChainConfigApiResponse, AnalyticsDetailLevel, AnalyticsEventPhase, AnalyticsOption, PartnerFee, RadfiSigner, SodaxConfig, SodaxOptions, XToken, OriginalAssetAddress, IntentRelayChainId, HubChainKey, HubConfig, PoolKey, SpokeChainConfig, RelayConfig, SolverConfig, SwapsConfig, BridgeConfig, MoneyMarketConfig, LeverageYieldConfig, DexConfig, GetSpokeChainConfigType, SodaxDefaultConfig, EvmContractCall, Hex, IEvmWalletProvider, EvmRawTransactionReceipt, QuoteType, EvmChainKey, DeepPartial, WalletProviderSlot, TxReturnType, ChainType, GetChainType, SolanaRawTransactionReceipt, StellarSorobanTransactionReceipt, IconTransactionResult, SuiRawTransactionReceipt, InjectiveRawTransactionReceipt, NearRawTransactionReceipt, StacksRawTransactionReceipt, BitcoinRawTransactionReceipt, GetAddressType, HubAddress, GetTokenAddressType, EvmSpokeOnlyChainKey, StellarChainKey, HookKind, SonicChainKey, AssetInfo, TokenInfo, VaultReserves, StacksChainKey, FeeEstimateTransaction, StacksTransactionParams, HttpUrl, RadfiConfig, IBitcoinWalletProvider, RadfiDepositTxResponse, BtcAddressType, BitcoinChainKey, BitcoinRawTransaction, NearChainKey, FillData, NearRawTransaction, INearWalletProvider, SuiTransport, SuiPaginatedCoins, SuiChainKey, SuiExecutionResult, SuiGasEstimate, IStellarWalletProvider, StellarGasEstimate, SolanaChainKey, SolanaGasEstimate, SolanaBase58PublicKey, SolanaRawTransactionInstruction, SolanaSerializedTransaction, SolanaRpcResponseAndContext, SolanaTokenAmount, IconChainKey, IconGasEstimate, InjectiveChainKey, InjectiveGasEstimate, JsonObject, InjectiveCoin, InjectiveRawTransaction, IInjectiveWalletProvider, InjectiveExecuteResponse, GetEstimateGasReturnType, SuiTransaction, SuiWaitForTransactionParams, IconAddress, IWalletProvider, EvmSpokeChainConfig, PartnerFeeAmount, PartnerFeePercentage, GetWalletProviderType, SodaxLoggerOption, SubmitTxStatusDataV2, SolverIntentStatusResponse, SpokeExecActionParams, FeeAmount, Hash as Hash$1, SolverIntentQuoteRequest, SolverIntentQuoteResponse, SolverErrorResponse, SolverIntentStatusRequest, SolverExecutionRequest, SolverExecutionResponse, IconEoaAddress, IcxTokenType, IconContractAddress, BridgeLimit, UserUnstakeInfo, ConcentratedLiquidityConfig, LeverageYieldVault, SponsoringApiErrorCode } from '@sodax/types';
|
|
1
|
+
import { SodaxFeature, ISwapsApiV2, Result, SwapsApiConfig, SodaxLogger, GetSwapTokensResponseV2, GetSwapTokensByChainResponseV2, QuoteRequestV2, QuoteQueryV2, QuoteResponseV2, DeadlineQueryV2, DeadlineResponseV2, CreateIntentParamsV2, AllowanceCheckResponseV2, ApproveResponseV2, CreateIntentResponseV2, SubmitIntentRequestV2, SubmitIntentResponseV2, StatusRequestV2, StatusResponseV2, CancelIntentRequestV2, CancelIntentResponseV2, IntentHashRequestV2, IntentHashResponseV2, IntentPacketRequestV2, IntentPacketResponseV2, IntentExtraDataRequestV2, IntentExtraDataResponseV2, IntentStateV2, GetIntentResponseV2, CreateLimitOrderParamsV2, CreateLimitOrderResponseV2, GasEstimateRequestV2, GasEstimateResponseV2, FeeQueryV2, FeeResponseV2, SubmitTxRequestV2, SubmitTxResponseV2, SubmitTxStatusQueryV2, SubmitTxStatusResponseV2, IStellarSponsoringApi, SponsoringApiConfig, StellarSponsorConfig, StellarSponsoredAccountRequest, StellarSponsoredAccountResponse, IBridgeApiV2, BaseApiConfig, GetBridgeTokensResponseV2, GetBridgeTokensByChainResponseV2, CreateBridgeIntentParamsV2, BridgeAllowanceCheckResponseV2, BridgeApproveResponseV2, CreateBridgeIntentResponseV2, BridgeSubmitTxRequestV2, BridgeSubmitTxResponseV2, BridgeSubmitTxStatusQueryV2, BridgeSubmitTxStatusResponseV2, BridgeFeeRequestV2, BridgeFeeResponseV2, BridgeQuoteRequestV2, BridgeableAmountResponseV2, BridgeableCheckResponseV2, BitcoinBoundExtrasV2, PartnerFeeV2, ILeverageYieldApiV2, GetLeverageVaultsResponseV2, GetLeverageVaultResponseV2, VaultQueryV2, VaultAssetResponseV2, LeverageYieldPositionV2, LeverageYieldAprV2, LeverageYieldEffectiveAprV2, LeverageYieldLsdAprV2, VaultTotalAssetsResponseV2, VaultAssetsQueryV2, PreviewDepositResponseV2, PreviewWithdrawResponseV2, VaultSharesQueryV2, PreviewRedeemResponseV2, VaultOwnerQueryV2, ShareBalanceResponseV2, MaxWithdrawResponseV2, LeverageYieldDepositQuoteRequestV2, LeverageYieldWithdrawQuoteRequestV2, CreateDepositIntentParamsV2, CreateWithdrawIntentParamsV2, LeverageYieldSubmitTxRequestV2, IConfigApiV1, ApiConfig, Address, GetAllConfigApiResponse, GetChainsApiResponse, GetSwapTokensApiResponse, SpokeChainKey, GetSwapTokensByChainIdApiResponse, GetMoneyMarketTokensApiResponse, GetMoneyMarketReserveAssetsApiResponse, GetMoneyMarketTokensByChainIdApiResponse, GetRelayChainIdMapApiResponse, GetSpokeChainConfigApiResponse, AnalyticsDetailLevel, AnalyticsEventPhase, AnalyticsOption, PartnerFee, RadfiSigner, SodaxConfig, SodaxOptions, XToken, OriginalAssetAddress, IntentRelayChainId, HubChainKey, HubConfig, PoolKey, SpokeChainConfig, RelayConfig, SolverConfig, SwapsConfig, BridgeConfig, MoneyMarketConfig, LeverageYieldConfig, DexConfig, GetSpokeChainConfigType, SodaxDefaultConfig, EvmContractCall, Hex, IEvmWalletProvider, EvmRawTransactionReceipt, QuoteType, EvmChainKey, DeepPartial, WalletProviderSlot, TxReturnType, ChainType, GetChainType, SolanaRawTransactionReceipt, StellarSorobanTransactionReceipt, IconTransactionResult, SuiRawTransactionReceipt, InjectiveRawTransactionReceipt, NearRawTransactionReceipt, StacksRawTransactionReceipt, BitcoinRawTransactionReceipt, GetAddressType, HubAddress, GetTokenAddressType, EvmSpokeOnlyChainKey, StellarChainKey, HookKind, SonicChainKey, AssetInfo, TokenInfo, VaultReserves, StacksChainKey, FeeEstimateTransaction, StacksTransactionParams, HttpUrl, RadfiConfig, IBitcoinWalletProvider, RadfiDepositTxResponse, BtcAddressType, BitcoinChainKey, BitcoinRawTransaction, NearChainKey, FillData, NearRawTransaction, INearWalletProvider, SuiTransport, SuiPaginatedCoins, SuiChainKey, SuiExecutionResult, SuiGasEstimate, IStellarWalletProvider, StellarGasEstimate, SolanaChainKey, SolanaGasEstimate, SolanaBase58PublicKey, SolanaRawTransactionInstruction, SolanaSerializedTransaction, SolanaRpcResponseAndContext, SolanaTokenAmount, IconChainKey, IconGasEstimate, InjectiveChainKey, InjectiveGasEstimate, JsonObject, InjectiveCoin, InjectiveRawTransaction, IInjectiveWalletProvider, InjectiveExecuteResponse, GetEstimateGasReturnType, SuiTransaction, SuiWaitForTransactionParams, IconAddress, IWalletProvider, EvmSpokeChainConfig, PartnerFeeAmount, PartnerFeePercentage, GetWalletProviderType, SodaxLoggerOption, SubmitTxStatusDataV2, SolverIntentStatusResponse, SpokeExecActionParams, FeeAmount, Hash as Hash$1, SolverIntentQuoteRequest, SolverIntentQuoteResponse, SolverErrorResponse, SolverIntentStatusRequest, SolverExecutionRequest, SolverExecutionResponse, IconEoaAddress, IcxTokenType, IconContractAddress, BridgeSubmitTxStatusDataV2, BridgeLimit, UserUnstakeInfo, ConcentratedLiquidityConfig, LeverageYieldVault, LeveragePosition, LeveragePositionAccount, LeveragePositionCollateral, LeveragePositionPendingState, EvmRawTransaction, SponsoringApiErrorCode } from '@sodax/types';
|
|
2
2
|
export * from '@sodax/types';
|
|
3
3
|
export { SodaxFeature } from '@sodax/types';
|
|
4
4
|
import * as v from 'valibot';
|
|
@@ -18,6 +18,7 @@ import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
|
18
18
|
import { Price, Token } from '@pancakeswap/swap-sdk-core';
|
|
19
19
|
import BigNumber$1 from 'bignumber.js';
|
|
20
20
|
export { SwapsApiError, SwapsApiErrorCode, SwapsApiErrorContext } from '@sodax/swaps-api';
|
|
21
|
+
export { BridgeApiError, BridgeApiErrorCode, BridgeApiErrorContext } from '@sodax/bridge-api';
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Unified error vocabulary for the SODAX SDK.
|
|
@@ -7558,7 +7559,7 @@ type ResultifiedSwapsApiV2 = {
|
|
|
7558
7559
|
[K in keyof ISwapsApiV2]: ISwapsApiV2[K] extends (...args: infer A) => Promise<infer R> ? (...args: [...A, config?: RequestOverrideConfig]) => Promise<Result<R>> : never;
|
|
7559
7560
|
};
|
|
7560
7561
|
/**
|
|
7561
|
-
* HTTP client for the backend **Swaps API
|
|
7562
|
+
* HTTP client for the backend **Swaps API** (`/swaps/*`).
|
|
7562
7563
|
*
|
|
7563
7564
|
* A thin adapter over the standalone `@sodax/swaps-api` package (the single source of the wire
|
|
7564
7565
|
* client — request building, per-chain `tx` validation/transform, response schemas, HTTP + retry).
|
|
@@ -7770,18 +7771,17 @@ declare function toCreateBridgeIntentParamsV2(params: {
|
|
|
7770
7771
|
partnerFee?: PartnerFeeV2;
|
|
7771
7772
|
}): CreateBridgeIntentParamsV2;
|
|
7772
7773
|
/**
|
|
7773
|
-
* HTTP client for the backend **Bridge API
|
|
7774
|
+
* HTTP client for the backend **Bridge API** (`/bridge/*`).
|
|
7774
7775
|
*
|
|
7775
|
-
*
|
|
7776
|
-
*
|
|
7777
|
-
*
|
|
7778
|
-
*
|
|
7776
|
+
* A thin adapter over the standalone `@sodax/bridge-api` package (the single source of the wire
|
|
7777
|
+
* client — request building, per-chain `tx` validation/transform, response schemas, HTTP + retry).
|
|
7778
|
+
* This service adds the SDK conventions on top: `Result<T>` (it never throws), a `SodaxLogger`,
|
|
7779
|
+
* config resolution, and per-call `RequestOverrideConfig`.
|
|
7779
7780
|
*
|
|
7780
|
-
* All public methods return `Promise<Result<T
|
|
7781
|
-
*
|
|
7782
|
-
*
|
|
7783
|
-
* `
|
|
7784
|
-
* in the `error` field; the underlying failure is preserved on `error.cause`.
|
|
7781
|
+
* All public methods return `Promise<Result<T>>`. On network failure, timeout, non-2xx HTTP
|
|
7782
|
+
* response, or response-shape validation failure, the returned Result has `ok: false` with a
|
|
7783
|
+
* canonical `SodaxError<'EXTERNAL_API_ERROR'>` (`feature: 'backend'`, `context.api: 'bridge'`,
|
|
7784
|
+
* `context.endpoint`); the underlying `BridgeApiError` is preserved on `error.cause`.
|
|
7785
7785
|
*
|
|
7786
7786
|
* Per-call request overrides (base URL, timeout, headers, API key) can be passed as the
|
|
7787
7787
|
* optional last argument to any method via `RequestOverrideConfig`.
|
|
@@ -7811,12 +7811,24 @@ declare class BridgeApiService implements ResultifiedBridgeApiV2 {
|
|
|
7811
7811
|
private readonly trimsLegacyOverrides;
|
|
7812
7812
|
constructor(config: BaseApiConfig, logger?: SodaxLogger, options?: BridgeApiServiceOptions);
|
|
7813
7813
|
/**
|
|
7814
|
-
*
|
|
7815
|
-
*
|
|
7816
|
-
*
|
|
7817
|
-
*
|
|
7814
|
+
* Build a `@sodax/bridge-api` client for a single call. Maps the SDK's {@link BaseApiConfig}
|
|
7815
|
+
* (`baseURL`/`timeout`/`headers`) to the package's config (`baseUrl`/`timeout`/`headers`), layering
|
|
7816
|
+
* the optional per-call `RequestOverrideConfig` on top (override wins per field; headers merge).
|
|
7817
|
+
* `timeout` falls back to the backend-API default so a config that omits it still gets a ceiling
|
|
7818
|
+
* rather than an unbounded request. Constructed per call so `setHeaders` mutations and per-call
|
|
7819
|
+
* overrides both take effect without caching stale state.
|
|
7818
7820
|
*/
|
|
7819
|
-
private
|
|
7821
|
+
private buildClient;
|
|
7822
|
+
/**
|
|
7823
|
+
* Run one delegated `BridgeApi` call and wrap it in `Result<T>`. A thrown `BridgeApiError`
|
|
7824
|
+
* (network/timeout/HTTP/parse/validation) becomes `{ ok: false }` with a canonical
|
|
7825
|
+
* `SodaxError<'EXTERNAL_API_ERROR'>`; the original error is kept as `cause`, and its
|
|
7826
|
+
* `code`/`status`/`issues` are projected into `context` so consumers can discriminate failure
|
|
7827
|
+
* kinds without unwrapping `cause`. Only a RESPONSE-shape validation failure is tagged
|
|
7828
|
+
* `reason: 'invalid_response_shape'` — a request-side validation error is a caller bug, not a
|
|
7829
|
+
* backend fault.
|
|
7830
|
+
*/
|
|
7831
|
+
private toResult;
|
|
7820
7832
|
/**
|
|
7821
7833
|
* Fetch all supported bridge tokens grouped by SpokeChainKey.
|
|
7822
7834
|
*
|
|
@@ -7887,7 +7899,8 @@ declare class BridgeApiService implements ResultifiedBridgeApiV2 {
|
|
|
7887
7899
|
isBridgeable(body: BridgeQuoteRequestV2, config?: RequestOverrideConfig): Promise<Result<BridgeableCheckResponseV2>>;
|
|
7888
7900
|
/**
|
|
7889
7901
|
* Merge additional headers into the service's default header set. Existing
|
|
7890
|
-
* keys are overwritten; keys absent from `headers` are preserved.
|
|
7902
|
+
* keys are overwritten; keys absent from `headers` are preserved. Applied to
|
|
7903
|
+
* every subsequent call (the delegated client is rebuilt per call).
|
|
7891
7904
|
*/
|
|
7892
7905
|
setHeaders(headers: Record<string, string>): void;
|
|
7893
7906
|
/** Return the base URL the service is currently pointing at. */
|
|
@@ -7914,7 +7927,7 @@ type ResultifiedLeverageYieldApiV2 = {
|
|
|
7914
7927
|
[K in keyof ILeverageYieldApiV2]: ILeverageYieldApiV2[K] extends (...args: infer A) => Promise<infer R> ? (...args: [...A, config?: RequestOverrideConfig]) => Promise<Result<R>> : never;
|
|
7915
7928
|
};
|
|
7916
7929
|
/**
|
|
7917
|
-
* HTTP client for the backend **Leverage Yield API
|
|
7930
|
+
* HTTP client for the backend **Leverage Yield API** (`/leverage-yield/*`).
|
|
7918
7931
|
*
|
|
7919
7932
|
* The leverage-yield counterpart to {@link import('./SwapsApiService.js').SwapsApiService}:
|
|
7920
7933
|
* one method per route of {@link ILeverageYieldApiV2}, each response validated at runtime
|
|
@@ -8917,8 +8930,14 @@ declare class ConfigService {
|
|
|
8917
8930
|
getDexPools(): PoolKey[];
|
|
8918
8931
|
getSodaToken(chainId: SpokeChainKey): XToken;
|
|
8919
8932
|
isMoneyMarketSupportedToken(chainId: SpokeChainKey, token: string): boolean;
|
|
8933
|
+
/**
|
|
8934
|
+
* Is `asset` one of the money-market reserve assets?
|
|
8935
|
+
*
|
|
8936
|
+
* The reserve set is built from `moneyMarketHubVaults`, so its members are hub **vault**
|
|
8937
|
+
* addresses. Query it with an `XToken.vault`; an `XToken.hubAsset` only matches for the Sonic
|
|
8938
|
+
* vault shares themselves, where `hubAsset === vault`.
|
|
8939
|
+
*/
|
|
8920
8940
|
isMoneyMarketReserveAsset(asset: Address): boolean;
|
|
8921
|
-
isMoneyMarketReserveHubAsset(hubAsset: Address): boolean;
|
|
8922
8941
|
private loadSodaxConfigDataStructures;
|
|
8923
8942
|
private loadSpokeChainDataStructures;
|
|
8924
8943
|
private loadSpokeChainConfigDataStructures;
|
|
@@ -10687,7 +10706,11 @@ declare class SuiSpokeService {
|
|
|
10687
10706
|
readonly transport: SuiTransport;
|
|
10688
10707
|
/** @deprecated Renamed to `transport`, and no longer a raw `@mysten/sui` client. */
|
|
10689
10708
|
readonly publicClient: SuiTransport;
|
|
10690
|
-
|
|
10709
|
+
/**
|
|
10710
|
+
* `latest_package_id` reads still in flight, keyed by chain. An entry is dropped as soon as its
|
|
10711
|
+
* read settles, so concurrent callers share one request while a later build always re-reads.
|
|
10712
|
+
*/
|
|
10713
|
+
private readonly assetManagerLookups;
|
|
10691
10714
|
private readonly pollingIntervalMs;
|
|
10692
10715
|
private readonly maxTimeoutMs;
|
|
10693
10716
|
constructor(config: ConfigService);
|
|
@@ -10704,6 +10727,11 @@ declare class SuiSpokeService {
|
|
|
10704
10727
|
encodedSrcAddress: Hex;
|
|
10705
10728
|
};
|
|
10706
10729
|
getAssetManagerAddress(chainId: SuiChainKey): Promise<string>;
|
|
10730
|
+
/**
|
|
10731
|
+
* An upgraded Sui package lives at a new address and the superseded one aborts on
|
|
10732
|
+
* `enforce_version`, so the id is read per call and never held between two builds.
|
|
10733
|
+
*/
|
|
10734
|
+
private resolveAssetManager;
|
|
10707
10735
|
viewContract(tx: Transaction, packageId: string, module: string, functionName: string, args: unknown[], typeArgs: string[] | undefined, sender: string): Promise<SuiExecutionResult>;
|
|
10708
10736
|
/**
|
|
10709
10737
|
* Deposit tokens to the spoke chain.
|
|
@@ -10712,6 +10740,8 @@ declare class SuiSpokeService {
|
|
|
10712
10740
|
* @returns {Promise<TxReturnType<SuiChainKey, R>>} A promise that resolves to the transaction hash or raw transaction base64 string.
|
|
10713
10741
|
*/
|
|
10714
10742
|
deposit<R extends boolean = false>(params: DepositParams<SuiChainKey, R>): Promise<TxReturnType<SuiChainKey, R>>;
|
|
10743
|
+
/** Both deposit paths build here, so the asset manager is resolved the same way for each. */
|
|
10744
|
+
private buildDepositTransaction;
|
|
10715
10745
|
sendMessage<Raw extends boolean>(params: SendMessageParams<SuiChainKey, Raw>): Promise<TxReturnType<SuiChainKey, Raw>>;
|
|
10716
10746
|
/**
|
|
10717
10747
|
* Estimate the gas for a transaction.
|
|
@@ -13363,8 +13393,9 @@ declare const isOracleCandleInterval: (value: string) => value is OracleCandleIn
|
|
|
13363
13393
|
/**
|
|
13364
13394
|
* Estimated settlement-speed bucket for a swap token pair.
|
|
13365
13395
|
*
|
|
13366
|
-
* TODO:
|
|
13367
|
-
*
|
|
13396
|
+
* TODO: the sodax-contracts wiki (Mainnet) says "slow, normal, fast, etc." without pinning the
|
|
13397
|
+
* enum, so this three-label set is our reading of it. Widening it later is a breaking change for
|
|
13398
|
+
* consumers switching on `tier` — settle the set with the contracts team before 2.2.0 ships.
|
|
13368
13399
|
*/
|
|
13369
13400
|
type SwapSpeedTier = 'fast' | 'normal' | 'slow';
|
|
13370
13401
|
/**
|
|
@@ -13389,10 +13420,12 @@ type SwapSpeedTierParams = {
|
|
|
13389
13420
|
* behavior, NOT measured at runtime. The optional future enhancement (analyzing public intents
|
|
13390
13421
|
* data) would refine them; for the base feature they are intentionally hardcoded.
|
|
13391
13422
|
*
|
|
13392
|
-
* TODO:
|
|
13423
|
+
* TODO: these came from the sodax-contracts wiki (Mainnet) via #280 and have not been re-confirmed
|
|
13424
|
+
* against it since. Re-read that page before 2.2.0 ships; the exhaustive table in the test file
|
|
13425
|
+
* pins the resulting tiers, so any correction surfaces there.
|
|
13393
13426
|
*/
|
|
13394
13427
|
declare const SPEED_TIER_SECONDS: {
|
|
13395
|
-
/** Either token
|
|
13428
|
+
/** Either token's vault is a money-market-reserve (sodaAsset). */
|
|
13396
13429
|
readonly sodaAsset: 15;
|
|
13397
13430
|
/** Anything else / default. */
|
|
13398
13431
|
readonly default: 35;
|
|
@@ -13400,10 +13433,11 @@ declare const SPEED_TIER_SECONDS: {
|
|
|
13400
13433
|
readonly ethereumPenalty: 10;
|
|
13401
13434
|
};
|
|
13402
13435
|
/**
|
|
13403
|
-
*
|
|
13436
|
+
* Second→tier boundaries (inclusive upper bounds).
|
|
13404
13437
|
*
|
|
13405
|
-
*
|
|
13406
|
-
*
|
|
13438
|
+
* The rules produce exactly four totals — 15 / 25 / 35 / 45 — which these bucket as
|
|
13439
|
+
* fast(15) · normal(25) · slow(35, 45). That mapping is locked by the exhaustive table in
|
|
13440
|
+
* `speed-tier.test.ts`; the boundaries only need revisiting if the seconds above change.
|
|
13407
13441
|
*/
|
|
13408
13442
|
declare const SPEED_TIER_THRESHOLDS: {
|
|
13409
13443
|
readonly fast: 20;
|
|
@@ -13414,13 +13448,46 @@ declare const SPEED_TIER_THRESHOLDS: {
|
|
|
13414
13448
|
* network or on-chain call — it classifies the pair from SDK config alone.
|
|
13415
13449
|
*
|
|
13416
13450
|
* @param params `{ srcToken, dstToken }` spoke token pair to classify
|
|
13417
|
-
* @param isSodaAssetRelated predicate answering "is this
|
|
13418
|
-
* (sodaAsset)?".
|
|
13419
|
-
*
|
|
13451
|
+
* @param isSodaAssetRelated predicate answering "is this vault a money-market-reserve
|
|
13452
|
+
* (sodaAsset)?". It is queried with `XToken.vault`, not `XToken.hubAsset`: the reserve set is
|
|
13453
|
+
* built from `moneyMarketHubVaults` addresses, so a hub asset only matches for the Sonic vault
|
|
13454
|
+
* shares themselves, where `hubAsset === vault`. In the service this is wired to
|
|
13455
|
+
* `config.isMoneyMarketReserveAsset`. The predicate is injected so this function stays pure and
|
|
13456
|
+
* unit-testable without a ConfigService.
|
|
13420
13457
|
*
|
|
13421
13458
|
* The fast 15s base applies when either token is sodaAsset-related; otherwise the base is 35s.
|
|
13422
13459
|
*/
|
|
13423
|
-
declare function estimateSwapSpeedTier({ srcToken, dstToken }: SwapSpeedTierParams, isSodaAssetRelated: (
|
|
13460
|
+
declare function estimateSwapSpeedTier({ srcToken, dstToken }: SwapSpeedTierParams, isSodaAssetRelated: (vault: Address) => boolean): SwapSpeedTierResult;
|
|
13461
|
+
|
|
13462
|
+
/**
|
|
13463
|
+
* The pieces every "what happened to this source tx?" router shares, whichever feature asks.
|
|
13464
|
+
*
|
|
13465
|
+
* A feature's backend submit-tx record answers only while it is in play: with the backend path
|
|
13466
|
+
* opted out there is no record at all, and on the default path the client-side fallback leaves
|
|
13467
|
+
* behind whatever state the backend last reached. The relay packet is the second source, and
|
|
13468
|
+
* reading it is identical for every feature — so the read, its failure classification and the
|
|
13469
|
+
* budget vocabulary live here rather than once per feature.
|
|
13470
|
+
*
|
|
13471
|
+
* Deliberately NOT exported from `./index.js`: `DETAILED_STATUS_NOT_DELIVERED` is already public
|
|
13472
|
+
* through the swap barrel, and the SDK's root barrel re-exports both with a flat `export *`, so a
|
|
13473
|
+
* second path to the same name would be an ambiguous star export.
|
|
13474
|
+
*/
|
|
13475
|
+
/**
|
|
13476
|
+
* `error.context.reason` on the one lookup failure that is not a dependency outage: the relay has
|
|
13477
|
+
* no packet for this source tx. That covers both shapes the relayer uses — a 404 for a tx it has
|
|
13478
|
+
* not indexed, and a successful response with no matching delivered packet.
|
|
13479
|
+
*
|
|
13480
|
+
* The state is ambiguous by nature — a transfer still in flight and one whose tx never relayed at
|
|
13481
|
+
* all look identical here — so it is the only `LOOKUP_FAILED` a caller can sensibly bound with a
|
|
13482
|
+
* retry budget. Every other one (relay 5xx or unreachable, malformed response) is something failing
|
|
13483
|
+
* *right now* and should be retried until it recovers; spending a budget on those would turn a
|
|
13484
|
+
* transient outage into a permanently stuck read.
|
|
13485
|
+
*
|
|
13486
|
+
* It is set only when the **backend also answered** — a record, or a definitive 404. Behind a
|
|
13487
|
+
* backend outage a relay miss proves nothing: the record may be progressing unseen, so the failure
|
|
13488
|
+
* stays unbudgeted.
|
|
13489
|
+
*/
|
|
13490
|
+
declare const DETAILED_STATUS_NOT_DELIVERED = "relay_not_delivered";
|
|
13424
13491
|
|
|
13425
13492
|
/** The tagged status union behind `SwapService.getDetailedStatus`. Pure — no I/O. */
|
|
13426
13493
|
|
|
@@ -13441,22 +13508,6 @@ type DetailedSwapStatus = {
|
|
|
13441
13508
|
dstTxHash: Hex;
|
|
13442
13509
|
data: SolverIntentStatusResponse;
|
|
13443
13510
|
};
|
|
13444
|
-
/**
|
|
13445
|
-
* `error.context.reason` on the one `getDetailedStatus` failure that is not a dependency outage:
|
|
13446
|
-
* the relay has no packet for this source tx. That covers both shapes the relayer uses — a 404 for
|
|
13447
|
-
* a tx it has not indexed, and a successful response with no matching delivered packet.
|
|
13448
|
-
*
|
|
13449
|
-
* The state is ambiguous by nature — a swap still in flight and one whose tx never relayed at all
|
|
13450
|
-
* look identical here — so it is the only `LOOKUP_FAILED` a caller can sensibly bound with a retry
|
|
13451
|
-
* budget. Every other one (relay 5xx or unreachable, malformed response, solver down) is something
|
|
13452
|
-
* failing *right now* and should be retried until it recovers; spending a budget on those would
|
|
13453
|
-
* turn a transient outage into a permanently stuck read.
|
|
13454
|
-
*
|
|
13455
|
-
* It is set only when the **backend also answered** — a record, or a definitive 404. Behind a
|
|
13456
|
-
* backend outage a relay miss proves nothing: the record may be progressing unseen, so the failure
|
|
13457
|
-
* stays unbudgeted.
|
|
13458
|
-
*/
|
|
13459
|
-
declare const DETAILED_STATUS_NOT_DELIVERED = "relay_not_delivered";
|
|
13460
13511
|
|
|
13461
13512
|
/** Swap-module narrow error types. */
|
|
13462
13513
|
|
|
@@ -13663,7 +13714,9 @@ declare class SwapService {
|
|
|
13663
13714
|
/**
|
|
13664
13715
|
* `reason` is set only for {@link DETAILED_STATUS_NOT_DELIVERED} — the miss a caller can bound
|
|
13665
13716
|
* with a retry budget. Leaving it off marks a dependency that is failing right now, which a
|
|
13666
|
-
* caller should keep retrying rather than give up on.
|
|
13717
|
+
* caller should keep retrying rather than give up on. `status` is lifted for a rejected key so
|
|
13718
|
+
* `isAuthFailure` recognises the wrapped error; it reads `context.status` and does not walk the
|
|
13719
|
+
* cause chain.
|
|
13667
13720
|
*/
|
|
13668
13721
|
private detailedStatusLookupFailed;
|
|
13669
13722
|
/**
|
|
@@ -14081,7 +14134,7 @@ declare class SwapService {
|
|
|
14081
14134
|
/**
|
|
14082
14135
|
* Offline, rule-based estimate of how fast a `srcToken`→`dstToken` swap will settle.
|
|
14083
14136
|
*
|
|
14084
|
-
* Derived purely from SDK config (no network / on-chain / backend call): tokens
|
|
14137
|
+
* Derived purely from SDK config (no network / on-chain / backend call): tokens whose vault is a
|
|
14085
14138
|
* money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. See
|
|
14086
14139
|
* {@link estimateSwapSpeedTier} for the rules.
|
|
14087
14140
|
*
|
|
@@ -14785,6 +14838,32 @@ declare class MigrationService {
|
|
|
14785
14838
|
createRevertSodaToIcxMigrationIntent<Raw extends boolean>(_params: IcxRevertMigrationAction<Raw>): Promise<Result<IntentTxResult<SonicChainKey, Raw>, MigrationCreateIntentError>>;
|
|
14786
14839
|
}
|
|
14787
14840
|
|
|
14841
|
+
/** The tagged status union behind `BridgeService.getDetailedStatus`. Pure — no I/O. */
|
|
14842
|
+
|
|
14843
|
+
/** The identity a detailed status is read for — the backend submit-tx record's key. */
|
|
14844
|
+
type DetailedBridgeStatusKey = {
|
|
14845
|
+
srcChainKey: SpokeChainKey;
|
|
14846
|
+
srcTxHash: string;
|
|
14847
|
+
};
|
|
14848
|
+
/**
|
|
14849
|
+
* Which of the two existing status sources answered, with that source's payload unmodified.
|
|
14850
|
+
* A router, not a merge — see `docs/BRIDGE.md` § Get Detailed Status.
|
|
14851
|
+
*
|
|
14852
|
+
* The relay arm carries the matched packet whole rather than hoisting a hash out of it, because
|
|
14853
|
+
* `dst_tx_hash` means different things by route: for a spoke-source bridge it is the **hub
|
|
14854
|
+
* settlement** tx, and for a hub-source one it is the destination spoke's tx. No single field name
|
|
14855
|
+
* would be true in both directions, so the caller reads it off the packet with the packet's own
|
|
14856
|
+
* semantics. It is always an `executed` packet with a non-empty `dst_tx_hash` — the router does not
|
|
14857
|
+
* return any other kind — so this arm is terminal.
|
|
14858
|
+
*/
|
|
14859
|
+
type DetailedBridgeStatus = {
|
|
14860
|
+
source: 'backend';
|
|
14861
|
+
data: BridgeSubmitTxStatusDataV2;
|
|
14862
|
+
} | {
|
|
14863
|
+
source: 'relay';
|
|
14864
|
+
data: PacketData;
|
|
14865
|
+
};
|
|
14866
|
+
|
|
14788
14867
|
/**
|
|
14789
14868
|
* Bridge module narrow error types.
|
|
14790
14869
|
*
|
|
@@ -14799,12 +14878,18 @@ type BridgeCreateIntentErrorCode = CreateIntentErrorCode;
|
|
|
14799
14878
|
type BridgeApproveErrorCode = ApproveErrorCode;
|
|
14800
14879
|
type BridgeAllowanceCheckErrorCode = AllowanceCheckErrorCode;
|
|
14801
14880
|
type BridgeLookupErrorCode = LookupErrorCode;
|
|
14881
|
+
/**
|
|
14882
|
+
* The only code `getDetailedStatus` returns: no status source could produce a usable answer.
|
|
14883
|
+
* Narrower than {@link BridgeLookupErrorCode}, which also admits `VALIDATION_FAILED` / `UNKNOWN`.
|
|
14884
|
+
*/
|
|
14885
|
+
type BridgeDetailedStatusErrorCode = Extract<SodaxErrorCode, 'LOOKUP_FAILED'>;
|
|
14802
14886
|
type BridgeErrorCode = Extract<SodaxErrorCode, 'USER_REJECTED' | 'VALIDATION_FAILED' | 'INTENT_CREATION_FAILED' | 'TX_VERIFICATION_FAILED' | 'TX_SUBMIT_FAILED' | 'RELAY_TIMEOUT' | 'RELAY_FAILED' | 'EXECUTION_FAILED' | 'APPROVE_FAILED' | 'ALLOWANCE_CHECK_FAILED' | 'LOOKUP_FAILED' | 'UNKNOWN'>;
|
|
14803
14887
|
type BridgeOrchestrationError = SodaxError<BridgeOrchestrationErrorCode>;
|
|
14804
14888
|
type BridgeCreateIntentError = SodaxError<BridgeCreateIntentErrorCode>;
|
|
14805
14889
|
type BridgeApproveError = SodaxError<BridgeApproveErrorCode>;
|
|
14806
14890
|
type BridgeAllowanceCheckError = SodaxError<BridgeAllowanceCheckErrorCode>;
|
|
14807
14891
|
type BridgeLookupError = SodaxError<BridgeLookupErrorCode>;
|
|
14892
|
+
type BridgeDetailedStatusError = SodaxError<BridgeDetailedStatusErrorCode>;
|
|
14808
14893
|
type BridgeError = SodaxError<BridgeErrorCode>;
|
|
14809
14894
|
declare const isBridgeOrchestrationError: (e: unknown) => e is SodaxError<BridgeOrchestrationErrorCode>;
|
|
14810
14895
|
declare const isBridgeCreateIntentError: (e: unknown) => e is SodaxError<CreateIntentErrorCode>;
|
|
@@ -15090,6 +15175,42 @@ declare class BridgeService {
|
|
|
15090
15175
|
* @throws When `dstToken` cannot be resolved for the destination chain (invariant).
|
|
15091
15176
|
*/
|
|
15092
15177
|
buildBridgeData(params: CreateBridgeIntentParams, srcToken: XToken, dstToken: XToken, partnerFee: PartnerFee | undefined): Hex;
|
|
15178
|
+
/**
|
|
15179
|
+
* Answers "what is the status of this bridge?" from the **source-chain** tx — the one identifier a
|
|
15180
|
+
* caller always holds. It does not define a new status: it routes to whichever of the two existing
|
|
15181
|
+
* sources can answer, and returns that source's payload unmodified.
|
|
15182
|
+
*
|
|
15183
|
+
* `sodax.api.bridge.getSubmitTxStatus` cannot answer for every bridge. Sometimes there is no
|
|
15184
|
+
* record — `useBackendSubmitTx: false`, or the submit itself never landed. More often the record
|
|
15185
|
+
* exists but is stale: the backend path POSTs the tx first and only falls back to the client-side
|
|
15186
|
+
* relay once that stalls, so a fallback-completed bridge leaves behind whatever state the backend
|
|
15187
|
+
* last reached, including a record it abandoned outright. Neither shape reflects what happened.
|
|
15188
|
+
*
|
|
15189
|
+
* 1. Read the backend record; return it while it is still in play.
|
|
15190
|
+
* 2. Otherwise return the delivered relay packet, which is terminal by construction.
|
|
15191
|
+
*
|
|
15192
|
+
* A rejected API key is the one failure that does **not** fall through to step 2: the status route
|
|
15193
|
+
* is key-guarded, so degrading would bury a 401/403 behind a relay error and leave a poller
|
|
15194
|
+
* retrying a request only a corrected key can satisfy. It surfaces with `context.status` instead,
|
|
15195
|
+
* which is what `isAuthFailure` reads.
|
|
15196
|
+
*
|
|
15197
|
+
* A point-in-time read; poll it yourself, or use dapp-kit's `useBridgeDetailedStatus`.
|
|
15198
|
+
*
|
|
15199
|
+
* @param params - `srcChainKey` and `srcTxHash` of the source-chain bridge transaction.
|
|
15200
|
+
* @param config - Optional per-request override for the backend read (e.g. a per-action API key).
|
|
15201
|
+
* The relay leg is unauthenticated and takes none.
|
|
15202
|
+
* @returns A `Result` containing a {@link DetailedBridgeStatus}. Fails with `LOOKUP_FAILED` when no
|
|
15203
|
+
* source can answer yet — usually the relay has not delivered the packet. Branch on
|
|
15204
|
+
* `error.context.reason`: `DETAILED_STATUS_NOT_DELIVERED` is the ambiguous miss a caller should
|
|
15205
|
+
* bound with a retry budget; anything else is a dependency failing right now, so keep retrying.
|
|
15206
|
+
*/
|
|
15207
|
+
getDetailedStatus(params: DetailedBridgeStatusKey, config?: RequestOverrideConfig): Promise<Result<DetailedBridgeStatus, BridgeDetailedStatusError>>;
|
|
15208
|
+
/**
|
|
15209
|
+
* `reason` is set only for {@link DETAILED_STATUS_NOT_DELIVERED} — the miss a caller can bound with
|
|
15210
|
+
* a retry budget. `status` is lifted for a rejected key so `isAuthFailure` recognises the wrapped
|
|
15211
|
+
* error; it reads `context.status` and does not walk the cause chain.
|
|
15212
|
+
*/
|
|
15213
|
+
private detailedStatusLookupFailed;
|
|
15093
15214
|
/**
|
|
15094
15215
|
* Returns the maximum amount that can currently be bridged between two tokens,
|
|
15095
15216
|
* taking into account both deposit capacity on the source side and withdrawal liquidity
|
|
@@ -18213,6 +18334,31 @@ declare class RecoveryService {
|
|
|
18213
18334
|
withdrawHubAsset<K extends SpokeChainKey, Raw extends boolean>(_params: WithdrawHubAssetAction<K, Raw>): Promise<Result<TxReturnType<K, Raw>>>;
|
|
18214
18335
|
}
|
|
18215
18336
|
|
|
18337
|
+
/** The tagged status union behind `LeverageYieldService.getDetailedStatus`. Pure — no I/O. */
|
|
18338
|
+
|
|
18339
|
+
/** The identity a detailed status is read for — the backend submit-tx record's key. */
|
|
18340
|
+
type DetailedLeverageYieldStatusKey = {
|
|
18341
|
+
srcChainKey: SpokeChainKey;
|
|
18342
|
+
srcTxHash: string;
|
|
18343
|
+
};
|
|
18344
|
+
/**
|
|
18345
|
+
* Which of the two existing status sources answered, with that source's payload unmodified.
|
|
18346
|
+
* A router, not a merge — see `docs/LEVERAGE_YIELD.md` § Get Detailed Status.
|
|
18347
|
+
*
|
|
18348
|
+
* The arms are swap's, not bridge's: a vault deposit or withdrawal IS a solver intent, so once the
|
|
18349
|
+
* backend record stops answering the solver is who knows what became of it. Bridge's second arm is
|
|
18350
|
+
* the relay packet, which is terminal on arrival; here the packet is only the route to `dstTxHash`,
|
|
18351
|
+
* the hub tx the solver is keyed on, so it is hoisted rather than returned whole.
|
|
18352
|
+
*/
|
|
18353
|
+
type DetailedLeverageYieldStatus = {
|
|
18354
|
+
source: 'backend';
|
|
18355
|
+
data: SubmitTxStatusDataV2;
|
|
18356
|
+
} | {
|
|
18357
|
+
source: 'solver';
|
|
18358
|
+
dstTxHash: Hex;
|
|
18359
|
+
data: SolverIntentStatusResponse;
|
|
18360
|
+
};
|
|
18361
|
+
|
|
18216
18362
|
/**
|
|
18217
18363
|
* leverageYield module narrow error types.
|
|
18218
18364
|
*
|
|
@@ -18229,11 +18375,18 @@ declare class RecoveryService {
|
|
|
18229
18375
|
*/
|
|
18230
18376
|
|
|
18231
18377
|
declare const leverageYieldInvariant: FeatureInvariant;
|
|
18232
|
-
type LeverageYieldAction = 'deposit' | 'withdraw' | 'approve' | 'allowanceCheck' | 'vaultSwap';
|
|
18378
|
+
type LeverageYieldAction = 'deposit' | 'withdraw' | 'approve' | 'allowanceCheck' | 'vaultSwap' | 'openPosition' | 'openPositionFromDebtToken' | 'operatePosition' | 'openLeveragePosition' | 'submitLeveragePositionIntent' | 'runLeveragePositionOperation' | 'getPositionLegQuote';
|
|
18233
18379
|
type LeverageYieldCreateIntentErrorCode = CreateIntentErrorCode;
|
|
18234
18380
|
type LeverageYieldApproveErrorCode = ApproveErrorCode;
|
|
18235
18381
|
type LeverageYieldAllowanceCheckErrorCode = AllowanceCheckErrorCode;
|
|
18236
18382
|
type LeverageYieldLookupErrorCode = LookupErrorCode;
|
|
18383
|
+
/**
|
|
18384
|
+
* The only code `getDetailedStatus` returns: no status source could produce a usable answer.
|
|
18385
|
+
* Narrower than {@link LeverageYieldLookupErrorCode}, which also admits `VALIDATION_FAILED` /
|
|
18386
|
+
* `UNKNOWN`. Prefixed because swap's equivalent is not — the root barrel is a flat `export *`, so
|
|
18387
|
+
* an unprefixed `DetailedStatusError` here would collide with it.
|
|
18388
|
+
*/
|
|
18389
|
+
type LeverageYieldDetailedStatusErrorCode = Extract<SodaxErrorCode, 'LOOKUP_FAILED'>;
|
|
18237
18390
|
/**
|
|
18238
18391
|
* Codes returnable by the solver-notify step inside `vaultSwap`. Mirrors the swap
|
|
18239
18392
|
* domain's `PostExecutionErrorCode` — duplicated deliberately so the leverage-yield
|
|
@@ -18250,6 +18403,7 @@ type LeverageYieldCreateIntentError = SodaxError<LeverageYieldCreateIntentErrorC
|
|
|
18250
18403
|
type LeverageYieldApproveError = SodaxError<LeverageYieldApproveErrorCode>;
|
|
18251
18404
|
type LeverageYieldAllowanceCheckError = SodaxError<LeverageYieldAllowanceCheckErrorCode>;
|
|
18252
18405
|
type LeverageYieldLookupError = SodaxError<LeverageYieldLookupErrorCode>;
|
|
18406
|
+
type LeverageYieldDetailedStatusError = SodaxError<LeverageYieldDetailedStatusErrorCode>;
|
|
18253
18407
|
type LeverageYieldPostExecutionError = SodaxError<LeverageYieldPostExecutionErrorCode>;
|
|
18254
18408
|
type LeverageYieldSwapError = SodaxError<LeverageYieldSwapErrorCode>;
|
|
18255
18409
|
type LeverageYieldError = SodaxError<LeverageYieldErrorCode>;
|
|
@@ -18261,6 +18415,188 @@ declare const isLeverageYieldPostExecutionError: (e: unknown) => e is SodaxError
|
|
|
18261
18415
|
declare const isLeverageYieldSwapError: (e: unknown) => e is SodaxError<LeverageYieldSwapErrorCode>;
|
|
18262
18416
|
declare const isLeverageYieldError: (e: unknown) => e is SodaxError<LeverageYieldErrorCode>;
|
|
18263
18417
|
|
|
18418
|
+
/**
|
|
18419
|
+
* Quoting one leg of a position operation, and reading the solver's refusal correctly.
|
|
18420
|
+
*
|
|
18421
|
+
* WHAT THE LEG IS. A position's intent swaps HUB RESERVES — sodaETH for sodaS — so that is what has
|
|
18422
|
+
* to be quoted. Mapping each side back to its spoke original first asks about a different pair: on
|
|
18423
|
+
* the hub `sodaS` is its own hub asset while `S` is not, and it is the reserves the fill moves.
|
|
18424
|
+
*
|
|
18425
|
+
* WHY NOT A PARTNER FEE. A position's intent is a hook intent carrying no fee data — the position's
|
|
18426
|
+
* own fee is charged on-chain from `PositionConfig.feeBps`, which `projectLeverageLeg` accounts for
|
|
18427
|
+
* separately. Quoting net of a configured fee would size the floor for a deduction the solver never
|
|
18428
|
+
* makes, and count the fee twice.
|
|
18429
|
+
*/
|
|
18430
|
+
/** What the solver expects to deliver for the leg, in output-token units. */
|
|
18431
|
+
type PositionLegQuote = {
|
|
18432
|
+
quotedAmount: bigint;
|
|
18433
|
+
};
|
|
18434
|
+
/**
|
|
18435
|
+
* Whether a refusal was a ROUTING one, which is also what the solver answers for a leg that is
|
|
18436
|
+
* merely too SMALL.
|
|
18437
|
+
*
|
|
18438
|
+
* Read off the wording, not `detail.code`: the solver answers this with `-1`, which is not a member
|
|
18439
|
+
* of `SolverIntentErrorCode` at all — `NO_PATH_FOUND` is `-4` and does not come back. Measured on
|
|
18440
|
+
* sodaS/sodaETH, the same pair refused at 1.7756 units and quoted at 1.7778.
|
|
18441
|
+
*
|
|
18442
|
+
* It does NOT say which of the two it is. To tell them apart, quote the same pair again at a healthy
|
|
18443
|
+
* notional and treat "routes there, refused here" as too small — and only when the failed amount was
|
|
18444
|
+
* BELOW the probe, since the window closes at the top as well ($1 through $10,000 quote on that pair,
|
|
18445
|
+
* $100,000 does not) and a leg that is too large must not be told to grow. The probe size is priced,
|
|
18446
|
+
* so it is the caller's to choose: this module takes prices from the caller by design.
|
|
18447
|
+
*/
|
|
18448
|
+
declare function isNoRouteRefusal(error: unknown): boolean;
|
|
18449
|
+
|
|
18450
|
+
/**
|
|
18451
|
+
* The result of a position write that posts a solver intent, and the reporting step it depends on.
|
|
18452
|
+
*
|
|
18453
|
+
* Kept beside the service rather than inside it because the shape is a public contract: every caller
|
|
18454
|
+
* — React or not — has to be able to tell "the transaction landed" from "the solver knows about it",
|
|
18455
|
+
* and those are not the same event.
|
|
18456
|
+
*/
|
|
18457
|
+
|
|
18458
|
+
/**
|
|
18459
|
+
* What a position write that POSTS AN INTENT returns.
|
|
18460
|
+
*
|
|
18461
|
+
* `notified` is separate from success on purpose. An intent lives on the hub the moment the call
|
|
18462
|
+
* lands, but the solver only learns of it when its hub-side hash is reported — and an unreported one
|
|
18463
|
+
* expires unfilled, leaving the owner funded with leverage that never arrives.
|
|
18464
|
+
*
|
|
18465
|
+
* SO A FAILED NOTIFICATION IS `ok: true`, NOT `ok: false`. The money has already moved and the intent
|
|
18466
|
+
* is live; returning a failure would tell the caller nothing happened, and a caller that retries on
|
|
18467
|
+
* failure would open a second position. Report it, do not raise it.
|
|
18468
|
+
*/
|
|
18469
|
+
type LeveragePositionIntentResult = {
|
|
18470
|
+
/**
|
|
18471
|
+
* Both hashes, and they are not interchangeable: `srcChainTxHash` is what the user signed,
|
|
18472
|
+
* `dstChainTxHash` is the hub transaction the intent actually exists in.
|
|
18473
|
+
*/
|
|
18474
|
+
txHashes: TxHashPair;
|
|
18475
|
+
/** False means the intent is live but nothing will fill it before it expires. */
|
|
18476
|
+
notified: boolean;
|
|
18477
|
+
/** Why the notification failed, when it did. */
|
|
18478
|
+
notifyError?: string;
|
|
18479
|
+
};
|
|
18480
|
+
/** The notify half, narrowed so it can be exercised without constructing a whole service. */
|
|
18481
|
+
type PositionIntentNotifier = (request: SolverExecutionRequest) => Promise<Result<SolverExecutionResponse, LeverageYieldPostExecutionError>>;
|
|
18482
|
+
/**
|
|
18483
|
+
* Reports a position intent to the solver and says whether that landed.
|
|
18484
|
+
*
|
|
18485
|
+
* WHICH HASH: `dstChainTxHash`. On the hub that is the transaction the user signed, but from a spoke
|
|
18486
|
+
* the intent is created by the relayed message, so the signed hash is not where it lives.
|
|
18487
|
+
*/
|
|
18488
|
+
declare function reportPositionIntent(notifySolver: PositionIntentNotifier, txHashes: TxHashPair): Promise<LeveragePositionIntentResult>;
|
|
18489
|
+
|
|
18490
|
+
/** Mirrors `LeveragePosition.MAX_FEE_BPS`. Unlike a vault quote's bound, this one is permanent. */
|
|
18491
|
+
declare const MAX_POSITION_FEE_BPS = 100;
|
|
18492
|
+
/**
|
|
18493
|
+
* Where a position's funds came from, and so where a failed intent refunds to.
|
|
18494
|
+
*
|
|
18495
|
+
* Given as a chain KEY rather than a number: the on-chain field is a SODAX relay chain id (Arbitrum
|
|
18496
|
+
* is 23, not 42161), and `getIntentRelayChainId` is the map for that. Asking callers for the raw
|
|
18497
|
+
* number invites passing an EVM id, which would route a refund nowhere.
|
|
18498
|
+
*/
|
|
18499
|
+
type PositionOrigin = {
|
|
18500
|
+
/** Chain the user funded from and is refunded on. */
|
|
18501
|
+
chainKey: SpokeChainKey;
|
|
18502
|
+
/** The user's address on `chainKey`. */
|
|
18503
|
+
address: string;
|
|
18504
|
+
/**
|
|
18505
|
+
* Hub asset a cross-chain refund unwraps the reserve into. Required off-hub, since the
|
|
18506
|
+
* AssetManager moves only its own registered assets and never vault tokens, and ignored on the
|
|
18507
|
+
* hub, where a refund is a plain transfer.
|
|
18508
|
+
*/
|
|
18509
|
+
asset?: Address;
|
|
18510
|
+
};
|
|
18511
|
+
/**
|
|
18512
|
+
* Funding a position from whichever chain the user actually holds tokens on.
|
|
18513
|
+
*
|
|
18514
|
+
* Positions live on the hub, but nothing requires the user to. The deposit is relayed to their hub
|
|
18515
|
+
* wallet and the position is opened from inside that relayed batch, so the whole thing is one
|
|
18516
|
+
* signature on the source chain — and the hub is just another source chain here, not a special case.
|
|
18517
|
+
*
|
|
18518
|
+
* `token` is a token on `srcChainKey`, in that token's own decimals. Its hub reserve is what the
|
|
18519
|
+
* position uses: the collateral for {@link LeverageYieldService.openPosition}, the borrow token for
|
|
18520
|
+
* {@link LeverageYieldService.openPositionFromDebtToken}. Wrapping into that reserve is part of the
|
|
18521
|
+
* relayed batch, so callers pass the amount they hold, not a vault-share amount.
|
|
18522
|
+
*/
|
|
18523
|
+
type PositionFundingParams<K extends SpokeChainKey> = {
|
|
18524
|
+
srcChainKey: K;
|
|
18525
|
+
/** The user's address on `srcChainKey`. Funds come from here and a failed intent refunds to here. */
|
|
18526
|
+
srcAddress: string;
|
|
18527
|
+
/** Token on `srcChainKey` to fund with. */
|
|
18528
|
+
token: string;
|
|
18529
|
+
/** Amount of `token`, in its own decimals. */
|
|
18530
|
+
amount: bigint;
|
|
18531
|
+
/** AAVE eMode category, fixed for the life of the position. Defaults to 0 (none). */
|
|
18532
|
+
eModeCategory?: number;
|
|
18533
|
+
/** Slippage floor on the collateral the solver must deliver, in the collateral reserve's units. */
|
|
18534
|
+
minCollateralOut: bigint;
|
|
18535
|
+
/**
|
|
18536
|
+
* Partner fee to bake into the position, percentage variant only. Defaults to the configured
|
|
18537
|
+
* `leverageYield.partnerFee`. FIXED AT CREATION on-chain and charged on every later operation, so
|
|
18538
|
+
* it must also be fed to {@link projectLeverageLeg} as `feeBps` — the fee is borrowed on top of
|
|
18539
|
+
* what the solver is paid, so a projection that ignores it understates LTV.
|
|
18540
|
+
*/
|
|
18541
|
+
partnerFee?: PartnerFee;
|
|
18542
|
+
};
|
|
18543
|
+
/** Opening from the collateral side: deposit collateral, borrow against it, swap into more collateral. */
|
|
18544
|
+
type OpenPositionParams<K extends SpokeChainKey> = PositionFundingParams<K> & {
|
|
18545
|
+
/** Hub reserve to borrow. */
|
|
18546
|
+
borrowToken: Address;
|
|
18547
|
+
/** Amount to borrow, in `borrowToken`'s units (hub reserves are 18-decimal). */
|
|
18548
|
+
borrowAmount: bigint;
|
|
18549
|
+
};
|
|
18550
|
+
/**
|
|
18551
|
+
* Opening from the debt side: the deposit IS the debt token, and the position ends up long
|
|
18552
|
+
* `collateral` without the user ever having held it.
|
|
18553
|
+
*/
|
|
18554
|
+
type OpenPositionFromDebtTokenParams<K extends SpokeChainKey> = PositionFundingParams<K> & {
|
|
18555
|
+
/** Hub reserve the position ends up long. */
|
|
18556
|
+
collateral: Address;
|
|
18557
|
+
/** Total debt token paid to the solver. The hook borrows this minus the deposit's contribution. */
|
|
18558
|
+
totalInput: bigint;
|
|
18559
|
+
};
|
|
18560
|
+
/**
|
|
18561
|
+
* Operating an existing position from any chain. No funds move, so this is a bare message rather
|
|
18562
|
+
* than a deposit — the calls execute as the user's hub wallet, which is what the position's
|
|
18563
|
+
* `onlyOwner` requires.
|
|
18564
|
+
*/
|
|
18565
|
+
declare const positionIntentCall: unique symbol;
|
|
18566
|
+
declare const positionDirectCall: unique symbol;
|
|
18567
|
+
/**
|
|
18568
|
+
* A position call that POSTS a solver intent, so it must be reported or it expires unfilled.
|
|
18569
|
+
*
|
|
18570
|
+
* The brand is type-only and erased at runtime; it exists so the compiler refuses the one mistake
|
|
18571
|
+
* that costs money — routing a leverage change through the path that does not report it.
|
|
18572
|
+
*/
|
|
18573
|
+
type PositionIntentCall = EvmRawTransaction & {
|
|
18574
|
+
readonly [positionIntentCall]: true;
|
|
18575
|
+
};
|
|
18576
|
+
/** A position call that completes on the hub, with nothing to report. Same brand mechanics. */
|
|
18577
|
+
type PositionDirectCall = EvmRawTransaction & {
|
|
18578
|
+
readonly [positionDirectCall]: true;
|
|
18579
|
+
};
|
|
18580
|
+
/**
|
|
18581
|
+
* What may ride along in a batch that posts an intent.
|
|
18582
|
+
*
|
|
18583
|
+
* The brand guards ONE direction. An intent call on the route-only path is never reported and expires
|
|
18584
|
+
* unfilled — that has to be refused. A direct call on the reporting path is noise, not damage, and
|
|
18585
|
+
* refusing it would take the settle-then-act batch with it: `[buildSettlePosition, buildAddLeverage]`
|
|
18586
|
+
* is exactly a direct call riding along, and it is the sequence the batch exists for.
|
|
18587
|
+
*/
|
|
18588
|
+
type PositionBatchCall = PositionIntentCall | PositionDirectCall;
|
|
18589
|
+
type PositionOperationParams<K extends SpokeChainKey, C extends EvmRawTransaction = EvmRawTransaction> = {
|
|
18590
|
+
srcChainKey: K;
|
|
18591
|
+
/** The user's address on `srcChainKey`; its hub wallet is what executes the calls. */
|
|
18592
|
+
srcAddress: string;
|
|
18593
|
+
/**
|
|
18594
|
+
* Calls to run as the hub wallet, from the position builders
|
|
18595
|
+
* ({@link LeverageYieldService.buildAddLeverage} and friends). More than one is allowed and they
|
|
18596
|
+
* execute in order, which is how a settle-then-act sequence stays atomic.
|
|
18597
|
+
*/
|
|
18598
|
+
calls: readonly C[];
|
|
18599
|
+
};
|
|
18264
18600
|
/**
|
|
18265
18601
|
* Leveraged-position snapshot from the vault's non-standard `getPositionDetails()`.
|
|
18266
18602
|
* Field scales (mirroring the AAVE conventions the vault inherits):
|
|
@@ -18445,6 +18781,19 @@ type LeverageYieldSwapPayload = {
|
|
|
18445
18781
|
*/
|
|
18446
18782
|
partnerFee?: PartnerFee;
|
|
18447
18783
|
};
|
|
18784
|
+
/**
|
|
18785
|
+
* Per-action extras for a vault swap, supplied via the `extras` slot of the action params.
|
|
18786
|
+
* Deliberately smaller than `SwapExtras` / `BridgeExtras`: a vault swap has no Stacks or Bitcoin
|
|
18787
|
+
* source variants to key off `K`, so this stays chain-agnostic.
|
|
18788
|
+
*/
|
|
18789
|
+
type LeverageYieldExtras = {
|
|
18790
|
+
/**
|
|
18791
|
+
* Overrides the configured backend API key for this action's backend submit-tx leg; sent as the
|
|
18792
|
+
* `x-api-key` header on both the submit POST and its status polls. Falls back to config when
|
|
18793
|
+
* omitted. Has no effect on the client-side relay path, which never calls the backend.
|
|
18794
|
+
*/
|
|
18795
|
+
apiKey?: string;
|
|
18796
|
+
};
|
|
18448
18797
|
/**
|
|
18449
18798
|
* Exec-mode params for {@link LeverageYieldService.createVaultIntent} /
|
|
18450
18799
|
* {@link LeverageYieldService.vaultSwap}: `walletProvider` is required and K-narrowed
|
|
@@ -18457,8 +18806,12 @@ type LeverageYieldSwapPayload = {
|
|
|
18457
18806
|
* instead of a spoke-side AssetManager deposit.
|
|
18458
18807
|
* - `partnerFee` overrides the effective leverage-yield fee
|
|
18459
18808
|
* (`config.leverageYieldPartnerFee`) for this intent only.
|
|
18809
|
+
*
|
|
18810
|
+
* Both stay intersected here rather than moving into {@link LeverageYieldExtras}, where swap and
|
|
18811
|
+
* bridge keep their own `partnerFee`: they are vault *execution* modifiers read by
|
|
18812
|
+
* `createVaultIntent`, and relocating them would break every existing caller for no gain.
|
|
18460
18813
|
*/
|
|
18461
|
-
type VaultSwapActionParams<K extends SpokeChainKey, Raw extends boolean = false> = SpokeExecActionParams<K, Raw, CreateIntentParams<K
|
|
18814
|
+
type VaultSwapActionParams<K extends SpokeChainKey, Raw extends boolean = false> = SpokeExecActionParams<K, Raw, CreateIntentParams<K>, LeverageYieldExtras> & {
|
|
18462
18815
|
hubWalletSwap?: boolean;
|
|
18463
18816
|
partnerFee?: PartnerFee;
|
|
18464
18817
|
};
|
|
@@ -18533,9 +18886,9 @@ declare class LeverageYieldService {
|
|
|
18533
18886
|
private readonly spoke;
|
|
18534
18887
|
private readonly backendApi;
|
|
18535
18888
|
/**
|
|
18536
|
-
* Effective backend submit-tx flow (`leverageYield.useBackendSubmitTx`, default
|
|
18537
|
-
* `ConfigService`, like `config.leverageYieldPartnerFee`, so the config
|
|
18538
|
-
* never disagree.
|
|
18889
|
+
* Effective backend submit-tx flow (`leverageYield.useBackendSubmitTx`, default ON; opt out with
|
|
18890
|
+
* `false`). Read live off `ConfigService`, like `config.leverageYieldPartnerFee`, so the config
|
|
18891
|
+
* object and the behavior can never disagree.
|
|
18539
18892
|
*/
|
|
18540
18893
|
get useBackendSubmitTx(): boolean;
|
|
18541
18894
|
constructor({ hubProvider, config, spoke, backendApi }: LeverageYieldServiceConstructorParams);
|
|
@@ -18663,15 +19016,17 @@ declare class LeverageYieldService {
|
|
|
18663
19016
|
*/
|
|
18664
19017
|
vaultSwap<K extends SpokeChainKey>(_params: VaultSwapActionParams<K, false>): Promise<Result<VaultSwapResponse, LeverageYieldSwapError>>;
|
|
18665
19018
|
/**
|
|
18666
|
-
* Client-side vault-swap completion (the
|
|
19019
|
+
* Client-side vault-swap completion (the opt-out path, and the fallback): verify the broadcast
|
|
19020
|
+
* intent tx landed,
|
|
18667
19021
|
* relay it to the hub (Sonic) — or use it directly when the source IS the hub — then notify the
|
|
18668
19022
|
* solver via {@link LeverageYieldService.notifySolver} and build the {@link VaultSwapResponse}.
|
|
18669
|
-
* Extracted from `vaultSwap()` so the
|
|
19023
|
+
* Extracted from `vaultSwap()` so the default backend 2-step path ({@link LeverageYieldService.submitTx})
|
|
18670
19024
|
* can fall back to it on any non-success. Leverage-yield copy of `SwapService.fallbackSwapSteps`.
|
|
18671
19025
|
*/
|
|
18672
19026
|
private fallbackVaultSwapSteps;
|
|
18673
19027
|
/**
|
|
18674
|
-
* Backend 2-step vault-swap path (opt
|
|
19028
|
+
* Backend 2-step vault-swap path (the default; opt out with `leverageYield.useBackendSubmitTx:
|
|
19029
|
+
* false`): hand the
|
|
18675
19030
|
* broadcast intent tx to the leverage-yield API (`POST /leverage-yield/submit-tx`); the backend
|
|
18676
19031
|
* relays + post-executes server-side. Polls `getSubmitTxStatus` until `solved`, then reconstructs
|
|
18677
19032
|
* the same {@link VaultSwapResponse} the client-side path returns.
|
|
@@ -18693,7 +19048,12 @@ declare class LeverageYieldService {
|
|
|
18693
19048
|
*/
|
|
18694
19049
|
private submitTx;
|
|
18695
19050
|
/**
|
|
18696
|
-
* Notifies the solver that
|
|
19051
|
+
* Notifies the solver that an intent landed on the hub, triggering it to fill.
|
|
19052
|
+
*
|
|
19053
|
+
* REQUIRED for anything that creates an intent, not an optimisation. An intent created on the hub
|
|
19054
|
+
* is invisible to the solver until this call puts it in the task pool, so an unnotified intent
|
|
19055
|
+
* simply expires. Leverage positions post their intents on-chain from the position contract, so
|
|
19056
|
+
* the caller that sent the transaction is the only one who can report the hash.
|
|
18697
19057
|
* Leverage-yield copy of the swap domain's `postExecution` — emits only
|
|
18698
19058
|
* `EXECUTION_FAILED` / `EXTERNAL_API_ERROR` / `UNKNOWN` (relay/verify codes appear only
|
|
18699
19059
|
* on {@link LeverageYieldService.vaultSwap}, which owns the verify + relay steps).
|
|
@@ -18708,6 +19068,91 @@ declare class LeverageYieldService {
|
|
|
18708
19068
|
* intents).
|
|
18709
19069
|
*/
|
|
18710
19070
|
notifySolver(request: SolverExecutionRequest): Promise<Result<SolverExecutionResponse, LeverageYieldPostExecutionError>>;
|
|
19071
|
+
/**
|
|
19072
|
+
* Polls the solver for the execution status of an intent this service created.
|
|
19073
|
+
*
|
|
19074
|
+
* Pair with {@link LeverageYieldService.notifySolver}: `notifySolver` puts the intent in the
|
|
19075
|
+
* solver's task pool, this reports what became of it. `fill_tx_hash` is set only once
|
|
19076
|
+
* `status === SolverIntentStatusCode.SOLVED`.
|
|
19077
|
+
*
|
|
19078
|
+
* A `NOT_FOUND` status usually means the notification never landed rather than that the intent
|
|
19079
|
+
* does not exist — an intent created on the hub is invisible to the solver until it is told.
|
|
19080
|
+
*
|
|
19081
|
+
* Reports the solver verbatim. It does NOT reconcile a `NOT_FOUND` against the backend's durable
|
|
19082
|
+
* record the way {@link LeverageYieldService.getDetailedStatus} does — a restarted solver answers
|
|
19083
|
+
* `NOT_FOUND` for intents it already filled, and that read resolves it. Keeping this one
|
|
19084
|
+
* unreconciled is deliberate: it has shipped with this contract, and folding the reconcile in
|
|
19085
|
+
* would turn a `NOT_FOUND` behind an unreadable backend into an error for every existing caller.
|
|
19086
|
+
* Prefer `getDetailedStatus` when you hold the source tx hash.
|
|
19087
|
+
*
|
|
19088
|
+
* @param request - `{ intent_tx_hash }` — the hub-chain (Sonic) tx hash the intent was
|
|
19089
|
+
* registered in. For a position that is the tx that called the factory or the position.
|
|
19090
|
+
*/
|
|
19091
|
+
getIntentStatus(request: SolverIntentStatusRequest): Promise<Result<SolverIntentStatusResponse, LeverageYieldPostExecutionError>>;
|
|
19092
|
+
/**
|
|
19093
|
+
* The raw solver read, in the solver's own vocabulary. Both public status surfaces start here; the
|
|
19094
|
+
* api key is the 5th argument, and leaving it out let a keyed partner notify and then fail to poll.
|
|
19095
|
+
*/
|
|
19096
|
+
private solverStatus;
|
|
19097
|
+
/**
|
|
19098
|
+
* {@link LeverageYieldService.solverStatus} plus the durable-record reconcile, for
|
|
19099
|
+
* {@link LeverageYieldService.getDetailedStatus}. Deliberately not shared with
|
|
19100
|
+
* {@link LeverageYieldService.getIntentStatus}: the reconcile turns a `NOT_FOUND` behind an
|
|
19101
|
+
* unreadable backend into an error, which is right for a polled read that would otherwise spend a
|
|
19102
|
+
* budget on an unverified miss, and wrong to impose on a surface that already ships without it.
|
|
19103
|
+
*
|
|
19104
|
+
* `timeoutMs` bounds the solver request alone. The reconcile carries its own
|
|
19105
|
+
* {@link RECONCILE_TIMEOUT_MS}, so a bounded call can cost both.
|
|
19106
|
+
*/
|
|
19107
|
+
private resolveSolverStatus;
|
|
19108
|
+
/**
|
|
19109
|
+
* Reads a vault swap's status from its source-chain transaction — the identifier a caller always
|
|
19110
|
+
* holds after `vaultSwap()`.
|
|
19111
|
+
*
|
|
19112
|
+
* **Routes; does not translate.** Returns the backend submit-tx record while it is in play,
|
|
19113
|
+
* otherwise the solver's answer via the hub tx hash resolved from the relay packet. The result is
|
|
19114
|
+
* tagged with `source` (discriminate on it) and carries that source's payload unmodified.
|
|
19115
|
+
*
|
|
19116
|
+
* `sodax.api.leverageYield.getSubmitTxStatus` cannot answer for every vault swap. Sometimes there
|
|
19117
|
+
* is no record — `useBackendSubmitTx: false`, or the submit was rejected. More often the record
|
|
19118
|
+
* exists but is stale: the backend path POSTs first and falls back to the client-side relay once
|
|
19119
|
+
* that stalls, so a fallback-completed vault swap leaves behind whatever state the backend last
|
|
19120
|
+
* reached, including a record it abandoned outright.
|
|
19121
|
+
*
|
|
19122
|
+
* **Any** unusable backend response routes to the solver — a 404, a transport or server error, or
|
|
19123
|
+
* a record the backend gave up on. A rejected API key is the exception: it is not a source with
|
|
19124
|
+
* nothing to say, it is a configuration problem only a corrected key resolves, so routing it on
|
|
19125
|
+
* would bury it behind a relay or solver error and leave a poller retrying a request that cannot
|
|
19126
|
+
* succeed. The same rule the swap and bridge siblings apply. It holds here even though
|
|
19127
|
+
* `GET /leverage-yield/submit-tx/status` declares no scope of its own: whether a key is checked
|
|
19128
|
+
* is a per-deployment setting, so this must not assume the read is unauthenticated.
|
|
19129
|
+
*
|
|
19130
|
+
* A point-in-time read; poll it yourself, or use dapp-kit's `useLeverageYieldDetailedStatus`.
|
|
19131
|
+
*
|
|
19132
|
+
* @param params - `srcChainKey` and `srcTxHash` of the source-chain vault-swap transaction.
|
|
19133
|
+
* @param config - Optional per-request override. Its `apiKey` reaches every keyed leg — the
|
|
19134
|
+
* submit-tx record read, the solver read, and the durable-intent read a solver `NOT_FOUND` falls
|
|
19135
|
+
* back to — so one override keys the whole call. The relay leg is unauthenticated and takes none.
|
|
19136
|
+
* @returns A `Result` containing a {@link DetailedLeverageYieldStatus}. Fails with `LOOKUP_FAILED`
|
|
19137
|
+
* when no source can answer yet. Branch on `error.context.reason`:
|
|
19138
|
+
* `DETAILED_STATUS_NOT_DELIVERED` is the ambiguous miss a caller should bound with a retry
|
|
19139
|
+
* budget; anything else is a dependency failing right now, so keep retrying.
|
|
19140
|
+
*/
|
|
19141
|
+
getDetailedStatus(params: DetailedLeverageYieldStatusKey, config?: RequestOverrideConfig): Promise<Result<DetailedLeverageYieldStatus, LeverageYieldDetailedStatusError>>;
|
|
19142
|
+
/**
|
|
19143
|
+
* The hub-chain tx hash the solver is keyed on. A hub-source vault swap has no relay leg — the
|
|
19144
|
+
* source tx *is* the hub tx. Otherwise the delivered relay packet carries it, so an undelivered
|
|
19145
|
+
* packet is simply "no hash yet".
|
|
19146
|
+
*/
|
|
19147
|
+
private resolveHubTxHash;
|
|
19148
|
+
/**
|
|
19149
|
+
* `reason` is set only for {@link DETAILED_STATUS_NOT_DELIVERED} — the miss a caller can bound
|
|
19150
|
+
* with a retry budget. Leaving it off marks a dependency that is failing right now, which a
|
|
19151
|
+
* caller should keep retrying rather than give up on. `status` is lifted for a rejected key so
|
|
19152
|
+
* `isAuthFailure` recognises the wrapped error; it reads `context.status` and does not walk the
|
|
19153
|
+
* cause chain.
|
|
19154
|
+
*/
|
|
19155
|
+
private detailedStatusLookupFailed;
|
|
18711
19156
|
/**
|
|
18712
19157
|
* Approves the vault's underlying asset to the leverage vault on Sonic. For callers
|
|
18713
19158
|
* interacting with the vault directly on the hub — the swap-style {@link
|
|
@@ -18781,6 +19226,540 @@ declare class LeverageYieldService {
|
|
|
18781
19226
|
* returns its on-chain share balance.
|
|
18782
19227
|
*/
|
|
18783
19228
|
getShareBalanceForUser<K extends SpokeChainKey>(vault: Address, srcChainKey: K, srcAddress: string): Promise<Result<bigint, LeverageYieldLookupError>>;
|
|
19229
|
+
/**
|
|
19230
|
+
* Resolves the `LeveragePositionFactory` address, or a validation error when it is missing.
|
|
19231
|
+
*
|
|
19232
|
+
* The deployed factory ships in `leverageYieldConfig`, so this only fails when an integrator
|
|
19233
|
+
* overrides it with an empty value — which is what a bad env var produces. Failing closed there is
|
|
19234
|
+
* deliberate: a placeholder address would post real intents at nothing.
|
|
19235
|
+
*/
|
|
19236
|
+
private requireFactory;
|
|
19237
|
+
/** Position clones owned by `owner`, in creation order. Empty when the owner has none. */
|
|
19238
|
+
listPositions(owner: Address): Promise<Result<readonly Address[], LeverageYieldLookupError>>;
|
|
19239
|
+
/**
|
|
19240
|
+
* Positions belonging to a user, resolved by their spoke-side address rather than a hub address.
|
|
19241
|
+
*
|
|
19242
|
+
* Positions are owned by the user's hub wallet, so discovery goes through
|
|
19243
|
+
* `getUserHubWalletAddress` — which returns the wallet router for a Sonic user and the
|
|
19244
|
+
* cross-chain wallet for a spoke user, so the same call works on every chain. Prefer this over
|
|
19245
|
+
* `listPositions` in user-facing code; passing a raw EOA finds nothing.
|
|
19246
|
+
*/
|
|
19247
|
+
listPositionsForUser<K extends SpokeChainKey>(srcChainKey: K, srcAddress: string): Promise<Result<readonly Address[], LeverageYieldLookupError>>;
|
|
19248
|
+
/** Static descriptor of a position — owner, both legs, and the fixed eMode category. */
|
|
19249
|
+
getPositionInfo(position: Address): Promise<Result<LeveragePosition, LeverageYieldLookupError>>;
|
|
19250
|
+
/**
|
|
19251
|
+
* Live AAVE account snapshot for a position. Read from the pool, not the position: the
|
|
19252
|
+
* position contract keeps no accounting of its own, so collateral, debt and health factor
|
|
19253
|
+
* all come from `getUserAccountData`.
|
|
19254
|
+
*
|
|
19255
|
+
* The pool comes from `moneyMarket.lendingPool` config rather than the position's own
|
|
19256
|
+
* `pool()` getter — same address, one fewer round trip, and it keeps the deployment address
|
|
19257
|
+
* sourced from config like the rest of the SDK.
|
|
19258
|
+
*/
|
|
19259
|
+
getPositionAccount(position: Address): Promise<Result<LeveragePositionAccount, LeverageYieldLookupError>>;
|
|
19260
|
+
/**
|
|
19261
|
+
* The position's collateral holding, as an exact aToken balance.
|
|
19262
|
+
*
|
|
19263
|
+
* Needed to size a full exit. {@link LeverageYieldService.getPositionAccount} reports collateral
|
|
19264
|
+
* in the oracle's base currency at 8 decimals, which is fine to display but cannot name an amount:
|
|
19265
|
+
* dividing it back out by a price lands near the balance, and a `decreaseLeverage` asking for more
|
|
19266
|
+
* collateral than the position holds does not fail on submission — the hook's `transferFrom`
|
|
19267
|
+
* reverts at fill time, so the intent silently expires instead.
|
|
19268
|
+
*
|
|
19269
|
+
* Safe to act on a slightly stale read: aToken balances only grow, since interest accrues into
|
|
19270
|
+
* them, so a value from a few blocks ago is always still spendable. Selling it leaves interest
|
|
19271
|
+
* dust behind rather than coming up short.
|
|
19272
|
+
*
|
|
19273
|
+
* @param collateral The position's collateral reserve. Read from the position when omitted; pass
|
|
19274
|
+
* it if you already hold a {@link LeveragePosition} to save the round trip.
|
|
19275
|
+
*/
|
|
19276
|
+
getPositionCollateralBalance(position: Address, collateral?: Address): Promise<Result<LeveragePositionCollateral, LeverageYieldLookupError>>;
|
|
19277
|
+
/**
|
|
19278
|
+
* The position's operation slot: which operation it recorded, and whether that intent is still
|
|
19279
|
+
* live on `Intents`.
|
|
19280
|
+
*
|
|
19281
|
+
* Both are needed, because the interesting state is when they disagree. `isLive` false with a
|
|
19282
|
+
* non-zero `kind` means the intent resolved — filled, expired, or cancelled by someone else — but
|
|
19283
|
+
* the position has not been told, so its grant is still open and any debt-side contribution is
|
|
19284
|
+
* still sitting there. That is what `needsSettle` flags, and `buildSettlePosition` clears. A live
|
|
19285
|
+
* intent instead blocks any second operation until it resolves.
|
|
19286
|
+
*/
|
|
19287
|
+
getPositionPendingState(position: Address): Promise<Result<LeveragePositionPendingState, LeverageYieldLookupError>>;
|
|
19288
|
+
/** Deterministic clone address for the next position a given creator opens for `owner`. */
|
|
19289
|
+
predictPosition(creator: Address, owner: Address, positionId?: bigint): Promise<Result<Address, LeverageYieldLookupError>>;
|
|
19290
|
+
/**
|
|
19291
|
+
* Opens a new position and requests leverage on it in the same transaction — the standard way
|
|
19292
|
+
* to open a leveraged position: one approve, then this.
|
|
19293
|
+
*
|
|
19294
|
+
* `initialAssets` of `collateral` is pulled from the signer, so the factory needs an allowance
|
|
19295
|
+
* first. Control is assigned to `owner`, which may differ from the signer — pass a user's hub
|
|
19296
|
+
* wallet address to have the existing cross-chain path drive the position.
|
|
19297
|
+
*
|
|
19298
|
+
* The leverage is still asynchronous: this posts the intent and a solver fills it afterwards,
|
|
19299
|
+
* so on confirmation the position is funded with the request outstanding, not yet levered. If
|
|
19300
|
+
* no solver fills it, `buildCancelPositionOperation` returns the deposit to the owner.
|
|
19301
|
+
*/
|
|
19302
|
+
/**
|
|
19303
|
+
* Turns a {@link PositionOrigin} into the tuple the factory takes, and refuses the combinations the
|
|
19304
|
+
* contract would refuse anyway — better a rejected build than a transaction that reverts.
|
|
19305
|
+
*/
|
|
19306
|
+
private resolveOrigin;
|
|
19307
|
+
/**
|
|
19308
|
+
* Partner fee for a position, in the shape `PositionConfig` takes.
|
|
19309
|
+
*
|
|
19310
|
+
* Only the PERCENTAGE variant of `PartnerFee` maps: the contract stores basis points and derives
|
|
19311
|
+
* the amount per operation (`_feeFor`), so a fixed-amount fee has nowhere to go and is rejected
|
|
19312
|
+
* rather than silently dropped. Same precedence as the vault flows — per-call, then
|
|
19313
|
+
* `leverageYield.partnerFee`, then none.
|
|
19314
|
+
*
|
|
19315
|
+
* The fee is FIXED AT CREATION on-chain, so this is read when a position is created and never
|
|
19316
|
+
* again; changing the config later does not re-price positions already open.
|
|
19317
|
+
*/
|
|
19318
|
+
/**
|
|
19319
|
+
* The fee a position created NOW would carry, in basis points, plus who receives it.
|
|
19320
|
+
*
|
|
19321
|
+
* Public because a caller cannot project a position correctly without it and cannot derive it:
|
|
19322
|
+
* the fee resolves from `leverageYield.partnerFee`, then the global fee, then none, and it is
|
|
19323
|
+
* FIXED AT CREATION on-chain. Feed `feeBps` to {@link projectLeverageLeg} — the hooks require
|
|
19324
|
+
* `inputAmount + fee`, so a leverage-up borrows the fee ON TOP of what the solver is paid. Leaving
|
|
19325
|
+
* it out understates LTV and overstates the ceiling, which is the Aave `'36'` failure at fill time
|
|
19326
|
+
* this module exists to prevent: 50 bp takes a debt-side ceiling from 9.88x to about 9.44x.
|
|
19327
|
+
*
|
|
19328
|
+
* Pass the same `override` here as to the open call, or omit it on both.
|
|
19329
|
+
*/
|
|
19330
|
+
getEffectivePositionFee(override?: PartnerFee): Result<{
|
|
19331
|
+
feeReceiver: Address;
|
|
19332
|
+
feeBps: number;
|
|
19333
|
+
}, LeverageYieldLookupError>;
|
|
19334
|
+
private resolvePositionFee;
|
|
19335
|
+
/** A hub transaction. Every builder below produces this shape and none of them sends value. */
|
|
19336
|
+
private hubTx;
|
|
19337
|
+
/**
|
|
19338
|
+
* The `PositionConfig` struct both factory entry points take, assembled from a resolved origin.
|
|
19339
|
+
*
|
|
19340
|
+
* Shared so the two create paths cannot drift: which side the funded reserve goes on is their only
|
|
19341
|
+
* real difference, and a field silently spelled differently in one of them would be a
|
|
19342
|
+
* mis-recorded refund destination rather than a compile error.
|
|
19343
|
+
*/
|
|
19344
|
+
private positionConfig;
|
|
19345
|
+
buildCreatePositionAndLeverage(params: {
|
|
19346
|
+
from: Address;
|
|
19347
|
+
owner: Address;
|
|
19348
|
+
collateral: Address;
|
|
19349
|
+
borrowToken: Address;
|
|
19350
|
+
eModeCategory: number;
|
|
19351
|
+
origin: PositionOrigin;
|
|
19352
|
+
partnerFee?: PartnerFee;
|
|
19353
|
+
initialAssets: bigint;
|
|
19354
|
+
borrowAmount: bigint;
|
|
19355
|
+
minCollateralOut: bigint;
|
|
19356
|
+
}): Result<EvmRawTransaction, LeverageYieldLookupError>;
|
|
19357
|
+
/**
|
|
19358
|
+
* Opens a levered position starting from the **debt** token, with no collateral of your own.
|
|
19359
|
+
*
|
|
19360
|
+
* Pulls `contribution` of `borrowToken` from the signer — not the collateral. On fill the hook
|
|
19361
|
+
* supplies the solver's collateral, adds the contribution, borrows `totalInput - contribution`,
|
|
19362
|
+
* and pays the solver the total, so a holder of the debt asset lands in a levered collateral
|
|
19363
|
+
* position having never owned collateral. Requires the deployment's implementation to have a
|
|
19364
|
+
* debt-side hook configured; otherwise the position reverts with `DebtSideHookUnavailable`.
|
|
19365
|
+
*/
|
|
19366
|
+
buildCreatePositionFromDebtToken(params: {
|
|
19367
|
+
from: Address;
|
|
19368
|
+
owner: Address;
|
|
19369
|
+
collateral: Address;
|
|
19370
|
+
borrowToken: Address;
|
|
19371
|
+
eModeCategory: number;
|
|
19372
|
+
origin: PositionOrigin;
|
|
19373
|
+
partnerFee?: PartnerFee;
|
|
19374
|
+
contribution: bigint;
|
|
19375
|
+
totalInput: bigint;
|
|
19376
|
+
minCollateralOut: bigint;
|
|
19377
|
+
}): Result<EvmRawTransaction, LeverageYieldLookupError>;
|
|
19378
|
+
/** Borrows `borrowAmount` and swaps it into more collateral. `minCollateralOut` is the slippage floor. */
|
|
19379
|
+
buildAddLeverage(params: {
|
|
19380
|
+
from: Address;
|
|
19381
|
+
position: Address;
|
|
19382
|
+
borrowAmount: bigint;
|
|
19383
|
+
minCollateralOut: bigint;
|
|
19384
|
+
}): PositionIntentCall;
|
|
19385
|
+
/**
|
|
19386
|
+
* Gives up `collateralIn` of collateral to repay debt. `minDebtOut` is the slippage floor.
|
|
19387
|
+
*
|
|
19388
|
+
* CLOSING INTO THE DEBT TOKEN is this call with the position's collateral balance, less the fee a
|
|
19389
|
+
* non-zero `feeBps` gives up on top of the input (`balance x 10_000 / (10_000 + feeBps)`) — there is
|
|
19390
|
+
* no separate close entry point, because selling everything is the same operation as selling part.
|
|
19391
|
+
* Size it with {@link LeverageYieldService.getPositionCollateralBalance}, never off
|
|
19392
|
+
* `totalCollateralBase`, and quote the full amount so `minDebtOut` reflects what the solver will
|
|
19393
|
+
* actually pay for all of it.
|
|
19394
|
+
*
|
|
19395
|
+
* What that leaves behind is worth knowing. The solver delivers more debt token than is owed, so
|
|
19396
|
+
* the hook repays the debt and hands the surplus to the position, which is the owner's equity now
|
|
19397
|
+
* denominated in the debt asset. It sits in the position until someone calls
|
|
19398
|
+
* {@link LeverageYieldService.buildSettlePosition} — that sweep is what actually delivers it, and
|
|
19399
|
+
* it goes to the position's `owner` (the hub wallet), not to whoever signed. Exiting into the
|
|
19400
|
+
* *collateral* instead means repaying only the debt and then calling
|
|
19401
|
+
* {@link LeverageYieldService.buildPositionWithdraw}, which can pay out to any address.
|
|
19402
|
+
*/
|
|
19403
|
+
buildDecreaseLeverage(params: {
|
|
19404
|
+
from: Address;
|
|
19405
|
+
position: Address;
|
|
19406
|
+
collateralIn: bigint;
|
|
19407
|
+
minDebtOut: bigint;
|
|
19408
|
+
/**
|
|
19409
|
+
* Underlying a surplus is delivered in, straight to the owner's own address on their origin chain.
|
|
19410
|
+
* Only a full close produces a surplus, so this is ignored on a partial deleverage. Omit — or pass
|
|
19411
|
+
* the zero address — to leave any surplus in the position for `buildSettlePosition` to sweep, which
|
|
19412
|
+
* hands over the reserve rather than the token.
|
|
19413
|
+
*/
|
|
19414
|
+
exitAsset?: Address;
|
|
19415
|
+
}): PositionIntentCall;
|
|
19416
|
+
/**
|
|
19417
|
+
* Withdraws collateral out of the position. The pool rejects a withdrawal that would drop
|
|
19418
|
+
* the position below its liquidation threshold, so no client-side health check is applied
|
|
19419
|
+
* here — but note that bound is health factor 1, not a safety buffer above it.
|
|
19420
|
+
*/
|
|
19421
|
+
buildPositionWithdraw(params: {
|
|
19422
|
+
from: Address;
|
|
19423
|
+
position: Address;
|
|
19424
|
+
amount: bigint;
|
|
19425
|
+
to: Address;
|
|
19426
|
+
}): PositionDirectCall;
|
|
19427
|
+
/**
|
|
19428
|
+
* Clears an operation that has already resolved and returns anything the position is holding
|
|
19429
|
+
* loose to its owner.
|
|
19430
|
+
*
|
|
19431
|
+
* PERMISSIONLESS, and deliberately so: it only ever tightens state, so a stranded balance can be
|
|
19432
|
+
* pushed back by anyone rather than waiting on the owner to notice. That matters because an intent
|
|
19433
|
+
* can be cancelled by a third party once past its deadline, which leaves the position resolved but
|
|
19434
|
+
* un-swept if the hook's notification did not land.
|
|
19435
|
+
*
|
|
19436
|
+
* Reverts while the intent is still live — use {@link LeverageYieldService.buildCancelPositionOperation}
|
|
19437
|
+
* to end one that has not resolved yet.
|
|
19438
|
+
*/
|
|
19439
|
+
buildSettlePosition(params: {
|
|
19440
|
+
from: Address;
|
|
19441
|
+
position: Address;
|
|
19442
|
+
}): PositionDirectCall;
|
|
19443
|
+
/**
|
|
19444
|
+
* Cancels the in-flight operation and returns the deposit.
|
|
19445
|
+
*
|
|
19446
|
+
* Nothing is escrowed when an intent is posted, so cancelling recovers nothing by itself — but
|
|
19447
|
+
* a position carrying no debt withdraws its whole collateral balance back to the owner, which
|
|
19448
|
+
* is what a leveraged open whose intent never filled needs. With debt outstanding the
|
|
19449
|
+
* collateral stays put: the pool would reject the withdrawal on its health-factor check.
|
|
19450
|
+
*/
|
|
19451
|
+
buildCancelPositionOperation(params: {
|
|
19452
|
+
from: Address;
|
|
19453
|
+
position: Address;
|
|
19454
|
+
}): PositionDirectCall;
|
|
19455
|
+
/**
|
|
19456
|
+
* Encodes position calls as a hub-wallet payload.
|
|
19457
|
+
*
|
|
19458
|
+
* Takes the raw transactions from the builders above and produces the `(address,uint256,bytes)[]`
|
|
19459
|
+
* payload the hub wallet executes. Public because that payload is the unit the transport takes:
|
|
19460
|
+
* pass it to `spoke.deposit` / `spoke.sendMessage` yourself when you want manual relay control,
|
|
19461
|
+
* or use {@link LeverageYieldService.openPosition} / {@link LeverageYieldService.operatePosition},
|
|
19462
|
+
* which do it for you.
|
|
19463
|
+
*/
|
|
19464
|
+
encodePositionCalls(txs: readonly EvmRawTransaction[]): Hex;
|
|
19465
|
+
/**
|
|
19466
|
+
* Resolves the hub reserve a spoke token funds, and the hub asset it arrives as.
|
|
19467
|
+
*
|
|
19468
|
+
* Three addresses per token and they are not interchangeable: `hubAsset` is what lands in the hub
|
|
19469
|
+
* wallet, `vault` is the 18-decimal money-market reserve a position actually uses, and the spoke
|
|
19470
|
+
* `address` is neither. Getting this wrong is silent — the wrong one is still a valid ERC-20.
|
|
19471
|
+
*/
|
|
19472
|
+
private resolveFunding;
|
|
19473
|
+
/**
|
|
19474
|
+
* What a refund should pay back: the asset the user actually funded with, or `undefined` when that IS
|
|
19475
|
+
* the reserve and there is nothing to unwrap.
|
|
19476
|
+
*
|
|
19477
|
+
* A named asset makes `IntentRefund` unwrap before paying, on the hub as well as off it — so someone
|
|
19478
|
+
* who deposited USSD is refunded USSD rather than `sodaUSSD`.
|
|
19479
|
+
*/
|
|
19480
|
+
private refundAsset;
|
|
19481
|
+
/**
|
|
19482
|
+
* Encodes the wrap of an arriving deposit into its money-market reserve, and returns the reserve
|
|
19483
|
+
* amount that produces.
|
|
19484
|
+
*
|
|
19485
|
+
* A hub asset that is already a soda vault token IS the reserve, so nothing is wrapped. Otherwise
|
|
19486
|
+
* the vault mints 18-decimal shares one-for-one with the asset, which is what
|
|
19487
|
+
* `translateIncomingDecimals` computes — the same conversion the asset manager applies to a spoke
|
|
19488
|
+
* deposit, rather than a second implementation of it. A reserve carrying a non-zero deposit fee
|
|
19489
|
+
* would mint fewer shares than this predicts and the factory's pull would revert; both reserves in
|
|
19490
|
+
* use today are fee-free.
|
|
19491
|
+
*/
|
|
19492
|
+
private encodeWrapIntoReserve;
|
|
19493
|
+
/**
|
|
19494
|
+
* Everything both opens do before they diverge: resolve the factory, the funding token's hub asset
|
|
19495
|
+
* and reserve, and the origin to refund to; predict the address the position will be created at;
|
|
19496
|
+
* and encode the wrap plus the transfer that funds it.
|
|
19497
|
+
*
|
|
19498
|
+
* Only the factory call itself differs between the collateral side and the debt side — which side
|
|
19499
|
+
* the funded reserve lands on, and the two amounts — so everything up to that point lives here
|
|
19500
|
+
* once. `calls` is returned ready to be appended to.
|
|
19501
|
+
*/
|
|
19502
|
+
private prepareOpen;
|
|
19503
|
+
/**
|
|
19504
|
+
* Hub-side payload for opening a position from the collateral side.
|
|
19505
|
+
*
|
|
19506
|
+
* Wrap the arriving deposit into its reserve, TRANSFER it to the address the position will be
|
|
19507
|
+
* created at, create the position and post its leverage intent — one batch, executed by the user's
|
|
19508
|
+
* hub wallet. The position's collateral is the reserve behind `params.token`; `borrowToken` is
|
|
19509
|
+
* borrowed against it.
|
|
19510
|
+
*
|
|
19511
|
+
* Nothing is ever approved to the factory: it holds no allowance and pulls from nobody, so funding
|
|
19512
|
+
* is a transfer to `predictPosition(creator, owner, nextPositionIdFor(owner))` and the clone supplies
|
|
19513
|
+
* whatever it finds. The id is per-owner, so an unrelated user creating a position cannot move the
|
|
19514
|
+
* address out from under this batch — and because the transfer and the create are in the same batch,
|
|
19515
|
+
* a stale prediction reverts both rather than stranding the tokens.
|
|
19516
|
+
*
|
|
19517
|
+
* The owner's OWN concurrent opens are the one thing that can still advance the id between building
|
|
19518
|
+
* this payload and executing it. On the hub that reverts atomically and nothing is lost; funded from
|
|
19519
|
+
* a spoke the deposit has already landed in the user's hub wallet when the batch reverts, and is
|
|
19520
|
+
* recovered with `sodax.recovery` (see RECOVERY.md). Do not open two positions for one owner at once.
|
|
19521
|
+
*
|
|
19522
|
+
* The origin recorded on the position is `srcChainKey` / `srcAddress` / the deposited hub asset,
|
|
19523
|
+
* so a leverage intent that never fills refunds to the user on the chain they funded from — not to
|
|
19524
|
+
* the position, and not to the hub wallet.
|
|
19525
|
+
*/
|
|
19526
|
+
buildOpenPositionData(params: OpenPositionParams<SpokeChainKey> & {
|
|
19527
|
+
owner: Address;
|
|
19528
|
+
}): Promise<Result<Hex, LeverageYieldLookupError>>;
|
|
19529
|
+
/**
|
|
19530
|
+
* Hub-side payload for opening a position from the debt side.
|
|
19531
|
+
*
|
|
19532
|
+
* The mirror of {@link LeverageYieldService.buildOpenPositionData}: here the deposit is the
|
|
19533
|
+
* position's *debt* token, contributed rather than supplied, and `collateral` is the reserve the
|
|
19534
|
+
* position ends up long. The hook supplies the solver's collateral on fill and borrows only the
|
|
19535
|
+
* shortfall, so the position legitimately starts with no collateral of its own.
|
|
19536
|
+
*/
|
|
19537
|
+
buildOpenPositionFromDebtTokenData(params: OpenPositionFromDebtTokenParams<SpokeChainKey> & {
|
|
19538
|
+
owner: Address;
|
|
19539
|
+
}): Promise<Result<Hex, LeverageYieldLookupError>>;
|
|
19540
|
+
/**
|
|
19541
|
+
* Whether the funding token is already approved for an open from `srcChainKey`.
|
|
19542
|
+
*
|
|
19543
|
+
* The spender differs by chain and neither choice is guessable: on the hub the deposit is pulled
|
|
19544
|
+
* by the user's own hub wallet, executing inside the routed batch; on an EVM spoke it is pulled by
|
|
19545
|
+
* that spoke's asset manager. Chains with no allowance concept report `true`, and Stellar reports
|
|
19546
|
+
* whether the trustline covers the amount.
|
|
19547
|
+
*/
|
|
19548
|
+
isPositionFundingAllowanceValid<K extends SpokeChainKey>(params: {
|
|
19549
|
+
srcChainKey: K;
|
|
19550
|
+
srcAddress: string;
|
|
19551
|
+
token: string;
|
|
19552
|
+
amount: bigint;
|
|
19553
|
+
}): Promise<Result<boolean, LeverageYieldAllowanceCheckError>>;
|
|
19554
|
+
/**
|
|
19555
|
+
* Approves the funding token for an open, against the spender that chain's deposit actually uses —
|
|
19556
|
+
* see {@link LeverageYieldService.isPositionFundingAllowanceValid} for which that is.
|
|
19557
|
+
*
|
|
19558
|
+
* WAITS FOR THE APPROVAL TO LAND before returning. `Erc20Service.approve` resolves with the hash the
|
|
19559
|
+
* moment it is broadcast, so a caller that immediately re-reads the allowance sees the value from
|
|
19560
|
+
* BEFORE the approval — a UI then keeps showing "approve" and the user signs a second, pointless
|
|
19561
|
+
* approval. Returning early from a helper whose whole purpose is "the allowance is now sufficient" is
|
|
19562
|
+
* a footgun, so the wait lives here rather than in each caller.
|
|
19563
|
+
*/
|
|
19564
|
+
approvePositionFunding<K extends SpokeChainKey>(params: {
|
|
19565
|
+
srcChainKey: K;
|
|
19566
|
+
srcAddress: string;
|
|
19567
|
+
token: string;
|
|
19568
|
+
amount: bigint;
|
|
19569
|
+
walletProvider?: GetWalletProviderType<K>;
|
|
19570
|
+
}): Promise<Result<TxReturnType<K, false>, LeverageYieldApproveError>>;
|
|
19571
|
+
/**
|
|
19572
|
+
* Who pulls the deposit on an EVM source chain.
|
|
19573
|
+
*
|
|
19574
|
+
* On the hub the pull happens inside the routed batch, so the spender is the user's own hub wallet
|
|
19575
|
+
* rather than any protocol contract; on an EVM spoke it is that spoke's asset manager. Chains with
|
|
19576
|
+
* no ERC-20 allowance never reach here.
|
|
19577
|
+
*/
|
|
19578
|
+
private resolveFundingSpender;
|
|
19579
|
+
/**
|
|
19580
|
+
* Opens a leveraged position, funded from any chain, in one signature.
|
|
19581
|
+
*
|
|
19582
|
+
* The deposit is carried to the user's hub wallet and the position is created from inside that
|
|
19583
|
+
* same batch, so there is no window in which the funds sit on the hub unattached to a position.
|
|
19584
|
+
* On the hub this routes locally; from a spoke it relays and this waits for the hub side to land.
|
|
19585
|
+
*
|
|
19586
|
+
* WHAT IS AND IS NOT DONE WHEN THIS RESOLVES: the position exists and its leverage intent is
|
|
19587
|
+
* posted. The leverage itself is not applied — a solver fills that intent afterwards. And an
|
|
19588
|
+
* intent is invisible to the solver until its hub transaction hash is reported, so pass the
|
|
19589
|
+
* returned `dstChainTxHash` to {@link LeverageYieldService.notifySolver}; an unreported intent
|
|
19590
|
+
* simply expires and the deposit comes back.
|
|
19591
|
+
*
|
|
19592
|
+
* Spoke tokens need the spoke asset manager approved first, the same as any other deposit.
|
|
19593
|
+
*
|
|
19594
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN. Every path here has been exercised
|
|
19595
|
+
* end to end on Sonic, the hub. From a spoke the inbound half is proven only by a fork
|
|
19596
|
+
* replay of a real relayed message, and the OUTBOUND half — an exit or a cancellation
|
|
19597
|
+
* delivering the underlying back to the spoke it came from — has never run on mainnet.
|
|
19598
|
+
* Treat a non-hub `srcChainKey` as experimental until it has. Bitcoin is refused
|
|
19599
|
+
* outright — see {@link BITCOIN_UNSUPPORTED_MESSAGE}.
|
|
19600
|
+
*/
|
|
19601
|
+
openPosition<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, OpenPositionParams<K>>): Promise<Result<TxHashPair, LeverageYieldSwapError | LeverageYieldLookupError>>;
|
|
19602
|
+
/**
|
|
19603
|
+
* Opens a leveraged position from the **debt** token, funded from any chain.
|
|
19604
|
+
*
|
|
19605
|
+
* Same transport and the same asynchronous settlement as
|
|
19606
|
+
* {@link LeverageYieldService.openPosition} — see there for what is and is not done when this
|
|
19607
|
+
* resolves. The difference is only which side the user funds: here they hand over debt token and
|
|
19608
|
+
* end up long collateral they never held.
|
|
19609
|
+
*
|
|
19610
|
+
* Requires the deployed implementation to have a debt-side hook configured; without one the
|
|
19611
|
+
* position reverts `DebtSideHookUnavailable`.
|
|
19612
|
+
*
|
|
19613
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN. Every path here has been exercised
|
|
19614
|
+
* end to end on Sonic, the hub. From a spoke the inbound half is proven only by a fork
|
|
19615
|
+
* replay of a real relayed message, and the OUTBOUND half — an exit or a cancellation
|
|
19616
|
+
* delivering the underlying back to the spoke it came from — has never run on mainnet.
|
|
19617
|
+
* Treat a non-hub `srcChainKey` as experimental until it has. Bitcoin is refused
|
|
19618
|
+
* outright — see {@link BITCOIN_UNSUPPORTED_MESSAGE}.
|
|
19619
|
+
*/
|
|
19620
|
+
openPositionFromDebtToken<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, OpenPositionFromDebtTokenParams<K>>): Promise<Result<TxHashPair, LeverageYieldSwapError | LeverageYieldLookupError>>;
|
|
19621
|
+
/**
|
|
19622
|
+
* Shared body of the two open paths. They differ only in which factory call the payload ends with,
|
|
19623
|
+
* so everything around it — owner resolution, deposit, verify, relay — lives here rather than
|
|
19624
|
+
* being written twice and drifting.
|
|
19625
|
+
*/
|
|
19626
|
+
/**
|
|
19627
|
+
* Instrumentation for both opens. Wrapping the shared runner rather than each entry point keeps
|
|
19628
|
+
* `openPosition` and `openPositionFromDebtToken` from drifting, and `action` is already threaded
|
|
19629
|
+
* through for the error context, so it doubles as the analytics action.
|
|
19630
|
+
*
|
|
19631
|
+
* `start` carries only the fields common to both param shapes — the funding side's token and
|
|
19632
|
+
* amount. The side-specific ones (`borrowToken`/`borrowAmount` vs `collateral`/`totalInput`) are
|
|
19633
|
+
* not on `PositionFundingParams`, and inventing a cast to reach them would be worse than omitting
|
|
19634
|
+
* them.
|
|
19635
|
+
*/
|
|
19636
|
+
private runPositionOpen;
|
|
19637
|
+
private executePositionOpen;
|
|
19638
|
+
/**
|
|
19639
|
+
* Which address actually funds a position from `chainKey` — what a balance must be read against,
|
|
19640
|
+
* and what the deposit is built from.
|
|
19641
|
+
*
|
|
19642
|
+
* ONE ANSWER FOR BOTH, because two answers cost an open on mainnet: the balance was read from the
|
|
19643
|
+
* registry `address` while the deposit rewrote it to `hubAsset`, so for Sonic's native S the form
|
|
19644
|
+
* showed 42 S and the batch then called `wS.transferFrom(user, hubWallet, 5e18)` against a wS
|
|
19645
|
+
* balance of zero. The approval was correct; the revert surfaced as nothing but "External call
|
|
19646
|
+
* failed". Any integrator reading a balance for a position deposit needs this same answer.
|
|
19647
|
+
*
|
|
19648
|
+
* Three addresses hang off a registry entry and they are not interchangeable:
|
|
19649
|
+
*
|
|
19650
|
+
* `address` the spoke-side original; for a bridged entry it can name another chain entirely
|
|
19651
|
+
* `hubAsset` what the user holds ON THE HUB, and the vault's deposit input
|
|
19652
|
+
* `vault` the hub money-market reserve the position ends up in
|
|
19653
|
+
*
|
|
19654
|
+
* Off the hub the answer is always `address` — that is the chain the user is on. On the hub it is
|
|
19655
|
+
* `hubAsset`, EXCEPT for a native entry: `EvmSpokeService.deposit` keys on the chain's own
|
|
19656
|
+
* `nativeToken` to send `msg.value` rather than an ERC-20 `transferFrom`, and the native entry
|
|
19657
|
+
* carries exactly that sentinel as its `address`. Rewriting that to the wrapper asks for a token
|
|
19658
|
+
* the wallet does not hold.
|
|
19659
|
+
*
|
|
19660
|
+
* @returns The funding address, or `undefined` when the token is not supported on `chainKey`.
|
|
19661
|
+
*/
|
|
19662
|
+
resolvePositionFunding(chainKey: SpokeChainKey, token: XToken): Address | undefined;
|
|
19663
|
+
/**
|
|
19664
|
+
* Quotes one leg of a position operation: the borrowed side when levering up, the collateral when
|
|
19665
|
+
* levering down or exiting.
|
|
19666
|
+
*
|
|
19667
|
+
* Use this rather than {@link LeverageYieldService.getQuote} for a position. Both hit the same
|
|
19668
|
+
* endpoint, but this one names the hub reserves as the pair the intent actually swaps and quotes
|
|
19669
|
+
* GROSS — see `positionLegQuote.ts` for why either alone gets the floor wrong. Feed `quotedAmount`
|
|
19670
|
+
* to {@link projectLeverageLeg}.
|
|
19671
|
+
*
|
|
19672
|
+
* A refusal is not always a dead pair: {@link isNoRouteRefusal} is also what the solver answers
|
|
19673
|
+
* for a leg that is only too small, and telling the two apart means quoting again at a healthy
|
|
19674
|
+
* notional. That size is priced, so it is the caller's to choose.
|
|
19675
|
+
*/
|
|
19676
|
+
getPositionLegQuote(params: {
|
|
19677
|
+
/** Hub reserve given up. */
|
|
19678
|
+
inputHubToken: Address;
|
|
19679
|
+
/** Hub reserve expected back. */
|
|
19680
|
+
outputHubToken: Address;
|
|
19681
|
+
/** Input amount in `inputHubToken`'s units. */
|
|
19682
|
+
amount: bigint;
|
|
19683
|
+
}): Promise<Result<PositionLegQuote, SolverErrorResponse | LeverageYieldLookupError>>;
|
|
19684
|
+
/**
|
|
19685
|
+
* Opens a leveraged position AND reports the intent it posts. Prefer this to
|
|
19686
|
+
* {@link LeverageYieldService.openPosition} / {@link LeverageYieldService.openPositionFromDebtToken}.
|
|
19687
|
+
*
|
|
19688
|
+
* Those two only post the intent. Reporting it is a separate call that must not be skipped — an
|
|
19689
|
+
* unreported intent expires unfilled, so the owner is left funded with leverage that never arrives
|
|
19690
|
+
* and nothing said so. Pairing them here is the difference between an API that works and one that
|
|
19691
|
+
* works only if you read the docs.
|
|
19692
|
+
*
|
|
19693
|
+
* `side` picks which asset funds the open: `'collateral'` supplies the deposit and borrows against
|
|
19694
|
+
* it, `'debt'` hands the deposit to the solver and ends up long collateral never held.
|
|
19695
|
+
*
|
|
19696
|
+
* RESOLVING MEANS THE INTENT IS LIVE, not that the position is open, and a failed notification is
|
|
19697
|
+
* still `ok: true` — see {@link LeveragePositionIntentResult}.
|
|
19698
|
+
*
|
|
19699
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN — see `operatePosition`.
|
|
19700
|
+
*/
|
|
19701
|
+
openLeveragePosition<K extends SpokeChainKey>(_params: ({
|
|
19702
|
+
side?: 'collateral';
|
|
19703
|
+
} & SpokeExecActionParams<K, false, OpenPositionParams<K>>) | ({
|
|
19704
|
+
side: 'debt';
|
|
19705
|
+
} & SpokeExecActionParams<K, false, OpenPositionFromDebtTokenParams<K>>)): Promise<Result<LeveragePositionIntentResult, LeverageYieldSwapError | LeverageYieldLookupError>>;
|
|
19706
|
+
/**
|
|
19707
|
+
* Runs position calls that POST A SOLVER INTENT — `addLeverage` and `decreaseLeverage` — and
|
|
19708
|
+
* reports it. Prefer this to {@link LeverageYieldService.operatePosition} for those two.
|
|
19709
|
+
*
|
|
19710
|
+
* USE {@link LeverageYieldService.runLeveragePositionOperation} FOR `withdraw`, `settle` AND
|
|
19711
|
+
* `cancel`. Those are synchronous on the hub and need no notification, and the split is not
|
|
19712
|
+
* cosmetic: sending a leverage change through the route-only path leaves an intent nothing will
|
|
19713
|
+
* fill, and it expires without a word. The other direction is merely noisy.
|
|
19714
|
+
*
|
|
19715
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN — see `operatePosition`.
|
|
19716
|
+
*/
|
|
19717
|
+
submitLeveragePositionIntent<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, PositionOperationParams<K, PositionBatchCall>>): Promise<Result<LeveragePositionIntentResult, LeverageYieldSwapError>>;
|
|
19718
|
+
/**
|
|
19719
|
+
* Runs position calls that do NOT post an intent — `withdraw`, `settle` and `cancel` — as the
|
|
19720
|
+
* owning hub wallet. They are synchronous on the hub, so resolving means the work is done.
|
|
19721
|
+
*
|
|
19722
|
+
* Still routed, never sent directly: the position's `onlyOwner` is the hub wallet, so a builder's
|
|
19723
|
+
* transaction sent from the signer reverts `NotOwner`. Use
|
|
19724
|
+
* {@link LeverageYieldService.submitLeveragePositionIntent} for `addLeverage` and
|
|
19725
|
+
* `decreaseLeverage`, which this deliberately does not report.
|
|
19726
|
+
*
|
|
19727
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN, and this path carries the worst of
|
|
19728
|
+
* it: an exit or cancellation delivering the underlying back to the spoke it came from
|
|
19729
|
+
* has never run on mainnet.
|
|
19730
|
+
*/
|
|
19731
|
+
runLeveragePositionOperation<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, PositionOperationParams<K, PositionDirectCall>>): Promise<Result<TxHashPair, LeverageYieldSwapError>>;
|
|
19732
|
+
/** Bound once so the notify half can be handed around without losing `this`. */
|
|
19733
|
+
private readonly notifyIntent;
|
|
19734
|
+
/**
|
|
19735
|
+
* Runs position calls as the user's hub wallet, from any chain.
|
|
19736
|
+
*
|
|
19737
|
+
* The write counterpart to the read hooks: add or decrease leverage, withdraw, settle, cancel. No
|
|
19738
|
+
* funds move, so this is a bare message rather than a deposit — on the hub it routes locally, from
|
|
19739
|
+
* a spoke it relays and this waits for the hub side to land.
|
|
19740
|
+
*
|
|
19741
|
+
* The leverage calls only *post* an intent, so a resolved promise means the intent is live, not
|
|
19742
|
+
* that leverage moved. Report the returned `dstChainTxHash` to
|
|
19743
|
+
* {@link LeverageYieldService.notifySolver} for those two; `withdraw`, `settle` and `cancel` are
|
|
19744
|
+
* synchronous on the hub and need no notification.
|
|
19745
|
+
*
|
|
19746
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN. Every path here has been exercised
|
|
19747
|
+
* end to end on Sonic, the hub. From a spoke the inbound half is proven only by a fork
|
|
19748
|
+
* replay of a real relayed message, and the OUTBOUND half — an exit or a cancellation
|
|
19749
|
+
* delivering the underlying back to the spoke it came from — has never run on mainnet.
|
|
19750
|
+
* Treat a non-hub `srcChainKey` as experimental until it has. Bitcoin is refused
|
|
19751
|
+
* outright — see {@link BITCOIN_UNSUPPORTED_MESSAGE}.
|
|
19752
|
+
*/
|
|
19753
|
+
operatePosition<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, PositionOperationParams<K>>): Promise<Result<TxHashPair, LeverageYieldSwapError>>;
|
|
19754
|
+
private executePositionOperation;
|
|
19755
|
+
/**
|
|
19756
|
+
* Verifies a submitted source transaction and, off the hub, relays it and waits for the hub side.
|
|
19757
|
+
*
|
|
19758
|
+
* Shared by both write paths because the tail is identical whether funds moved or not. The hub
|
|
19759
|
+
* short-circuit is not an optimisation: a hub transaction has already executed the calls, so there
|
|
19760
|
+
* is nothing to relay, and both hashes are the same transaction.
|
|
19761
|
+
*/
|
|
19762
|
+
private settleHubWalletMessage;
|
|
18784
19763
|
}
|
|
18785
19764
|
|
|
18786
19765
|
declare const sponsoringInvariant: FeatureInvariant;
|
|
@@ -19663,4 +20642,237 @@ type DexApproveErrorCode = ApproveErrorCode;
|
|
|
19663
20642
|
type DexApproveError = SodaxError<DexApproveErrorCode>;
|
|
19664
20643
|
declare const isDexApproveError: (e: unknown) => e is SodaxError<ApproveErrorCode>;
|
|
19665
20644
|
|
|
19666
|
-
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, type ActivateStellarAccountParams, type ActivateStellarAccountResult, type AggregatedReserveData, type AllowanceCheckErrorCode, type AllowanceInfo, type AllowanceResponse, type AllowanceTransferDetails, type AnalyticsActionData, type ApiResponse, type ApprovalTxs, type ApproveErrorCode, type ApyRange, type AssetDepositAction, type AssetEntry, AssetService, type AssetServiceConstructorParams, type AssetWithdrawAction, type AutoSwapPreferences, BackendApiService, type BackendApiServiceOptions, BackendHttpError, type BalanceCollector, type BalanceReadContext, type BalnLockParams, type BalnMigrateAction, type BalnMigrateParams, type BalnSwapAbi, BalnSwapService, type BalnSwapServiceConstructorParams, type BaseCurrencyInfo, BigIntToHex, type BigNumberValue, BigNumberZeroDecimal, type BitcoinBoundExtras, BitcoinSpokeService, type BitcoinTransactionResult, type BitcoinUTXO, BnUSDMigrationService, type BnUSDMigrationServiceConstructorParams, type BnUSDRevertMigrationParams, type BorrowInfo, type BridgeAction, type BridgeAllowanceCheckError, type BridgeAllowanceCheckErrorCode, BridgeApiService, type BridgeApiServiceOptions, type BridgeApproveError, type BridgeApproveErrorCode, type BridgeCreateIntentError, type BridgeCreateIntentErrorCode, type BridgeError, type BridgeErrorCode, type BridgeExtras, type BridgeLookupError, type BridgeLookupErrorCode, type BridgeOrchestrationError, type BridgeOrchestrationErrorCode, type BridgeParams, BridgeService, type BridgeServiceConstructorParams, type BtcPayload, CREATE_INTENT_CODES, type CalculateAllReserveIncentivesRequest, type CalculateAllUserIncentivesRequest, type CalculateCompoundedRateRequest, type CallResponse, type CancelIntentActionParams, type CancelIntentParams, type CancelUnstakeAction, type CancelUnstakeParams, type ClClaimRewardsParams, type ClDecreaseLiquidityParams, type ClGetPoolDataParams, type ClIncreaseLiquidityParams, type ClLiquidityClaimRewardsAction, type ClLiquidityDecreaseLiquidityAction, type ClLiquidityIncreaseLiquidityAction, type ClLiquidityWithdrawAction, type ClMintPositionEventLog, type ClPositionInfo, ClService, type ClServiceConstructorParams, type ClSupplyAction, type ClSupplyParams, type ClWithdrawParams, type ClaimAction, type ClaimParams, type CombinedReserveData, type ComputedUserReserve, type ConcentratedLiquidityParams, type ConcentratedLiquidityTokenInfo, ConfigService, type ConfigServiceConstructorParams, type ConnMsg, type CreateAssetDepositParams, type CreateAssetWithdrawParams, type CreateBridgeIntentParams, type CreateIntentErrorCode, type CreateIntentParams, type CreateIntentResult, type CreateLimitOrderParams, type CreateSonicSwapIntentParams, type CreateVaultIntentResult, type CreateViemPublicClientParams, CustomSorobanServer, CustomStellarAccount, DETAILED_STATUS_NOT_DELIVERED, type DepositParams, type DepositSimulationParams, type DestinationParamsType, type DetailedLock, type DetailedStatusError, type DetailedStatusErrorCode, type DetailedSwapStatus, type DetailedSwapStatusKey, type DexApproveError, type DexApproveErrorCode, type DexCreateIntentError, type DexCreateIntentErrorCode, type DexError, type DexErrorCode, DexService, type DexServiceConstructorParams, type EModeCategory, type EModeCategoryHumanized, type EModeData, type EModeDataString, type EmodeDataHumanized, type EnrichedToken, type Erc20ApprovalPlan, type Erc20ApprovalPlanReason, type Erc20ApproveParams, type Erc20GetAllowanceParams, type Erc20IsAllowanceParams, type Erc20PlanApprovalParams, Erc20Service, type Erc20Token, Erc4626Service, type EstimateGasParams, EvmAssetManagerService, type EvmDepositToDataParams, EvmHubProvider, type EvmHubProviderConstructorParams, EvmSolverService, EvmSpokeService, EvmVaultTokenService, type EvmWithdrawAssetDataParams, type ExecuteMsg, type FeatureInvariant, type FeeData, type FeeTokenApproveAction, type FeeTokenApproveParams, type FetchHubAssetBalancesParams, type FillEvent, type FormatReserveRequest, type FormatReserveResponse, type FormatReserveUSDRequest, type FormatReserveUSDResponse, type FormatReservesAndIncentivesUSDRequest, type FormatReservesUSDRequest, type FormatUserSummaryAndIncentivesRequest, type FormatUserSummaryAndIncentivesResponse, type FormatUserSummaryRequest, type FormatUserSummaryResponse, type FormattedReserveEMode, GAS_ESTIMATION_CODES, type GasEstimationErrorCode, type GetBalanceParams, type GetBalancesParams, type GetDepositParams, type GetIntentSubmitTxExtraDataParams, type GetPacketParams, type GetPacketResponse, type GetQuoteParams, type GetRelayRequestParamType, type GetRelayResponse, type GetSpokeServiceType, type GetTransactionPacketsParams, type GetTransactionPacketsResponse, type GetTxReceiptType, type GetUserIntentParams, type GetUserRouterParams, HALF_RAY, HALF_WAD, type HanaWalletRequestEvent, type HanaWalletResponseEvent, type HookRequest, HookService, HttpRelayError, type HubAssetBalance, type HubProvider, type IconJsonRpcVersion, IconSpokeService, type IcxCreateRevertMigrationParams, type IcxMigrateAction, type IcxMigrateParams, IcxMigrationService, type IcxMigrationServiceConstructorParams, type IcxRevertMigrationAction, type IcxRevertMigrationParams, type IncentiveDataHumanized, type InjTokenInfo, Injective20Token, type InjectiveBalance, InjectiveSpokeService, type InstantUnstakeAction, type InstantUnstakeParams, type InstantiateMsg, type Intent, type IntentAutoSwapResult, IntentCreatedEventAbi, type IntentCreatedEventLog, type IntentData, IntentDataService, IntentDataType, type IntentDeliveryInfo, IntentFilledEventAbi, type IntentFilledEventLog, type IntentRelayRequest, type IntentRelayRequestParams, type IntentResponse, type IntentState, type IntentTxResult, IntentsAbi, type JsonRpcPayloadResponse, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, type LendingPoolServiceConstructorParams, type LeverageYieldAction, type LeverageYieldAllowanceCheckError, type LeverageYieldAllowanceCheckErrorCode, type LeverageYieldAllowanceParams, LeverageYieldApiService, type LeverageYieldApiServiceOptions, type LeverageYieldApproveError, type LeverageYieldApproveErrorCode, type LeverageYieldApproveParams, type LeverageYieldApr, type LeverageYieldCreateIntentError, type LeverageYieldCreateIntentErrorCode, type LeverageYieldEffectiveApr, type LeverageYieldError, type LeverageYieldErrorCode, type LeverageYieldLookupError, type LeverageYieldLookupErrorCode, type LeverageYieldLsdApr, type LeverageYieldPosition, type LeverageYieldPostExecutionError, type LeverageYieldPostExecutionErrorCode, type LeverageYieldQuoteParams, LeverageYieldService, type LeverageYieldServiceConstructorParams, type LeverageYieldSwapDepositParams, type LeverageYieldSwapError, type LeverageYieldSwapErrorCode, type LeverageYieldSwapPayload, type LeverageYieldSwapWithdrawParams, type LimitOrderActionParams, LockupMultiplier, LockupPeriod, type LookupErrorCode, type MapRelayFailureCtx, type MigrateOrchestrationError, type MigrateOrchestrationErrorCode, type MigrationAction, type MigrationAllowanceCheckError, type MigrationAllowanceCheckErrorCode, type MigrationApproveError, type MigrationApproveErrorCode, type MigrationCreateIntentError, type MigrationCreateIntentErrorCode, type MigrationDirection, type MigrationError, type MigrationErrorCode, type MigrationLookupError, type MigrationLookupErrorCode, type MigrationOp, type MigrationParams, type MigrationRevertParams, MigrationService, type MigrationServiceConstructorParams, type MigrationTokens, MintPositionEventAbi, type MintPositionEventLog, type MoneyMarketAction, type MoneyMarketAllowanceCheckError, type MoneyMarketAllowanceCheckErrorCode, type MoneyMarketAllowanceParams, type MoneyMarketApproveActionParams, type MoneyMarketApproveError, type MoneyMarketApproveErrorCode, type MoneyMarketAsset, type MoneyMarketAssetBorrowers, type MoneyMarketAssetSuppliers, type MoneyMarketBorrowActionParams, type MoneyMarketBorrowParams, type MoneyMarketBorrowers, type MoneyMarketCreateIntentError, type MoneyMarketCreateIntentErrorCode, MoneyMarketDataService, type MoneyMarketDataServiceConstructorParams, type MoneyMarketEncodeBorrowParams, type MoneyMarketEncodeRepayParams, type MoneyMarketEncodeRepayWithATokensParams, type MoneyMarketEncodeSupplyParams, type MoneyMarketEncodeWithdrawParams, type MoneyMarketError, type MoneyMarketErrorCode, type MoneyMarketGasEstimationError, type MoneyMarketGasEstimationErrorCode, type MoneyMarketOrchestrationError, type MoneyMarketOrchestrationErrorCode, type MoneyMarketParams, type MoneyMarketPosition, type MoneyMarketRepayActionParams, type MoneyMarketRepayParams, MoneyMarketService, type MoneyMarketServiceConstructorParams, type MoneyMarketSupplyActionParams, type MoneyMarketSupplyParams, type MoneyMarketWithdrawActionParams, type MoneyMarketWithdrawParams, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, ORACLE_CANDLE_INTERVALS, type OnDemandBtcPayload, type OnDemandRelayData, type OptionalRaw, type OptionalSkipSimulation, type OptionalTimeout, type OracleCandle, type OracleCandleInterval, type OracleCandlesResponse, type OracleMarketInterval, type OracleMarketsResponse, type OrderbookResponse, type PacketData, type PartnerAction, type PartnerError, type PartnerErrorCode, type PartnerFeeClaimAssetBalance, type PartnerFeeClaimCancelAction, type PartnerFeeClaimCancelParams, PartnerFeeClaimService, type PartnerFeeClaimServiceConstructorParams, type PartnerFeeClaimSwapAction, type PartnerFeeClaimSwapParams, PartnerService, type PartnerServiceConfig, type PartnerServiceConstructorParams, Permit2Service, type PermitBatch, type PermitDetails, type PermitSingle, type PoolBaseCurrencyHumanized, type PoolData, type PoolRewardConfig, type PoolSpokeAssets, type PostExecutionError, type PostExecutionErrorCode, ProtocolIntentsAbi, type QueryMsg, type QueryResponse, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RELAY_FALLBACK_FLOOR_MS, RELAY_REQUEST_TIMEOUT_MS, RadfiApiError, type RadfiAuthResult, type RadfiBuildTxResponse, type RadfiErrorBody, type RadfiHost, type RadfiMaxSpentResponse, RadfiProvider, type RadfiProviderOptions, type RadfiResponseEnvelope, type RadfiTradingWallet, type RadfiUtxo, type RadfiUtxoListResponse, type RadfiWalletBalance, type RateLimitConfig, type RawDestinationParams, type RecoveryAction, type RecoveryError, type RecoveryErrorCode, RecoveryService, type RecoveryServiceConstructorParams, type RelayAction, type RelayAndWaitParams, type RelayCode, type RelayErrorCode, type RelayExtraData, type RelayRequestDetail, type RelayRequestSigning, type RelayTxStatus, type RelayWrappedErrorCode, type RequestConfig, type RequestOverrideConfig, type RequestTrustlineParams, type ReserveCalculationData, type ReserveData, type ReserveDataHumanized, type ReserveDataLegacy, type ReserveDataWithPrice, type ReserveEMode, type ReserveIncentiveDict, type ReservesDataHumanized, type ReservesIncentiveDataHumanized, type ResolvedAnalytics, type ResponseAddressType, type ResponseSigningType, type RevertMigrationOrchestrationError, type RevertMigrationOrchestrationErrorCode, type RewardInfoHumanized, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, SPEED_TIER_SECONDS, SPEED_TIER_THRESHOLDS, SPONSOR_CONFIG_TTL_MS, STELLAR_BASE_RESERVE_TTL_MS, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, type SendMessageParams, type SetSwapPreferenceAction, type SetSwapPreferenceParams, Sodax, SodaxError, type SodaxErrorCode, type SodaxErrorContext, type SodaxErrorJSON, type SodaxPhase, SolanaSpokeService, SolverApiService, SonicSpokeService, type SpokeApproveParams, type SpokeApproveParamsEvmSpoke, type SpokeApproveParamsHub, type SpokeApproveParamsStellar, type SpokeIsAllowanceValidParams, type SpokeIsAllowanceValidParamsEvmSpoke, type SpokeIsAllowanceValidParamsHub, type SpokeIsAllowanceValidParamsOther, type SpokeIsAllowanceValidParamsStellar, SpokeService, type SpokeServiceConstructorParams, type SpokeServiceType, type SponsorFailureAction, type SponsorFailureClass, type SponsoringAction, SponsoringApiService, type SponsoringApiServiceOptions, type SponsoringConfigError, type SponsoringConfigErrorCode, type SponsoringLookupError, type SponsoringLookupErrorCode, type SponsoringOrchestrationError, type SponsoringOrchestrationErrorCode, SponsoringService, StacksSpokeService, type StakeAction, type StakeOrchestrationError, type StakeOrchestrationErrorCode, type StakeParams, type StakingActionType, type StakingActionUnion, type StakingAllowanceCheckError, type StakingAllowanceCheckErrorCode, type StakingApproveError, type StakingApproveErrorCode, type StakingConfig, type StakingCreateIntentError, type StakingCreateIntentErrorCode, type StakingError, type StakingErrorCode, type StakingInfo, type StakingInfoFetchError, type StakingInfoFetchErrorCode, StakingLogic, type StakingOrchestrationError, type StakingOrchestrationErrorCode, type StakingParamsUnion, StakingService, type StakingServiceConstructorParams, type State, type StellarAccountStatus, StellarSpokeService, type SubmitTxParams, type SubmitTxResponse, SuiGrpcTransport, SuiSpokeService, SupportedMigrationTokens, type SwapAction, type SwapActionParams, type SwapCreateIntentError, type SwapCreateIntentErrorCode, type SwapError, type SwapErrorCode, type SwapExtras, type SwapResponse, SwapService, type SwapServiceConstructorParams, type SwapSpeedTier, type SwapSpeedTierParams, type SwapSpeedTierResult, SwapsApiService, type SwapsApiServiceOptions, type TokenSpenderPair, type TokenWithConversion, type TxHashPair, type TxStatus, USD_DECIMALS, type UiPoolDataProviderInterface, UiPoolDataProviderService, type UiPoolDataProviderServiceConstructorParams, type UnifiedBnUSDMigrateAction, type UnifiedBnUSDMigrateParams, type UnstakeAction, type UnstakeParams, type UnstakeRequest, type UnstakeRequestWithPenalty, type UnstakingInfo, type UserIncentiveData, type UserIncentiveDataHumanized, type UserIncentiveDict, type UserIntentsResponse, type UserReserveCalculationData, type UserReserveData, type UserReserveDataHumanized, type UserReserveDataString, type UserReservesIncentivesDataHumanized, type UserRewardInfoHumanized, type VaultSwapActionParams, type VaultSwapResponse, type VerifySimulationParams, type VerifyTxHashParams, WAD, WAD_RAY_RATIO, WEI_DECIMALS, type WaitForTxReceiptParams, type WaitForTxReceiptReturnType, type WaitUntilIntentExecutedPayload, type WalletBalanceMap, type WalletMode, type WalletSimulationParams, type WithdrawHubAssetAction, type WithdrawHubAssetParams, type WithdrawInfo, adjustAmountByFee, allowanceCheckFailed, approveFailed, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bridgeInvariant, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, canonicalizeBitcoinAddress, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, classifySponsorError, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createBalanceCollector, createInvariant, deepMerge, defaultHookAbi, dexInvariant, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, encodeTokenIdentifier, erc20Abi, erc4626Abi, estimateBitcoinTxSize, estimateSwapSpeedTier, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getCompoundedBalance, getConnectionIdl, getConnectionProgram, getEvmViemChain, getIconAddressBytes, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getTransactionPackets, hexToBigInt, hexToSolanaAddress, hyper, intentCreationFailed, isApprovalSupportedChainKeyType, isAuthFailure, isAuthStatus, isBackendHttpError, isBalnMigrateParams, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isFillEvent, isHubChainKeyType, isIconAddress, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNativeBitcoinTransfer, isNearChainKeyType, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isOracleCandleInterval, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isSponsoringConfigError, isSponsoringLookupError, isSponsoringOrchestrationError, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKeyType, isStellarWalletProviderType, isSuiChainKeyType, isSwapCreateIntentError, isSwapError, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, isValidBitcoinAddress, isValidInjectiveAddress, isValidNearAccountId, leverageYieldInvariant, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, nativeToUSD, noopAnalytics, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveAnalytics, resolveLogger, retry, reverseEncodeAddress, robinhoodChain, serializeAddressData, settleWalletBalances, silentLogger, sleep, sodaxInvariant, sonicWalletFactoryAbi, spokeAssetManagerAbi, sponsoringInvariant, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, submitTransaction, swapExactInSingleParamsAbi, swapInvariant, toCreateBridgeIntentParamsV2, uiPoolDataAbi, universalRouterAbi, unknownFailed, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
|
20645
|
+
/**
|
|
20646
|
+
* Sizing a leverage position's swap leg.
|
|
20647
|
+
*
|
|
20648
|
+
* WHY THIS EXISTS AND WHY IT IS NOT OPTIONAL. A position's leverage is bought through the solver, and
|
|
20649
|
+
* the two legs do not trade at their oracle ratio. `LeverageHook` supplies whatever the solver
|
|
20650
|
+
* actually paid and only *then* borrows against it, so the pool's health check at fill time sees
|
|
20651
|
+
* `deposit + solver output`, never `deposit x leverage`. Size the leg from oracle prices and the
|
|
20652
|
+
* borrow reverts with Aave error `'36'` (COLLATERAL_CANNOT_COVER_NEW_BORROW) — the intent is accepted,
|
|
20653
|
+
* the solver fills, and the whole fill unwinds. That is not a hypothetical, it happened twice on
|
|
20654
|
+
* mainnet, and the two failures had different causes worth keeping apart:
|
|
20655
|
+
*
|
|
20656
|
+
* - counting a debt-side deposit as collateral as well as handing it to the solver, which put an
|
|
20657
|
+
* 11.03x open at a projected 84% LTV;
|
|
20658
|
+
* - pricing the solver's output at oracle parity, which put the same open at 90.9% when the real
|
|
20659
|
+
* figure was 92.06% against a 91% cap.
|
|
20660
|
+
*
|
|
20661
|
+
* `side` addresses the first and `f` the second.
|
|
20662
|
+
*
|
|
20663
|
+
* So sizing is a two-phase thing, and both phases are here:
|
|
20664
|
+
*
|
|
20665
|
+
* 1. {@link sizeLeverageBorrow} — how much to borrow for a target leverage. Oracle-priced, because
|
|
20666
|
+
* there is nothing else to go on yet. Quote THIS amount.
|
|
20667
|
+
* 2. {@link projectLeverageLeg} — given that quote, the slippage floor, what the position really
|
|
20668
|
+
* looks like at that floor, and the highest leverage the quote actually supports.
|
|
20669
|
+
*
|
|
20670
|
+
* Everything in phase 2 is projected from the FLOOR rather than the quote, deliberately: the floor is
|
|
20671
|
+
* the worst fill the intent permits, so if the floor is safe every fill is. Projecting from the quote
|
|
20672
|
+
* leaves the slippage tolerance as unmodelled headroom, which is exactly the gap that failed.
|
|
20673
|
+
*
|
|
20674
|
+
* Prices are the pool oracle's, in its base currency; any consistent unit works since only ratios
|
|
20675
|
+
* matter. Rates and LTVs are fractions, not percentages.
|
|
20676
|
+
*/
|
|
20677
|
+
/** Which asset the user is funding with. */
|
|
20678
|
+
type PositionSide = 'collateral' | 'debt';
|
|
20679
|
+
type LeverageLegRequest = {
|
|
20680
|
+
/**
|
|
20681
|
+
* `'collateral'` funds with the collateral asset, which is supplied. `'debt'` funds with the debt
|
|
20682
|
+
* asset, which is NOT supplied — it is handed to the solver as part of the intent's input, so the
|
|
20683
|
+
* only collateral the position ends up with is what the solver delivers. Counting the deposit on
|
|
20684
|
+
* both sides is what produced the 84%-vs-92.06% miss.
|
|
20685
|
+
*/
|
|
20686
|
+
side: PositionSide;
|
|
20687
|
+
/** Deposit in its own token decimals — the collateral token or the debt token, per `side`. */
|
|
20688
|
+
deposit: bigint;
|
|
20689
|
+
depositDecimals: number;
|
|
20690
|
+
collateralPriceUsd: number;
|
|
20691
|
+
borrowPriceUsd: number;
|
|
20692
|
+
borrowDecimals: number;
|
|
20693
|
+
/**
|
|
20694
|
+
* Target leverage as a multiple of the DEPOSIT, not of equity. 1 borrows nothing.
|
|
20695
|
+
*
|
|
20696
|
+
* The pool books the borrow in full while the collateral arrives short by the haircut, so equity
|
|
20697
|
+
* ends up under the deposit and the open position reports MORE than this — always more, never
|
|
20698
|
+
* less. See {@link LeverageLegProjection.exposureLeverage}.
|
|
20699
|
+
*/
|
|
20700
|
+
leverage: number;
|
|
20701
|
+
/**
|
|
20702
|
+
* Partner fee in basis points, as configured on the position (`PositionConfig.feeBps`). Omit or 0
|
|
20703
|
+
* when the position charges none.
|
|
20704
|
+
*
|
|
20705
|
+
* IT IS NOT A CUT OF THE OUTPUT. The hooks require `inputAmount + fee` and `Intents` pays the
|
|
20706
|
+
* receiver on the fill, so on a leverage-up the position borrows the fee ON TOP of what the solver
|
|
20707
|
+
* is paid — extra debt against unchanged collateral — and on an exit it gives up extra collateral.
|
|
20708
|
+
* Leaving it out of the projection therefore understates LTV and overstates the ceiling, which is
|
|
20709
|
+
* the Aave `'36'` failure mode this module exists to prevent.
|
|
20710
|
+
*/
|
|
20711
|
+
feeBps?: number;
|
|
20712
|
+
};
|
|
20713
|
+
type LeverageBorrowSizing = {
|
|
20714
|
+
/** Borrow-token amount the position should borrow. */
|
|
20715
|
+
borrowAmount: bigint;
|
|
20716
|
+
/**
|
|
20717
|
+
* What the solver receives as the intent's input: the borrowed amount, plus the user's own
|
|
20718
|
+
* contribution on a debt-side open, since the debt-side hook is paid both. Quote this.
|
|
20719
|
+
*/
|
|
20720
|
+
intentInput: bigint;
|
|
20721
|
+
/** The deposit's value, priced with the token actually deposited. */
|
|
20722
|
+
depositUsd: number;
|
|
20723
|
+
/** Value being borrowed, EXCLUDING the partner fee. This is what the solver is paid. */
|
|
20724
|
+
borrowUsd: number;
|
|
20725
|
+
/** Partner fee on this leg, in the borrow token's own units. Zero when none is configured. */
|
|
20726
|
+
feeAmount: bigint;
|
|
20727
|
+
/** Total the position ends up owing: `borrowUsd` plus the fee's value. */
|
|
20728
|
+
debtUsd: number;
|
|
20729
|
+
};
|
|
20730
|
+
/**
|
|
20731
|
+
* Phase 1: the borrow for a target leverage, and the input to quote.
|
|
20732
|
+
*
|
|
20733
|
+
* ORACLE SIZING ONLY. It deliberately does not project the result, because at this point it cannot —
|
|
20734
|
+
* the collateral that lands is whatever the solver pays. Feed `intentInput` to a solver quote and
|
|
20735
|
+
* pass the result to {@link projectLeverageLeg}.
|
|
20736
|
+
*/
|
|
20737
|
+
declare function sizeLeverageBorrow(request: LeverageLegRequest): LeverageBorrowSizing;
|
|
20738
|
+
type LeverageLegQuote = {
|
|
20739
|
+
/** What the solver quoted for `intentInput`, in the collateral reserve's decimals. */
|
|
20740
|
+
quotedCollateral: bigint;
|
|
20741
|
+
collateralDecimals: number;
|
|
20742
|
+
};
|
|
20743
|
+
type ReserveRiskParams = {
|
|
20744
|
+
/** Reserve (or eMode) max LTV as a fraction. The Aave `'36'` boundary. */
|
|
20745
|
+
ltv: number;
|
|
20746
|
+
/** Liquidation threshold as a fraction. */
|
|
20747
|
+
liquidationThreshold: number;
|
|
20748
|
+
};
|
|
20749
|
+
type LeverageLegProjection = {
|
|
20750
|
+
/** Slippage floor to post as the intent's `minCollateralOut`. Never zero. */
|
|
20751
|
+
minCollateralOut: bigint;
|
|
20752
|
+
/** Collateral the position holds after the fill, at the floor. */
|
|
20753
|
+
collateralUsd: number;
|
|
20754
|
+
debtUsd: number;
|
|
20755
|
+
ltv: number;
|
|
20756
|
+
/** Aave health factor at the floor; `Infinity` with no debt. */
|
|
20757
|
+
healthFactor: number;
|
|
20758
|
+
/**
|
|
20759
|
+
* Whether the pool would reject the borrow outright. This is the Aave `'36'` check, and the one
|
|
20760
|
+
* thing a caller must not post through: the intent is accepted and fails at fill.
|
|
20761
|
+
*/
|
|
20762
|
+
exceedsMaxLtv: boolean;
|
|
20763
|
+
/**
|
|
20764
|
+
* Fraction of the input's oracle value the solver keeps, measured from the QUOTE rather than the
|
|
20765
|
+
* floor — the expected cost of the leg, not the worst permitted one. Negative when the quote beats
|
|
20766
|
+
* parity, which a correlated pair can do.
|
|
20767
|
+
*/
|
|
20768
|
+
haircut: number;
|
|
20769
|
+
/** Oracle value handed to the solver: the borrow, plus the contribution on a debt-side open. */
|
|
20770
|
+
inputUsd: number;
|
|
20771
|
+
/**
|
|
20772
|
+
* What the leg costs once, in the same units as the prices: the solver's cut PLUS the partner fee.
|
|
20773
|
+
* Paid up front and in full, unlike the yield it buys, so it is what a payback period is measured
|
|
20774
|
+
* against. Can be negative when the quote beats parity and no fee is charged.
|
|
20775
|
+
*
|
|
20776
|
+
* The fee belongs here even though it is borrowed rather than deducted — the owner owes it without
|
|
20777
|
+
* receiving anything for it, so a breakeven that left it out would promise too short a payback.
|
|
20778
|
+
*/
|
|
20779
|
+
costUsd: number;
|
|
20780
|
+
/**
|
|
20781
|
+
* Collateral over equity — what the open position reports, and what `request.leverage` is not.
|
|
20782
|
+
* The two differ by the haircut, this one always larger: 2.00x requested at a 4.657% haircut
|
|
20783
|
+
* reports 2.0488x. At the floor like the rest of phase 2, so it is an upper bound.
|
|
20784
|
+
*/
|
|
20785
|
+
exposureLeverage: number;
|
|
20786
|
+
/**
|
|
20787
|
+
* The most leverage this price actually supports, from `debt <= ltv x collateral` with `f` as the
|
|
20788
|
+
* USD of collateral the floor returns per USD handed to the solver:
|
|
20789
|
+
*
|
|
20790
|
+
* debt side: L <= 1 / (1 - ltv x f) — the deposit buys collateral, none is supplied
|
|
20791
|
+
* collateral side: L <= 1 + ltv / (1 - ltv x f) — the deposit is also collateral
|
|
20792
|
+
*
|
|
20793
|
+
* At `f = 1` the second collapses to the familiar `1 / (1 - ltv)`. Below 1 it is strictly lower,
|
|
20794
|
+
* which is the whole point: `ltv` 91% with `f` 0.9877 gives 9.88x, and the 11.03x that looked fine
|
|
20795
|
+
* against oracle parity was never available. Above `f = 1 / ltv` there is no ceiling at all and
|
|
20796
|
+
* this is `Infinity` — a favourable enough fill adds borrowing power faster than debt.
|
|
20797
|
+
*/
|
|
20798
|
+
usableMaxLeverage: number;
|
|
20799
|
+
};
|
|
20800
|
+
/**
|
|
20801
|
+
* Phase 2: the floor to post, the position that results from it, and the leverage ceiling this quote
|
|
20802
|
+
* actually supports.
|
|
20803
|
+
*
|
|
20804
|
+
* `slippagePct` is a percentage (1 means 1%) and comes off what the solver QUOTED, not off the input
|
|
20805
|
+
* amount — sizing the floor as `deposit x leverage x (1 - slippage)` assumes 1:1 token parity and put
|
|
20806
|
+
* earlier attempts above what the solver would pay, which made them unfillable.
|
|
20807
|
+
*/
|
|
20808
|
+
declare function projectLeverageLeg(request: LeverageLegRequest, quote: LeverageLegQuote, risk: ReserveRiskParams, slippagePct: number): LeverageLegProjection;
|
|
20809
|
+
|
|
20810
|
+
/**
|
|
20811
|
+
* Whether a leveraged position is worth opening at all, and how long it must be held to pay for
|
|
20812
|
+
* itself.
|
|
20813
|
+
*
|
|
20814
|
+
* The sibling of `positionSizing.ts`, and here for the same reason: `sizeLeverageBorrow` answers how
|
|
20815
|
+
* to open a position, this answers whether to. Both are pure, and a partner integrating without the
|
|
20816
|
+
* reference UI needs both — getting this one wrong does not revert, it just quietly sells a position
|
|
20817
|
+
* that never earns its entry cost back.
|
|
20818
|
+
*
|
|
20819
|
+
* Rates are percentages throughout, amounts are USD, and durations are years.
|
|
20820
|
+
*/
|
|
20821
|
+
/** Net APY on equity at `leverage`, all rates as percentages. */
|
|
20822
|
+
declare function leveragedNetApyPct(supplyApyPct: number, borrowApyPct: number, leverage: number): number;
|
|
20823
|
+
/** What the swap costs relative to oracle parity, and the yield that has to earn it back. */
|
|
20824
|
+
type BreakevenInput = {
|
|
20825
|
+
/** One-time cost of the leg: what the solver is handed, less what it pays back, in USD. */
|
|
20826
|
+
costUsd: number;
|
|
20827
|
+
/**
|
|
20828
|
+
* Equity the incremental yield accrues on, in USD — `collateral - debt` AFTER the fill, not the
|
|
20829
|
+
* deposit. They differ by the solver's spread, and the deposit is the larger, so passing it makes
|
|
20830
|
+
* every payback look shorter than it is.
|
|
20831
|
+
*/
|
|
20832
|
+
equityUsd: number;
|
|
20833
|
+
/** Leverage being moved FROM — 1 for a fresh open, since the alternative is just holding. */
|
|
20834
|
+
fromLeverage: number;
|
|
20835
|
+
};
|
|
20836
|
+
/**
|
|
20837
|
+
* Years until the extra yield from levering up repays what the swap cost, or a reason it never does.
|
|
20838
|
+
*
|
|
20839
|
+
* Levering is a trade: the solver's cut is paid ONCE, up front and in full, while the benefit arrives
|
|
20840
|
+
* as a rate. So the question a target leverage actually poses is how long the position must be held
|
|
20841
|
+
* for the second to cover the first:
|
|
20842
|
+
*
|
|
20843
|
+
* costUsd = equityUsd x (net(to) - net(from)) x years
|
|
20844
|
+
*
|
|
20845
|
+
* and `net(to) - net(from)` reduces to `(supply - borrow) x (to - from)` — the incremental term, NOT
|
|
20846
|
+
* the headline net APY. Using the headline number would flatter every case: an already-levered
|
|
20847
|
+
* position earns most of that rate whether or not you adjust it, so charging the entry cost against
|
|
20848
|
+
* the whole thing understates the payback period.
|
|
20849
|
+
*
|
|
20850
|
+
* Two regimes return no number rather than a misleading one. When supply does not exceed borrow the
|
|
20851
|
+
* incremental rate is zero or negative and no holding period repays the cost — levering up is simply
|
|
20852
|
+
* a worse position, which is the same fact the zero-crossing row reports. And a non-positive cost
|
|
20853
|
+
* means the quote beat parity, so there is nothing to earn back.
|
|
20854
|
+
*
|
|
20855
|
+
* COUNTS THE ENTRY ONLY. Unwinding sells collateral back through the solver and pays a comparable
|
|
20856
|
+
* spread a second time, so a full round trip needs roughly double this to come out even. Treat the
|
|
20857
|
+
* number as the floor on how long the position has to be worth holding, not the whole bill.
|
|
20858
|
+
*/
|
|
20859
|
+
declare function timeToBreakevenYears(supplyApyPct: number, borrowApyPct: number, toLeverage: number, { costUsd, equityUsd, fromLeverage }: BreakevenInput): number | 'never' | 'immediate' | undefined;
|
|
20860
|
+
|
|
20861
|
+
/**
|
|
20862
|
+
* Which of a registry entry's three addresses funds a position deposit.
|
|
20863
|
+
*
|
|
20864
|
+
* Pure, and separate from the service so it can be checked against the whole token registry without
|
|
20865
|
+
* constructing one — see `positionFunding.test.ts`, which asserts the answer for every supported
|
|
20866
|
+
* token on every chain. The bug this exists to prevent was two code paths disagreeing, and a
|
|
20867
|
+
* disagreement is exactly what an exhaustive check catches.
|
|
20868
|
+
*/
|
|
20869
|
+
|
|
20870
|
+
/**
|
|
20871
|
+
* @param chainKey The chain the user funds from.
|
|
20872
|
+
* @param hubChainKey The hub's own chain key, from `hubProvider.chainConfig.chain.key`.
|
|
20873
|
+
* @param token The registry entry being funded with.
|
|
20874
|
+
* @returns The funding address, or `''` when the entry carries none.
|
|
20875
|
+
*/
|
|
20876
|
+
declare function resolvePositionFundingAddress(chainKey: SpokeChainKey, hubChainKey: SpokeChainKey, token: XToken | undefined): string;
|
|
20877
|
+
|
|
20878
|
+
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, type ActivateStellarAccountParams, type ActivateStellarAccountResult, type AggregatedReserveData, type AllowanceCheckErrorCode, type AllowanceInfo, type AllowanceResponse, type AllowanceTransferDetails, type AnalyticsActionData, type ApiResponse, type ApprovalTxs, type ApproveErrorCode, type ApyRange, type AssetDepositAction, type AssetEntry, AssetService, type AssetServiceConstructorParams, type AssetWithdrawAction, type AutoSwapPreferences, BackendApiService, type BackendApiServiceOptions, BackendHttpError, type BalanceCollector, type BalanceReadContext, type BalnLockParams, type BalnMigrateAction, type BalnMigrateParams, type BalnSwapAbi, BalnSwapService, type BalnSwapServiceConstructorParams, type BaseCurrencyInfo, BigIntToHex, type BigNumberValue, BigNumberZeroDecimal, type BitcoinBoundExtras, BitcoinSpokeService, type BitcoinTransactionResult, type BitcoinUTXO, BnUSDMigrationService, type BnUSDMigrationServiceConstructorParams, type BnUSDRevertMigrationParams, type BorrowInfo, type BreakevenInput, type BridgeAction, type BridgeAllowanceCheckError, type BridgeAllowanceCheckErrorCode, BridgeApiService, type BridgeApiServiceOptions, type BridgeApproveError, type BridgeApproveErrorCode, type BridgeCreateIntentError, type BridgeCreateIntentErrorCode, type BridgeDetailedStatusError, type BridgeDetailedStatusErrorCode, type BridgeError, type BridgeErrorCode, type BridgeExtras, type BridgeLookupError, type BridgeLookupErrorCode, type BridgeOrchestrationError, type BridgeOrchestrationErrorCode, type BridgeParams, BridgeService, type BridgeServiceConstructorParams, type BtcPayload, CREATE_INTENT_CODES, type CalculateAllReserveIncentivesRequest, type CalculateAllUserIncentivesRequest, type CalculateCompoundedRateRequest, type CallResponse, type CancelIntentActionParams, type CancelIntentParams, type CancelUnstakeAction, type CancelUnstakeParams, type ClClaimRewardsParams, type ClDecreaseLiquidityParams, type ClGetPoolDataParams, type ClIncreaseLiquidityParams, type ClLiquidityClaimRewardsAction, type ClLiquidityDecreaseLiquidityAction, type ClLiquidityIncreaseLiquidityAction, type ClLiquidityWithdrawAction, type ClMintPositionEventLog, type ClPositionInfo, ClService, type ClServiceConstructorParams, type ClSupplyAction, type ClSupplyParams, type ClWithdrawParams, type ClaimAction, type ClaimParams, type CombinedReserveData, type ComputedUserReserve, type ConcentratedLiquidityParams, type ConcentratedLiquidityTokenInfo, ConfigService, type ConfigServiceConstructorParams, type ConnMsg, type CreateAssetDepositParams, type CreateAssetWithdrawParams, type CreateBridgeIntentParams, type CreateIntentErrorCode, type CreateIntentParams, type CreateIntentResult, type CreateLimitOrderParams, type CreateSonicSwapIntentParams, type CreateVaultIntentResult, type CreateViemPublicClientParams, CustomSorobanServer, CustomStellarAccount, DETAILED_STATUS_NOT_DELIVERED, type DepositParams, type DepositSimulationParams, type DestinationParamsType, type DetailedBridgeStatus, type DetailedBridgeStatusKey, type DetailedLeverageYieldStatus, type DetailedLeverageYieldStatusKey, type DetailedLock, type DetailedStatusError, type DetailedStatusErrorCode, type DetailedSwapStatus, type DetailedSwapStatusKey, type DexApproveError, type DexApproveErrorCode, type DexCreateIntentError, type DexCreateIntentErrorCode, type DexError, type DexErrorCode, DexService, type DexServiceConstructorParams, type EModeCategory, type EModeCategoryHumanized, type EModeData, type EModeDataString, type EmodeDataHumanized, type EnrichedToken, type Erc20ApprovalPlan, type Erc20ApprovalPlanReason, type Erc20ApproveParams, type Erc20GetAllowanceParams, type Erc20IsAllowanceParams, type Erc20PlanApprovalParams, Erc20Service, type Erc20Token, Erc4626Service, type EstimateGasParams, EvmAssetManagerService, type EvmDepositToDataParams, EvmHubProvider, type EvmHubProviderConstructorParams, EvmSolverService, EvmSpokeService, EvmVaultTokenService, type EvmWithdrawAssetDataParams, type ExecuteMsg, type FeatureInvariant, type FeeData, type FeeTokenApproveAction, type FeeTokenApproveParams, type FetchHubAssetBalancesParams, type FillEvent, type FormatReserveRequest, type FormatReserveResponse, type FormatReserveUSDRequest, type FormatReserveUSDResponse, type FormatReservesAndIncentivesUSDRequest, type FormatReservesUSDRequest, type FormatUserSummaryAndIncentivesRequest, type FormatUserSummaryAndIncentivesResponse, type FormatUserSummaryRequest, type FormatUserSummaryResponse, type FormattedReserveEMode, GAS_ESTIMATION_CODES, type GasEstimationErrorCode, type GetBalanceParams, type GetBalancesParams, type GetDepositParams, type GetIntentSubmitTxExtraDataParams, type GetPacketParams, type GetPacketResponse, type GetQuoteParams, type GetRelayRequestParamType, type GetRelayResponse, type GetSpokeServiceType, type GetTransactionPacketsParams, type GetTransactionPacketsResponse, type GetTxReceiptType, type GetUserIntentParams, type GetUserRouterParams, HALF_RAY, HALF_WAD, type HanaWalletRequestEvent, type HanaWalletResponseEvent, type HookRequest, HookService, HttpRelayError, type HubAssetBalance, type HubProvider, type IconJsonRpcVersion, IconSpokeService, type IcxCreateRevertMigrationParams, type IcxMigrateAction, type IcxMigrateParams, IcxMigrationService, type IcxMigrationServiceConstructorParams, type IcxRevertMigrationAction, type IcxRevertMigrationParams, type IncentiveDataHumanized, type InjTokenInfo, Injective20Token, type InjectiveBalance, InjectiveSpokeService, type InstantUnstakeAction, type InstantUnstakeParams, type InstantiateMsg, type Intent, type IntentAutoSwapResult, IntentCreatedEventAbi, type IntentCreatedEventLog, type IntentData, IntentDataService, IntentDataType, type IntentDeliveryInfo, IntentFilledEventAbi, type IntentFilledEventLog, type IntentRelayRequest, type IntentRelayRequestParams, type IntentResponse, type IntentState, type IntentTxResult, IntentsAbi, type JsonRpcPayloadResponse, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, type LendingPoolServiceConstructorParams, type LeverageBorrowSizing, type LeverageLegProjection, type LeverageLegQuote, type LeverageLegRequest, type LeveragePositionIntentResult, type LeverageYieldAction, type LeverageYieldAllowanceCheckError, type LeverageYieldAllowanceCheckErrorCode, type LeverageYieldAllowanceParams, LeverageYieldApiService, type LeverageYieldApiServiceOptions, type LeverageYieldApproveError, type LeverageYieldApproveErrorCode, type LeverageYieldApproveParams, type LeverageYieldApr, type LeverageYieldCreateIntentError, type LeverageYieldCreateIntentErrorCode, type LeverageYieldDetailedStatusError, type LeverageYieldDetailedStatusErrorCode, type LeverageYieldEffectiveApr, type LeverageYieldError, type LeverageYieldErrorCode, type LeverageYieldExtras, type LeverageYieldLookupError, type LeverageYieldLookupErrorCode, type LeverageYieldLsdApr, type LeverageYieldPosition, type LeverageYieldPostExecutionError, type LeverageYieldPostExecutionErrorCode, type LeverageYieldQuoteParams, LeverageYieldService, type LeverageYieldServiceConstructorParams, type LeverageYieldSwapDepositParams, type LeverageYieldSwapError, type LeverageYieldSwapErrorCode, type LeverageYieldSwapPayload, type LeverageYieldSwapWithdrawParams, type LimitOrderActionParams, LockupMultiplier, LockupPeriod, type LookupErrorCode, MAX_POSITION_FEE_BPS, type MapRelayFailureCtx, type MigrateOrchestrationError, type MigrateOrchestrationErrorCode, type MigrationAction, type MigrationAllowanceCheckError, type MigrationAllowanceCheckErrorCode, type MigrationApproveError, type MigrationApproveErrorCode, type MigrationCreateIntentError, type MigrationCreateIntentErrorCode, type MigrationDirection, type MigrationError, type MigrationErrorCode, type MigrationLookupError, type MigrationLookupErrorCode, type MigrationOp, type MigrationParams, type MigrationRevertParams, MigrationService, type MigrationServiceConstructorParams, type MigrationTokens, MintPositionEventAbi, type MintPositionEventLog, type MoneyMarketAction, type MoneyMarketAllowanceCheckError, type MoneyMarketAllowanceCheckErrorCode, type MoneyMarketAllowanceParams, type MoneyMarketApproveActionParams, type MoneyMarketApproveError, type MoneyMarketApproveErrorCode, type MoneyMarketAsset, type MoneyMarketAssetBorrowers, type MoneyMarketAssetSuppliers, type MoneyMarketBorrowActionParams, type MoneyMarketBorrowParams, type MoneyMarketBorrowers, type MoneyMarketCreateIntentError, type MoneyMarketCreateIntentErrorCode, MoneyMarketDataService, type MoneyMarketDataServiceConstructorParams, type MoneyMarketEncodeBorrowParams, type MoneyMarketEncodeRepayParams, type MoneyMarketEncodeRepayWithATokensParams, type MoneyMarketEncodeSupplyParams, type MoneyMarketEncodeWithdrawParams, type MoneyMarketError, type MoneyMarketErrorCode, type MoneyMarketGasEstimationError, type MoneyMarketGasEstimationErrorCode, type MoneyMarketOrchestrationError, type MoneyMarketOrchestrationErrorCode, type MoneyMarketParams, type MoneyMarketPosition, type MoneyMarketRepayActionParams, type MoneyMarketRepayParams, MoneyMarketService, type MoneyMarketServiceConstructorParams, type MoneyMarketSupplyActionParams, type MoneyMarketSupplyParams, type MoneyMarketWithdrawActionParams, type MoneyMarketWithdrawParams, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, ORACLE_CANDLE_INTERVALS, type OnDemandBtcPayload, type OnDemandRelayData, type OpenPositionFromDebtTokenParams, type OpenPositionParams, type OptionalRaw, type OptionalSkipSimulation, type OptionalTimeout, type OracleCandle, type OracleCandleInterval, type OracleCandlesResponse, type OracleMarketInterval, type OracleMarketsResponse, type OrderbookResponse, type PacketData, type PartnerAction, type PartnerError, type PartnerErrorCode, type PartnerFeeClaimAssetBalance, type PartnerFeeClaimCancelAction, type PartnerFeeClaimCancelParams, PartnerFeeClaimService, type PartnerFeeClaimServiceConstructorParams, type PartnerFeeClaimSwapAction, type PartnerFeeClaimSwapParams, PartnerService, type PartnerServiceConfig, type PartnerServiceConstructorParams, Permit2Service, type PermitBatch, type PermitDetails, type PermitSingle, type PoolBaseCurrencyHumanized, type PoolData, type PoolRewardConfig, type PoolSpokeAssets, type PositionBatchCall, type PositionDirectCall, type PositionFundingParams, type PositionIntentCall, type PositionIntentNotifier, type PositionLegQuote, type PositionOperationParams, type PositionOrigin, type PositionSide, type PostExecutionError, type PostExecutionErrorCode, ProtocolIntentsAbi, type QueryMsg, type QueryResponse, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RELAY_FALLBACK_FLOOR_MS, RELAY_REQUEST_TIMEOUT_MS, RadfiApiError, type RadfiAuthResult, type RadfiBuildTxResponse, type RadfiErrorBody, type RadfiHost, type RadfiMaxSpentResponse, RadfiProvider, type RadfiProviderOptions, type RadfiResponseEnvelope, type RadfiTradingWallet, type RadfiUtxo, type RadfiUtxoListResponse, type RadfiWalletBalance, type RateLimitConfig, type RawDestinationParams, type RecoveryAction, type RecoveryError, type RecoveryErrorCode, RecoveryService, type RecoveryServiceConstructorParams, type RelayAction, type RelayAndWaitParams, type RelayCode, type RelayErrorCode, type RelayExtraData, type RelayRequestDetail, type RelayRequestSigning, type RelayTxStatus, type RelayWrappedErrorCode, type RequestConfig, type RequestOverrideConfig, type RequestTrustlineParams, type ReserveCalculationData, type ReserveData, type ReserveDataHumanized, type ReserveDataLegacy, type ReserveDataWithPrice, type ReserveEMode, type ReserveIncentiveDict, type ReserveRiskParams, type ReservesDataHumanized, type ReservesIncentiveDataHumanized, type ResolvedAnalytics, type ResponseAddressType, type ResponseSigningType, type RevertMigrationOrchestrationError, type RevertMigrationOrchestrationErrorCode, type RewardInfoHumanized, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, SPEED_TIER_SECONDS, SPEED_TIER_THRESHOLDS, SPONSOR_CONFIG_TTL_MS, STELLAR_BASE_RESERVE_TTL_MS, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, type SendMessageParams, type SetSwapPreferenceAction, type SetSwapPreferenceParams, Sodax, SodaxError, type SodaxErrorCode, type SodaxErrorContext, type SodaxErrorJSON, type SodaxPhase, SolanaSpokeService, SolverApiService, SonicSpokeService, type SpokeApproveParams, type SpokeApproveParamsEvmSpoke, type SpokeApproveParamsHub, type SpokeApproveParamsStellar, type SpokeIsAllowanceValidParams, type SpokeIsAllowanceValidParamsEvmSpoke, type SpokeIsAllowanceValidParamsHub, type SpokeIsAllowanceValidParamsOther, type SpokeIsAllowanceValidParamsStellar, SpokeService, type SpokeServiceConstructorParams, type SpokeServiceType, type SponsorFailureAction, type SponsorFailureClass, type SponsoringAction, SponsoringApiService, type SponsoringApiServiceOptions, type SponsoringConfigError, type SponsoringConfigErrorCode, type SponsoringLookupError, type SponsoringLookupErrorCode, type SponsoringOrchestrationError, type SponsoringOrchestrationErrorCode, SponsoringService, StacksSpokeService, type StakeAction, type StakeOrchestrationError, type StakeOrchestrationErrorCode, type StakeParams, type StakingActionType, type StakingActionUnion, type StakingAllowanceCheckError, type StakingAllowanceCheckErrorCode, type StakingApproveError, type StakingApproveErrorCode, type StakingConfig, type StakingCreateIntentError, type StakingCreateIntentErrorCode, type StakingError, type StakingErrorCode, type StakingInfo, type StakingInfoFetchError, type StakingInfoFetchErrorCode, StakingLogic, type StakingOrchestrationError, type StakingOrchestrationErrorCode, type StakingParamsUnion, StakingService, type StakingServiceConstructorParams, type State, type StellarAccountStatus, StellarSpokeService, type SubmitTxParams, type SubmitTxResponse, SuiGrpcTransport, SuiSpokeService, SupportedMigrationTokens, type SwapAction, type SwapActionParams, type SwapCreateIntentError, type SwapCreateIntentErrorCode, type SwapError, type SwapErrorCode, type SwapExtras, type SwapResponse, SwapService, type SwapServiceConstructorParams, type SwapSpeedTier, type SwapSpeedTierParams, type SwapSpeedTierResult, SwapsApiService, type SwapsApiServiceOptions, type TokenSpenderPair, type TokenWithConversion, type TxHashPair, type TxStatus, USD_DECIMALS, type UiPoolDataProviderInterface, UiPoolDataProviderService, type UiPoolDataProviderServiceConstructorParams, type UnifiedBnUSDMigrateAction, type UnifiedBnUSDMigrateParams, type UnstakeAction, type UnstakeParams, type UnstakeRequest, type UnstakeRequestWithPenalty, type UnstakingInfo, type UserIncentiveData, type UserIncentiveDataHumanized, type UserIncentiveDict, type UserIntentsResponse, type UserReserveCalculationData, type UserReserveData, type UserReserveDataHumanized, type UserReserveDataString, type UserReservesIncentivesDataHumanized, type UserRewardInfoHumanized, type VaultSwapActionParams, type VaultSwapResponse, type VerifySimulationParams, type VerifyTxHashParams, WAD, WAD_RAY_RATIO, WEI_DECIMALS, type WaitForTxReceiptParams, type WaitForTxReceiptReturnType, type WaitUntilIntentExecutedPayload, type WalletBalanceMap, type WalletMode, type WalletSimulationParams, type WithdrawHubAssetAction, type WithdrawHubAssetParams, type WithdrawInfo, adjustAmountByFee, allowanceCheckFailed, approveFailed, assetManagerAbi, balnSwapAbi, binomialApproximatedRayPow, bridgeInvariant, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, canonicalizeBitcoinAddress, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, classifySponsorError, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createBalanceCollector, createInvariant, deepMerge, defaultHookAbi, dexInvariant, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, encodeTokenIdentifier, erc20Abi, erc4626Abi, estimateBitcoinTxSize, estimateSwapSpeedTier, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getCompoundedBalance, getConnectionIdl, getConnectionProgram, getEvmViemChain, getIconAddressBytes, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getTransactionPackets, hexToBigInt, hexToSolanaAddress, hyper, intentCreationFailed, isApprovalSupportedChainKeyType, isAuthFailure, isAuthStatus, isBackendHttpError, isBalnMigrateParams, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isFillEvent, isHubChainKeyType, isIconAddress, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNativeBitcoinTransfer, isNearChainKeyType, isNoRouteRefusal, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isOracleCandleInterval, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isSponsoringConfigError, isSponsoringLookupError, isSponsoringOrchestrationError, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKeyType, isStellarWalletProviderType, isSuiChainKeyType, isSwapCreateIntentError, isSwapError, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, isValidBitcoinAddress, isValidInjectiveAddress, isValidNearAccountId, leverageYieldInvariant, leveragedNetApyPct, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, nativeToUSD, noopAnalytics, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, poolAbi, poolKeyAbi, projectLeverageLeg, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, relayTxAndWaitPacket, reportPositionIntent, requestAddress, requestJsonRpc, requestSigning, resolveAnalytics, resolveLogger, resolvePositionFundingAddress, retry, reverseEncodeAddress, robinhoodChain, serializeAddressData, settleWalletBalances, silentLogger, sizeLeverageBorrow, sleep, sodaxInvariant, sonicWalletFactoryAbi, spokeAssetManagerAbi, sponsoringInvariant, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, submitTransaction, swapExactInSingleParamsAbi, swapInvariant, timeToBreakevenYears, toCreateBridgeIntentParamsV2, uiPoolDataAbi, universalRouterAbi, unknownFailed, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|