@gearbox-protocol/sdk 16.0.0-next.45 → 16.0.0-next.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/withdrawals.schema.js +7 -2
- package/dist/cjs/onchain/accounts/intents/index.js +38 -13
- package/dist/cjs/onchain/accounts/intents/tail.js +112 -5
- package/dist/cjs/onchain/index.js +0 -2
- package/dist/cjs/onchain/market/MarketSuite.js +9 -1
- package/dist/cjs/onchain/market/credit/CreditSuite.js +1 -2
- package/dist/cjs/onchain/market/pool/PoolV310Contract.js +25 -0
- package/dist/cjs/onchain/pools/PoolService.js +5 -40
- package/dist/cjs/onchain/pools/index.js +0 -2
- package/dist/cjs/onchain/positions/PositionsService.js +8 -2
- package/dist/cjs/preview/preview/previewPoolPositionOperation.js +31 -12
- package/dist/cjs/preview/simulate/index.js +1 -1
- package/dist/cjs/preview/simulate/simulateOperation.js +1 -1
- package/dist/cjs/preview/simulate/simulatePoolOperation.js +2 -0
- package/dist/cjs/sdk/prepare/PrepareApi.js +132 -82
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/index.js +2 -2
- package/dist/esm/model/withdrawals.schema.js +7 -3
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/onchain/accounts/intents/index.js +38 -13
- package/dist/esm/onchain/accounts/intents/tail.js +112 -5
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/onchain/base/TokensMeta.js +3 -3
- package/dist/esm/onchain/core/createAddressProvider.js +1 -1
- package/dist/esm/onchain/index.js +2 -2
- package/dist/esm/onchain/market/MarketSuite.js +9 -1
- package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
- package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/onchain/market/credit/CreditSuite.js +1 -2
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +26 -1
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/pools/PoolService.js +7 -40
- package/dist/esm/onchain/pools/index.js +2 -2
- package/dist/esm/onchain/positions/PositionsService.js +8 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/preview/preview/previewPoolPositionOperation.js +33 -14
- package/dist/esm/preview/simulate/index.js +1 -1
- package/dist/esm/preview/simulate/simulateOperation.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +2 -2
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/prepare/PrepareApi.js +132 -82
- package/dist/types/model/index.d.ts +3 -3
- package/dist/types/model/positions.d.ts +4 -1
- package/dist/types/model/previews.d.ts +28 -12
- package/dist/types/model/withdrawals.d.ts +24 -5
- package/dist/types/model/withdrawals.schema.d.ts +21 -1
- package/dist/types/onchain/accounts/index.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +19 -11
- package/dist/types/onchain/accounts/intents/tail.d.ts +13 -3
- package/dist/types/onchain/accounts/intents/types.d.ts +74 -1
- package/dist/types/onchain/index.d.ts +3 -3
- package/dist/types/onchain/market/MarketSuite.d.ts +6 -0
- package/dist/types/onchain/market/pool/PoolV310Contract.d.ts +12 -0
- package/dist/types/onchain/market/pool/types.d.ts +18 -0
- package/dist/types/onchain/pools/PoolService.d.ts +1 -19
- package/dist/types/onchain/pools/index.d.ts +2 -2
- package/dist/types/preview/simulate/simulatePoolOperation.d.ts +18 -1
- package/dist/types/preview/simulate/types.d.ts +12 -4
- package/dist/types/sdk/index.d.ts +3 -3
- package/dist/types/sdk/prepare/PrepareApi.d.ts +8 -7
- package/dist/types/sdk/prepare/index.d.ts +3 -3
- package/dist/types/sdk/prepare/types.d.ts +87 -28
- package/package.json +1 -1
|
@@ -224,7 +224,7 @@ import "./opportunities/index.js";
|
|
|
224
224
|
import { BasePlugin } from "./plugins/BasePlugin.js";
|
|
225
225
|
import { PluginStateVersionError } from "./plugins/errors.js";
|
|
226
226
|
import "./plugins/index.js";
|
|
227
|
-
import { PoolService
|
|
227
|
+
import { PoolService } from "./pools/PoolService.js";
|
|
228
228
|
import "./pools/index.js";
|
|
229
229
|
import { calcBorrowRate } from "./positions/calcBorrowRate.js";
|
|
230
230
|
import { calcHealthFactor } from "./positions/calcHealthFactor.js";
|
|
@@ -244,4 +244,4 @@ import { MultichainSDK } from "./MultichainSDK.js";
|
|
|
244
244
|
import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
|
|
245
245
|
import "./types/index.js";
|
|
246
246
|
import "./validation/index.js";
|
|
247
|
-
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, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, 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, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, 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, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, borrowable, botPermissionsToString, bpsToRay, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkBorrowLimit, checkCollateralised, checkCreditManagerPaused, checkDebtInBand, checkForbiddenToken, checkFunding, checkLeverageAtLeastOne, checkMarketExpired, checkPoolPaused, checkPoolPayout, checkPoolSunset, checkPreviewError, checkQuotaCount, checkQuotaLimit, childLogger, classifyCurveOperation, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isDust, isLPPriceFeed, isMalformedPreviewError, isPhantomToken, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, percentFmt, pickStrategyTargetCollateral, raise, rayToBps, rayToNumber, refuse, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
247
|
+
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, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, 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, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, 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, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, borrowable, botPermissionsToString, bpsToRay, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkBorrowLimit, checkCollateralised, checkCreditManagerPaused, checkDebtInBand, checkForbiddenToken, checkFunding, checkLeverageAtLeastOne, checkMarketExpired, checkPoolPaused, checkPoolPayout, checkPoolSunset, checkPreviewError, checkQuotaCount, checkQuotaLimit, childLogger, classifyCurveOperation, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isDust, isLPPriceFeed, isMalformedPreviewError, isPhantomToken, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, percentFmt, pickStrategyTargetCollateral, raise, rayToBps, rayToNumber, refuse, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
@@ -127,6 +127,14 @@ var MarketSuite = class extends SDKConstruct {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
/**
|
|
130
|
+
* Whether `token` is this market's pool underlying or the asset it wraps
|
|
131
|
+
* (dcUSDC or USDC on an RWA pool). Amounts in either unit are 1:1 with the
|
|
132
|
+
* figure {@link toUnderlyingAmount} reports.
|
|
133
|
+
*/
|
|
134
|
+
isUnderlyingLike(token) {
|
|
135
|
+
return isAddressEqual(token, this.underlying) || isAddressEqual(token, this.unwrappedUnderlying);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
130
138
|
* Prices a figure already denominated in this market's underlying — a debt,
|
|
131
139
|
* a TVL, a payout — as the read model reports one.
|
|
132
140
|
*
|
|
@@ -165,7 +173,7 @@ var MarketSuite = class extends SDKConstruct {
|
|
|
165
173
|
seen.upsert(this.unwrappedUnderlying, this.underlyingToken);
|
|
166
174
|
for (const zapper of this.sdk.marketRegister.poolZappers(this.pool.pool.address)) {
|
|
167
175
|
const tokenIn = zapper.tokenIn.addr;
|
|
168
|
-
if (
|
|
176
|
+
if (this.isUnderlyingLike(tokenIn)) continue;
|
|
169
177
|
seen.upsert(tokenIn, this.tokensMeta.mustGetToken(tokenIn));
|
|
170
178
|
}
|
|
171
179
|
return seen.values();
|
|
@@ -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,
|
|
@@ -391,8 +391,7 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
391
391
|
*/
|
|
392
392
|
#allowedDepositTokens(targetCollateral) {
|
|
393
393
|
const unwrappedUnderlying = this.market.unwrappedUnderlying;
|
|
394
|
-
const
|
|
395
|
-
const skip = (token) => isAddressEqual(token, unwrappedUnderlying) || isAddressEqual(token, contractUnderlying) || isAddressEqual(token, targetCollateral);
|
|
394
|
+
const skip = (token) => this.market.isUnderlyingLike(token) || isAddressEqual(token, targetCollateral);
|
|
396
395
|
return [
|
|
397
396
|
unwrappedUnderlying,
|
|
398
397
|
targetCollateral,
|
|
@@ -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 {
|
|
@@ -50,6 +50,31 @@ var PoolV310Contract = class extends BaseContract {
|
|
|
50
50
|
return this.totalSupply * this.dieselRate / RAY;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
+
* {@inheritDoc IPoolContract.getShareBalance}
|
|
54
|
+
*/
|
|
55
|
+
async getShareBalance(wallet, blockNumber) {
|
|
56
|
+
return this.client.readContract({
|
|
57
|
+
address: this.address,
|
|
58
|
+
abi: this.abi,
|
|
59
|
+
functionName: "balanceOf",
|
|
60
|
+
args: [wallet],
|
|
61
|
+
blockNumber
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* {@inheritDoc IPoolContract.sharesToUnderlying}
|
|
66
|
+
*/
|
|
67
|
+
sharesToUnderlying(shares) {
|
|
68
|
+
return this.dieselRate === 0n ? shares : shares * this.dieselRate / RAY;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* {@inheritDoc IPoolContract.underlyingToShares}
|
|
72
|
+
*/
|
|
73
|
+
underlyingToShares(underlying, roundUp = false) {
|
|
74
|
+
if (this.dieselRate === 0n) return underlying;
|
|
75
|
+
return roundUp ? (underlying * RAY + this.dieselRate - 1n) / this.dieselRate : underlying * RAY / this.dieselRate;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
53
78
|
* {@inheritDoc IPoolContract.unwrappedUnderlying}
|
|
54
79
|
*/
|
|
55
80
|
get unwrappedUnderlying() {
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
2
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
3
3
|
import "../constants/addresses.js";
|
|
4
|
-
import { PERCENTAGE_FACTOR
|
|
4
|
+
import { PERCENTAGE_FACTOR } from "../constants/math.js";
|
|
5
5
|
import "../constants/index.js";
|
|
6
6
|
import { hexEq } from "../utils/hex.js";
|
|
7
7
|
import "../utils/index.js";
|
|
@@ -145,7 +145,7 @@ var PoolService = class extends SDKConstruct {
|
|
|
145
145
|
const { zapper } = this.getDepositMetadata(poolAddr, tokenIn, tokenOut);
|
|
146
146
|
return {
|
|
147
147
|
tokenIn: toTokenAmount(tokenIn, amount),
|
|
148
|
-
tokenOut: toTokenAmount(tokenOut,
|
|
148
|
+
tokenOut: toTokenAmount(tokenOut, pool.pool.underlyingToShares(amount)),
|
|
149
149
|
zapper: zapper?.baseParams.addr
|
|
150
150
|
};
|
|
151
151
|
}
|
|
@@ -165,7 +165,7 @@ var PoolService = class extends SDKConstruct {
|
|
|
165
165
|
});
|
|
166
166
|
const { zapper } = this.getWithdrawalMetadata(poolAddr, tokenIn, tokenOut);
|
|
167
167
|
return {
|
|
168
|
-
tokenIn: toTokenAmount(tokenIn,
|
|
168
|
+
tokenIn: toTokenAmount(tokenIn, pool.pool.underlyingToShares(amount * PERCENTAGE_FACTOR / (PERCENTAGE_FACTOR - pool.pool.withdrawFee), true)),
|
|
169
169
|
tokenOut: toTokenAmount(tokenOut, amount),
|
|
170
170
|
zapper: zapper?.baseParams.addr,
|
|
171
171
|
availableLiquidity: payoutCeiling(market)
|
|
@@ -188,7 +188,7 @@ var PoolService = class extends SDKConstruct {
|
|
|
188
188
|
const { zapper } = this.getWithdrawalMetadata(poolAddr, tokenIn, tokenOut);
|
|
189
189
|
return {
|
|
190
190
|
tokenIn: toTokenAmount(tokenIn, amount),
|
|
191
|
-
tokenOut: toTokenAmount(tokenOut,
|
|
191
|
+
tokenOut: toTokenAmount(tokenOut, pool.pool.sharesToUnderlying(amount) * (PERCENTAGE_FACTOR - pool.pool.withdrawFee) / PERCENTAGE_FACTOR),
|
|
192
192
|
zapper: zapper?.baseParams.addr,
|
|
193
193
|
availableLiquidity: payoutCeiling(market)
|
|
194
194
|
};
|
|
@@ -220,7 +220,7 @@ var PoolService = class extends SDKConstruct {
|
|
|
220
220
|
}
|
|
221
221
|
const poolContract = this.sdk.marketRegister.findByPool(pool).pool.pool;
|
|
222
222
|
if (meta.zapper instanceof IETHZapperContract || meta.zapper instanceof IERC20ZapperContract) {
|
|
223
|
-
const shares = mode === "withdraw" ?
|
|
223
|
+
const shares = mode === "withdraw" ? poolContract.underlyingToShares(amount * PERCENTAGE_FACTOR / (PERCENTAGE_FACTOR - poolContract.withdrawFee), true) : amount;
|
|
224
224
|
const tx = permit ? meta.zapper.redeemWithPermit(shares, wallet, permit.deadline, permit.v, permit.r, permit.s) : meta.zapper.redeem(shares, wallet);
|
|
225
225
|
return {
|
|
226
226
|
tx,
|
|
@@ -414,43 +414,10 @@ var PoolService = class extends SDKConstruct {
|
|
|
414
414
|
chainId: this.chainId,
|
|
415
415
|
pool: pool.address,
|
|
416
416
|
underlyingToken: market.underlyingToken,
|
|
417
|
-
netValue:
|
|
418
|
-
token: this.sdk.tokensMeta.mustGetToken(market.unwrappedUnderlying),
|
|
419
|
-
...market.priceOracle.toAmount(market.underlying, shares * pool.dieselRate / RAY)
|
|
420
|
-
},
|
|
417
|
+
netValue: market.toUnderlyingAmount(pool.sharesToUnderlying(shares)),
|
|
421
418
|
apy: { organicApy: rayToBps(pool.supplyRate) }
|
|
422
419
|
};
|
|
423
420
|
}
|
|
424
421
|
};
|
|
425
|
-
/**
|
|
426
|
-
* Shares minted for `assets`, as `previewDeposit` would report them.
|
|
427
|
-
*
|
|
428
|
-
* Both directions convert through the diesel rate — underlying per RAY of
|
|
429
|
-
* shares — because that is the rate the pool itself divides by, and the only
|
|
430
|
-
* exact one the SDK holds: `totalAssets` is this rate multiplied out, so
|
|
431
|
-
* converting back through it costs a wei on large amounts. Rounds down, as
|
|
432
|
-
* minting does.
|
|
433
|
-
*/
|
|
434
|
-
function toShares(pool, assets) {
|
|
435
|
-
const { dieselRate } = pool;
|
|
436
|
-
return dieselRate === 0n ? assets : assets * RAY / dieselRate;
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Shares a withdrawal of `assets` burns, as `previewWithdraw` would report
|
|
440
|
-
* them: {@link toShares} rounded the other way, since the burn has to cover
|
|
441
|
-
* the payout the caller asked for.
|
|
442
|
-
*/
|
|
443
|
-
function toSharesUp(pool, assets) {
|
|
444
|
-
const { dieselRate } = pool;
|
|
445
|
-
return dieselRate === 0n ? assets : (assets * RAY + dieselRate - 1n) / dieselRate;
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Underlying paid out for `shares`, as `previewRedeem` would report it:
|
|
449
|
-
* {@link toShares} run backwards, less the pool's withdrawal fee.
|
|
450
|
-
*/
|
|
451
|
-
function toAssets(pool, shares) {
|
|
452
|
-
const { dieselRate, withdrawFee } = pool;
|
|
453
|
-
return (dieselRate === 0n ? shares : shares * dieselRate / RAY) * (PERCENTAGE_FACTOR - withdrawFee) / PERCENTAGE_FACTOR;
|
|
454
|
-
}
|
|
455
422
|
//#endregion
|
|
456
|
-
export { PoolService
|
|
423
|
+
export { PoolService };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PoolService
|
|
1
|
+
import { PoolService } from "./PoolService.js";
|
|
2
2
|
import "./types.js";
|
|
3
|
-
export { PoolService
|
|
3
|
+
export { PoolService };
|
|
@@ -372,7 +372,10 @@ var PositionsService = class extends SDKConstruct {
|
|
|
372
372
|
return {
|
|
373
373
|
sourceToken: this.sdk.tokensMeta.mustGetToken(w.token),
|
|
374
374
|
withdrawalPhantomToken: priceOracle.toTokenAmount(w.withdrawalPhantomToken, w.withdrawalTokenSpent),
|
|
375
|
-
outputs: w.outputs.map((o) =>
|
|
375
|
+
outputs: w.outputs.map((o) => ({
|
|
376
|
+
...priceOracle.toTokenAmount(o.token, o.amount),
|
|
377
|
+
isDelayed: o.isDelayed
|
|
378
|
+
})),
|
|
376
379
|
claimCall: this.#claimTx(w.claimCalls, w.token),
|
|
377
380
|
redeemer: w.redeemer,
|
|
378
381
|
intent: w.intent
|
|
@@ -382,7 +385,10 @@ var PositionsService = class extends SDKConstruct {
|
|
|
382
385
|
return {
|
|
383
386
|
sourceToken: this.sdk.tokensMeta.mustGetToken(w.token),
|
|
384
387
|
withdrawalPhantomToken: this.sdk.tokensMeta.mustGetToken(w.withdrawalPhantomToken),
|
|
385
|
-
expectedOutputs: w.expectedOutputs.map((o) =>
|
|
388
|
+
expectedOutputs: w.expectedOutputs.map((o) => ({
|
|
389
|
+
...priceOracle.toTokenAmount(o.token, o.amount),
|
|
390
|
+
isDelayed: o.isDelayed
|
|
391
|
+
})),
|
|
386
392
|
claimableAt: Number(w.claimableAt),
|
|
387
393
|
redeemer: w.redeemer,
|
|
388
394
|
intent: w.intent
|
|
@@ -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,28 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ierc20Abi } from "../../abi/iERC20.js";
|
|
2
|
+
import { sdkErr, sdkOk } from "../../model/result.js";
|
|
2
3
|
import "../../model/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import "../simulate/
|
|
4
|
+
import { asPreviewSimulationError } from "../simulate/errors.js";
|
|
5
|
+
import { amountsInOut, previewContract } from "../simulate/simulatePoolOperation.js";
|
|
5
6
|
//#region src/preview/preview/previewPoolPositionOperation.ts
|
|
6
7
|
async function previewPoolPositionOperation(input, operation, options) {
|
|
7
|
-
const { sdk
|
|
8
|
+
const { sdk } = input;
|
|
8
9
|
const { tokenIn, tokenOut } = operation;
|
|
9
10
|
const market = sdk.marketRegister.findByPool(operation.pool);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const pool = market.pool.pool;
|
|
12
|
+
const holder = "owner" in operation ? operation.owner : operation.receiver;
|
|
13
|
+
let previewAmount;
|
|
14
|
+
let shares;
|
|
15
|
+
try {
|
|
16
|
+
[previewAmount, shares] = await sdk.client.multicall({
|
|
17
|
+
contracts: [previewContract(operation), {
|
|
18
|
+
address: operation.pool,
|
|
19
|
+
abi: ierc20Abi,
|
|
20
|
+
functionName: "balanceOf",
|
|
21
|
+
args: [holder]
|
|
22
|
+
}],
|
|
23
|
+
allowFailure: false,
|
|
24
|
+
batchSize: 0,
|
|
25
|
+
blockNumber: options?.blockNumber
|
|
26
|
+
});
|
|
27
|
+
} catch (cause) {
|
|
28
|
+
const error = asPreviewSimulationError(cause, "multicall");
|
|
29
|
+
options?.logger?.error(error, "pool operation simulation failed");
|
|
30
|
+
return sdkErr(error);
|
|
31
|
+
}
|
|
32
|
+
const sim = amountsInOut(operation, previewAmount);
|
|
33
|
+
const inflow = operation.operation === "Deposit" || operation.operation === "Mint";
|
|
34
|
+
const after = shares + (inflow ? sim.amountOut : -sim.amountIn);
|
|
18
35
|
return sdkOk({
|
|
19
36
|
operation: operation.operation,
|
|
20
37
|
pool: operation.pool,
|
|
21
38
|
name: sdk.tokensMeta.mustGetToken(operation.pool).name,
|
|
22
39
|
underlyingToken: market.underlyingToken,
|
|
23
|
-
shareRate:
|
|
40
|
+
shareRate: pool.dieselRate,
|
|
24
41
|
tokenIn: market.priceOracle.toTokenAmount(tokenIn, sim.amountIn),
|
|
25
|
-
tokenOut: market.priceOracle.toTokenAmount(tokenOut, sim.amountOut)
|
|
42
|
+
tokenOut: market.priceOracle.toTokenAmount(tokenOut, sim.amountOut),
|
|
43
|
+
curator: market.curator,
|
|
44
|
+
netValue: market.toUnderlyingAmount(pool.sharesToUnderlying(after > 0n ? after : 0n))
|
|
26
45
|
});
|
|
27
46
|
}
|
|
28
47
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { asPreviewSimulationError } from "./errors.js";
|
|
2
|
-
import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
3
2
|
import { simulatePoolOperation } from "./simulatePoolOperation.js";
|
|
3
|
+
import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
4
4
|
import { simulateRWAOperation } from "./simulateRWAOperation.js";
|
|
5
5
|
import { simulateOperation } from "./simulateOperation.js";
|
|
6
6
|
export { asPreviewSimulationError, simulateFacadeOperation, simulateOperation, simulatePoolOperation, simulateRWAOperation };
|
|
@@ -2,8 +2,8 @@ import { sdkOk } from "../../model/result.js";
|
|
|
2
2
|
import "../../model/index.js";
|
|
3
3
|
import { isPoolOperation, isRWAOperation } from "../parse/types.js";
|
|
4
4
|
import "../parse/index.js";
|
|
5
|
-
import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
6
5
|
import { simulatePoolOperation } from "./simulatePoolOperation.js";
|
|
6
|
+
import { simulateFacadeOperation } from "./simulateFacadeOperation.js";
|
|
7
7
|
import { simulateRWAOperation } from "./simulateRWAOperation.js";
|
|
8
8
|
//#region src/preview/simulate/simulateOperation.ts
|
|
9
9
|
/**
|
|
@@ -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) {
|
|
@@ -103,4 +103,4 @@ async function simulatePoolOperation(input, options = {}) {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
|
-
export { simulatePoolOperation };
|
|
106
|
+
export { amountsInOut, previewContract, simulatePoolOperation };
|
|
@@ -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";
|