@gearbox-protocol/sdk 14.12.0-next.77 → 14.12.0-next.79

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 (107) hide show
  1. package/dist/cjs/model/filters.js +20 -0
  2. package/dist/cjs/model/filters.schema.js +21 -0
  3. package/dist/cjs/model/index.js +6 -0
  4. package/dist/cjs/model/liquidations.js +10 -8
  5. package/dist/cjs/model/liquidations.schema.js +6 -5
  6. package/dist/cjs/model/opportunities.js +11 -9
  7. package/dist/cjs/model/opportunities.schema.js +7 -6
  8. package/dist/cjs/model/positions.js +10 -8
  9. package/dist/cjs/model/positions.schema.js +5 -4
  10. package/dist/cjs/model/primitives.schema.js +5 -4
  11. package/dist/cjs/preview/index.js +0 -1
  12. package/dist/cjs/preview/preview/buildDelayedPreview.js +4 -3
  13. package/dist/cjs/preview/preview/index.js +0 -1
  14. package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +3 -2
  15. package/dist/cjs/preview/preview/types.js +0 -16
  16. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +12 -38
  17. package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +1 -1
  18. package/dist/cjs/sdk/index.js +3 -0
  19. package/dist/cjs/sdk/market/MarketSuite.js +5 -3
  20. package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +10 -0
  21. package/dist/cjs/sdk/market/credit/expectedBalanceDeltas.js +25 -0
  22. package/dist/cjs/sdk/market/credit/index.js +2 -0
  23. package/dist/cjs/sdk/market/index.js +2 -0
  24. package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +5 -2
  25. package/dist/cjs/sdk/opportunities/OpportunitiesService.js +4 -1
  26. package/dist/cjs/sdk/positions/MultichainPositionsService.js +5 -2
  27. package/dist/cjs/sdk/positions/PositionsService.js +8 -4
  28. package/dist/cjs/sdk/utils/index.js +1 -0
  29. package/dist/cjs/sdk/utils/zod.js +36 -14
  30. package/dist/esm/model/filters.js +18 -0
  31. package/dist/esm/model/filters.schema.js +19 -0
  32. package/dist/esm/model/index.js +3 -1
  33. package/dist/esm/model/liquidations.js +10 -8
  34. package/dist/esm/model/liquidations.schema.js +6 -5
  35. package/dist/esm/model/opportunities.js +11 -9
  36. package/dist/esm/model/opportunities.schema.js +7 -6
  37. package/dist/esm/model/positions.js +10 -8
  38. package/dist/esm/model/positions.schema.js +5 -4
  39. package/dist/esm/model/primitives.schema.js +6 -5
  40. package/dist/esm/preview/index.js +2 -2
  41. package/dist/esm/preview/preview/buildDelayedPreview.js +5 -4
  42. package/dist/esm/preview/preview/index.js +2 -2
  43. package/dist/esm/preview/preview/previewAdjustCreditAccount.js +4 -3
  44. package/dist/esm/preview/preview/types.js +1 -16
  45. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +12 -38
  46. package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +1 -1
  47. package/dist/esm/sdk/index.js +3 -2
  48. package/dist/esm/sdk/market/MarketSuite.js +5 -3
  49. package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +10 -0
  50. package/dist/esm/sdk/market/credit/expectedBalanceDeltas.js +24 -0
  51. package/dist/esm/sdk/market/credit/index.js +2 -1
  52. package/dist/esm/sdk/market/index.js +2 -1
  53. package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +5 -2
  54. package/dist/esm/sdk/opportunities/OpportunitiesService.js +4 -1
  55. package/dist/esm/sdk/positions/MultichainPositionsService.js +5 -2
  56. package/dist/esm/sdk/positions/PositionsService.js +8 -4
  57. package/dist/esm/sdk/utils/index.js +2 -2
  58. package/dist/esm/sdk/utils/zod.js +36 -15
  59. package/dist/types/dev/AccountOpener.d.ts +1 -1
  60. package/dist/types/model/curators.schema.d.ts +1 -1
  61. package/dist/types/model/filters.d.ts +30 -0
  62. package/dist/types/model/filters.schema.d.ts +16 -0
  63. package/dist/types/model/history.schema.d.ts +6 -6
  64. package/dist/types/model/index.d.ts +3 -1
  65. package/dist/types/model/liquidations.d.ts +14 -10
  66. package/dist/types/model/liquidations.schema.d.ts +52 -52
  67. package/dist/types/model/opportunities.d.ts +15 -11
  68. package/dist/types/model/opportunities.schema.d.ts +107 -107
  69. package/dist/types/model/positions.d.ts +14 -10
  70. package/dist/types/model/positions.schema.d.ts +96 -96
  71. package/dist/types/model/primitives.d.ts +1 -0
  72. package/dist/types/model/primitives.schema.d.ts +9 -8
  73. package/dist/types/preview/index.d.ts +2 -2
  74. package/dist/types/preview/preview/index.d.ts +2 -2
  75. package/dist/types/preview/preview/types.d.ts +1 -16
  76. package/dist/types/sdk/OnchainSDK.d.ts +3 -3
  77. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +8 -7
  78. package/dist/types/sdk/accounts/bots/types.d.ts +1 -1
  79. package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressor.d.ts +1 -1
  80. package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.d.ts +1 -1
  81. package/dist/types/sdk/accounts/credit-account-compressor/types.d.ts +3 -3
  82. package/dist/types/sdk/accounts/index.d.ts +2 -2
  83. package/dist/types/sdk/accounts/intents/operations/repay-credit-account/index.d.ts +1 -2
  84. package/dist/types/sdk/accounts/liquidations/types.d.ts +1 -1
  85. package/dist/types/sdk/accounts/types.d.ts +8 -78
  86. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.d.ts +1 -1
  87. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.d.ts +1 -1
  88. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +1 -1
  89. package/dist/types/sdk/base/index.d.ts +2 -2
  90. package/dist/types/sdk/base/types.d.ts +43 -2
  91. package/dist/types/sdk/index.d.ts +25 -24
  92. package/dist/types/sdk/market/MarketSuite.d.ts +1 -1
  93. package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +6 -3
  94. package/dist/types/sdk/market/credit/CreditSuite.d.ts +2 -2
  95. package/dist/types/sdk/market/credit/expectedBalanceDeltas.d.ts +39 -0
  96. package/dist/types/sdk/market/credit/index.d.ts +3 -2
  97. package/dist/types/sdk/market/credit/types.d.ts +26 -3
  98. package/dist/types/sdk/market/index.d.ts +4 -3
  99. package/dist/types/sdk/market/rwa/index.d.ts +2 -2
  100. package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +1 -2
  101. package/dist/types/sdk/market/rwa/types.d.ts +11 -2
  102. package/dist/types/sdk/options.d.ts +4 -4
  103. package/dist/types/sdk/pools/types.d.ts +1 -12
  104. package/dist/types/sdk/positions/PositionsService.d.ts +1 -1
  105. package/dist/types/sdk/utils/index.d.ts +2 -2
  106. package/dist/types/sdk/utils/zod.d.ts +7 -3
  107. package/package.json +1 -1
