@gearbox-protocol/sdk 16.0.0-next.48 → 16.0.0-next.49

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.
Files changed (32) hide show
  1. package/dist/cjs/model/positions.schema.js +7 -2
  2. package/dist/cjs/offchain/positions/OffchainPositions.js +9 -0
  3. package/dist/cjs/sdk/positions/PositionsNamespace.js +6 -0
  4. package/dist/esm/dev/AccountOpener.js +1 -1
  5. package/dist/esm/dev/withdrawalUtils.js +1 -1
  6. package/dist/esm/model/positions.schema.js +7 -2
  7. package/dist/esm/offchain/positions/OffchainPositions.js +10 -1
  8. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  9. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  10. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  11. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  12. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  13. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  14. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  15. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  16. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  17. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  18. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  19. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  20. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  21. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  22. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  23. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  24. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  25. package/dist/esm/sdk/positions/PositionsNamespace.js +6 -0
  26. package/dist/types/model/positions.d.ts +36 -2
  27. package/dist/types/model/positions.schema.d.ts +26 -2
  28. package/dist/types/offchain/positions/OffchainPositions.d.ts +5 -1
  29. package/dist/types/offchain/positions/types.d.ts +7 -1
  30. package/dist/types/sdk/positions/PositionsNamespace.d.ts +5 -1
  31. package/dist/types/sdk/positions/types.d.ts +10 -1
  32. package/package.json +1 -1
@@ -208,7 +208,10 @@ const positionTransactionKindSchema = zod_v4.z.union([
208
208
  zod_v4.z.literal("adjustLeverage"),
209
209
  zod_v4.z.literal("addCollateral"),
210
210
  zod_v4.z.literal("withdrawCollateral"),
211
- zod_v4.z.literal("liquidation")
211
+ zod_v4.z.literal("liquidation"),
212
+ zod_v4.z.literal("repay"),
213
+ zod_v4.z.literal("rebalance"),
214
+ zod_v4.z.literal("other")
212
215
  ]);
213
216
  /**
214
217
  * {@link PositionTransaction}
@@ -217,7 +220,9 @@ const positionTransactionSchema = zod_v4.z.object({
217
220
  txHash: require_onchain_utils_zod.ZodHex(),
218
221
  timestamp: require_model_primitives_schema.timestampSchema,
219
222
  kind: positionTransactionKindSchema,
220
- assets: zod_v4.z.array(require_model_primitives_schema.tokenAmountSchema)
223
+ assets: zod_v4.z.array(require_model_primitives_schema.tokenAmountSchema),
224
+ balanceChanges: zod_v4.z.array(require_model_primitives_schema.tokenAmountSchema),
225
+ debtChange: require_model_primitives_schema.tokenAmountSchema
221
226
  });
222
227
  //#endregion
223
228
  exports.borrowRateBreakdownSchema = borrowRateBreakdownSchema;
@@ -39,6 +39,15 @@ var OffchainPositions = class extends require_offchain_AbstractOffchainNamespace
39
39
  async getCharts(key, metrics, range) {
40
40
  return this.readCharts(`${this.#chartRoot(key)}/charts`, metrics, range);
41
41
  }
42
+ /**
43
+ * {@inheritDoc IOffchainPositions.getTransactions}
44
+ **/
45
+ async getTransactions(key) {
46
+ return this.get({
47
+ path: `${this.#strategyPath(key)}/transactions`,
48
+ schema: zod_v4.z.array(require_model_positions_schema.positionTransactionSchema)
49
+ });
50
+ }
42
51
  #poolPath(key) {
43
52
  return `${this.#root}/pool/${key.chainId}/${key.pool}/${key.wallet}`;
44
53
  }
@@ -51,6 +51,12 @@ var PositionsNamespace = class extends require_sdk_AbstractNamespace.AbstractNam
51
51
  return this.offchain.getCharts(key, metrics, range);
52
52
  }
