@gearbox-protocol/sdk 16.0.0-next.30 → 16.0.0-next.31

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.
@@ -30,7 +30,7 @@ function toCreditAccountSlice(ca) {
30
30
  * Reads an account by address and narrows it to {@link CreditAccountSlice}.
31
31
  *
32
32
  * The shared read model's `StrategyPosition` carries neither `tokens` nor
33
- * `enabledTokensMask` / `creditFacade` / `totalDebtUSD`, so simulating against
33
+ * `enabledTokensMask` / `creditFacade` / `totalDebtUSD`, so preparing against
34
34
  * an existing position costs one account read.
35
35
  *
36
36
  * @throws When the account is not found in the connected markets.
@@ -124,7 +124,7 @@ function collectQuotaChange(assetsBefore, assetsAfter) {
124
124
  }
125
125
  /**
126
126
  * SDK `getSingleQuotaChange` requires `assetAfter` to emit quota decreases.
127
- * Simulation drops zero balances, so fully spent collaterals (e.g. claim
127
+ * The ledger drops zero balances, so fully spent collaterals (e.g. claim
128
128
  * phantom) vanish — reinsert them with balance 0 when they still have
129
129
  * initial quota so `calcQuotaUpdate` can zero / remove that quota.
130
130
  */
@@ -12,7 +12,7 @@ var ExecuteApi = class {
12
12
  * {@inheritDoc IOpportunitiesExecute.buildTx}
13
13
  **/
14
14
  async buildTx(request) {
15
- if (!request.sim.ok) throw new Error(`cannot build a transaction from a failed ${request.kind} simulation`);
15
+ if (!request.sim.ok) throw new Error(`cannot build a transaction from a failed ${request.kind} preparation`);
16
16
  const sdk = this.#chainOf(request.chainId);
17
17
  switch (request.kind) {
18
18
  case "pool": return poolTx(sdk, request);
@@ -86,10 +86,10 @@ async function accountTx(sdk, request) {
86
86
  return sdk.accounts.executeCaUpdate(account, request.sim.calls, { ethAmount: nativeValue(request.sim.operations) });
87
87
  }
88
88
  /**
89
- * The coin the simulation asked the wallet for, which the facade wraps out of
89
+ * The coin the preparation asked the wallet for, which the facade wraps out of
90
90
  * `msg.value` before running the multicall. Taken off the collateral step that
91
91
  * recorded it rather than from the caller, so it cannot disagree with what was
92
- * simulated.
92
+ * prepared.
93
93
  **/
94
94
  function nativeValue(operations) {
95
95
  return operations.reduce((total, op) => total + (op.type === "addCollateral" ? op.value ?? 0n : 0n), 0n);
@@ -16,7 +16,7 @@ const require_sdk_prepare_withdrawable_collaterals = require("./withdrawable-col
16
16
  * protocol knowledge stays in `CreditAccountOperationsService` and
17
17
  * `PoolService`.
18
18
  *
19
- * A simulation names one chain, so it reads through
19
+ * A prepared operation names one chain, so it reads through
20
20
  * {@link MultichainConstruct.queryChain}: there is no second source to fall back
21
21
  * to, hence a chain the SDK does not cover, or one that fails the read, throws
22
22
  * rather than answering with empty metadata.
@@ -29,7 +29,7 @@ function toCreditAccountSlice(ca) {
29
29
  * Reads an account by address and narrows it to {@link CreditAccountSlice}.
30
30
  *
31
31
  * The shared read model's `StrategyPosition` carries neither `tokens` nor
32
- * `enabledTokensMask` / `creditFacade` / `totalDebtUSD`, so simulating against
32
+ * `enabledTokensMask` / `creditFacade` / `totalDebtUSD`, so preparing against
33
33
  * an existing position costs one account read.
34
34
  *
35
35
  * @throws When the account is not found in the connected markets.
@@ -123,7 +123,7 @@ function collectQuotaChange(assetsBefore, assetsAfter) {
123
123
  }
124
124
  /**
125
125
  * SDK `getSingleQuotaChange` requires `assetAfter` to emit quota decreases.
126
- * Simulation drops zero balances, so fully spent collaterals (e.g. claim
126
+ * The ledger drops zero balances, so fully spent collaterals (e.g. claim
127
127
  * phantom) vanish — reinsert them with balance 0 when they still have
128
128
  * initial quota so `calcQuotaUpdate` can zero / remove that quota.
129
129
  */
@@ -11,7 +11,7 @@ var ExecuteApi = class {
11
11
  * {@inheritDoc IOpportunitiesExecute.buildTx}
12
12
  **/
13
13
  async buildTx(request) {
14
- if (!request.sim.ok) throw new Error(`cannot build a transaction from a failed ${request.kind} simulation`);
14
+ if (!request.sim.ok) throw new Error(`cannot build a transaction from a failed ${request.kind} preparation`);
15
15
  const sdk = this.#chainOf(request.chainId);
16
16
  switch (request.kind) {
17
17
  case "pool": return poolTx(sdk, request);
@@ -85,10 +85,10 @@ async function accountTx(sdk, request) {
85
85
  return sdk.accounts.executeCaUpdate(account, request.sim.calls, { ethAmount: nativeValue(request.sim.operations) });
86
86
  }
87
87
  /**
88
- * The coin the simulation asked the wallet for, which the facade wraps out of
88
+ * The coin the preparation asked the wallet for, which the facade wraps out of
89
89
  * `msg.value` before running the multicall. Taken off the collateral step that
90
90
  * recorded it rather than from the caller, so it cannot disagree with what was
91
- * simulated.
91
+ * prepared.
92
92
  **/
93
93
  function nativeValue(operations) {
94
94
  return operations.reduce((total, op) => total + (op.type === "addCollateral" ? op.value ?? 0n : 0n), 0n);
@@ -15,7 +15,7 @@ import { withdrawableCollaterals } from "./withdrawable-collaterals.js";
15
15
  * protocol knowledge stays in `CreditAccountOperationsService` and
16
16
  * `PoolService`.
17
17
  *
18
- * A simulation names one chain, so it reads through
18
+ * A prepared operation names one chain, so it reads through
19
19
  * {@link MultichainConstruct.queryChain}: there is no second source to fall back
20
20
  * to, hence a chain the SDK does not cover, or one that fails the read, throws
21
21
  * rather than answering with empty metadata.
@@ -4,7 +4,7 @@ import "../../../model/index.js";
4
4
  import { Asset } from "../../base/types.js";
5
5
  import { MultiCall } from "../../types/transactions.js";
6
6
  import { OnchainSDK } from "../../OnchainSDK.js";
7
- import { SimulationPrices } from "./types.js";
7
+ import { PreparedPrices } from "./types.js";
8
8
  import "../../index.js";
9
9
  import { Address } from "viem";
10
10
  //#region src/onchain/accounts/intents/open-strategy.d.ts
@@ -32,7 +32,7 @@ interface OpenStrategyProps {
32
32
  * hands back expected and floor balances from a single call, and `openCA` wants
33
33
  * both `minQuota` and `averageQuota`, so there is nothing to gain by dropping one.
34
34
  */
35
- interface OpenStrategyState extends Omit<AccountProjection, "assets" | "quotas">, SimulationPrices {
35
+ interface OpenStrategyState extends Omit<AccountProjection, "assets" | "quotas">, PreparedPrices {
36
36
  /** Expected post-open balances. */
37
37
  averageAssets: TokenAmount[];
38
38
  /** Floor post-open balances after slippage. */
@@ -31,14 +31,14 @@ interface PathLossRate {
31
31
  totalValuePriceImpact: bigint;
32
32
  }
33
33
  /**
34
- * The two prices only a planned walk can quote, carried by every simulation
34
+ * The two prices only a planned walk can quote, carried by every `prepare`
35
35
  * result beside its projection.
36
36
  *
37
37
  * A calldata preview is asked for neither: it reads a transaction that already
38
38
  * names its amounts, and it reports what that transaction does rather than what
39
39
  * the market charges while a form is open.
40
40
  */
41
- interface SimulationPrices {
41
+ interface PreparedPrices {
42
42
  /**
43
43
  * What the routed legs lost to market depth. `undefined` where nothing was
44
44
  * routed or nothing could be measured — never a manufactured zero.
@@ -60,7 +60,7 @@ interface SimulationPrices {
60
60
  * {@link AccountProjection} vocabulary, plus the prices only a routed walk can
61
61
  * report.
62
62
  */
63
- interface OperationState extends AccountProjection, SimulationPrices {}
63
+ interface OperationState extends AccountProjection, PreparedPrices {}
64
64
  /**
65
65
  * What a preview yields: the operation chain, the state it projects, and the
66
66
  * calldata that realises it — or the reason the request is not viable.
@@ -395,4 +395,4 @@ type FinishIntentProps = StartIntentProps & {
395
395
  claimable: ClaimableWithdrawal;
396
396
  };
397
397
  //#endregion
398
- export { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, SimulationPrices, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawStrategyIntent };
398
+ export { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, PreparedPrices, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawStrategyIntent };
@@ -19,7 +19,7 @@ declare function toCreditAccountSlice(ca: CreditAccountDataPayload): CreditAccou
19
19
  * Reads an account by address and narrows it to {@link CreditAccountSlice}.
20
20
  *
21
21
  * The shared read model's `StrategyPosition` carries neither `tokens` nor
22
- * `enabledTokensMask` / `creditFacade` / `totalDebtUSD`, so simulating against
22
+ * `enabledTokensMask` / `creditFacade` / `totalDebtUSD`, so preparing against
23
23
  * an existing position costs one account read.
24
24
  *
25
25
  * @throws When the account is not found in the connected markets.
@@ -4,15 +4,15 @@ import { Asset } from "../../onchain/base/types.js";
4
4
  import { SecuritizeRegisterMessage } from "../../onchain/market/rwa/securitize/types.js";
5
5
  import { RawTx } from "../../onchain/types/transactions.js";
6
6
  import "../../onchain/index.js";
7
- import { LpSimulate, OpenStrategySimulate, StrategySimulate } from "../prepare/types.js";
7
+ import { LpPrepare, OpenStrategyPrepare, StrategyPrepare } from "../prepare/types.js";
8
8
  import "../prepare/index.js";
9
9
  import { Address } from "viem";
10
10
  //#region src/sdk/execute/types.d.ts
11
11
  /**
12
12
  * A pool deposit, withdrawal or redemption, as
13
13
  * {@link IOpportunitiesPrepare.deposit} / {@link IOpportunitiesPrepare.withdraw}
14
- * / {@link IOpportunitiesPrepare.redeem} priced it. The simulation carries the
15
- * tokens on both sides and the zapper, so nothing else is needed to encode
14
+ * / {@link IOpportunitiesPrepare.redeem} priced it. The prepared state carries
15
+ * the tokens on both sides and the zapper, so nothing else is needed to encode
16
16
  * the call.
17
17
  **/
18
18
  interface PoolPrepareRequest {
@@ -21,13 +21,13 @@ interface PoolPrepareRequest {
21
21
  pool: Address;
22
22
  wallet: Address;
23
23
  op: "deposit" | "withdraw" | "redeem";
24
- sim: Extract<LpSimulate, {
24
+ sim: Extract<LpPrepare, {
25
25
  ok: true;
26
26
  }>;
27
27
  }
28
28
  /**
29
29
  * Opening a new position, from a viable
30
- * {@link IOpportunitiesPrepare.openNewStrategy} result. The simulated state
30
+ * {@link IOpportunitiesPrepare.openNewStrategy} result. The prepared state
31
31
  * values collateral in underlying only, so the wallet's actual collateral
32
32
  * assets and the native value to attach come from the caller.
33
33
  **/
@@ -36,7 +36,7 @@ interface OpenPrepareRequest {
36
36
  chainId: ChainId;
37
37
  creditManager: Address;
38
38
  wallet: Address;
39
- sim: Extract<OpenStrategySimulate, {
39
+ sim: Extract<OpenStrategyPrepare, {
40
40
  ok: true;
41
41
  }>;
42
42
  /** What leaves the wallet, token by token. */
@@ -56,20 +56,20 @@ interface OpenPrepareRequest {
56
56
  }
57
57
  /**
58
58
  * Any of the five operations on an existing account, from a viable
59
- * {@link StrategySimulate}: the facade multicall is the simulation's `calls`.
59
+ * {@link StrategyPrepare}: the facade multicall is the result's `calls`.
60
60
  **/
61
61
  interface AccountPrepareRequest {
62
62
  kind: "account";
63
63
  chainId: ChainId;
64
64
  creditAccount: Address;
65
65
  wallet: Address;
66
- sim: Extract<StrategySimulate, {
66
+ sim: Extract<StrategyPrepare, {
67
67
  ok: true;
68
68
  }>;
69
69
  }
70
70
  /**
71
71
  * What {@link IOpportunitiesExecute.buildTx} turns into a transaction: a
72
- * `prepare` result plus the few facts about the wallet the simulation does not
72
+ * `prepare` result plus the few facts about the wallet the preparation does not
73
73
  * carry.
74
74
  **/
75
75
  type PrepareRequest = PoolPrepareRequest | OpenPrepareRequest | AccountPrepareRequest;
@@ -82,11 +82,11 @@ type PrepareRequest = PoolPrepareRequest | OpenPrepareRequest | AccountPrepareRe
82
82
  interface IOpportunitiesExecute {
83
83
  /**
84
84
  * The transaction to sign, from a `prepare` result. No second round of math:
85
- * `account` requests submit the simulation's own multicall, `open` requests
86
- * hand the state's router path and quotas to `openCA`, `pool` requests
87
- * encode the deposit / redeem the simulation priced.
85
+ * `account` requests submit the result's own multicall, `open` requests hand
86
+ * the state's router path and quotas to `openCA`, `pool` requests encode the
87
+ * deposit / redeem the result priced.
88
88
  *
89
- * @throws on a simulation that is not `ok`; when a `pool` request names a
89
+ * @throws on a `prepare` result that is not `ok`; when a `pool` request names a
90
90
  * route the pool has no metadata for, or one the pool does not accept a
91
91
  * transaction for (RWA on-demand deposits)
92
92
  **/
@@ -2,7 +2,7 @@ import { BorrowLimitBinding, IntentPreviewError, PreviewErrorDetails, PreviewErr
2
2
  import { LeverageBand } from "../onchain/accounts/intents/leverage-band.js";
3
3
  import { OperationState, PathLossRate } from "../onchain/accounts/intents/types.js";
4
4
  import { ILiquidations, ILiquidationsByMode } from "./liquidations/types.js";
5
- import { AddCollateralParams, AdjustLeverageParams, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
5
+ import { AddCollateralParams, AdjustLeverageParams, DelayedStrategyPrepare, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, LpParams, LpPrepare, LpRedeemParams, OpenStrategyParams, OpenStrategyPrepare, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyPrepare, StrategyRoutesPrepare, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
6
6
  import { ChainOf, PrepareApi } from "./prepare/PrepareApi.js";
7
7
  import "./prepare/index.js";
8
8
  import { AccountPrepareRequest, IOpportunitiesExecute, OpenPrepareRequest, PoolPrepareRequest, PrepareRequest } from "./execute/types.js";
@@ -34,4 +34,4 @@ import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
34
34
  import { assertSameChains } from "./errors/assertSameChains.js";
35
35
  import { everyChainFailed } from "./errors/everyChainFailed.js";
36
36
  import "./errors/index.js";
37
- export { AbstractNamespace, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, BorrowLimitBinding, ChainOf, ChainRef, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategySimulate, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, GearboxSDK, GearboxSDKOptions, IGearboxSDK, ILiquidations, ILiquidationsByMode, INotices, INoticesByMode, IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesExecute, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunitiesPrepare, IOpportunityMergers, IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly, IPreview, IPreviewByMode, IntentPreviewError, type LeverageBand, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpSimulate, type MergeListResult, MergedQuery, MissingSourceError, Mode, NamespaceOptions, NoSourceServedError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenPrepareRequest, OpenStrategyParams, OpenStrategySimulate, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewNamespace, PreviewRefusal, RepayStrategyParams, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, raise, refuse };
37
+ export { AbstractNamespace, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, BorrowLimitBinding, ChainOf, ChainRef, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategyPrepare, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, GearboxSDK, GearboxSDKOptions, IGearboxSDK, ILiquidations, ILiquidationsByMode, INotices, INoticesByMode, IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesExecute, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunitiesPrepare, IOpportunityMergers, IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly, IPreview, IPreviewByMode, IntentPreviewError, type LeverageBand, LiquidationsNamespace, type ListMerger, LpParams, LpPrepare, LpRedeemParams, type MergeListResult, MergedQuery, MissingSourceError, Mode, NamespaceOptions, NoSourceServedError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenPrepareRequest, OpenStrategyParams, OpenStrategyPrepare, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewNamespace, PreviewRefusal, RepayStrategyParams, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyPrepare, StrategyRoutesPrepare, WithdrawCollateralParams, WithdrawStrategyParams, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, raise, refuse };
@@ -72,7 +72,8 @@ interface IOpportunitiesOffchainOnly {
72
72
  **/
73
73
  interface IOpportunitiesOnchainOnly {
74
74
  /**
75
- * Simulations of what a deposit, withdrawal or leverage change would do.
75
+ * What a deposit, withdrawal or leverage change would do, and the calldata
76
+ * that does it.
76
77
  *
77
78
  * Absent in `offchain` mode: every one of them reads live account and pool
78
79
  * state, and the strategy flows additionally need the pathfinder for real swap
@@ -8,14 +8,14 @@ import { MultichainSDK } from "../../onchain/MultichainSDK.js";
8
8
  import { ChainQueryOneProps, MultichainConstruct } from "../../onchain/base/MultichainConstruct.js";
9
9
  import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
10
10
  import "../../onchain/index.js";
11
- import { AddCollateralParams, AdjustLeverageParams, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, PoolInput, PositionInput, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
11
+ import { AddCollateralParams, AdjustLeverageParams, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, LpParams, LpPrepare, LpRedeemParams, OpenStrategyParams, OpenStrategyPrepare, PoolInput, PositionInput, RepayStrategyParams, StrategyInput, StrategyPrepare, StrategyRoutesPrepare, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
12
12
  import { EnsureFreshChains } from "../types.js";
13
13
  import { Address } from "viem";
14
14
  //#region src/sdk/prepare/PrepareApi.d.ts
15
15
  /**
16
16
  * The chain's SDK, resolved on the spot.
17
17
  *
18
- * The LP simulations need it synchronously, because they only do arithmetic on
18
+ * The LP methods need it synchronously, because they only do arithmetic on
19
19
  * loaded state and have nothing to await; the execute namespace resolves its
20
20
  * chain the same way.
21
21
  **/
@@ -28,7 +28,7 @@ type ChainOf = (chainId: ChainId) => OnchainSDK;
28
28
  * protocol knowledge stays in `CreditAccountOperationsService` and
29
29
  * `PoolService`.
30
30
  *
31
- * A simulation names one chain, so it reads through
31
+ * A prepared operation names one chain, so it reads through
32
32
  * {@link MultichainConstruct.queryChain}: there is no second source to fall back
33
33
  * to, hence a chain the SDK does not cover, or one that fails the read, throws
34
34
  * rather than answering with empty metadata.
@@ -40,31 +40,31 @@ declare class PrepareApi extends MultichainConstruct implements IOpportunitiesPr
40
40
  /**
41
41
  * {@inheritDoc IOpportunitiesPrepare.finalize}
42
42
  **/
43
- finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategySimulate>>;
43
+ finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategyPrepare>>;
44
44
  /**
45
45
  * {@inheritDoc IOpportunitiesPrepare.deposit}
46
46
  **/
47
- deposit(pool: PoolInput, params: LpParams): LpSimulate;
47
+ deposit(pool: PoolInput, params: LpParams): LpPrepare;
48
48
  /**
49
49
  * {@inheritDoc IOpportunitiesPrepare.withdraw}
50
50
  **/
51
- withdraw(pool: PoolInput, params: LpParams): LpSimulate;
51
+ withdraw(pool: PoolInput, params: LpParams): LpPrepare;
52
52
  /**
53
53
  * {@inheritDoc IOpportunitiesPrepare.redeem}
54
54
  **/
55
- redeem(pool: PoolInput, params: LpRedeemParams): LpSimulate;
55
+ redeem(pool: PoolInput, params: LpRedeemParams): LpPrepare;
56
56
  /**
57
57
  * {@inheritDoc IOpportunitiesPrepare.openNewStrategy}
58
58
  **/
59
- openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<DataResponse<OpenStrategySimulate>>;
59
+ openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<DataResponse<OpenStrategyPrepare>>;
60
60
  /**
61
61
  * {@inheritDoc IOpportunitiesPrepare.depositStrategy}
62
62
  **/
63
- depositStrategy(position: PositionInput, params: DepositStrategyParams): Promise<DataResponse<StrategySimulate>>;
63
+ depositStrategy(position: PositionInput, params: DepositStrategyParams): Promise<DataResponse<StrategyPrepare>>;
64
64
  /**
65
65
  * {@inheritDoc IOpportunitiesPrepare.withdrawStrategy}
66
66
  **/
67
- withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<DataResponse<StrategyRoutesSimulate>>;
67
+ withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<DataResponse<StrategyRoutesPrepare>>;
68
68
  /**
69
69
  * {@inheritDoc IOpportunitiesPrepare.maxWithdraw}
70
70
  **/
@@ -72,7 +72,7 @@ declare class PrepareApi extends MultichainConstruct implements IOpportunitiesPr
72
72
  /**
73
73
  * {@inheritDoc IOpportunitiesPrepare.repayStrategy}
74
74
  **/
75
- repayStrategy(position: PositionInput, params: RepayStrategyParams): Promise<DataResponse<StrategySimulate>>;
75
+ repayStrategy(position: PositionInput, params: RepayStrategyParams): Promise<DataResponse<StrategyPrepare>>;
76
76
  /**
77
77
  * {@inheritDoc IOpportunitiesPrepare.maxRepay}
78
78
  **/
@@ -80,15 +80,15 @@ declare class PrepareApi extends MultichainConstruct implements IOpportunitiesPr
80
80
  /**
81
81
  * {@inheritDoc IOpportunitiesPrepare.adjustLeverage}
82
82
  **/
83
- adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<DataResponse<StrategyRoutesSimulate>>;
83
+ adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<DataResponse<StrategyRoutesPrepare>>;
84
84
  /**
85
85
  * {@inheritDoc IOpportunitiesPrepare.addCollateral}
86
86
  **/
87
- addCollateral(position: PositionInput, params: AddCollateralParams): Promise<DataResponse<StrategySimulate>>;
87
+ addCollateral(position: PositionInput, params: AddCollateralParams): Promise<DataResponse<StrategyPrepare>>;
88
88
  /**
89
89
  * {@inheritDoc IOpportunitiesPrepare.withdrawCollateral}
90
90
  **/
91
- withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise<DataResponse<StrategySimulate>>;
91
+ withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise<DataResponse<StrategyPrepare>>;
92
92
  /**
93
93
  * {@inheritDoc IOpportunitiesPrepare.leverageBand}
94
94
  **/
@@ -1,6 +1,6 @@
1
1
  import { BorrowLimitBinding, IntentPreviewError, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, raise, refuse } from "../../onchain/validation/refusal.js";
2
2
  import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
3
3
  import { OperationState, PathLossRate } from "../../onchain/accounts/intents/types.js";
4
- import { AddCollateralParams, AdjustLeverageParams, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
4
+ import { AddCollateralParams, AdjustLeverageParams, DelayedStrategyPrepare, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, LpParams, LpPrepare, LpRedeemParams, OpenStrategyParams, OpenStrategyPrepare, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyPrepare, StrategyRoutesPrepare, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
5
5
  import { ChainOf, PrepareApi } from "./PrepareApi.js";
6
- export { AddCollateralParams, AdjustLeverageParams, BorrowLimitBinding, ChainOf, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, IntentPreviewError, type LeverageBand, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, type OperationState, type PathLossRate, PoolInput, PositionInput, PrepareApi, PrepareOptions, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams, raise, refuse };
6
+ export { AddCollateralParams, AdjustLeverageParams, BorrowLimitBinding, ChainOf, DelayedStrategyPrepare, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, IntentPreviewError, type LeverageBand, LpParams, LpPrepare, LpRedeemParams, OpenStrategyParams, OpenStrategyPrepare, type OperationState, type PathLossRate, PoolInput, PositionInput, PrepareApi, PrepareOptions, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, RepayStrategyParams, StrategyInput, StrategyPrepare, StrategyRoutesPrepare, WithdrawCollateralParams, WithdrawStrategyParams, raise, refuse };
@@ -18,17 +18,17 @@ import { Address } from "viem";
18
18
  /**
19
19
  * What a pool deposit or withdrawal would yield.
20
20
  *
21
- * Shaped like {@link StrategySimulate} so both kinds of simulation are consumed
22
- * the same way, with the pool's own numbers as the state: the ERC-4626
21
+ * Shaped like {@link StrategyPrepare} so both kinds of result are consumed the
22
+ * same way, with the pool's own numbers as the state: the ERC-4626
23
23
  * conversion applied to the amount, at the rate of the block the market was
24
24
  * loaded at.
25
25
  **/
26
- type LpSimulate = {
26
+ type LpPrepare = {
27
27
  ok: true;
28
28
  /**
29
29
  * Always empty: a pool operation is a single transaction, so there is no
30
- * chain of steps to show. Present so callers can treat both simulations
31
- * alike.
30
+ * chain of steps to show. Present so callers can treat both kinds of
31
+ * result alike.
32
32
  **/
33
33
  operations: [];
34
34
  /**
@@ -49,7 +49,7 @@ type LpSimulate = {
49
49
  * so the reason is a value rather than an exception: too much leverage, too
50
50
  * little of the source token, a token the flow does not accept.
51
51
  **/
52
- type StrategySimulate = {
52
+ type StrategyPrepare = {
53
53
  ok: true;
54
54
  /**
55
55
  * The logical steps, each carrying the amounts it was computed from.
@@ -72,15 +72,15 @@ type StrategySimulate = {
72
72
  * What the leading half of a delayed operation would yield: the request
73
73
  * transaction, plus what it recorded for the tail and where that tail leads.
74
74
  *
75
- * Shaped like {@link StrategySimulate} with one field more, so the instant and
75
+ * Shaped like {@link StrategyPrepare} with one field more, so the instant and
76
76
  * the delayed route of the same request are compared side by side — and they
77
77
  * are meant to be compared on the same footing, so `state` is the end of the
78
78
  * operation in both, not the end of the transaction.
79
79
  **/
80
- type DelayedStrategySimulate = {
80
+ type DelayedStrategyPrepare = {
81
81
  ok: true;
82
82
  /**
83
- * {@inheritDoc StrategySimulate.operations}
83
+ * {@inheritDoc StrategyPrepare.operations}
84
84
  **/
85
85
  operations: AccountCalculatorOperation[];
86
86
  /**
@@ -95,7 +95,7 @@ type DelayedStrategySimulate = {
95
95
  **/
96
96
  state: OperationState;
97
97
  /**
98
- * {@inheritDoc StrategySimulate.calls}
98
+ * {@inheritDoc StrategyPrepare.calls}
99
99
  **/
100
100
  calls: MultiCall[];
101
101
  /**
@@ -116,13 +116,13 @@ type DelayedStrategySimulate = {
116
116
  * with its refusal in `refused`, which is what lets a form offer exactly the
117
117
  * routes that exist; `ok: false` means neither does.
118
118
  **/
119
- type StrategyRoutesSimulate = {
119
+ type StrategyRoutesPrepare = {
120
120
  ok: true;
121
121
  /**
122
122
  * The router route: one transaction, settled on the spot. `undefined`
123
123
  * when the asset cannot be sold, see `refused.instant`.
124
124
  **/
125
- instant: Extract<StrategySimulate, {
125
+ instant: Extract<StrategyPrepare, {
126
126
  ok: true;
127
127
  }> | undefined;
128
128
  /**
@@ -131,7 +131,7 @@ type StrategyRoutesSimulate = {
131
131
  * `undefined` when the route does not exist — no redemption venue for the
132
132
  * asset, or a request that settles at once anyway — see `refused.delayed`.
133
133
  **/
134
- delayed: Extract<DelayedStrategySimulate, {
134
+ delayed: Extract<DelayedStrategyPrepare, {
135
135
  ok: true;
136
136
  }> | undefined;
137
137
  /**
@@ -145,17 +145,17 @@ type StrategyRoutesSimulate = {
145
145
  **/
146
146
  (PreviewRefusal & {
147
147
  /**
148
- * {@inheritDoc StrategyRoutesSimulate.refused}
148
+ * {@inheritDoc StrategyRoutesPrepare.refused}
149
149
  **/
150
150
  refused: RouteRefusals;
151
151
  });
152
152
  /**
153
153
  * What opening a new leveraged position would yield.
154
154
  *
155
- * The only simulation that reports both an expected and a floor branch: opening
155
+ * The only result that reports both an expected and a floor branch: opening
156
156
  * takes both from a single pathfinder call, and `openCA` consumes both.
157
157
  **/
158
- type OpenStrategySimulate = {
158
+ type OpenStrategyPrepare = {
159
159
  ok: true;
160
160
  state: OpenStrategyState;
161
161
  } | PreviewRefusal;
@@ -167,17 +167,17 @@ interface PrepareOptions {
167
167
  slippage?: number;
168
168
  /**
169
169
  * Extra quota headroom in PERCENTAGE_FORMAT, to survive price drift between
170
- * the simulation and execution.
170
+ * the preparation and execution.
171
171
  **/
172
172
  quotaReserve?: number;
173
173
  }
174
174
  /**
175
- * Position to simulate against. A `StrategyPosition` from
175
+ * Position to prepare against. A `StrategyPosition` from
176
176
  * `sdk.positions.list()` satisfies this, as does a bare key.
177
177
  **/
178
178
  type PositionInput = StrategyPositionKey;
179
179
  /**
180
- * Pool to simulate against. A `PoolOpportunity` from
180
+ * Pool to prepare against. A `PoolOpportunity` from
181
181
  * `sdk.opportunities.list()` satisfies this, as does a bare key.
182
182
  **/
183
183
  type PoolInput = PoolOpportunityKey;
@@ -303,8 +303,8 @@ interface LpParams {
303
303
  tokenIn?: Address;
304
304
  /**
305
305
  * Token the user receives. Defaults to the only route available for `tokenIn`;
306
- * required when the pool offers several, otherwise the simulation reports
307
- * `unsupportedTokenPair`.
306
+ * required when the pool offers several, otherwise the preparation is refused
307
+ * with `unsupportedTokenPair`.
308
308
  **/
309
309
  tokenOut?: Address;
310
310
  }
@@ -337,23 +337,23 @@ interface FinalizeParams extends PrepareOptions {
337
337
  intent?: ResumableIntent;
338
338
  }
339
339
  /**
340
- * Simulations of everything a wallet can do to a pool or a credit account.
340
+ * Everything a wallet can do to a pool or a credit account, prepared.
341
341
  *
342
342
  * On-chain only: every method reads live state and, for strategies, asks the
343
343
  * pathfinder for real swap paths. Nothing is executed and nothing is signed —
344
344
  * the result is the numbers plus the calldata that would produce them.
345
345
  *
346
- * Not to be confused with `src/preview/simulate`, which goes the other way: it
347
- * takes calldata that already exists and reports what it would do.
346
+ * Not to be confused with `src/preview`, which goes the other way: it takes
347
+ * calldata that already exists and reports what it would do.
348
348
  **/
349
349
  interface IOpportunitiesPrepare {
350
350
  /**
351
351
  * Depositing into a pool: underlying in, shares out.
352
352
  *
353
- * Synchronous, unlike every strategy simulation below: the answer is the
354
- * pool's share rate applied to the amount, and that rate is already loaded.
353
+ * Synchronous, unlike every strategy method below: the answer is the pool's
354
+ * share rate applied to the amount, and that rate is already loaded.
355
355
  **/
356
- deposit(pool: PoolInput, params: LpParams): LpSimulate;
356
+ deposit(pool: PoolInput, params: LpParams): LpPrepare;
357
357
  /**
358
358
  * Taking underlying out of a pool: `amount` is the `tokenOut` the wallet
359
359
  * wants back, and the pool burns whatever shares that costs.
@@ -361,26 +361,26 @@ interface IOpportunitiesPrepare {
361
361
  * The LP counterpart of {@link withdrawStrategy} / {@link withdrawCollateral},
362
362
  * which act on credit accounts.
363
363
  **/
364
- withdraw(pool: PoolInput, params: LpParams): LpSimulate;
364
+ withdraw(pool: PoolInput, params: LpParams): LpPrepare;
365
365
  /**
366
366
  * Redeeming pool shares: `amount` is the `tokenIn` the wallet parts with,
367
367
  * and the reported state is the underlying it converts to.
368
368
  **/
369
- redeem(pool: PoolInput, params: LpRedeemParams): LpSimulate;
369
+ redeem(pool: PoolInput, params: LpRedeemParams): LpPrepare;
370
370
  /**
371
371
  * Opening a leveraged position from wallet collateral.
372
372
  *
373
373
  * The one flow with no account yet, so the result carries no operation list —
374
374
  * it feeds `sdk.accounts.openCA` instead.
375
375
  **/
376
- openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<DataResponse<OpenStrategySimulate>>;
376
+ openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<DataResponse<OpenStrategyPrepare>>;
377
377
  /**
378
378
  * Growing a position: collateral in, debt drawn on top, both converted into
379
379
  * the position token.
380
380
  *
381
381
  * Leverage stays put unless `targetLeverage` asks for more.
382
382
  **/
383
- depositStrategy(position: PositionInput, params: DepositStrategyParams): Promise<DataResponse<StrategySimulate>>;
383
+ depositStrategy(position: PositionInput, params: DepositStrategyParams): Promise<DataResponse<StrategyPrepare>>;
384
384
  /**
385
385
  * Shrinking a position: part of its net value goes to the wallet and debt is
386
386
  * repaid in the same proportion, so leverage is unchanged.
@@ -388,7 +388,7 @@ interface IOpportunitiesPrepare {
388
388
  * Answers with both routes the withdrawal can take — sold through the router
389
389
  * now, or redeemed through the source's issuer and finished days later — since
390
390
  * the source token decides which of them exist, see
391
- * {@link StrategyRoutesSimulate}.
391
+ * {@link StrategyRoutesPrepare}.
392
392
  *
393
393
  * `MAX_UINT256` — or any amount at or above the account's net value — is an
394
394
  * exit instead: the quotas are dropped, the position is sold whole in one
@@ -406,7 +406,7 @@ interface IOpportunitiesPrepare {
406
406
  * @see withdrawCollateral to move an asset out without touching debt, which
407
407
  * raises leverage instead.
408
408
  **/
409
- withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<DataResponse<StrategyRoutesSimulate>>;
409
+ withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<DataResponse<StrategyRoutesPrepare>>;
410
410
  /**
411
411
  * Largest partial withdrawal {@link withdrawStrategy} accepts, in underlying
412
412
  * units: the amount whose proportional repayment leaves the debt at the
@@ -429,12 +429,12 @@ interface IOpportunitiesPrepare {
429
429
  * A repayment that covers the whole debt clears the account's quotas with it,
430
430
  * which the facade requires of a loan going to zero, and asks for the full
431
431
  * outstanding amount, so nothing is left owing because interest moved between
432
- * this simulation and the transaction. `MAX_UINT256` is how to ask for that
432
+ * this preparation and the transaction. `MAX_UINT256` is how to ask for that
433
433
  * settlement without naming a figure: the wallet is charged the debt plus a
434
434
  * 10bps margin for the interest still to come, and whatever the facade does
435
435
  * not take stays on the account.
436
436
  **/
437
- repayStrategy(position: PositionInput, params: RepayStrategyParams): Promise<DataResponse<StrategySimulate>>;
437
+ repayStrategy(position: PositionInput, params: RepayStrategyParams): Promise<DataResponse<StrategyPrepare>>;
438
438
  /**
439
439
  * Debt {@link repayStrategy} would have to cover to clear the account, in
440
440
  * underlying units: principal, interest and fees as of this read. Interest
@@ -449,12 +449,12 @@ interface IOpportunitiesPrepare {
449
449
  * buys instead, so there the delayed route is always absent with
450
450
  * `refused.delayed: "noDelayedRoute"`.
451
451
  **/
452
- adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<DataResponse<StrategyRoutesSimulate>>;
452
+ adjustLeverage(position: PositionInput, params: AdjustLeverageParams): Promise<DataResponse<StrategyRoutesPrepare>>;
453
453
  /**
454
454
  * Putting the position token onto the account at fixed debt, which lowers
455
455
  * leverage and raises the health factor.
456
456
  **/
457
- addCollateral(position: PositionInput, params: AddCollateralParams): Promise<DataResponse<StrategySimulate>>;
457
+ addCollateral(position: PositionInput, params: AddCollateralParams): Promise<DataResponse<StrategyPrepare>>;
458
458
  /**
459
459
  * Moving one asset that already sits on the account out to the wallet, at
460
460
  * fixed debt — so TVL falls and leverage rises.
@@ -462,7 +462,7 @@ interface IOpportunitiesPrepare {
462
462
  * @see withdrawStrategy for the deleveraging withdrawal, which repays debt in
463
463
  * proportion and leaves leverage unchanged.
464
464
  **/
465
- withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise<DataResponse<StrategySimulate>>;
465
+ withdrawCollateral(position: PositionInput, params: WithdrawCollateralParams): Promise<DataResponse<StrategyPrepare>>;
466
466
  /**
467
467
  * The leverages a deposit of a given size can reach in this market: the
468
468
  * range a leverage slider should mark as available.
@@ -499,7 +499,7 @@ interface IOpportunitiesPrepare {
499
499
  * Synchronous, like {@link leverageBand}: it reads loaded token metadata and
500
500
  * the position it was handed, so a form can ask on every render. Nothing is
501
501
  * quoted here — which of these the router can sell is a different question,
502
- * and the answer to it is a simulation.
502
+ * and the answer to it is a prepared operation.
503
503
  **/
504
504
  withdrawableCollaterals(position: StrategyPosition): PositionCollateral[];
505
505
  /**
@@ -531,7 +531,7 @@ interface IOpportunitiesPrepare {
531
531
  * Answers like the instant flows, so both halves are consumed the same way.
532
532
  * Reports `noRecordedIntent` when the claim names no operation to resume.
533
533
  **/
534
- finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategySimulate>>;
534
+ finalize(position: PositionInput, params: FinalizeParams): Promise<DataResponse<StrategyPrepare>>;
535
535
  }
536
536
  //#endregion
537
- export { AddCollateralParams, AdjustLeverageParams, BorrowLimitBinding, DelayedStrategySimulate, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, IntentPreviewError, type LeverageBand, LpParams, LpRedeemParams, LpSimulate, OpenStrategyParams, OpenStrategySimulate, type OperationState, type PathLossRate, PoolInput, PositionInput, PrepareOptions, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, RepayStrategyParams, StrategyInput, StrategyRoutesSimulate, StrategySimulate, WithdrawCollateralParams, WithdrawStrategyParams, raise, refuse };
537
+ export { AddCollateralParams, AdjustLeverageParams, BorrowLimitBinding, DelayedStrategyPrepare, DepositStrategyParams, FinalizeParams, IOpportunitiesPrepare, IntentPreviewError, type LeverageBand, LpParams, LpPrepare, LpRedeemParams, OpenStrategyParams, OpenStrategyPrepare, type OperationState, type PathLossRate, PoolInput, PositionInput, PrepareOptions, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, RepayStrategyParams, StrategyInput, StrategyPrepare, StrategyRoutesPrepare, WithdrawCollateralParams, WithdrawStrategyParams, raise, refuse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.0.0-next.30",
3
+ "version": "16.0.0-next.31",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {