@sodax/sdk 2.2.0-rc.5 → 2.2.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- package/dist/index.cjs +1700 -357
- package/dist/index.d.cts +1041 -36
- package/dist/index.d.ts +1041 -36
- package/dist/index.mjs +1695 -367
- package/package.json +5 -4
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, 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,16 @@ 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;
|
|
13424
13461
|
|
|
13425
13462
|
/** The tagged status union behind `SwapService.getDetailedStatus`. Pure — no I/O. */
|
|
13426
13463
|
|
|
@@ -14081,7 +14118,7 @@ declare class SwapService {
|
|
|
14081
14118
|
/**
|
|
14082
14119
|
* Offline, rule-based estimate of how fast a `srcToken`→`dstToken` swap will settle.
|
|
14083
14120
|
*
|
|
14084
|
-
* Derived purely from SDK config (no network / on-chain / backend call): tokens
|
|
14121
|
+
* Derived purely from SDK config (no network / on-chain / backend call): tokens whose vault is a
|
|
14085
14122
|
* money-market-reserve sodaAsset settle faster, and an Ethereum leg adds a fixed penalty. See
|
|
14086
14123
|
* {@link estimateSwapSpeedTier} for the rules.
|
|
14087
14124
|
*
|
|
@@ -18229,7 +18266,7 @@ declare class RecoveryService {
|
|
|
18229
18266
|
*/
|
|
18230
18267
|
|
|
18231
18268
|
declare const leverageYieldInvariant: FeatureInvariant;
|
|
18232
|
-
type LeverageYieldAction = 'deposit' | 'withdraw' | 'approve' | 'allowanceCheck' | 'vaultSwap';
|
|
18269
|
+
type LeverageYieldAction = 'deposit' | 'withdraw' | 'approve' | 'allowanceCheck' | 'vaultSwap' | 'openPosition' | 'openPositionFromDebtToken' | 'operatePosition' | 'openLeveragePosition' | 'submitLeveragePositionIntent' | 'runLeveragePositionOperation' | 'getPositionLegQuote';
|
|
18233
18270
|
type LeverageYieldCreateIntentErrorCode = CreateIntentErrorCode;
|
|
18234
18271
|
type LeverageYieldApproveErrorCode = ApproveErrorCode;
|
|
18235
18272
|
type LeverageYieldAllowanceCheckErrorCode = AllowanceCheckErrorCode;
|
|
@@ -18261,6 +18298,188 @@ declare const isLeverageYieldPostExecutionError: (e: unknown) => e is SodaxError
|
|
|
18261
18298
|
declare const isLeverageYieldSwapError: (e: unknown) => e is SodaxError<LeverageYieldSwapErrorCode>;
|
|
18262
18299
|
declare const isLeverageYieldError: (e: unknown) => e is SodaxError<LeverageYieldErrorCode>;
|
|
18263
18300
|
|
|
18301
|
+
/**
|
|
18302
|
+
* Quoting one leg of a position operation, and reading the solver's refusal correctly.
|
|
18303
|
+
*
|
|
18304
|
+
* WHAT THE LEG IS. A position's intent swaps HUB RESERVES — sodaETH for sodaS — so that is what has
|
|
18305
|
+
* to be quoted. Mapping each side back to its spoke original first asks about a different pair: on
|
|
18306
|
+
* the hub `sodaS` is its own hub asset while `S` is not, and it is the reserves the fill moves.
|
|
18307
|
+
*
|
|
18308
|
+
* WHY NOT A PARTNER FEE. A position's intent is a hook intent carrying no fee data — the position's
|
|
18309
|
+
* own fee is charged on-chain from `PositionConfig.feeBps`, which `projectLeverageLeg` accounts for
|
|
18310
|
+
* separately. Quoting net of a configured fee would size the floor for a deduction the solver never
|
|
18311
|
+
* makes, and count the fee twice.
|
|
18312
|
+
*/
|
|
18313
|
+
/** What the solver expects to deliver for the leg, in output-token units. */
|
|
18314
|
+
type PositionLegQuote = {
|
|
18315
|
+
quotedAmount: bigint;
|
|
18316
|
+
};
|
|
18317
|
+
/**
|
|
18318
|
+
* Whether a refusal was a ROUTING one, which is also what the solver answers for a leg that is
|
|
18319
|
+
* merely too SMALL.
|
|
18320
|
+
*
|
|
18321
|
+
* Read off the wording, not `detail.code`: the solver answers this with `-1`, which is not a member
|
|
18322
|
+
* of `SolverIntentErrorCode` at all — `NO_PATH_FOUND` is `-4` and does not come back. Measured on
|
|
18323
|
+
* sodaS/sodaETH, the same pair refused at 1.7756 units and quoted at 1.7778.
|
|
18324
|
+
*
|
|
18325
|
+
* It does NOT say which of the two it is. To tell them apart, quote the same pair again at a healthy
|
|
18326
|
+
* notional and treat "routes there, refused here" as too small — and only when the failed amount was
|
|
18327
|
+
* BELOW the probe, since the window closes at the top as well ($1 through $10,000 quote on that pair,
|
|
18328
|
+
* $100,000 does not) and a leg that is too large must not be told to grow. The probe size is priced,
|
|
18329
|
+
* so it is the caller's to choose: this module takes prices from the caller by design.
|
|
18330
|
+
*/
|
|
18331
|
+
declare function isNoRouteRefusal(error: unknown): boolean;
|
|
18332
|
+
|
|
18333
|
+
/**
|
|
18334
|
+
* The result of a position write that posts a solver intent, and the reporting step it depends on.
|
|
18335
|
+
*
|
|
18336
|
+
* Kept beside the service rather than inside it because the shape is a public contract: every caller
|
|
18337
|
+
* — React or not — has to be able to tell "the transaction landed" from "the solver knows about it",
|
|
18338
|
+
* and those are not the same event.
|
|
18339
|
+
*/
|
|
18340
|
+
|
|
18341
|
+
/**
|
|
18342
|
+
* What a position write that POSTS AN INTENT returns.
|
|
18343
|
+
*
|
|
18344
|
+
* `notified` is separate from success on purpose. An intent lives on the hub the moment the call
|
|
18345
|
+
* lands, but the solver only learns of it when its hub-side hash is reported — and an unreported one
|
|
18346
|
+
* expires unfilled, leaving the owner funded with leverage that never arrives.
|
|
18347
|
+
*
|
|
18348
|
+
* SO A FAILED NOTIFICATION IS `ok: true`, NOT `ok: false`. The money has already moved and the intent
|
|
18349
|
+
* is live; returning a failure would tell the caller nothing happened, and a caller that retries on
|
|
18350
|
+
* failure would open a second position. Report it, do not raise it.
|
|
18351
|
+
*/
|
|
18352
|
+
type LeveragePositionIntentResult = {
|
|
18353
|
+
/**
|
|
18354
|
+
* Both hashes, and they are not interchangeable: `srcChainTxHash` is what the user signed,
|
|
18355
|
+
* `dstChainTxHash` is the hub transaction the intent actually exists in.
|
|
18356
|
+
*/
|
|
18357
|
+
txHashes: TxHashPair;
|
|
18358
|
+
/** False means the intent is live but nothing will fill it before it expires. */
|
|
18359
|
+
notified: boolean;
|
|
18360
|
+
/** Why the notification failed, when it did. */
|
|
18361
|
+
notifyError?: string;
|
|
18362
|
+
};
|
|
18363
|
+
/** The notify half, narrowed so it can be exercised without constructing a whole service. */
|
|
18364
|
+
type PositionIntentNotifier = (request: SolverExecutionRequest) => Promise<Result<SolverExecutionResponse, LeverageYieldPostExecutionError>>;
|
|
18365
|
+
/**
|
|
18366
|
+
* Reports a position intent to the solver and says whether that landed.
|
|
18367
|
+
*
|
|
18368
|
+
* WHICH HASH: `dstChainTxHash`. On the hub that is the transaction the user signed, but from a spoke
|
|
18369
|
+
* the intent is created by the relayed message, so the signed hash is not where it lives.
|
|
18370
|
+
*/
|
|
18371
|
+
declare function reportPositionIntent(notifySolver: PositionIntentNotifier, txHashes: TxHashPair): Promise<LeveragePositionIntentResult>;
|
|
18372
|
+
|
|
18373
|
+
/** Mirrors `LeveragePosition.MAX_FEE_BPS`. Unlike a vault quote's bound, this one is permanent. */
|
|
18374
|
+
declare const MAX_POSITION_FEE_BPS = 100;
|
|
18375
|
+
/**
|
|
18376
|
+
* Where a position's funds came from, and so where a failed intent refunds to.
|
|
18377
|
+
*
|
|
18378
|
+
* Given as a chain KEY rather than a number: the on-chain field is a SODAX relay chain id (Arbitrum
|
|
18379
|
+
* is 23, not 42161), and `getIntentRelayChainId` is the map for that. Asking callers for the raw
|
|
18380
|
+
* number invites passing an EVM id, which would route a refund nowhere.
|
|
18381
|
+
*/
|
|
18382
|
+
type PositionOrigin = {
|
|
18383
|
+
/** Chain the user funded from and is refunded on. */
|
|
18384
|
+
chainKey: SpokeChainKey;
|
|
18385
|
+
/** The user's address on `chainKey`. */
|
|
18386
|
+
address: string;
|
|
18387
|
+
/**
|
|
18388
|
+
* Hub asset a cross-chain refund unwraps the reserve into. Required off-hub, since the
|
|
18389
|
+
* AssetManager moves only its own registered assets and never vault tokens, and ignored on the
|
|
18390
|
+
* hub, where a refund is a plain transfer.
|
|
18391
|
+
*/
|
|
18392
|
+
asset?: Address;
|
|
18393
|
+
};
|
|
18394
|
+
/**
|
|
18395
|
+
* Funding a position from whichever chain the user actually holds tokens on.
|
|
18396
|
+
*
|
|
18397
|
+
* Positions live on the hub, but nothing requires the user to. The deposit is relayed to their hub
|
|
18398
|
+
* wallet and the position is opened from inside that relayed batch, so the whole thing is one
|
|
18399
|
+
* signature on the source chain — and the hub is just another source chain here, not a special case.
|
|
18400
|
+
*
|
|
18401
|
+
* `token` is a token on `srcChainKey`, in that token's own decimals. Its hub reserve is what the
|
|
18402
|
+
* position uses: the collateral for {@link LeverageYieldService.openPosition}, the borrow token for
|
|
18403
|
+
* {@link LeverageYieldService.openPositionFromDebtToken}. Wrapping into that reserve is part of the
|
|
18404
|
+
* relayed batch, so callers pass the amount they hold, not a vault-share amount.
|
|
18405
|
+
*/
|
|
18406
|
+
type PositionFundingParams<K extends SpokeChainKey> = {
|
|
18407
|
+
srcChainKey: K;
|
|
18408
|
+
/** The user's address on `srcChainKey`. Funds come from here and a failed intent refunds to here. */
|
|
18409
|
+
srcAddress: string;
|
|
18410
|
+
/** Token on `srcChainKey` to fund with. */
|
|
18411
|
+
token: string;
|
|
18412
|
+
/** Amount of `token`, in its own decimals. */
|
|
18413
|
+
amount: bigint;
|
|
18414
|
+
/** AAVE eMode category, fixed for the life of the position. Defaults to 0 (none). */
|
|
18415
|
+
eModeCategory?: number;
|
|
18416
|
+
/** Slippage floor on the collateral the solver must deliver, in the collateral reserve's units. */
|
|
18417
|
+
minCollateralOut: bigint;
|
|
18418
|
+
/**
|
|
18419
|
+
* Partner fee to bake into the position, percentage variant only. Defaults to the configured
|
|
18420
|
+
* `leverageYield.partnerFee`. FIXED AT CREATION on-chain and charged on every later operation, so
|
|
18421
|
+
* it must also be fed to {@link projectLeverageLeg} as `feeBps` — the fee is borrowed on top of
|
|
18422
|
+
* what the solver is paid, so a projection that ignores it understates LTV.
|
|
18423
|
+
*/
|
|
18424
|
+
partnerFee?: PartnerFee;
|
|
18425
|
+
};
|
|
18426
|
+
/** Opening from the collateral side: deposit collateral, borrow against it, swap into more collateral. */
|
|
18427
|
+
type OpenPositionParams<K extends SpokeChainKey> = PositionFundingParams<K> & {
|
|
18428
|
+
/** Hub reserve to borrow. */
|
|
18429
|
+
borrowToken: Address;
|
|
18430
|
+
/** Amount to borrow, in `borrowToken`'s units (hub reserves are 18-decimal). */
|
|
18431
|
+
borrowAmount: bigint;
|
|
18432
|
+
};
|
|
18433
|
+
/**
|
|
18434
|
+
* Opening from the debt side: the deposit IS the debt token, and the position ends up long
|
|
18435
|
+
* `collateral` without the user ever having held it.
|
|
18436
|
+
*/
|
|
18437
|
+
type OpenPositionFromDebtTokenParams<K extends SpokeChainKey> = PositionFundingParams<K> & {
|
|
18438
|
+
/** Hub reserve the position ends up long. */
|
|
18439
|
+
collateral: Address;
|
|
18440
|
+
/** Total debt token paid to the solver. The hook borrows this minus the deposit's contribution. */
|
|
18441
|
+
totalInput: bigint;
|
|
18442
|
+
};
|
|
18443
|
+
/**
|
|
18444
|
+
* Operating an existing position from any chain. No funds move, so this is a bare message rather
|
|
18445
|
+
* than a deposit — the calls execute as the user's hub wallet, which is what the position's
|
|
18446
|
+
* `onlyOwner` requires.
|
|
18447
|
+
*/
|
|
18448
|
+
declare const positionIntentCall: unique symbol;
|
|
18449
|
+
declare const positionDirectCall: unique symbol;
|
|
18450
|
+
/**
|
|
18451
|
+
* A position call that POSTS a solver intent, so it must be reported or it expires unfilled.
|
|
18452
|
+
*
|
|
18453
|
+
* The brand is type-only and erased at runtime; it exists so the compiler refuses the one mistake
|
|
18454
|
+
* that costs money — routing a leverage change through the path that does not report it.
|
|
18455
|
+
*/
|
|
18456
|
+
type PositionIntentCall = EvmRawTransaction & {
|
|
18457
|
+
readonly [positionIntentCall]: true;
|
|
18458
|
+
};
|
|
18459
|
+
/** A position call that completes on the hub, with nothing to report. Same brand mechanics. */
|
|
18460
|
+
type PositionDirectCall = EvmRawTransaction & {
|
|
18461
|
+
readonly [positionDirectCall]: true;
|
|
18462
|
+
};
|
|
18463
|
+
/**
|
|
18464
|
+
* What may ride along in a batch that posts an intent.
|
|
18465
|
+
*
|
|
18466
|
+
* The brand guards ONE direction. An intent call on the route-only path is never reported and expires
|
|
18467
|
+
* unfilled — that has to be refused. A direct call on the reporting path is noise, not damage, and
|
|
18468
|
+
* refusing it would take the settle-then-act batch with it: `[buildSettlePosition, buildAddLeverage]`
|
|
18469
|
+
* is exactly a direct call riding along, and it is the sequence the batch exists for.
|
|
18470
|
+
*/
|
|
18471
|
+
type PositionBatchCall = PositionIntentCall | PositionDirectCall;
|
|
18472
|
+
type PositionOperationParams<K extends SpokeChainKey, C extends EvmRawTransaction = EvmRawTransaction> = {
|
|
18473
|
+
srcChainKey: K;
|
|
18474
|
+
/** The user's address on `srcChainKey`; its hub wallet is what executes the calls. */
|
|
18475
|
+
srcAddress: string;
|
|
18476
|
+
/**
|
|
18477
|
+
* Calls to run as the hub wallet, from the position builders
|
|
18478
|
+
* ({@link LeverageYieldService.buildAddLeverage} and friends). More than one is allowed and they
|
|
18479
|
+
* execute in order, which is how a settle-then-act sequence stays atomic.
|
|
18480
|
+
*/
|
|
18481
|
+
calls: readonly C[];
|
|
18482
|
+
};
|
|
18264
18483
|
/**
|
|
18265
18484
|
* Leveraged-position snapshot from the vault's non-standard `getPositionDetails()`.
|
|
18266
18485
|
* Field scales (mirroring the AAVE conventions the vault inherits):
|
|
@@ -18693,7 +18912,12 @@ declare class LeverageYieldService {
|
|
|
18693
18912
|
*/
|
|
18694
18913
|
private submitTx;
|
|
18695
18914
|
/**
|
|
18696
|
-
* Notifies the solver that
|
|
18915
|
+
* Notifies the solver that an intent landed on the hub, triggering it to fill.
|
|
18916
|
+
*
|
|
18917
|
+
* REQUIRED for anything that creates an intent, not an optimisation. An intent created on the hub
|
|
18918
|
+
* is invisible to the solver until this call puts it in the task pool, so an unnotified intent
|
|
18919
|
+
* simply expires. Leverage positions post their intents on-chain from the position contract, so
|
|
18920
|
+
* the caller that sent the transaction is the only one who can report the hash.
|
|
18697
18921
|
* Leverage-yield copy of the swap domain's `postExecution` — emits only
|
|
18698
18922
|
* `EXECUTION_FAILED` / `EXTERNAL_API_ERROR` / `UNKNOWN` (relay/verify codes appear only
|
|
18699
18923
|
* on {@link LeverageYieldService.vaultSwap}, which owns the verify + relay steps).
|
|
@@ -18708,6 +18932,20 @@ declare class LeverageYieldService {
|
|
|
18708
18932
|
* intents).
|
|
18709
18933
|
*/
|
|
18710
18934
|
notifySolver(request: SolverExecutionRequest): Promise<Result<SolverExecutionResponse, LeverageYieldPostExecutionError>>;
|
|
18935
|
+
/**
|
|
18936
|
+
* Polls the solver for the execution status of an intent this service created.
|
|
18937
|
+
*
|
|
18938
|
+
* Pair with {@link LeverageYieldService.notifySolver}: `notifySolver` puts the intent in the
|
|
18939
|
+
* solver's task pool, this reports what became of it. `fill_tx_hash` is set only once
|
|
18940
|
+
* `status === SolverIntentStatusCode.SOLVED`.
|
|
18941
|
+
*
|
|
18942
|
+
* A `NOT_FOUND` status usually means the notification never landed rather than that the intent
|
|
18943
|
+
* does not exist — an intent created on the hub is invisible to the solver until it is told.
|
|
18944
|
+
*
|
|
18945
|
+
* @param request - `{ intent_tx_hash }` — the hub-chain (Sonic) tx hash the intent was
|
|
18946
|
+
* registered in. For a position that is the tx that called the factory or the position.
|
|
18947
|
+
*/
|
|
18948
|
+
getIntentStatus(request: SolverIntentStatusRequest): Promise<Result<SolverIntentStatusResponse, LeverageYieldPostExecutionError>>;
|
|
18711
18949
|
/**
|
|
18712
18950
|
* Approves the vault's underlying asset to the leverage vault on Sonic. For callers
|
|
18713
18951
|
* interacting with the vault directly on the hub — the swap-style {@link
|
|
@@ -18781,6 +19019,540 @@ declare class LeverageYieldService {
|
|
|
18781
19019
|
* returns its on-chain share balance.
|
|
18782
19020
|
*/
|
|
18783
19021
|
getShareBalanceForUser<K extends SpokeChainKey>(vault: Address, srcChainKey: K, srcAddress: string): Promise<Result<bigint, LeverageYieldLookupError>>;
|
|
19022
|
+
/**
|
|
19023
|
+
* Resolves the `LeveragePositionFactory` address, or a validation error when it is missing.
|
|
19024
|
+
*
|
|
19025
|
+
* The deployed factory ships in `leverageYieldConfig`, so this only fails when an integrator
|
|
19026
|
+
* overrides it with an empty value — which is what a bad env var produces. Failing closed there is
|
|
19027
|
+
* deliberate: a placeholder address would post real intents at nothing.
|
|
19028
|
+
*/
|
|
19029
|
+
private requireFactory;
|
|
19030
|
+
/** Position clones owned by `owner`, in creation order. Empty when the owner has none. */
|
|
19031
|
+
listPositions(owner: Address): Promise<Result<readonly Address[], LeverageYieldLookupError>>;
|
|
19032
|
+
/**
|
|
19033
|
+
* Positions belonging to a user, resolved by their spoke-side address rather than a hub address.
|
|
19034
|
+
*
|
|
19035
|
+
* Positions are owned by the user's hub wallet, so discovery goes through
|
|
19036
|
+
* `getUserHubWalletAddress` — which returns the wallet router for a Sonic user and the
|
|
19037
|
+
* cross-chain wallet for a spoke user, so the same call works on every chain. Prefer this over
|
|
19038
|
+
* `listPositions` in user-facing code; passing a raw EOA finds nothing.
|
|
19039
|
+
*/
|
|
19040
|
+
listPositionsForUser<K extends SpokeChainKey>(srcChainKey: K, srcAddress: string): Promise<Result<readonly Address[], LeverageYieldLookupError>>;
|
|
19041
|
+
/** Static descriptor of a position — owner, both legs, and the fixed eMode category. */
|
|
19042
|
+
getPositionInfo(position: Address): Promise<Result<LeveragePosition, LeverageYieldLookupError>>;
|
|
19043
|
+
/**
|
|
19044
|
+
* Live AAVE account snapshot for a position. Read from the pool, not the position: the
|
|
19045
|
+
* position contract keeps no accounting of its own, so collateral, debt and health factor
|
|
19046
|
+
* all come from `getUserAccountData`.
|
|
19047
|
+
*
|
|
19048
|
+
* The pool comes from `moneyMarket.lendingPool` config rather than the position's own
|
|
19049
|
+
* `pool()` getter — same address, one fewer round trip, and it keeps the deployment address
|
|
19050
|
+
* sourced from config like the rest of the SDK.
|
|
19051
|
+
*/
|
|
19052
|
+
getPositionAccount(position: Address): Promise<Result<LeveragePositionAccount, LeverageYieldLookupError>>;
|
|
19053
|
+
/**
|
|
19054
|
+
* The position's collateral holding, as an exact aToken balance.
|
|
19055
|
+
*
|
|
19056
|
+
* Needed to size a full exit. {@link LeverageYieldService.getPositionAccount} reports collateral
|
|
19057
|
+
* in the oracle's base currency at 8 decimals, which is fine to display but cannot name an amount:
|
|
19058
|
+
* dividing it back out by a price lands near the balance, and a `decreaseLeverage` asking for more
|
|
19059
|
+
* collateral than the position holds does not fail on submission — the hook's `transferFrom`
|
|
19060
|
+
* reverts at fill time, so the intent silently expires instead.
|
|
19061
|
+
*
|
|
19062
|
+
* Safe to act on a slightly stale read: aToken balances only grow, since interest accrues into
|
|
19063
|
+
* them, so a value from a few blocks ago is always still spendable. Selling it leaves interest
|
|
19064
|
+
* dust behind rather than coming up short.
|
|
19065
|
+
*
|
|
19066
|
+
* @param collateral The position's collateral reserve. Read from the position when omitted; pass
|
|
19067
|
+
* it if you already hold a {@link LeveragePosition} to save the round trip.
|
|
19068
|
+
*/
|
|
19069
|
+
getPositionCollateralBalance(position: Address, collateral?: Address): Promise<Result<LeveragePositionCollateral, LeverageYieldLookupError>>;
|
|
19070
|
+
/**
|
|
19071
|
+
* The position's operation slot: which operation it recorded, and whether that intent is still
|
|
19072
|
+
* live on `Intents`.
|
|
19073
|
+
*
|
|
19074
|
+
* Both are needed, because the interesting state is when they disagree. `isLive` false with a
|
|
19075
|
+
* non-zero `kind` means the intent resolved — filled, expired, or cancelled by someone else — but
|
|
19076
|
+
* the position has not been told, so its grant is still open and any debt-side contribution is
|
|
19077
|
+
* still sitting there. That is what `needsSettle` flags, and `buildSettlePosition` clears. A live
|
|
19078
|
+
* intent instead blocks any second operation until it resolves.
|
|
19079
|
+
*/
|
|
19080
|
+
getPositionPendingState(position: Address): Promise<Result<LeveragePositionPendingState, LeverageYieldLookupError>>;
|
|
19081
|
+
/** Deterministic clone address for the next position a given creator opens for `owner`. */
|
|
19082
|
+
predictPosition(creator: Address, owner: Address, positionId?: bigint): Promise<Result<Address, LeverageYieldLookupError>>;
|
|
19083
|
+
/**
|
|
19084
|
+
* Opens a new position and requests leverage on it in the same transaction — the standard way
|
|
19085
|
+
* to open a leveraged position: one approve, then this.
|
|
19086
|
+
*
|
|
19087
|
+
* `initialAssets` of `collateral` is pulled from the signer, so the factory needs an allowance
|
|
19088
|
+
* first. Control is assigned to `owner`, which may differ from the signer — pass a user's hub
|
|
19089
|
+
* wallet address to have the existing cross-chain path drive the position.
|
|
19090
|
+
*
|
|
19091
|
+
* The leverage is still asynchronous: this posts the intent and a solver fills it afterwards,
|
|
19092
|
+
* so on confirmation the position is funded with the request outstanding, not yet levered. If
|
|
19093
|
+
* no solver fills it, `buildCancelPositionOperation` returns the deposit to the owner.
|
|
19094
|
+
*/
|
|
19095
|
+
/**
|
|
19096
|
+
* Turns a {@link PositionOrigin} into the tuple the factory takes, and refuses the combinations the
|
|
19097
|
+
* contract would refuse anyway — better a rejected build than a transaction that reverts.
|
|
19098
|
+
*/
|
|
19099
|
+
private resolveOrigin;
|
|
19100
|
+
/**
|
|
19101
|
+
* Partner fee for a position, in the shape `PositionConfig` takes.
|
|
19102
|
+
*
|
|
19103
|
+
* Only the PERCENTAGE variant of `PartnerFee` maps: the contract stores basis points and derives
|
|
19104
|
+
* the amount per operation (`_feeFor`), so a fixed-amount fee has nowhere to go and is rejected
|
|
19105
|
+
* rather than silently dropped. Same precedence as the vault flows — per-call, then
|
|
19106
|
+
* `leverageYield.partnerFee`, then none.
|
|
19107
|
+
*
|
|
19108
|
+
* The fee is FIXED AT CREATION on-chain, so this is read when a position is created and never
|
|
19109
|
+
* again; changing the config later does not re-price positions already open.
|
|
19110
|
+
*/
|
|
19111
|
+
/**
|
|
19112
|
+
* The fee a position created NOW would carry, in basis points, plus who receives it.
|
|
19113
|
+
*
|
|
19114
|
+
* Public because a caller cannot project a position correctly without it and cannot derive it:
|
|
19115
|
+
* the fee resolves from `leverageYield.partnerFee`, then the global fee, then none, and it is
|
|
19116
|
+
* FIXED AT CREATION on-chain. Feed `feeBps` to {@link projectLeverageLeg} — the hooks require
|
|
19117
|
+
* `inputAmount + fee`, so a leverage-up borrows the fee ON TOP of what the solver is paid. Leaving
|
|
19118
|
+
* it out understates LTV and overstates the ceiling, which is the Aave `'36'` failure at fill time
|
|
19119
|
+
* this module exists to prevent: 50 bp takes a debt-side ceiling from 9.88x to about 9.44x.
|
|
19120
|
+
*
|
|
19121
|
+
* Pass the same `override` here as to the open call, or omit it on both.
|
|
19122
|
+
*/
|
|
19123
|
+
getEffectivePositionFee(override?: PartnerFee): Result<{
|
|
19124
|
+
feeReceiver: Address;
|
|
19125
|
+
feeBps: number;
|
|
19126
|
+
}, LeverageYieldLookupError>;
|
|
19127
|
+
private resolvePositionFee;
|
|
19128
|
+
/** A hub transaction. Every builder below produces this shape and none of them sends value. */
|
|
19129
|
+
private hubTx;
|
|
19130
|
+
/**
|
|
19131
|
+
* The `PositionConfig` struct both factory entry points take, assembled from a resolved origin.
|
|
19132
|
+
*
|
|
19133
|
+
* Shared so the two create paths cannot drift: which side the funded reserve goes on is their only
|
|
19134
|
+
* real difference, and a field silently spelled differently in one of them would be a
|
|
19135
|
+
* mis-recorded refund destination rather than a compile error.
|
|
19136
|
+
*/
|
|
19137
|
+
private positionConfig;
|
|
19138
|
+
buildCreatePositionAndLeverage(params: {
|
|
19139
|
+
from: Address;
|
|
19140
|
+
owner: Address;
|
|
19141
|
+
collateral: Address;
|
|
19142
|
+
borrowToken: Address;
|
|
19143
|
+
eModeCategory: number;
|
|
19144
|
+
origin: PositionOrigin;
|
|
19145
|
+
partnerFee?: PartnerFee;
|
|
19146
|
+
initialAssets: bigint;
|
|
19147
|
+
borrowAmount: bigint;
|
|
19148
|
+
minCollateralOut: bigint;
|
|
19149
|
+
}): Result<EvmRawTransaction, LeverageYieldLookupError>;
|
|
19150
|
+
/**
|
|
19151
|
+
* Opens a levered position starting from the **debt** token, with no collateral of your own.
|
|
19152
|
+
*
|
|
19153
|
+
* Pulls `contribution` of `borrowToken` from the signer — not the collateral. On fill the hook
|
|
19154
|
+
* supplies the solver's collateral, adds the contribution, borrows `totalInput - contribution`,
|
|
19155
|
+
* and pays the solver the total, so a holder of the debt asset lands in a levered collateral
|
|
19156
|
+
* position having never owned collateral. Requires the deployment's implementation to have a
|
|
19157
|
+
* debt-side hook configured; otherwise the position reverts with `DebtSideHookUnavailable`.
|
|
19158
|
+
*/
|
|
19159
|
+
buildCreatePositionFromDebtToken(params: {
|
|
19160
|
+
from: Address;
|
|
19161
|
+
owner: Address;
|
|
19162
|
+
collateral: Address;
|
|
19163
|
+
borrowToken: Address;
|
|
19164
|
+
eModeCategory: number;
|
|
19165
|
+
origin: PositionOrigin;
|
|
19166
|
+
partnerFee?: PartnerFee;
|
|
19167
|
+
contribution: bigint;
|
|
19168
|
+
totalInput: bigint;
|
|
19169
|
+
minCollateralOut: bigint;
|
|
19170
|
+
}): Result<EvmRawTransaction, LeverageYieldLookupError>;
|
|
19171
|
+
/** Borrows `borrowAmount` and swaps it into more collateral. `minCollateralOut` is the slippage floor. */
|
|
19172
|
+
buildAddLeverage(params: {
|
|
19173
|
+
from: Address;
|
|
19174
|
+
position: Address;
|
|
19175
|
+
borrowAmount: bigint;
|
|
19176
|
+
minCollateralOut: bigint;
|
|
19177
|
+
}): PositionIntentCall;
|
|
19178
|
+
/**
|
|
19179
|
+
* Gives up `collateralIn` of collateral to repay debt. `minDebtOut` is the slippage floor.
|
|
19180
|
+
*
|
|
19181
|
+
* CLOSING INTO THE DEBT TOKEN is this call with the position's collateral balance, less the fee a
|
|
19182
|
+
* non-zero `feeBps` gives up on top of the input (`balance x 10_000 / (10_000 + feeBps)`) — there is
|
|
19183
|
+
* no separate close entry point, because selling everything is the same operation as selling part.
|
|
19184
|
+
* Size it with {@link LeverageYieldService.getPositionCollateralBalance}, never off
|
|
19185
|
+
* `totalCollateralBase`, and quote the full amount so `minDebtOut` reflects what the solver will
|
|
19186
|
+
* actually pay for all of it.
|
|
19187
|
+
*
|
|
19188
|
+
* What that leaves behind is worth knowing. The solver delivers more debt token than is owed, so
|
|
19189
|
+
* the hook repays the debt and hands the surplus to the position, which is the owner's equity now
|
|
19190
|
+
* denominated in the debt asset. It sits in the position until someone calls
|
|
19191
|
+
* {@link LeverageYieldService.buildSettlePosition} — that sweep is what actually delivers it, and
|
|
19192
|
+
* it goes to the position's `owner` (the hub wallet), not to whoever signed. Exiting into the
|
|
19193
|
+
* *collateral* instead means repaying only the debt and then calling
|
|
19194
|
+
* {@link LeverageYieldService.buildPositionWithdraw}, which can pay out to any address.
|
|
19195
|
+
*/
|
|
19196
|
+
buildDecreaseLeverage(params: {
|
|
19197
|
+
from: Address;
|
|
19198
|
+
position: Address;
|
|
19199
|
+
collateralIn: bigint;
|
|
19200
|
+
minDebtOut: bigint;
|
|
19201
|
+
/**
|
|
19202
|
+
* Underlying a surplus is delivered in, straight to the owner's own address on their origin chain.
|
|
19203
|
+
* Only a full close produces a surplus, so this is ignored on a partial deleverage. Omit — or pass
|
|
19204
|
+
* the zero address — to leave any surplus in the position for `buildSettlePosition` to sweep, which
|
|
19205
|
+
* hands over the reserve rather than the token.
|
|
19206
|
+
*/
|
|
19207
|
+
exitAsset?: Address;
|
|
19208
|
+
}): PositionIntentCall;
|
|
19209
|
+
/**
|
|
19210
|
+
* Withdraws collateral out of the position. The pool rejects a withdrawal that would drop
|
|
19211
|
+
* the position below its liquidation threshold, so no client-side health check is applied
|
|
19212
|
+
* here — but note that bound is health factor 1, not a safety buffer above it.
|
|
19213
|
+
*/
|
|
19214
|
+
buildPositionWithdraw(params: {
|
|
19215
|
+
from: Address;
|
|
19216
|
+
position: Address;
|
|
19217
|
+
amount: bigint;
|
|
19218
|
+
to: Address;
|
|
19219
|
+
}): PositionDirectCall;
|
|
19220
|
+
/**
|
|
19221
|
+
* Clears an operation that has already resolved and returns anything the position is holding
|
|
19222
|
+
* loose to its owner.
|
|
19223
|
+
*
|
|
19224
|
+
* PERMISSIONLESS, and deliberately so: it only ever tightens state, so a stranded balance can be
|
|
19225
|
+
* pushed back by anyone rather than waiting on the owner to notice. That matters because an intent
|
|
19226
|
+
* can be cancelled by a third party once past its deadline, which leaves the position resolved but
|
|
19227
|
+
* un-swept if the hook's notification did not land.
|
|
19228
|
+
*
|
|
19229
|
+
* Reverts while the intent is still live — use {@link LeverageYieldService.buildCancelPositionOperation}
|
|
19230
|
+
* to end one that has not resolved yet.
|
|
19231
|
+
*/
|
|
19232
|
+
buildSettlePosition(params: {
|
|
19233
|
+
from: Address;
|
|
19234
|
+
position: Address;
|
|
19235
|
+
}): PositionDirectCall;
|
|
19236
|
+
/**
|
|
19237
|
+
* Cancels the in-flight operation and returns the deposit.
|
|
19238
|
+
*
|
|
19239
|
+
* Nothing is escrowed when an intent is posted, so cancelling recovers nothing by itself — but
|
|
19240
|
+
* a position carrying no debt withdraws its whole collateral balance back to the owner, which
|
|
19241
|
+
* is what a leveraged open whose intent never filled needs. With debt outstanding the
|
|
19242
|
+
* collateral stays put: the pool would reject the withdrawal on its health-factor check.
|
|
19243
|
+
*/
|
|
19244
|
+
buildCancelPositionOperation(params: {
|
|
19245
|
+
from: Address;
|
|
19246
|
+
position: Address;
|
|
19247
|
+
}): PositionDirectCall;
|
|
19248
|
+
/**
|
|
19249
|
+
* Encodes position calls as a hub-wallet payload.
|
|
19250
|
+
*
|
|
19251
|
+
* Takes the raw transactions from the builders above and produces the `(address,uint256,bytes)[]`
|
|
19252
|
+
* payload the hub wallet executes. Public because that payload is the unit the transport takes:
|
|
19253
|
+
* pass it to `spoke.deposit` / `spoke.sendMessage` yourself when you want manual relay control,
|
|
19254
|
+
* or use {@link LeverageYieldService.openPosition} / {@link LeverageYieldService.operatePosition},
|
|
19255
|
+
* which do it for you.
|
|
19256
|
+
*/
|
|
19257
|
+
encodePositionCalls(txs: readonly EvmRawTransaction[]): Hex;
|
|
19258
|
+
/**
|
|
19259
|
+
* Resolves the hub reserve a spoke token funds, and the hub asset it arrives as.
|
|
19260
|
+
*
|
|
19261
|
+
* Three addresses per token and they are not interchangeable: `hubAsset` is what lands in the hub
|
|
19262
|
+
* wallet, `vault` is the 18-decimal money-market reserve a position actually uses, and the spoke
|
|
19263
|
+
* `address` is neither. Getting this wrong is silent — the wrong one is still a valid ERC-20.
|
|
19264
|
+
*/
|
|
19265
|
+
private resolveFunding;
|
|
19266
|
+
/**
|
|
19267
|
+
* What a refund should pay back: the asset the user actually funded with, or `undefined` when that IS
|
|
19268
|
+
* the reserve and there is nothing to unwrap.
|
|
19269
|
+
*
|
|
19270
|
+
* A named asset makes `IntentRefund` unwrap before paying, on the hub as well as off it — so someone
|
|
19271
|
+
* who deposited USSD is refunded USSD rather than `sodaUSSD`.
|
|
19272
|
+
*/
|
|
19273
|
+
private refundAsset;
|
|
19274
|
+
/**
|
|
19275
|
+
* Encodes the wrap of an arriving deposit into its money-market reserve, and returns the reserve
|
|
19276
|
+
* amount that produces.
|
|
19277
|
+
*
|
|
19278
|
+
* A hub asset that is already a soda vault token IS the reserve, so nothing is wrapped. Otherwise
|
|
19279
|
+
* the vault mints 18-decimal shares one-for-one with the asset, which is what
|
|
19280
|
+
* `translateIncomingDecimals` computes — the same conversion the asset manager applies to a spoke
|
|
19281
|
+
* deposit, rather than a second implementation of it. A reserve carrying a non-zero deposit fee
|
|
19282
|
+
* would mint fewer shares than this predicts and the factory's pull would revert; both reserves in
|
|
19283
|
+
* use today are fee-free.
|
|
19284
|
+
*/
|
|
19285
|
+
private encodeWrapIntoReserve;
|
|
19286
|
+
/**
|
|
19287
|
+
* Everything both opens do before they diverge: resolve the factory, the funding token's hub asset
|
|
19288
|
+
* and reserve, and the origin to refund to; predict the address the position will be created at;
|
|
19289
|
+
* and encode the wrap plus the transfer that funds it.
|
|
19290
|
+
*
|
|
19291
|
+
* Only the factory call itself differs between the collateral side and the debt side — which side
|
|
19292
|
+
* the funded reserve lands on, and the two amounts — so everything up to that point lives here
|
|
19293
|
+
* once. `calls` is returned ready to be appended to.
|
|
19294
|
+
*/
|
|
19295
|
+
private prepareOpen;
|
|
19296
|
+
/**
|
|
19297
|
+
* Hub-side payload for opening a position from the collateral side.
|
|
19298
|
+
*
|
|
19299
|
+
* Wrap the arriving deposit into its reserve, TRANSFER it to the address the position will be
|
|
19300
|
+
* created at, create the position and post its leverage intent — one batch, executed by the user's
|
|
19301
|
+
* hub wallet. The position's collateral is the reserve behind `params.token`; `borrowToken` is
|
|
19302
|
+
* borrowed against it.
|
|
19303
|
+
*
|
|
19304
|
+
* Nothing is ever approved to the factory: it holds no allowance and pulls from nobody, so funding
|
|
19305
|
+
* is a transfer to `predictPosition(creator, owner, nextPositionIdFor(owner))` and the clone supplies
|
|
19306
|
+
* whatever it finds. The id is per-owner, so an unrelated user creating a position cannot move the
|
|
19307
|
+
* address out from under this batch — and because the transfer and the create are in the same batch,
|
|
19308
|
+
* a stale prediction reverts both rather than stranding the tokens.
|
|
19309
|
+
*
|
|
19310
|
+
* The owner's OWN concurrent opens are the one thing that can still advance the id between building
|
|
19311
|
+
* this payload and executing it. On the hub that reverts atomically and nothing is lost; funded from
|
|
19312
|
+
* a spoke the deposit has already landed in the user's hub wallet when the batch reverts, and is
|
|
19313
|
+
* recovered with `sodax.recovery` (see RECOVERY.md). Do not open two positions for one owner at once.
|
|
19314
|
+
*
|
|
19315
|
+
* The origin recorded on the position is `srcChainKey` / `srcAddress` / the deposited hub asset,
|
|
19316
|
+
* so a leverage intent that never fills refunds to the user on the chain they funded from — not to
|
|
19317
|
+
* the position, and not to the hub wallet.
|
|
19318
|
+
*/
|
|
19319
|
+
buildOpenPositionData(params: OpenPositionParams<SpokeChainKey> & {
|
|
19320
|
+
owner: Address;
|
|
19321
|
+
}): Promise<Result<Hex, LeverageYieldLookupError>>;
|
|
19322
|
+
/**
|
|
19323
|
+
* Hub-side payload for opening a position from the debt side.
|
|
19324
|
+
*
|
|
19325
|
+
* The mirror of {@link LeverageYieldService.buildOpenPositionData}: here the deposit is the
|
|
19326
|
+
* position's *debt* token, contributed rather than supplied, and `collateral` is the reserve the
|
|
19327
|
+
* position ends up long. The hook supplies the solver's collateral on fill and borrows only the
|
|
19328
|
+
* shortfall, so the position legitimately starts with no collateral of its own.
|
|
19329
|
+
*/
|
|
19330
|
+
buildOpenPositionFromDebtTokenData(params: OpenPositionFromDebtTokenParams<SpokeChainKey> & {
|
|
19331
|
+
owner: Address;
|
|
19332
|
+
}): Promise<Result<Hex, LeverageYieldLookupError>>;
|
|
19333
|
+
/**
|
|
19334
|
+
* Whether the funding token is already approved for an open from `srcChainKey`.
|
|
19335
|
+
*
|
|
19336
|
+
* The spender differs by chain and neither choice is guessable: on the hub the deposit is pulled
|
|
19337
|
+
* by the user's own hub wallet, executing inside the routed batch; on an EVM spoke it is pulled by
|
|
19338
|
+
* that spoke's asset manager. Chains with no allowance concept report `true`, and Stellar reports
|
|
19339
|
+
* whether the trustline covers the amount.
|
|
19340
|
+
*/
|
|
19341
|
+
isPositionFundingAllowanceValid<K extends SpokeChainKey>(params: {
|
|
19342
|
+
srcChainKey: K;
|
|
19343
|
+
srcAddress: string;
|
|
19344
|
+
token: string;
|
|
19345
|
+
amount: bigint;
|
|
19346
|
+
}): Promise<Result<boolean, LeverageYieldAllowanceCheckError>>;
|
|
19347
|
+
/**
|
|
19348
|
+
* Approves the funding token for an open, against the spender that chain's deposit actually uses —
|
|
19349
|
+
* see {@link LeverageYieldService.isPositionFundingAllowanceValid} for which that is.
|
|
19350
|
+
*
|
|
19351
|
+
* WAITS FOR THE APPROVAL TO LAND before returning. `Erc20Service.approve` resolves with the hash the
|
|
19352
|
+
* moment it is broadcast, so a caller that immediately re-reads the allowance sees the value from
|
|
19353
|
+
* BEFORE the approval — a UI then keeps showing "approve" and the user signs a second, pointless
|
|
19354
|
+
* approval. Returning early from a helper whose whole purpose is "the allowance is now sufficient" is
|
|
19355
|
+
* a footgun, so the wait lives here rather than in each caller.
|
|
19356
|
+
*/
|
|
19357
|
+
approvePositionFunding<K extends SpokeChainKey>(params: {
|
|
19358
|
+
srcChainKey: K;
|
|
19359
|
+
srcAddress: string;
|
|
19360
|
+
token: string;
|
|
19361
|
+
amount: bigint;
|
|
19362
|
+
walletProvider?: GetWalletProviderType<K>;
|
|
19363
|
+
}): Promise<Result<TxReturnType<K, false>, LeverageYieldApproveError>>;
|
|
19364
|
+
/**
|
|
19365
|
+
* Who pulls the deposit on an EVM source chain.
|
|
19366
|
+
*
|
|
19367
|
+
* On the hub the pull happens inside the routed batch, so the spender is the user's own hub wallet
|
|
19368
|
+
* rather than any protocol contract; on an EVM spoke it is that spoke's asset manager. Chains with
|
|
19369
|
+
* no ERC-20 allowance never reach here.
|
|
19370
|
+
*/
|
|
19371
|
+
private resolveFundingSpender;
|
|
19372
|
+
/**
|
|
19373
|
+
* Opens a leveraged position, funded from any chain, in one signature.
|
|
19374
|
+
*
|
|
19375
|
+
* The deposit is carried to the user's hub wallet and the position is created from inside that
|
|
19376
|
+
* same batch, so there is no window in which the funds sit on the hub unattached to a position.
|
|
19377
|
+
* On the hub this routes locally; from a spoke it relays and this waits for the hub side to land.
|
|
19378
|
+
*
|
|
19379
|
+
* WHAT IS AND IS NOT DONE WHEN THIS RESOLVES: the position exists and its leverage intent is
|
|
19380
|
+
* posted. The leverage itself is not applied — a solver fills that intent afterwards. And an
|
|
19381
|
+
* intent is invisible to the solver until its hub transaction hash is reported, so pass the
|
|
19382
|
+
* returned `dstChainTxHash` to {@link LeverageYieldService.notifySolver}; an unreported intent
|
|
19383
|
+
* simply expires and the deposit comes back.
|
|
19384
|
+
*
|
|
19385
|
+
* Spoke tokens need the spoke asset manager approved first, the same as any other deposit.
|
|
19386
|
+
*
|
|
19387
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN. Every path here has been exercised
|
|
19388
|
+
* end to end on Sonic, the hub. From a spoke the inbound half is proven only by a fork
|
|
19389
|
+
* replay of a real relayed message, and the OUTBOUND half — an exit or a cancellation
|
|
19390
|
+
* delivering the underlying back to the spoke it came from — has never run on mainnet.
|
|
19391
|
+
* Treat a non-hub `srcChainKey` as experimental until it has. Bitcoin is refused
|
|
19392
|
+
* outright — see {@link BITCOIN_UNSUPPORTED_MESSAGE}.
|
|
19393
|
+
*/
|
|
19394
|
+
openPosition<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, OpenPositionParams<K>>): Promise<Result<TxHashPair, LeverageYieldSwapError | LeverageYieldLookupError>>;
|
|
19395
|
+
/**
|
|
19396
|
+
* Opens a leveraged position from the **debt** token, funded from any chain.
|
|
19397
|
+
*
|
|
19398
|
+
* Same transport and the same asynchronous settlement as
|
|
19399
|
+
* {@link LeverageYieldService.openPosition} — see there for what is and is not done when this
|
|
19400
|
+
* resolves. The difference is only which side the user funds: here they hand over debt token and
|
|
19401
|
+
* end up long collateral they never held.
|
|
19402
|
+
*
|
|
19403
|
+
* Requires the deployed implementation to have a debt-side hook configured; without one the
|
|
19404
|
+
* position reverts `DebtSideHookUnavailable`.
|
|
19405
|
+
*
|
|
19406
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN. Every path here has been exercised
|
|
19407
|
+
* end to end on Sonic, the hub. From a spoke the inbound half is proven only by a fork
|
|
19408
|
+
* replay of a real relayed message, and the OUTBOUND half — an exit or a cancellation
|
|
19409
|
+
* delivering the underlying back to the spoke it came from — has never run on mainnet.
|
|
19410
|
+
* Treat a non-hub `srcChainKey` as experimental until it has. Bitcoin is refused
|
|
19411
|
+
* outright — see {@link BITCOIN_UNSUPPORTED_MESSAGE}.
|
|
19412
|
+
*/
|
|
19413
|
+
openPositionFromDebtToken<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, OpenPositionFromDebtTokenParams<K>>): Promise<Result<TxHashPair, LeverageYieldSwapError | LeverageYieldLookupError>>;
|
|
19414
|
+
/**
|
|
19415
|
+
* Shared body of the two open paths. They differ only in which factory call the payload ends with,
|
|
19416
|
+
* so everything around it — owner resolution, deposit, verify, relay — lives here rather than
|
|
19417
|
+
* being written twice and drifting.
|
|
19418
|
+
*/
|
|
19419
|
+
/**
|
|
19420
|
+
* Instrumentation for both opens. Wrapping the shared runner rather than each entry point keeps
|
|
19421
|
+
* `openPosition` and `openPositionFromDebtToken` from drifting, and `action` is already threaded
|
|
19422
|
+
* through for the error context, so it doubles as the analytics action.
|
|
19423
|
+
*
|
|
19424
|
+
* `start` carries only the fields common to both param shapes — the funding side's token and
|
|
19425
|
+
* amount. The side-specific ones (`borrowToken`/`borrowAmount` vs `collateral`/`totalInput`) are
|
|
19426
|
+
* not on `PositionFundingParams`, and inventing a cast to reach them would be worse than omitting
|
|
19427
|
+
* them.
|
|
19428
|
+
*/
|
|
19429
|
+
private runPositionOpen;
|
|
19430
|
+
private executePositionOpen;
|
|
19431
|
+
/**
|
|
19432
|
+
* Which address actually funds a position from `chainKey` — what a balance must be read against,
|
|
19433
|
+
* and what the deposit is built from.
|
|
19434
|
+
*
|
|
19435
|
+
* ONE ANSWER FOR BOTH, because two answers cost an open on mainnet: the balance was read from the
|
|
19436
|
+
* registry `address` while the deposit rewrote it to `hubAsset`, so for Sonic's native S the form
|
|
19437
|
+
* showed 42 S and the batch then called `wS.transferFrom(user, hubWallet, 5e18)` against a wS
|
|
19438
|
+
* balance of zero. The approval was correct; the revert surfaced as nothing but "External call
|
|
19439
|
+
* failed". Any integrator reading a balance for a position deposit needs this same answer.
|
|
19440
|
+
*
|
|
19441
|
+
* Three addresses hang off a registry entry and they are not interchangeable:
|
|
19442
|
+
*
|
|
19443
|
+
* `address` the spoke-side original; for a bridged entry it can name another chain entirely
|
|
19444
|
+
* `hubAsset` what the user holds ON THE HUB, and the vault's deposit input
|
|
19445
|
+
* `vault` the hub money-market reserve the position ends up in
|
|
19446
|
+
*
|
|
19447
|
+
* Off the hub the answer is always `address` — that is the chain the user is on. On the hub it is
|
|
19448
|
+
* `hubAsset`, EXCEPT for a native entry: `EvmSpokeService.deposit` keys on the chain's own
|
|
19449
|
+
* `nativeToken` to send `msg.value` rather than an ERC-20 `transferFrom`, and the native entry
|
|
19450
|
+
* carries exactly that sentinel as its `address`. Rewriting that to the wrapper asks for a token
|
|
19451
|
+
* the wallet does not hold.
|
|
19452
|
+
*
|
|
19453
|
+
* @returns The funding address, or `undefined` when the token is not supported on `chainKey`.
|
|
19454
|
+
*/
|
|
19455
|
+
resolvePositionFunding(chainKey: SpokeChainKey, token: XToken): Address | undefined;
|
|
19456
|
+
/**
|
|
19457
|
+
* Quotes one leg of a position operation: the borrowed side when levering up, the collateral when
|
|
19458
|
+
* levering down or exiting.
|
|
19459
|
+
*
|
|
19460
|
+
* Use this rather than {@link LeverageYieldService.getQuote} for a position. Both hit the same
|
|
19461
|
+
* endpoint, but this one names the hub reserves as the pair the intent actually swaps and quotes
|
|
19462
|
+
* GROSS — see `positionLegQuote.ts` for why either alone gets the floor wrong. Feed `quotedAmount`
|
|
19463
|
+
* to {@link projectLeverageLeg}.
|
|
19464
|
+
*
|
|
19465
|
+
* A refusal is not always a dead pair: {@link isNoRouteRefusal} is also what the solver answers
|
|
19466
|
+
* for a leg that is only too small, and telling the two apart means quoting again at a healthy
|
|
19467
|
+
* notional. That size is priced, so it is the caller's to choose.
|
|
19468
|
+
*/
|
|
19469
|
+
getPositionLegQuote(params: {
|
|
19470
|
+
/** Hub reserve given up. */
|
|
19471
|
+
inputHubToken: Address;
|
|
19472
|
+
/** Hub reserve expected back. */
|
|
19473
|
+
outputHubToken: Address;
|
|
19474
|
+
/** Input amount in `inputHubToken`'s units. */
|
|
19475
|
+
amount: bigint;
|
|
19476
|
+
}): Promise<Result<PositionLegQuote, SolverErrorResponse | LeverageYieldLookupError>>;
|
|
19477
|
+
/**
|
|
19478
|
+
* Opens a leveraged position AND reports the intent it posts. Prefer this to
|
|
19479
|
+
* {@link LeverageYieldService.openPosition} / {@link LeverageYieldService.openPositionFromDebtToken}.
|
|
19480
|
+
*
|
|
19481
|
+
* Those two only post the intent. Reporting it is a separate call that must not be skipped — an
|
|
19482
|
+
* unreported intent expires unfilled, so the owner is left funded with leverage that never arrives
|
|
19483
|
+
* and nothing said so. Pairing them here is the difference between an API that works and one that
|
|
19484
|
+
* works only if you read the docs.
|
|
19485
|
+
*
|
|
19486
|
+
* `side` picks which asset funds the open: `'collateral'` supplies the deposit and borrows against
|
|
19487
|
+
* it, `'debt'` hands the deposit to the solver and ends up long collateral never held.
|
|
19488
|
+
*
|
|
19489
|
+
* RESOLVING MEANS THE INTENT IS LIVE, not that the position is open, and a failed notification is
|
|
19490
|
+
* still `ok: true` — see {@link LeveragePositionIntentResult}.
|
|
19491
|
+
*
|
|
19492
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN — see `operatePosition`.
|
|
19493
|
+
*/
|
|
19494
|
+
openLeveragePosition<K extends SpokeChainKey>(_params: ({
|
|
19495
|
+
side?: 'collateral';
|
|
19496
|
+
} & SpokeExecActionParams<K, false, OpenPositionParams<K>>) | ({
|
|
19497
|
+
side: 'debt';
|
|
19498
|
+
} & SpokeExecActionParams<K, false, OpenPositionFromDebtTokenParams<K>>)): Promise<Result<LeveragePositionIntentResult, LeverageYieldSwapError | LeverageYieldLookupError>>;
|
|
19499
|
+
/**
|
|
19500
|
+
* Runs position calls that POST A SOLVER INTENT — `addLeverage` and `decreaseLeverage` — and
|
|
19501
|
+
* reports it. Prefer this to {@link LeverageYieldService.operatePosition} for those two.
|
|
19502
|
+
*
|
|
19503
|
+
* USE {@link LeverageYieldService.runLeveragePositionOperation} FOR `withdraw`, `settle` AND
|
|
19504
|
+
* `cancel`. Those are synchronous on the hub and need no notification, and the split is not
|
|
19505
|
+
* cosmetic: sending a leverage change through the route-only path leaves an intent nothing will
|
|
19506
|
+
* fill, and it expires without a word. The other direction is merely noisy.
|
|
19507
|
+
*
|
|
19508
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN — see `operatePosition`.
|
|
19509
|
+
*/
|
|
19510
|
+
submitLeveragePositionIntent<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, PositionOperationParams<K, PositionBatchCall>>): Promise<Result<LeveragePositionIntentResult, LeverageYieldSwapError>>;
|
|
19511
|
+
/**
|
|
19512
|
+
* Runs position calls that do NOT post an intent — `withdraw`, `settle` and `cancel` — as the
|
|
19513
|
+
* owning hub wallet. They are synchronous on the hub, so resolving means the work is done.
|
|
19514
|
+
*
|
|
19515
|
+
* Still routed, never sent directly: the position's `onlyOwner` is the hub wallet, so a builder's
|
|
19516
|
+
* transaction sent from the signer reverts `NotOwner`. Use
|
|
19517
|
+
* {@link LeverageYieldService.submitLeveragePositionIntent} for `addLeverage` and
|
|
19518
|
+
* `decreaseLeverage`, which this deliberately does not report.
|
|
19519
|
+
*
|
|
19520
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN, and this path carries the worst of
|
|
19521
|
+
* it: an exit or cancellation delivering the underlying back to the spoke it came from
|
|
19522
|
+
* has never run on mainnet.
|
|
19523
|
+
*/
|
|
19524
|
+
runLeveragePositionOperation<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, PositionOperationParams<K, PositionDirectCall>>): Promise<Result<TxHashPair, LeverageYieldSwapError>>;
|
|
19525
|
+
/** Bound once so the notify half can be handed around without losing `this`. */
|
|
19526
|
+
private readonly notifyIntent;
|
|
19527
|
+
/**
|
|
19528
|
+
* Runs position calls as the user's hub wallet, from any chain.
|
|
19529
|
+
*
|
|
19530
|
+
* The write counterpart to the read hooks: add or decrease leverage, withdraw, settle, cancel. No
|
|
19531
|
+
* funds move, so this is a bare message rather than a deposit — on the hub it routes locally, from
|
|
19532
|
+
* a spoke it relays and this waits for the hub side to land.
|
|
19533
|
+
*
|
|
19534
|
+
* The leverage calls only *post* an intent, so a resolved promise means the intent is live, not
|
|
19535
|
+
* that leverage moved. Report the returned `dstChainTxHash` to
|
|
19536
|
+
* {@link LeverageYieldService.notifySolver} for those two; `withdraw`, `settle` and `cancel` are
|
|
19537
|
+
* synchronous on the hub and need no notification.
|
|
19538
|
+
*
|
|
19539
|
+
* @experimental OFF-HUB (SPOKE) ORIGINS ARE UNVERIFIED ON-CHAIN. Every path here has been exercised
|
|
19540
|
+
* end to end on Sonic, the hub. From a spoke the inbound half is proven only by a fork
|
|
19541
|
+
* replay of a real relayed message, and the OUTBOUND half — an exit or a cancellation
|
|
19542
|
+
* delivering the underlying back to the spoke it came from — has never run on mainnet.
|
|
19543
|
+
* Treat a non-hub `srcChainKey` as experimental until it has. Bitcoin is refused
|
|
19544
|
+
* outright — see {@link BITCOIN_UNSUPPORTED_MESSAGE}.
|
|
19545
|
+
*/
|
|
19546
|
+
operatePosition<K extends SpokeChainKey>(_params: SpokeExecActionParams<K, false, PositionOperationParams<K>>): Promise<Result<TxHashPair, LeverageYieldSwapError>>;
|
|
19547
|
+
private executePositionOperation;
|
|
19548
|
+
/**
|
|
19549
|
+
* Verifies a submitted source transaction and, off the hub, relays it and waits for the hub side.
|
|
19550
|
+
*
|
|
19551
|
+
* Shared by both write paths because the tail is identical whether funds moved or not. The hub
|
|
19552
|
+
* short-circuit is not an optimisation: a hub transaction has already executed the calls, so there
|
|
19553
|
+
* is nothing to relay, and both hashes are the same transaction.
|
|
19554
|
+
*/
|
|
19555
|
+
private settleHubWalletMessage;
|
|
18784
19556
|
}
|
|
18785
19557
|
|
|
18786
19558
|
declare const sponsoringInvariant: FeatureInvariant;
|
|
@@ -19663,4 +20435,237 @@ type DexApproveErrorCode = ApproveErrorCode;
|
|
|
19663
20435
|
type DexApproveError = SodaxError<DexApproveErrorCode>;
|
|
19664
20436
|
declare const isDexApproveError: (e: unknown) => e is SodaxError<ApproveErrorCode>;
|
|
19665
20437
|
|
|
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 };
|
|
20438
|
+
/**
|
|
20439
|
+
* Sizing a leverage position's swap leg.
|
|
20440
|
+
*
|
|
20441
|
+
* WHY THIS EXISTS AND WHY IT IS NOT OPTIONAL. A position's leverage is bought through the solver, and
|
|
20442
|
+
* the two legs do not trade at their oracle ratio. `LeverageHook` supplies whatever the solver
|
|
20443
|
+
* actually paid and only *then* borrows against it, so the pool's health check at fill time sees
|
|
20444
|
+
* `deposit + solver output`, never `deposit x leverage`. Size the leg from oracle prices and the
|
|
20445
|
+
* borrow reverts with Aave error `'36'` (COLLATERAL_CANNOT_COVER_NEW_BORROW) — the intent is accepted,
|
|
20446
|
+
* the solver fills, and the whole fill unwinds. That is not a hypothetical, it happened twice on
|
|
20447
|
+
* mainnet, and the two failures had different causes worth keeping apart:
|
|
20448
|
+
*
|
|
20449
|
+
* - counting a debt-side deposit as collateral as well as handing it to the solver, which put an
|
|
20450
|
+
* 11.03x open at a projected 84% LTV;
|
|
20451
|
+
* - pricing the solver's output at oracle parity, which put the same open at 90.9% when the real
|
|
20452
|
+
* figure was 92.06% against a 91% cap.
|
|
20453
|
+
*
|
|
20454
|
+
* `side` addresses the first and `f` the second.
|
|
20455
|
+
*
|
|
20456
|
+
* So sizing is a two-phase thing, and both phases are here:
|
|
20457
|
+
*
|
|
20458
|
+
* 1. {@link sizeLeverageBorrow} — how much to borrow for a target leverage. Oracle-priced, because
|
|
20459
|
+
* there is nothing else to go on yet. Quote THIS amount.
|
|
20460
|
+
* 2. {@link projectLeverageLeg} — given that quote, the slippage floor, what the position really
|
|
20461
|
+
* looks like at that floor, and the highest leverage the quote actually supports.
|
|
20462
|
+
*
|
|
20463
|
+
* Everything in phase 2 is projected from the FLOOR rather than the quote, deliberately: the floor is
|
|
20464
|
+
* the worst fill the intent permits, so if the floor is safe every fill is. Projecting from the quote
|
|
20465
|
+
* leaves the slippage tolerance as unmodelled headroom, which is exactly the gap that failed.
|
|
20466
|
+
*
|
|
20467
|
+
* Prices are the pool oracle's, in its base currency; any consistent unit works since only ratios
|
|
20468
|
+
* matter. Rates and LTVs are fractions, not percentages.
|
|
20469
|
+
*/
|
|
20470
|
+
/** Which asset the user is funding with. */
|
|
20471
|
+
type PositionSide = 'collateral' | 'debt';
|
|
20472
|
+
type LeverageLegRequest = {
|
|
20473
|
+
/**
|
|
20474
|
+
* `'collateral'` funds with the collateral asset, which is supplied. `'debt'` funds with the debt
|
|
20475
|
+
* asset, which is NOT supplied — it is handed to the solver as part of the intent's input, so the
|
|
20476
|
+
* only collateral the position ends up with is what the solver delivers. Counting the deposit on
|
|
20477
|
+
* both sides is what produced the 84%-vs-92.06% miss.
|
|
20478
|
+
*/
|
|
20479
|
+
side: PositionSide;
|
|
20480
|
+
/** Deposit in its own token decimals — the collateral token or the debt token, per `side`. */
|
|
20481
|
+
deposit: bigint;
|
|
20482
|
+
depositDecimals: number;
|
|
20483
|
+
collateralPriceUsd: number;
|
|
20484
|
+
borrowPriceUsd: number;
|
|
20485
|
+
borrowDecimals: number;
|
|
20486
|
+
/**
|
|
20487
|
+
* Target leverage as a multiple of the DEPOSIT, not of equity. 1 borrows nothing.
|
|
20488
|
+
*
|
|
20489
|
+
* The pool books the borrow in full while the collateral arrives short by the haircut, so equity
|
|
20490
|
+
* ends up under the deposit and the open position reports MORE than this — always more, never
|
|
20491
|
+
* less. See {@link LeverageLegProjection.exposureLeverage}.
|
|
20492
|
+
*/
|
|
20493
|
+
leverage: number;
|
|
20494
|
+
/**
|
|
20495
|
+
* Partner fee in basis points, as configured on the position (`PositionConfig.feeBps`). Omit or 0
|
|
20496
|
+
* when the position charges none.
|
|
20497
|
+
*
|
|
20498
|
+
* IT IS NOT A CUT OF THE OUTPUT. The hooks require `inputAmount + fee` and `Intents` pays the
|
|
20499
|
+
* receiver on the fill, so on a leverage-up the position borrows the fee ON TOP of what the solver
|
|
20500
|
+
* is paid — extra debt against unchanged collateral — and on an exit it gives up extra collateral.
|
|
20501
|
+
* Leaving it out of the projection therefore understates LTV and overstates the ceiling, which is
|
|
20502
|
+
* the Aave `'36'` failure mode this module exists to prevent.
|
|
20503
|
+
*/
|
|
20504
|
+
feeBps?: number;
|
|
20505
|
+
};
|
|
20506
|
+
type LeverageBorrowSizing = {
|
|
20507
|
+
/** Borrow-token amount the position should borrow. */
|
|
20508
|
+
borrowAmount: bigint;
|
|
20509
|
+
/**
|
|
20510
|
+
* What the solver receives as the intent's input: the borrowed amount, plus the user's own
|
|
20511
|
+
* contribution on a debt-side open, since the debt-side hook is paid both. Quote this.
|
|
20512
|
+
*/
|
|
20513
|
+
intentInput: bigint;
|
|
20514
|
+
/** The deposit's value, priced with the token actually deposited. */
|
|
20515
|
+
depositUsd: number;
|
|
20516
|
+
/** Value being borrowed, EXCLUDING the partner fee. This is what the solver is paid. */
|
|
20517
|
+
borrowUsd: number;
|
|
20518
|
+
/** Partner fee on this leg, in the borrow token's own units. Zero when none is configured. */
|
|
20519
|
+
feeAmount: bigint;
|
|
20520
|
+
/** Total the position ends up owing: `borrowUsd` plus the fee's value. */
|
|
20521
|
+
debtUsd: number;
|
|
20522
|
+
};
|
|
20523
|
+
/**
|
|
20524
|
+
* Phase 1: the borrow for a target leverage, and the input to quote.
|
|
20525
|
+
*
|
|
20526
|
+
* ORACLE SIZING ONLY. It deliberately does not project the result, because at this point it cannot —
|
|
20527
|
+
* the collateral that lands is whatever the solver pays. Feed `intentInput` to a solver quote and
|
|
20528
|
+
* pass the result to {@link projectLeverageLeg}.
|
|
20529
|
+
*/
|
|
20530
|
+
declare function sizeLeverageBorrow(request: LeverageLegRequest): LeverageBorrowSizing;
|
|
20531
|
+
type LeverageLegQuote = {
|
|
20532
|
+
/** What the solver quoted for `intentInput`, in the collateral reserve's decimals. */
|
|
20533
|
+
quotedCollateral: bigint;
|
|
20534
|
+
collateralDecimals: number;
|
|
20535
|
+
};
|
|
20536
|
+
type ReserveRiskParams = {
|
|
20537
|
+
/** Reserve (or eMode) max LTV as a fraction. The Aave `'36'` boundary. */
|
|
20538
|
+
ltv: number;
|
|
20539
|
+
/** Liquidation threshold as a fraction. */
|
|
20540
|
+
liquidationThreshold: number;
|
|
20541
|
+
};
|
|
20542
|
+
type LeverageLegProjection = {
|
|
20543
|
+
/** Slippage floor to post as the intent's `minCollateralOut`. Never zero. */
|
|
20544
|
+
minCollateralOut: bigint;
|
|
20545
|
+
/** Collateral the position holds after the fill, at the floor. */
|
|
20546
|
+
collateralUsd: number;
|
|
20547
|
+
debtUsd: number;
|
|
20548
|
+
ltv: number;
|
|
20549
|
+
/** Aave health factor at the floor; `Infinity` with no debt. */
|
|
20550
|
+
healthFactor: number;
|
|
20551
|
+
/**
|
|
20552
|
+
* Whether the pool would reject the borrow outright. This is the Aave `'36'` check, and the one
|
|
20553
|
+
* thing a caller must not post through: the intent is accepted and fails at fill.
|
|
20554
|
+
*/
|
|
20555
|
+
exceedsMaxLtv: boolean;
|
|
20556
|
+
/**
|
|
20557
|
+
* Fraction of the input's oracle value the solver keeps, measured from the QUOTE rather than the
|
|
20558
|
+
* floor — the expected cost of the leg, not the worst permitted one. Negative when the quote beats
|
|
20559
|
+
* parity, which a correlated pair can do.
|
|
20560
|
+
*/
|
|
20561
|
+
haircut: number;
|
|
20562
|
+
/** Oracle value handed to the solver: the borrow, plus the contribution on a debt-side open. */
|
|
20563
|
+
inputUsd: number;
|
|
20564
|
+
/**
|
|
20565
|
+
* What the leg costs once, in the same units as the prices: the solver's cut PLUS the partner fee.
|
|
20566
|
+
* Paid up front and in full, unlike the yield it buys, so it is what a payback period is measured
|
|
20567
|
+
* against. Can be negative when the quote beats parity and no fee is charged.
|
|
20568
|
+
*
|
|
20569
|
+
* The fee belongs here even though it is borrowed rather than deducted — the owner owes it without
|
|
20570
|
+
* receiving anything for it, so a breakeven that left it out would promise too short a payback.
|
|
20571
|
+
*/
|
|
20572
|
+
costUsd: number;
|
|
20573
|
+
/**
|
|
20574
|
+
* Collateral over equity — what the open position reports, and what `request.leverage` is not.
|
|
20575
|
+
* The two differ by the haircut, this one always larger: 2.00x requested at a 4.657% haircut
|
|
20576
|
+
* reports 2.0488x. At the floor like the rest of phase 2, so it is an upper bound.
|
|
20577
|
+
*/
|
|
20578
|
+
exposureLeverage: number;
|
|
20579
|
+
/**
|
|
20580
|
+
* The most leverage this price actually supports, from `debt <= ltv x collateral` with `f` as the
|
|
20581
|
+
* USD of collateral the floor returns per USD handed to the solver:
|
|
20582
|
+
*
|
|
20583
|
+
* debt side: L <= 1 / (1 - ltv x f) — the deposit buys collateral, none is supplied
|
|
20584
|
+
* collateral side: L <= 1 + ltv / (1 - ltv x f) — the deposit is also collateral
|
|
20585
|
+
*
|
|
20586
|
+
* At `f = 1` the second collapses to the familiar `1 / (1 - ltv)`. Below 1 it is strictly lower,
|
|
20587
|
+
* which is the whole point: `ltv` 91% with `f` 0.9877 gives 9.88x, and the 11.03x that looked fine
|
|
20588
|
+
* against oracle parity was never available. Above `f = 1 / ltv` there is no ceiling at all and
|
|
20589
|
+
* this is `Infinity` — a favourable enough fill adds borrowing power faster than debt.
|
|
20590
|
+
*/
|
|
20591
|
+
usableMaxLeverage: number;
|
|
20592
|
+
};
|
|
20593
|
+
/**
|
|
20594
|
+
* Phase 2: the floor to post, the position that results from it, and the leverage ceiling this quote
|
|
20595
|
+
* actually supports.
|
|
20596
|
+
*
|
|
20597
|
+
* `slippagePct` is a percentage (1 means 1%) and comes off what the solver QUOTED, not off the input
|
|
20598
|
+
* amount — sizing the floor as `deposit x leverage x (1 - slippage)` assumes 1:1 token parity and put
|
|
20599
|
+
* earlier attempts above what the solver would pay, which made them unfillable.
|
|
20600
|
+
*/
|
|
20601
|
+
declare function projectLeverageLeg(request: LeverageLegRequest, quote: LeverageLegQuote, risk: ReserveRiskParams, slippagePct: number): LeverageLegProjection;
|
|
20602
|
+
|
|
20603
|
+
/**
|
|
20604
|
+
* Whether a leveraged position is worth opening at all, and how long it must be held to pay for
|
|
20605
|
+
* itself.
|
|
20606
|
+
*
|
|
20607
|
+
* The sibling of `positionSizing.ts`, and here for the same reason: `sizeLeverageBorrow` answers how
|
|
20608
|
+
* to open a position, this answers whether to. Both are pure, and a partner integrating without the
|
|
20609
|
+
* reference UI needs both — getting this one wrong does not revert, it just quietly sells a position
|
|
20610
|
+
* that never earns its entry cost back.
|
|
20611
|
+
*
|
|
20612
|
+
* Rates are percentages throughout, amounts are USD, and durations are years.
|
|
20613
|
+
*/
|
|
20614
|
+
/** Net APY on equity at `leverage`, all rates as percentages. */
|
|
20615
|
+
declare function leveragedNetApyPct(supplyApyPct: number, borrowApyPct: number, leverage: number): number;
|
|
20616
|
+
/** What the swap costs relative to oracle parity, and the yield that has to earn it back. */
|
|
20617
|
+
type BreakevenInput = {
|
|
20618
|
+
/** One-time cost of the leg: what the solver is handed, less what it pays back, in USD. */
|
|
20619
|
+
costUsd: number;
|
|
20620
|
+
/**
|
|
20621
|
+
* Equity the incremental yield accrues on, in USD — `collateral - debt` AFTER the fill, not the
|
|
20622
|
+
* deposit. They differ by the solver's spread, and the deposit is the larger, so passing it makes
|
|
20623
|
+
* every payback look shorter than it is.
|
|
20624
|
+
*/
|
|
20625
|
+
equityUsd: number;
|
|
20626
|
+
/** Leverage being moved FROM — 1 for a fresh open, since the alternative is just holding. */
|
|
20627
|
+
fromLeverage: number;
|
|
20628
|
+
};
|
|
20629
|
+
/**
|
|
20630
|
+
* Years until the extra yield from levering up repays what the swap cost, or a reason it never does.
|
|
20631
|
+
*
|
|
20632
|
+
* Levering is a trade: the solver's cut is paid ONCE, up front and in full, while the benefit arrives
|
|
20633
|
+
* as a rate. So the question a target leverage actually poses is how long the position must be held
|
|
20634
|
+
* for the second to cover the first:
|
|
20635
|
+
*
|
|
20636
|
+
* costUsd = equityUsd x (net(to) - net(from)) x years
|
|
20637
|
+
*
|
|
20638
|
+
* and `net(to) - net(from)` reduces to `(supply - borrow) x (to - from)` — the incremental term, NOT
|
|
20639
|
+
* the headline net APY. Using the headline number would flatter every case: an already-levered
|
|
20640
|
+
* position earns most of that rate whether or not you adjust it, so charging the entry cost against
|
|
20641
|
+
* the whole thing understates the payback period.
|
|
20642
|
+
*
|
|
20643
|
+
* Two regimes return no number rather than a misleading one. When supply does not exceed borrow the
|
|
20644
|
+
* incremental rate is zero or negative and no holding period repays the cost — levering up is simply
|
|
20645
|
+
* a worse position, which is the same fact the zero-crossing row reports. And a non-positive cost
|
|
20646
|
+
* means the quote beat parity, so there is nothing to earn back.
|
|
20647
|
+
*
|
|
20648
|
+
* COUNTS THE ENTRY ONLY. Unwinding sells collateral back through the solver and pays a comparable
|
|
20649
|
+
* spread a second time, so a full round trip needs roughly double this to come out even. Treat the
|
|
20650
|
+
* number as the floor on how long the position has to be worth holding, not the whole bill.
|
|
20651
|
+
*/
|
|
20652
|
+
declare function timeToBreakevenYears(supplyApyPct: number, borrowApyPct: number, toLeverage: number, { costUsd, equityUsd, fromLeverage }: BreakevenInput): number | 'never' | 'immediate' | undefined;
|
|
20653
|
+
|
|
20654
|
+
/**
|
|
20655
|
+
* Which of a registry entry's three addresses funds a position deposit.
|
|
20656
|
+
*
|
|
20657
|
+
* Pure, and separate from the service so it can be checked against the whole token registry without
|
|
20658
|
+
* constructing one — see `positionFunding.test.ts`, which asserts the answer for every supported
|
|
20659
|
+
* token on every chain. The bug this exists to prevent was two code paths disagreeing, and a
|
|
20660
|
+
* disagreement is exactly what an exhaustive check catches.
|
|
20661
|
+
*/
|
|
20662
|
+
|
|
20663
|
+
/**
|
|
20664
|
+
* @param chainKey The chain the user funds from.
|
|
20665
|
+
* @param hubChainKey The hub's own chain key, from `hubProvider.chainConfig.chain.key`.
|
|
20666
|
+
* @param token The registry entry being funded with.
|
|
20667
|
+
* @returns The funding address, or `''` when the entry carries none.
|
|
20668
|
+
*/
|
|
20669
|
+
declare function resolvePositionFundingAddress(chainKey: SpokeChainKey, hubChainKey: SpokeChainKey, token: XToken | undefined): string;
|
|
20670
|
+
|
|
20671
|
+
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 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 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 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, 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 };
|