53
53
  /**
54
+ * {@inheritDoc IPositionsOffchainOnly.transactions}
55
+ **/
56
+ async transactions(key) {
57
+ return this.offchain.getTransactions(key);
58
+ }
59
+ /**
54
60
  * {@inheritDoc IPositionsOnchainOnly.getCurrentWithdrawals}
55
61
  **/
56
62
  async getCurrentWithdrawals(props) {
@@ -1,5 +1,5 @@
1
- import { ierc20Abi } from "../abi/iERC20.js";
2
1
  import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
2
+ import { ierc20Abi } from "../abi/iERC20.js";
3
3
  import { AddressMap } from "../onchain/utils/AddressMap.js";
4
4
  import { AddressSet } from "../onchain/utils/AddressSet.js";
5
5
  import { AssetsMap } from "../onchain/utils/AssetsMap.js";
@@ -1,6 +1,6 @@
1
- import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
2
1
  import { getNetworkType } from "../onchain/chain/chains.js";
3
2
  import { getWithdrawalCompressorAddress } from "../onchain/accounts/withdrawal-compressor/addresses.js";
3
+ import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
4
4
  import "../onchain/index.js";
5
5
  import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
6
6
  import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
@@ -207,7 +207,10 @@ const positionTransactionKindSchema = z.union([
207
207
  z.literal("adjustLeverage"),
208
208
  z.literal("addCollateral"),
209
209
  z.literal("withdrawCollateral"),
210
- z.literal("liquidation")
210
+ z.literal("liquidation"),
211
+ z.literal("repay"),
212
+ z.literal("rebalance"),
213
+ z.literal("other")
211
214
  ]);
212
215
  /**
213
216
  * {@link PositionTransaction}
@@ -216,7 +219,9 @@ const positionTransactionSchema = z.object({
216
219
  txHash: ZodHex(),
217
220
  timestamp: timestampSchema,
218
221
  kind: positionTransactionKindSchema,
219
- assets: z.array(tokenAmountSchema)
222
+ assets: z.array(tokenAmountSchema),
223
+ balanceChanges: z.array(tokenAmountSchema),
224
+ debtChange: tokenAmountSchema
220
225
  });
221
226
  //#endregion
222
227
  export { borrowRateBreakdownSchema, pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema };
@@ -1,4 +1,4 @@
1
- import { positionFilterQuerySchema, positionSchema, positionsTotalsSchema } from "../../model/positions.schema.js";
1
+ import { positionFilterQuerySchema, positionSchema, positionTransactionSchema, positionsTotalsSchema } from "../../model/positions.schema.js";
2
2
  import { AbstractOffchainNamespace } from "../AbstractOffchainNamespace.js";
3
3
  import { z } from "zod/v4";
4
4
  //#region src/offchain/positions/OffchainPositions.ts
@@ -38,6 +38,15 @@ var OffchainPositions = class extends AbstractOffchainNamespace {
38
38
  async getCharts(key, metrics, range) {
39
39
  return this.readCharts(`${this.#chartRoot(key)}/charts`, metrics, range);
40
40
  }
41
+ /**
42
+ * {@inheritDoc IOffchainPositions.getTransactions}
43
+ **/
44
+ async getTransactions(key) {
45
+ return this.get({
46
+ path: `${this.#strategyPath(key)}/transactions`,
47
+ schema: z.array(positionTransactionSchema)
48
+ });
49
+ }
41
50
  #poolPath(key) {
42
51
  return `${this.#root}/pool/${key.chainId}/${key.pool}/${key.wallet}`;
43
52
  }
@@ -1,5 +1,3 @@
1
- import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
2
- import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
3
1
  import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
4
2
  import { ADDRESS_0X0 } from "../constants/addresses.js";
5
3
  import { MAX_UINT256 } from "../constants/math.js";
@@ -10,6 +8,8 @@ import "../base/index.js";
10
8
  import { AccountBotsService } from "./bots/AccountBotsService.js";
11
9
  import "./bots/index.js";
12
10
  import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