@@ -26,7 +26,7 @@ import { fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage,
26
26
  import { hexEq } from "./utils/hex.js";
27
27
  import { retry } from "./utils/retry.js";
28
28
  import { toAddress } from "./utils/toAddress.js";
29
- import { ZodAddress, ZodHex } from "./utils/zod.js";
29
+ import { ZodAddress, ZodBigInt, ZodHex } from "./utils/zod.js";
30
30
  import "./utils/index.js";
31
31
  import { generateCastTraceCall, getCastTraceArgs } from "./utils/viem/cast.js";
32
32
  import { SimulationError, simulateCall } from "./utils/viem/simulateCall.js";
@@ -53,6 +53,7 @@ import { PARTIAL_LIQUIDATION_BUFFER_BPS, additionalBorrowApyBps, borrowApyBps, h
53
53
  import { CreditManagerV310Contract } from "./market/credit/CreditManagerV310Contract.js";
54
54
  import { dominantCollateral, mustGetDominantCollateral } from "./market/credit/dominantCollateral.js";
55
55
  import { CreditSuite } from "./market/credit/CreditSuite.js";
56
+ import { expectedBalanceDeltas } from "./market/credit/expectedBalanceDeltas.js";
56
57
  import { simulateMulticall } from "./utils/viem/simulateMulticall.js";
57
58
  import { SimulateWithPriceUpdatesError, getSimulateWithPriceUpdatesError, simulateWithPriceUpdates } from "./utils/viem/simulateWithPriceUpdates.js";
58
59
  import { executeDelegatedMulticalls } from "./utils/viem/executeDelegatedMulticalls.js";
@@ -147,4 +148,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
147
148
  import { MultichainSDK } from "./MultichainSDK.js";
148
149
  import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
149
150
  import "./types/index.js";
150
- export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, fetchPythPayloads, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, positionLeverage, primaryInstantOutput, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
151
+ export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, expectedBalanceDeltas, fetchPythPayloads, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, positionLeverage, primaryInstantOutput, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
@@ -7,6 +7,7 @@ import { rayToBps } from "./math.js";
7
7
  import { CreditSuite } from "./credit/CreditSuite.js";
8
8
  import "./credit/index.js";
9
9
  import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
10
+ import { isFilterSet } from "../../model/filters.js";
10
11
  import { matchesOpportunityFilter } from "../../model/opportunities.js";
11
12
  import "../../model/index.js";
12
13
  import { createLossPolicy } from "./loss-policy/createLossPolicy.js";
@@ -199,12 +200,13 @@ var MarketSuite = class extends SDKConstruct {
199
200
  * @param filter - Optional narrowing. A filter naming a kind skips building
200
201
  * the other kind entirely; every built row is then checked in full by
201
202
  * {@link matchesOpportunityFilter}, so there is one definition of what each
202
- * criterion means.
203
+ * condition means.
203
204
  */
204
205
  opportunities(filter) {
205
206
  const rows = [];
206
- if (filter?.kind !== "strategy") rows.push(this.poolOpportunity());
207
- if (filter?.kind !== "pool") for (const { suite, collateral } of this.strategies) rows.push(suite.strategyOpportunity(collateral));
207
+ const kind = filter?.kind;
208
+ if (!isFilterSet(kind) || kind === "pool") rows.push(this.poolOpportunity());
209
+ if (!isFilterSet(kind) || kind === "strategy") for (const { suite, collateral } of this.strategies) rows.push(suite.strategyOpportunity(collateral));
208
210
  return rows.filter((row) => matchesOpportunityFilter(row, filter));
209
211
  }
210
212
  /**
@@ -288,6 +288,16 @@ var CreditFacadeV310Contract = class extends CreditFacadeV310BaseContract {
288
288
  })
289
289
  };
290
290
  }
291
+ /**
292
+ * {@inheritDoc ICreditFacadeContract.prepareWithBalanceCheck}
293
+ */
294
+ prepareWithBalanceCheck(deltas, calls) {
295
+ return [
296
+ this.prepareStoreExpectedBalances(deltas),
297
+ ...calls,
298
+ this.prepareCompareBalances()
299
+ ];
300
+ }
291
301
  };
292
302
  //#endregion
293
303
  export { CreditFacadeV310Contract };
@@ -0,0 +1,24 @@
1
+ import { AssetsMap } from "../../utils/AssetsMap.js";
2
+ import { DUST_THRESHOLD } from "../../constants/math.js";
3
+ import "../../constants/index.js";
4
+ import "../../utils/index.js";
5
+ //#region src/sdk/market/credit/expectedBalanceDeltas.ts
6
+ /**
7
+ * Builds the `storeExpectedBalances` deltas of a multicall from the amounts it
8
+ * is expected to produce and the token it spends.
9
+ */
10
+ function expectedBalanceDeltas({ outputs, spentToken, spentAmount }) {
11
+ const sums = new AssetsMap();
12
+ for (const { token, amount } of outputs) sums.inc(token, amount);
13
+ const deltas = sums.entries().filter(([, amount]) => amount > DUST_THRESHOLD).map(([token, amount]) => ({
14
+ token,
15
+ amount: amount - DUST_THRESHOLD
16
+ }));
17
+ if (spentAmount > 0n) deltas.push({
18
+ token: spentToken,
19
+ amount: -spentAmount
20
+ });
21
+ return deltas;
22
+ }
23
+ //#endregion
24
+ export { expectedBalanceDeltas };
@@ -4,5 +4,6 @@ import { CreditFacadeV310Contract } from "./CreditFacadeV310Contract.js";
4
4
  import { CreditManagerV310Contract } from "./CreditManagerV310Contract.js";
5
5
  import { dominantCollateral, mustGetDominantCollateral } from "./dominantCollateral.js";
6
6
  import { CreditSuite } from "./CreditSuite.js";
7
+ import { expectedBalanceDeltas } from "./expectedBalanceDeltas.js";
7
8
  import "./types.js";
8
- export { CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, abi as creditFacadeV310Abi, dominantCollateral, mustGetDominantCollateral };
9
+ export { CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, abi as creditFacadeV310Abi, dominantCollateral, expectedBalanceDeltas, mustGetDominantCollateral };
@@ -7,6 +7,7 @@ import { CreditFacadeV310Contract } from "./credit/CreditFacadeV310Contract.js";
7
7
  import { CreditManagerV310Contract } from "./credit/CreditManagerV310Contract.js";
8
8
  import { dominantCollateral, mustGetDominantCollateral } from "./credit/dominantCollateral.js";
9
9
  import { CreditSuite } from "./credit/CreditSuite.js";
10
+ import { expectedBalanceDeltas } from "./credit/expectedBalanceDeltas.js";
10
11
  import "./credit/index.js";
11
12
  import { isUpdatablePriceFeed } from "./pricefeeds/isUpdatablePriceFeed.js";
12
13
  import { PriceFeedRef } from "./pricefeeds/PriceFeedRef.js";
@@ -59,4 +60,4 @@ import { RWARegistry } from "./rwa/RWARegistry.js";
59
60
  import { RWA_FACTORY_TYPES, isRWAFactory } from "./rwa/types.js";
60
61
  import "./rwa/index.js";
61
62
  import "./types.js";
62
- export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, LinearInterestRateModelContract, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PlaceholderAdapterContract, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeLiquidatorContract, SecuritizeRWAFactory, UnsupportedZapperFunctionError, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, dominantCollateral, fetchPythPayloads, fetchRedstonePayloads, getRawPriceUpdates, isLPPriceFeed, isRWAFactory, isUpdatablePriceFeed, mustGetDominantCollateral };
63
+ export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, LinearInterestRateModelContract, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PlaceholderAdapterContract, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeLiquidatorContract, SecuritizeRWAFactory, UnsupportedZapperFunctionError, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, dominantCollateral, expectedBalanceDeltas, fetchPythPayloads, fetchRedstonePayloads, getRawPriceUpdates, isLPPriceFeed, isRWAFactory, isUpdatablePriceFeed, mustGetDominantCollateral };
@@ -1,6 +1,8 @@
1
1
  import { getNetworkType } from "../chain/chains.js";