11
+ import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
12
+ import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
13
13
  import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
14
14
  import "../market/index.js";
15
15
  import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
@@ -1,4 +1,3 @@
1
- import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
2
1
  import { AddressSet } from "../../utils/AddressSet.js";
3
2
  import { bytes32ToString } from "../../utils/bytes32ToString.js";
4
3
  import { ADDRESS_0X0 } from "../../constants/addresses.js";
@@ -20,6 +19,7 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
20
19
  import "../../market/rwa/securitize/index.js";
21
20
  import "../../market/index.js";
22
21
  import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
22
+ import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
23
23
  import { skipLiquidatableAccount } from "./skipLiquidatableAccount.js";
24
24
  //#region src/onchain/accounts/liquidations/LiquidationsService.ts
25
25
  /**
@@ -1,9 +1,9 @@
1
- import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
2
1
  import { BaseContract } from "../../base/BaseContract.js";
3
2
  import "../../base/index.js";
4
3
  import { sdkErr, sdkOk } from "../../../model/result.js";
5
4
  import "../../../model/index.js";
6
5
  import { decodeDelayedIntent } from "./intent-codec.js";
6
+ import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
7
7
  //#region src/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
8
8
  const abi = iRedemptionLoggerV310Abi;
9
9
  /**
@@ -1,5 +1,5 @@
1
- import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
2
1
  import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
2
+ import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
3
3
  //#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
4
4
  const abi = iWithdrawalCompressorV310Abi;
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
2
1
  import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
2
+ import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
3
3
  //#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
4
4
  const abi = iWithdrawalCompressorV311Abi;
5
5
  /**
@@ -1,6 +1,6 @@
1
- import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
2
1
  import { encodeDelayedIntent } from "./intent-codec.js";
3
2
  import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
3
+ import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
4
4
  import { toWithdrawalStatus } from "./types.js";
5
5
  //#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
6
6
  const abi = iWithdrawalCompressorV313Abi;
@@ -1,12 +1,12 @@
1
- import { iExpirableAbi } from "../../abi/iExpirable.js";
2
- import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
3
- import { iVersionAbi } from "../../abi/iVersion.js";
4
1
  import { AddressMap } from "../utils/AddressMap.js";
5
2
  import { AddressSet } from "../utils/AddressSet.js";
6
3
  import { bytes32ToString } from "../utils/bytes32ToString.js";
7
4
  import { getAssetType } from "../chain/chains.js";
8
5
  import { formatBN } from "../utils/formatter.js";
9
6
  import "../utils/index.js";
7
+ import { iExpirableAbi } from "../../abi/iExpirable.js";
8
+ import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
9
+ import { iVersionAbi } from "../../abi/iVersion.js";
10
10
  import { SdkRWADataNotLoadedError } from "../core/errors.js";
11
11
  import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
12
12
  //#region src/onchain/base/TokensMeta.ts
@@ -1,8 +1,8 @@
1
- import { iVersionAbi } from "../../abi/iVersion.js";
2
1
  import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
3
2
  import { isV310 } from "../constants/versions.js";
4
3
  import "../constants/index.js";
5
4
  import { hexEq } from "../utils/hex.js";
5
+ import { iVersionAbi } from "../../abi/iVersion.js";
6
6
  import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
7
7
  //#region src/onchain/core/createAddressProvider.ts
8
8
  const OVERRIDE_ADDRESSES = { Mainnet: {
@@ -1,5 +1,5 @@
1
- import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
2
1
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
2
+ import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
3
3
  //#region src/onchain/market/adapters/contracts/AccountMigratorAdapterContract.ts
4
4
  const abi = accountMigratorAbi;
5
5
  const protocolAbi = accountMigratorAbi;
@@ -1,6 +1,6 @@
1
- import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
2
1
  import { MissingSerializedParamsError } from "../../../base/errors.js";
3
2
  import "../../../base/index.js";
3
+ import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
4
4
  import { iERC4626Abi } from "../abi/targetContractAbi.js";
5
5
  import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
6
6
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
@@ -1,7 +1,7 @@
1
- import { iPausableAbi } from "../../../abi/iPausable.js";
2
1
  import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
3
2
  import { BaseContract } from "../../base/BaseContract.js";
4
3
  import "../../base/index.js";
4
+ import { iPausableAbi } from "../../../abi/iPausable.js";
5
5
  //#region src/onchain/market/credit/CreditFacadeV310BaseContract.ts
6
6
  const abi = [
7
7
  ...iCreditFacadeV310Abi,
@@ -1,4 +1,3 @@
1
- import { iPausableAbi } from "../../../abi/iPausable.js";
2
1
  import { iPoolV310Abi } from "../../../abi/310/generated.js";
3
2
  import { AddressMap } from "../../utils/AddressMap.js";
4
3
  import { RAY } from "../../constants/math.js";
@@ -8,6 +7,7 @@ import "../../utils/index.js";
8
7
  import { SdkRWADataNotLoadedError } from "../../core/errors.js";
9
8
  import { BaseContract } from "../../base/BaseContract.js";
10
9
  import "../../base/index.js";
10
+ import { iPausableAbi } from "../../../abi/iPausable.js";
11
11
  //#region src/onchain/market/pool/PoolV310Contract.ts
12
12
  const abi = [...iPoolV310Abi, ...iPausableAbi];
13
13
  var PoolV310Contract = class extends BaseContract {
@@ -1,5 +1,5 @@
1
- import { iethZapperAbi } from "../../../abi/iETHZapper.js";
2
1
  import { ZapperContract } from "./ZapperContract.js";
2
+ import { iethZapperAbi } from "../../../abi/iETHZapper.js";
3
3
  //#region src/onchain/market/zapper/IETHZapperContract.ts
4
4
  const abi = iethZapperAbi;
5
5
  var IETHZapperContract = class extends ZapperContract {
@@ -1,8 +1,8 @@
1
- import { iZapperAbi } from "../../../abi/iZapper.js";
2
1
  import { BaseContract } from "../../base/BaseContract.js";
3
2
  import "../../base/index.js";
4
3
  import { sdkErr, sdkOk } from "../../../model/result.js";
5
4
  import "../../../model/index.js";
5
+ import { iZapperAbi } from "../../../abi/iZapper.js";
6
6
  //#region src/onchain/market/zapper/ZapperContract.ts
7
7
  /**
8
8
  * Base contract for every Gearbox zapper. Specialized zappers (e.g.
@@ -1,6 +1,6 @@
1
1
  import { errorAbis } from "../../../abi/errors.js";
2
- import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
3
2
  import { generateCastTraceCall } from "./cast.js";
3
+ import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
4
4
  import { simulateMulticall } from "./simulateMulticall.js";
5
5
  import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
6
6
  import { getAction, parseAccount } from "viem/utils";
@@ -1,7 +1,7 @@
1
- import { iZapperAbi } from "../../abi/iZapper.js";
2
1
  import { iPoolV310Abi } from "../../abi/310/generated.js";
3
2
  import { sdkErr, sdkOk } from "../../model/result.js";
4
3
  import "../../model/index.js";
4
+ import { iZapperAbi } from "../../abi/iZapper.js";
5
5
  import { asPreviewSimulationError } from "./errors.js";
6
6
  //#region src/preview/simulate/simulatePoolOperation.ts
7
7
  function previewRead(operation) {
@@ -1,5 +1,5 @@
1
- import { ierc20Abi } from "../../abi/iERC20.js";
2
1
  import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
2
+ import { ierc20Abi } from "../../abi/iERC20.js";
3
3
  import { AddressMap } from "../../onchain/utils/AddressMap.js";
4
4
  import "../../onchain/index.js";
5
5
  import { UnexpectedFacadeEventOrderError } from "./errors.js";
@@ -50,6 +50,12 @@ var PositionsNamespace = class extends AbstractNamespace {
50
50
  return this.offchain.getCharts(key, metrics, range);
51
51
  }
52
52
  /**
53
+ * {@inheritDoc IPositionsOffchainOnly.transactions}
54
+ **/
55
+ async transactions(key) {
56
+ return this.offchain.getTransactions(key);
57
+ }
58
+ /**
53
59
  * {@inheritDoc IPositionsOnchainOnly.getCurrentWithdrawals}
54
60
  **/
55
61
  async getCurrentWithdrawals(props) {
@@ -489,11 +489,27 @@ interface PositionsTotals {
489
489
  /**
490
490
  * What a transaction did to a position.
491
491
  **/
492
- type PositionTransactionKind = "open" | "deposit" | "withdraw" | "adjustLeverage" | "addCollateral" | "withdrawCollateral" | "liquidation";
492
+ type PositionTransactionKind = "open" | "deposit" | "withdraw" | "adjustLeverage" | "addCollateral" | "withdrawCollateral" | "liquidation" | "repay" |
493
+ /**
494
+ * The transaction only rearranged what the account already held — a swap, a
495
+ * claim or a quota change — without moving its net value or its debt.
496
+ **/
497
+ "rebalance" |
498
+ /**
499
+ * The residual kind: the transaction is not one of the above. Either the
500
+ * backend could not attribute the account's state movement completely, or
501
+ * the movements it did observe contradict each other (value left the
502
+ * account while debt grew, say), so no single intent describes it. Never a
503
+ * synonym for "nothing happened", and never a direction to infer from.
504
+ **/
505
+ "other";
493
506
  /**
494
507
  * One transaction in a position's history, from the backend's indexer.
495
508
  **/
496
509
  interface PositionTransaction {
510
+ /**
511
+ * Hash of the transaction.
512
+ **/
497
513
  txHash: Hex;
498
514
  /**
499
515
  * Unix seconds of the block the transaction was mined in.
@@ -501,9 +517,27 @@ interface PositionTransaction {
501
517
  timestamp: Timestamp;
502
518
  kind: PositionTransactionKind;
503
519
  /**
504
- * Assets the transaction moved, in the direction the kind implies.
520
+ * Net magnitudes of the assets the borrower moved. A directional kind
521
+ * supplies the direction; callers must not infer one for an `other`
522
+ * transaction.
505
523
  **/
506
524
  assets: TokenAmount[];
525
+ /**
526
+ * Signed change of every credit-account token balance caused by the
527
+ * transaction. Positive values were added to the account; negative values
528
+ * left it. Tokens whose balance did not change are omitted.
529
+ **/
530
+ balanceChanges: TokenAmount[];
531
+ /**
532
+ * Signed change of the position's total debt — principal plus accrued
533
+ * interest plus accrued fees — denominated in the market underlying. It is
534
+ * differenced between the backend's consecutive debt observations around
535
+ * the transaction, so it is what the borrower ends up owing, not the
536
+ * principal the transaction asked to move: a repayment outrun by accrued
537
+ * interest is positive, and a transaction that moved no principal at all
538
+ * can still carry the interest that accrued alongside it.
539
+ **/
540
+ debtChange: TokenAmount;
507
541
  }
508
542
  //#endregion
509
543
  export { BorrowRateBreakdown, PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, PositionTransaction, PositionTransactionKind, PositionsTotals, RewardsPnL, STRATEGY_POSITION_COLLATERAL_ERROR, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenQuotaRate, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId };
@@ -1027,14 +1027,14 @@ declare const positionsTotalsSchema: z.ZodObject<{
1027
1027
  /**
1028
1028
  * {@link PositionTransactionKind}
1029
1029
  **/
1030
- declare const positionTransactionKindSchema: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodLiteral<"deposit">, z.ZodLiteral<"withdraw">, z.ZodLiteral<"adjustLeverage">, z.ZodLiteral<"addCollateral">, z.ZodLiteral<"withdrawCollateral">, z.ZodLiteral<"liquidation">]>;
1030
+ declare const positionTransactionKindSchema: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodLiteral<"deposit">, z.ZodLiteral<"withdraw">, z.ZodLiteral<"adjustLeverage">, z.ZodLiteral<"addCollateral">, z.ZodLiteral<"withdrawCollateral">, z.ZodLiteral<"liquidation">, z.ZodLiteral<"repay">, z.ZodLiteral<"rebalance">, z.ZodLiteral<"other">]>;
1031
1031
  /**
1032
1032
  * {@link PositionTransaction}
1033
1033
  **/
1034
1034
  declare const positionTransactionSchema: z.ZodObject<{
1035
1035
  txHash: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
1036
1036
  timestamp: z.ZodNumber;
1037
- kind: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodLiteral<"deposit">, z.ZodLiteral<"withdraw">, z.ZodLiteral<"adjustLeverage">, z.ZodLiteral<"addCollateral">, z.ZodLiteral<"withdrawCollateral">, z.ZodLiteral<"liquidation">]>;
1037
+ kind: z.ZodUnion<readonly [z.ZodLiteral<"open">, z.ZodLiteral<"deposit">, z.ZodLiteral<"withdraw">, z.ZodLiteral<"adjustLeverage">, z.ZodLiteral<"addCollateral">, z.ZodLiteral<"withdrawCollateral">, z.ZodLiteral<"liquidation">, z.ZodLiteral<"repay">, z.ZodLiteral<"rebalance">, z.ZodLiteral<"other">]>;
1038
1038
  assets: z.ZodArray<z.ZodObject<{
1039
1039
  value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
1040
1040
  valueUsd: z.ZodNullable<z.ZodNumber>;
@@ -1047,6 +1047,30 @@ declare const positionTransactionSchema: z.ZodObject<{
1047
1047
  assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
1048
1048
  }, z.core.$strip>;
1049
1049
  }, z.core.$strip>>;
1050
+ balanceChanges: z.ZodArray<z.ZodObject<{
1051
+ value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
1052
+ valueUsd: z.ZodNullable<z.ZodNumber>;
1053
+ token: z.ZodObject<{
1054
+ chainId: z.ZodNumber;
1055
+ address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
1056
+ symbol: z.ZodString;
1057
+ name: z.ZodString;
1058
+ decimals: z.ZodNumber;
1059
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
1060
+ }, z.core.$strip>;
1061
+ }, z.core.$strip>>;
1062
+ debtChange: z.ZodObject<{
1063
+ value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
1064
+ valueUsd: z.ZodNullable<z.ZodNumber>;
1065
+ token: z.ZodObject<{
1066
+ chainId: z.ZodNumber;
1067
+ address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
1068
+ symbol: z.ZodString;
1069
+ name: z.ZodString;
1070
+ decimals: z.ZodNumber;
1071
+ assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
1072
+ }, z.core.$strip>;
1073
+ }, z.core.$strip>;
1050
1074
  }, z.core.$strip>;