2
2
  import { MultichainConstruct } from "../base/MultichainConstruct.js";
3
3
  import "../base/index.js";
4
+ import { isFilterSet } from "../../model/filters.js";
5
+ import "../../model/index.js";
4
6
  //#region src/sdk/opportunities/MultichainOpportunitiesService.ts
5
7
  /**
6
8
  * Cross-chain counterpart of {@link OpportunitiesService}.
@@ -45,9 +47,10 @@ var MultichainOpportunitiesService = class extends MultichainConstruct {
45
47
  * a filter naming them is a narrowing, not a request.
46
48
  **/
47
49
  #networksOf(filter) {
48
- if (!filter?.chainIds) return;
50
+ const chainIds = filter?.chainIds;
51
+ if (!isFilterSet(chainIds)) return;
49
52
  const networks = [];
50
- for (const chainId of filter.chainIds) try {
53
+ for (const chainId of chainIds) try {
51
54
  networks.push(getNetworkType(chainId));
52
55
  } catch {
53
56
  this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in opportunities filter`);
@@ -1,5 +1,7 @@
1
1
  import { SDKConstruct } from "../base/SDKConstruct.js";
2
2
  import "../base/index.js";
3
+ import { isFilterSet } from "../../model/filters.js";
4
+ import "../../model/index.js";
3
5
  //#region src/sdk/opportunities/OpportunitiesService.ts
4
6
  /**
5
7
  * Builds the `opportunities` read model from the chain.
@@ -21,7 +23,8 @@ var OpportunitiesService = class extends SDKConstruct {
21
23
  * @param filter - Optional narrowing, applied to the built rows.
22
24
  **/
23
25
  async list(filter) {
24
- if (filter?.chainIds && !filter.chainIds.includes(this.chainId)) return [];
26
+ const chainIds = filter?.chainIds;
27
+ if (isFilterSet(chainIds) && !chainIds.includes(this.chainId)) return [];
25
28
  return this.sdk.marketRegister.markets.flatMap((market) => market.opportunities(filter));
26
29
  }
27
30
  /**
@@ -1,6 +1,8 @@
1
1
  import { getNetworkType } from "../chain/chains.js";
2
2
  import { MultichainConstruct } from "../base/MultichainConstruct.js";
3
3
  import "../base/index.js";
4
+ import { isFilterSet } from "../../model/filters.js";
5
+ import "../../model/index.js";
4
6
  //#region src/sdk/positions/MultichainPositionsService.ts
5
7
  /**
6
8
  * Cross-chain counterpart of {@link PositionsService}.
@@ -33,9 +35,10 @@ var MultichainPositionsService = class extends MultichainConstruct {
33
35
  * a filter naming them is a narrowing, not a request.
34
36
  **/
35
37
  #networksOf(filter) {
36
- if (!filter?.chainIds) return;
38
+ const chainIds = filter?.chainIds;
39
+ if (!isFilterSet(chainIds)) return;
37
40
  const networks = [];
38
- for (const chainId of filter.chainIds) try {
41
+ for (const chainId of chainIds) try {
39
42
  networks.push(getNetworkType(chainId));
40
43
  } catch {
41
44
  this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in positions filter`);
@@ -1,5 +1,6 @@
1
1
  import { SDKConstruct } from "../base/SDKConstruct.js";
2
2
  import "../base/index.js";
3
+ import { isFilterSet } from "../../model/filters.js";
3
4
  import { matchesPositionFilter } from "../../model/positions.js";
4
5
  import "../../model/index.js";
5
6
  //#region src/sdk/positions/PositionsService.ts
@@ -12,18 +13,21 @@ var PositionsService = class extends SDKConstruct {
12
13
  /**
13
14
  * Every position of a wallet on this chain, optionally narrowed by
14
15
  * {@link PositionFilter} (see {@link matchesPositionFilter} for what each
15
- * criterion selects). Reads live chain state, so rows reflect the moment of
16
+ * condition selects). Reads live chain state, so rows reflect the moment of
16
17
  * the call rather than the SDK's loaded snapshot.
17
18
  **/
18
19
  async list(props) {
19
20
  const { wallet, filter } = props;
20
- if (filter?.chainIds && !filter.chainIds.includes(this.chainId)) return [];
21
- const wanted = (kind) => !filter?.kind || filter.kind === kind;
21
+ const chainIds = filter?.chainIds;
22
+ if (isFilterSet(chainIds) && !chainIds.includes(this.chainId)) return [];
23
+ const wantedKind = filter?.kind;
24
+ const wanted = (kind) => !isFilterSet(wantedKind) || wantedKind === kind;
25
+ const isZeroDebt = filter?.isZeroDebt;
22
26
  const [pool, strategy, liquidation] = await Promise.all([
23
27
  wanted("pool") ? this.sdk.pools.listPositions({ wallet }) : Promise.resolve([]),
24
28
  wanted("strategy") ? this.sdk.accounts.listPositions({
25
29
  owner: wallet,
26
- includeZeroDebt: filter?.isZeroDebt !== false
30
+ includeZeroDebt: !isFilterSet(isZeroDebt) || isZeroDebt
27
31
  }) : Promise.resolve([]),
28
32
  wanted("liquidation") ? this.sdk.liquidations.getLiquidationPositions({ liquidator: wallet }) : Promise.resolve([])
29
33
  ]);
@@ -16,5 +16,5 @@ import { hexEq } from "./hex.js";
16
16
  import { retry } from "./retry.js";
17
17
  import { toAddress } from "./toAddress.js";
18
18
  import "./type-utils.js";
19
- import { ZodAddress, ZodHex } from "./zod.js";
20
- export { AddressMap, AddressSet, AssetsMap, BigIntMath, TypedObjectUtils, ZodAddress, ZodHex, bytes32ToString, childLogger, createRawTx, etherscanApiUrl, etherscanUrl, filterDust, filterDustUSD, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, getFunctionSignature, hexEq, isDust, json_parse, json_stringify, numberWithCommas, percentFmt, rayToNumber, retry, shortAddress, shortHash, toAddress, toBN, toBigInt, toSignificant };
19
+ import { ZodAddress, ZodBigInt, ZodHex } from "./zod.js";
20
+ export { AddressMap, AddressSet, AssetsMap, BigIntMath, TypedObjectUtils, ZodAddress, ZodBigInt, ZodHex, bytes32ToString, childLogger, createRawTx, etherscanApiUrl, etherscanUrl, filterDust, filterDustUSD, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, getFunctionSignature, hexEq, isDust, json_parse, json_stringify, numberWithCommas, percentFmt, rayToNumber, retry, shortAddress, shortHash, toAddress, toBN, toBigInt, toSignificant };
@@ -2,26 +2,47 @@ import { getAddress, isAddress, isHex } from "viem";
2
2
  import { z } from "zod/v4";
3
3
  //#region src/sdk/utils/zod.ts
4
4
  /**
5
+ * A `bigint` codec that serializes into string, deserializes into bigint.
6
+ */
7
+ const ZodBigInt = () => z.codec(z.union([z.string().regex(z.regexes.integer), z.bigint()]), z.bigint(), {
8
+ decode: (value) => typeof value === "bigint" ? value : BigInt(value),
9
+ encode: (value) => value.toString()
10
+ });
11
+ const addressOut = z.custom((val) => typeof val === "string" && isAddress(val, { strict: false }));
12
+ /**
5
13
  * Like Address from abitype/zod, but converts an address into an address that is checksum encoded.
6
14
  */
7
- const ZodAddress = () => z.string().transform((val, ctx) => {
8
- if (!isAddress(val)) ctx.issues.push({
9
- code: "custom",
10
- message: `invalid address ${val}`,
11
- input: ctx.value
12
- });
13
- return getAddress(val);
15
+ const ZodAddress = () => z.codec(z.string(), addressOut, {
16
+ decode: (val, ctx) => {
17
+ if (!isAddress(val, { strict: false })) {
18
+ ctx.issues.push({
19
+ code: "custom",
20
+ message: `invalid address ${val}`,
21
+ input: val
22
+ });
23
+ return z.NEVER;
24
+ }
25
+ return getAddress(val);
26
+ },
27
+ encode: (address) => address
14
28
  });
29
+ const hexOut = z.custom((val) => typeof val === "string" && isHex(val));
15
30
  /**
16
31
  * A `0x`-prefixed hex string, as viem's Hex.
17
32
  */
18
- const ZodHex = () => z.string().transform((val, ctx) => {
19
- if (!isHex(val)) ctx.issues.push({
20
- code: "custom",
21
- message: `invalid hex string ${val}`,
22
- input: ctx.value
23
- });
24
- return val;
33
+ const ZodHex = () => z.codec(z.string(), hexOut, {
34
+ decode: (val, ctx) => {
35
+ if (!isHex(val)) {
36
+ ctx.issues.push({
37
+ code: "custom",
38
+ message: `invalid hex string ${val}`,
39
+ input: val
40
+ });
41
+ return z.NEVER;
42
+ }
43
+ return val;
44
+ },
45
+ encode: (hex) => hex
25
46
  });
26
47
  //#endregion
27
- export { ZodAddress, ZodHex };
48
+ export { ZodAddress, ZodBigInt, ZodHex };
@@ -1,7 +1,7 @@
1
1
  import { Asset, CreditAccountData } from "../sdk/base/types.js";
2
- import { ICreditAccountsService } from "../sdk/accounts/types.js";
3
2
  import { RawTx } from "../sdk/types/transactions.js";
4
3
  import { SDKConstruct } from "../sdk/base/SDKConstruct.js";
4
+ import { ICreditAccountsService } from "../sdk/accounts/types.js";
5
5
  import "../sdk/index.js";
6
6
  import { Address, BaseError, Hash, Hex, PrivateKeyAccount } from "viem";
7
7
  //#region src/dev/AccountOpener.d.ts
@@ -27,7 +27,7 @@ declare const curatorNameSchema: z.ZodEnum<{
27
27
  * {@link Curator}
28
28
  **/
29
29
  declare const curatorSchema: z.ZodObject<{
30
- address: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
30
+ address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
31
31
  name: z.ZodOptional<z.ZodEnum<{
32
32
  "Chaos Labs": "Chaos Labs";
33
33
  "Gami Labs": "Gami Labs";
@@ -0,0 +1,30 @@
1
+ //#region src/model/filters.d.ts
2
+ /**
3
+ * The vocabulary every read-model filter is written in: how a single condition
4
+ * says "do not narrow", and how a predicate asks whether it narrows at all.
5
+ **/
6
+ /**
7
+ * Sentinel a filter condition can be set to instead of being omitted.
8
+ **/
9
+ declare const FILTER_ALL = "all";
10
+ /**
11
+ * Type of {@link FILTER_ALL}.
12
+ **/
13
+ type FilterAll = typeof FILTER_ALL;
14
+ /**
15
+ * A filter condition: a value, the {@link FILTER_ALL} sentinel, or omitted.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const kind: Filterable<OpportunityKind> = "pool"; // only pools
20
+ * const anyKind: Filterable<OpportunityKind> = "all"; // pools and strategies
21
+ * ```
22
+ **/
23
+ type Filterable<T> = T | FilterAll;
24
+ /**
25
+ * Whether a condition narrows anything. An omitted condition and one set to
26
+ * {@link FILTER_ALL} both do not, so this is the only check a predicate needs.
27
+ **/
28
+ declare function isFilterSet<T>(condition: Filterable<T> | undefined): condition is T;
29
+ //#endregion
30
+ export { FILTER_ALL, FilterAll, Filterable, isFilterSet };
@@ -0,0 +1,16 @@
1
+ import { z } from "zod/v4";
2
+ //#region src/model/filters.schema.d.ts
3
+ /**
4
+ * Runtime schemas for {@link ./filters.js}, see the note in
5
+ * `primitives.schema.ts` on why they are written by hand.
6
+ **/
7
+ /**
8
+ * {@link FilterAll}
9
+ **/
10
+ declare const filterAllSchema: z.ZodLiteral<"all">;
11
+ /**
12
+ * {@link Filterable}
13
+ **/
14
+ declare function filterable<T extends z.ZodType>(schema: T): z.ZodUnion<[T, typeof filterAllSchema]>;
15
+ //#endregion
16
+ export { filterAllSchema, filterable };
@@ -63,12 +63,12 @@ declare const historySeriesSchema: z.ZodObject<{
63
63
  declare const opportunityHistoryQuerySchema: z.ZodObject<{
64
64
  opportunity: z.ZodDiscriminatedUnion<[z.ZodObject<{
65
65
  chainId: z.ZodNumber;
66
- pool: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
66
+ pool: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
67
67
  kind: z.ZodLiteral<"pool">;
68
68
  }, z.core.$strip>, z.ZodObject<{
69
69
  chainId: z.ZodNumber;
70
- creditManager: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
71
- targetCollateral: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
70
+ creditManager: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
71
+ targetCollateral: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
72
72
  kind: z.ZodLiteral<"strategy">;
73
73
  }, z.core.$strip>], "kind">;
74
74
  range: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
@@ -80,12 +80,12 @@ declare const opportunityHistoryQuerySchema: z.ZodObject<{
80
80
  declare const positionHistoryQuerySchema: z.ZodObject<{
81
81
  position: z.ZodDiscriminatedUnion<[z.ZodObject<{
82
82
  chainId: z.ZodNumber;
83
- pool: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
84
- wallet: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
83
+ pool: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
84
+ wallet: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
85
85
  kind: z.ZodLiteral<"pool">;
86
86
  }, z.core.$strip>, z.ZodObject<{
87
87
  chainId: z.ZodNumber;
88
- creditAccount: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
88
+ creditAccount: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
89
89
  kind: z.ZodLiteral<"strategy">;
90
90
  }, z.core.$strip>], "kind">;
91
91
  range: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
@@ -1,6 +1,8 @@
1
1
  import { Curator, CuratorName } from "./curators.js";
2
2
  import { Amount, AssetType, Bps, ChainId, Leverage, Timestamp, Token, TokenAmount, TxCall } from "./primitives.js";
3
3
  import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
4
+ import { FILTER_ALL, FilterAll, Filterable, isFilterSet } from "./filters.js";
5
+ import { filterAllSchema, filterable } from "./filters.schema.js";
4
6
  import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
5
7
  import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
6
8
  import { PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionId, PositionKey, PositionKind, RewardsPnL, StrategyPosition, StrategyPositionKey, StrategyPositionRef, TokenRewardsPnL, liquidationPositionId, matchesPositionFilter, poolPositionId, positionId, strategyPositionId } from "./positions.js";
@@ -10,4 +12,4 @@ import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAcc
10
12
  import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
11
13
  import { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
12
14
  import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
13
- export { Amount, ApyBreakdown, AssetType, Bps, ChainId, Curator, CuratorName, DelayedReceivedAsset, HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityHistoryQuery, OpportunityId, OpportunityKey, OpportunityKind, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolHistoryMetric, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionHistoryMetric, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionHistoryMetric, PositionHistoryQuery, PositionId, PositionKey, PositionKind, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, Rewards, RewardsPnL, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, StrategyHistoryMetric, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionHistoryMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenRewards, TokenRewardsPnL, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorNameSchema, curatorSchema, delayedReceivedAssetSchema, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionHistoryMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, positionId, positionKeySchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionHistoryMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
15
+ export { Amount, ApyBreakdown, AssetType, Bps, ChainId, Curator, CuratorName, DelayedReceivedAsset, FILTER_ALL, FilterAll, Filterable, HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityHistoryQuery, OpportunityId, OpportunityKey, OpportunityKind, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolHistoryMetric, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, PoolPositionHistoryMetric, PoolPositionKey, PoolPositionRef, Position, PositionCollateral, PositionFilter, PositionHistoryMetric, PositionHistoryQuery, PositionId, PositionKey, PositionKind, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, Rewards, RewardsPnL, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, StrategyHistoryMetric, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, StrategyPositionHistoryMetric, StrategyPositionKey, StrategyPositionRef, Timestamp, Token, TokenAmount, TokenRewards, TokenRewardsPnL, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorNameSchema, curatorSchema, delayedReceivedAssetSchema, filterAllSchema, filterable, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionHistoryMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, positionId, positionKeySchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionHistoryMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
@@ -1,36 +1,39 @@
1
1
  import { AssetType, ChainId, Timestamp, Token, TokenAmount, TxCall } from "./primitives.js";
2
+ import { Filterable } from "./filters.js";
2
3
  import { Address } from "viem";
3
4
  //#region src/model/liquidations.d.ts
4
5
  /**
5
6
  * Optional narrowing of a liquidatable accounts list.
6
7
  *
7
- * Every criterion is optional and an omitted one matches any value, so an empty
8
- * filter is the same as no filter at all. Criteria combine with AND.
8
+ * Every condition is optional and an omitted one matches any value, so an
9
+ * empty filter is the same as no filter at all. A condition can also be set to
10
+ * `"all"` to say the same thing explicitly, which is what a UI whose state has
11
+ * an "any" option holds, see {@link Filterable}. Conditions combine with AND.
9
12
  **/
10
13
  interface LiquidatableAccountFilter {
11
14
  /**
12
15
  * Keep only accounts on these chains.
13
16
  **/
14
- chainIds?: ChainId[];
17
+ chainIds?: Filterable<ChainId[]>;
15
18
  /**
16
19
  * Keep only accounts whose underlying — the token of
17
20
  * {@link LiquidatableAccount.totalValue} — is of this class.
18
21
  **/
19
- underlyingType?: AssetType;
22
+ underlyingType?: Filterable<AssetType>;
20
23
  /**
21
24
  * Keep only accounts of paused credit facades, or only of unpaused ones.
22
25
  **/
23
- paused?: boolean;
26
+ paused?: Filterable<boolean>;
24
27
  /**
25
28
  * Keep only accounts in markets that accept RWA collateral, or only the ones
26
29
  * outside them.
27
30
  **/
28
- rwa?: boolean;
31
+ rwa?: Filterable<boolean>;
29
32
  /**
30
33
  * Keep only accounts with (`true`) or without (`false`) delayed
31
34
  * (phantom-token) withdrawals.
32
35
  **/
33
- delayed?: boolean;
36
+ delayed?: Filterable<boolean>;
34
37
  }
35
38
  /**
36
39
  * A credit account that can be liquidated, with amounts precomputed for
@@ -90,14 +93,15 @@ interface LiquidatableAccount {
90
93
  rwa: boolean;
91
94
  }
92
95
  /**
93
- * Whether a liquidatable account satisfies every criterion of a filter.
96
+ * Whether a liquidatable account satisfies every condition of a filter.
94
97
  *
95
- * This is the single definition of what each criterion means: every source
98
+ * This is the single definition of what each condition means: every source
96
99
  * builds its rows first and runs them through here, so the chain and the
97
100
  * backend cannot disagree on what a filter selects.
98
101
  *
99
102
  * @param account - Row to test.
100
- * @param filter - Criteria to test against. An absent filter matches anything.
103
+ * @param filter - Conditions to test against. An absent filter matches
104
+ * anything.
101
105
  **/
102
106
  declare function matchesLiquidatableAccountFilter(account: LiquidatableAccount, filter?: LiquidatableAccountFilter): boolean;
103
107
  /**