1051
1075
  //#endregion
1052
1076
  export { borrowRateBreakdownSchema, pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema };
@@ -1,5 +1,5 @@
1
1
  import { ChartBundle, ChartRange } from "../../model/charts.js";
2
- import { Position, PositionKey, PositionsTotals } from "../../model/positions.js";
2
+ import { Position, PositionKey, PositionTransaction, PositionsTotals, StrategyPositionKey } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
5
5
  import { GearboxAPIOptions } from "../types.js";
@@ -25,6 +25,10 @@ declare class OffchainPositions extends AbstractOffchainNamespace implements IOf
25
25
  * {@inheritDoc IOffchainPositions.getCharts}
26
26
  **/
27
27
  getCharts<K extends PositionKey, const Metrics extends readonly PositionChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
28
+ /**
29
+ * {@inheritDoc IOffchainPositions.getTransactions}
30
+ **/
31
+ getTransactions(key: StrategyPositionKey): Promise<DataResponse<PositionTransaction[]>>;
28
32
  }
29
33
  //#endregion
30
34
  export { OffchainPositions };
@@ -1,5 +1,5 @@
1
1
  import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
2
- import { Position, PositionKey, PositionsTotals } from "../../model/positions.js";
2
+ import { Position, PositionKey, PositionTransaction, PositionsTotals, StrategyPositionKey } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { ListPositionsPropsBase } from "../../onchain/positions/types.js";
5
5
  import { Address } from "viem";
@@ -25,6 +25,12 @@ interface IOffchainPositions {
25
25
  * Charts of one position: one series per metric, on a shared grid.
26
26
  **/
27
27
  getCharts<K extends PositionKey, const Metrics extends readonly PositionChartMetricFor<K>[]>(key: K, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
28
+ /**
29
+ * Every transaction that touched the credit account while its current
30
+ * session was open, newest first. There is no paging, and an account with
31
+ * no open session answers with an empty list.
32
+ **/
33
+ getTransactions(key: StrategyPositionKey): Promise<DataResponse<PositionTransaction[]>>;
28
34
  }
29
35
  //#endregion
30
36
  export { IOffchainPositions, PositionChartMetricFor };
@@ -1,5 +1,5 @@
1
1
  import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
2
- import { PoolPositionRef, Position, PositionFilter, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
2
+ import { PoolPositionRef, Position, PositionFilter, PositionTransaction, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { PositionWithdrawals } from "../../model/withdrawals.js";
5
5
  import "../../model/index.js";
@@ -42,6 +42,10 @@ declare class PositionsNamespace extends AbstractNamespace<MultichainSDK["positi
42
42
  **/
43
43
  charts<const Metrics extends readonly PoolPositionChartMetric[]>(key: PoolPositionRef, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
44
44
  charts<const Metrics extends readonly StrategyPositionChartMetric[]>(key: StrategyPositionRef, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
45
+ /**
46
+ * {@inheritDoc IPositionsOffchainOnly.transactions}
47
+ **/
48
+ transactions(key: StrategyPositionRef): Promise<DataResponse<PositionTransaction[]>>;
45
49
  /**
46
50
  * {@inheritDoc IPositionsOnchainOnly.getCurrentWithdrawals}
47
51
  **/
@@ -1,5 +1,5 @@
1
1
  import { ChartBundle, ChartRange, PoolPositionChartMetric, StrategyPositionChartMetric } from "../../model/charts.js";
2
- import { PoolPositionRef, Position, PositionFilter, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
2
+ import { PoolPositionRef, Position, PositionFilter, PositionTransaction, PositionsTotals, StrategyPositionRef } from "../../model/positions.js";
3
3
  import { DataResponse } from "../../model/response.js";
4
4
  import { PositionWithdrawals } from "../../model/withdrawals.js";
5
5
  import "../../model/index.js";
@@ -57,6 +57,15 @@ interface IPositionsOffchainOnly {
57
57
  **/
58
58
  charts<const Metrics extends readonly PoolPositionChartMetric[]>(key: PoolPositionRef, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
59
59
  charts<const Metrics extends readonly StrategyPositionChartMetric[]>(key: StrategyPositionRef, metrics: Metrics, range: ChartRange): Promise<DataResponse<ChartBundle<Metrics>>>;
60
+ /**
61
+ * History of one strategy position: every transaction that touched the
62
+ * credit account while its current session was open, newest first. There is
63
+ * no paging, and an account with no open session answers with an empty list.
64
+ *
65
+ * Absent in `onchain` mode: the history is indexed by the backend rather
66
+ * than reconstructed from the chain.
67
+ **/
68
+ transactions(key: StrategyPositionRef): Promise<DataResponse<PositionTransaction[]>>;
60
69
  }
61
70
  /**
62
71
  * Reads only the chain can answer.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "16.0.0-next.48",
3
+ "version": "16.0.0-next.49",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {