@gearbox-protocol/sdk 16.3.0-next.1 → 16.3.0-next.3
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/abi/rwa/iMidasAccessControl.js +23 -0
- package/dist/cjs/abi/rwa/iMidasDegenNFT.js +92 -0
- package/dist/cjs/model/errors/index.js +0 -1
- package/dist/cjs/model/errors/prepare-errors.js +0 -8
- package/dist/cjs/model/index.js +6 -2
- package/dist/cjs/model/opportunities.schema.js +3 -1
- package/dist/cjs/model/rwa.js +13 -0
- package/dist/cjs/model/rwa.schema.js +20 -0
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/cjs/onchain/accounts/intents/guards.js +4 -4
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +2 -2
- package/dist/cjs/onchain/index.js +8 -2
- package/dist/cjs/onchain/market/MarketSuite.js +3 -3
- package/dist/cjs/onchain/market/credit/CreditSuite.js +37 -3
- package/dist/cjs/onchain/market/index.js +8 -2
- package/dist/cjs/onchain/market/rwa/createDegenNFT.js +53 -0
- package/dist/cjs/onchain/market/rwa/index.js +7 -1
- package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +56 -0
- package/dist/cjs/onchain/market/rwa/midas/constants.js +2 -0
- package/dist/cjs/onchain/market/rwa/midas/index.js +3 -0
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +22 -3
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +2 -2
- package/dist/cjs/onchain/market/rwa/securitize/constants.js +2 -0
- package/dist/cjs/onchain/market/rwa/securitize/index.js +3 -0
- package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +2 -2
- package/dist/cjs/onchain/opportunities/OpportunitiesService.js +11 -3
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +2 -1
- package/dist/cjs/onchain/validation/bundles/checkDraw.js +3 -3
- package/dist/cjs/onchain/validation/checkSimulation.js +11 -14
- package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +3 -2
- package/dist/cjs/sdk/index.js +0 -1
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +19 -4
- package/dist/cjs/sdk/prepare/PrepareApi.js +27 -8
- package/dist/cjs/sdk/prepare/index.js +0 -1
- package/dist/esm/abi/rwa/iMidasAccessControl.js +22 -0
- package/dist/esm/abi/rwa/iMidasDegenNFT.js +91 -0
- package/dist/esm/model/errors/index.js +2 -2
- package/dist/esm/model/errors/prepare-errors.js +1 -8
- package/dist/esm/model/index.js +4 -3
- package/dist/esm/model/opportunities.schema.js +3 -1
- package/dist/esm/model/rwa.js +12 -1
- package/dist/esm/model/rwa.schema.js +18 -0
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/esm/onchain/accounts/intents/guards.js +4 -4
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +2 -2
- package/dist/esm/onchain/index.js +5 -3
- package/dist/esm/onchain/market/MarketSuite.js +3 -3
- package/dist/esm/onchain/market/credit/CreditSuite.js +37 -3
- package/dist/esm/onchain/market/index.js +5 -3
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +52 -0
- package/dist/esm/onchain/market/rwa/index.js +5 -3
- package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +55 -0
- package/dist/esm/onchain/market/rwa/midas/constants.js +2 -1
- package/dist/esm/onchain/market/rwa/midas/index.js +3 -2
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +20 -2
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +2 -2
- package/dist/esm/onchain/market/rwa/securitize/constants.js +2 -1
- package/dist/esm/onchain/market/rwa/securitize/index.js +3 -2
- package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +2 -2
- package/dist/esm/onchain/opportunities/OpportunitiesService.js +11 -3
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +2 -1
- package/dist/esm/onchain/validation/bundles/checkDraw.js +3 -3
- package/dist/esm/onchain/validation/checkSimulation.js +11 -14
- package/dist/esm/onchain/validation/checks/checkDebtLimits.js +3 -2
- package/dist/esm/sdk/index.js +2 -2
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +19 -4
- package/dist/esm/sdk/prepare/PrepareApi.js +28 -9
- package/dist/esm/sdk/prepare/index.js +2 -2
- package/dist/types/abi/rwa/iMidasAccessControl.d.ts +22 -0
- package/dist/types/abi/rwa/iMidasDegenNFT.d.ts +82 -0
- package/dist/types/model/errors/index.d.ts +2 -2
- package/dist/types/model/errors/operation-errors.d.ts +4 -0
- package/dist/types/model/errors/prepare-errors.d.ts +1 -10
- package/dist/types/model/index.d.ts +4 -3
- package/dist/types/model/opportunities.d.ts +9 -0
- package/dist/types/model/opportunities.schema.d.ts +30 -0
- package/dist/types/model/rwa.d.ts +25 -1
- package/dist/types/model/rwa.schema.d.ts +29 -0
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +2 -1
- package/dist/types/offchain/opportunities/types.d.ts +4 -1
- package/dist/types/onchain/index.d.ts +9 -7
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +12 -2
- package/dist/types/onchain/market/credit/types.d.ts +2 -2
- package/dist/types/onchain/market/index.d.ts +8 -6
- package/dist/types/onchain/market/rwa/RWARegistry.d.ts +1 -1
- package/dist/types/onchain/market/rwa/createDegenNFT.d.ts +12 -0
- package/dist/types/onchain/market/rwa/index.d.ts +9 -7
- package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +98 -0
- package/dist/types/onchain/market/rwa/midas/constants.d.ts +2 -1
- package/dist/types/onchain/market/rwa/midas/index.d.ts +3 -2
- package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +8 -2
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -2
- package/dist/types/onchain/market/rwa/securitize/constants.d.ts +2 -1
- package/dist/types/onchain/market/rwa/securitize/index.d.ts +4 -3
- package/dist/types/onchain/market/rwa/types.d.ts +20 -2
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +2 -1
- package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +5 -1
- package/dist/types/onchain/opportunities/types.d.ts +3 -2
- package/dist/types/onchain/validation/checkSimulation.d.ts +9 -20
- package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +4 -0
- package/dist/types/onchain/validation/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +4 -3
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +2 -1
- package/dist/types/sdk/opportunities/types.d.ts +8 -2
- package/dist/types/sdk/prepare/PrepareApi.d.ts +6 -5
- package/dist/types/sdk/prepare/index.d.ts +4 -3
- package/dist/types/sdk/prepare/types.d.ts +47 -21
- package/package.json +1 -1
|
@@ -43,13 +43,13 @@ function assertMarketOperable(suite) {
|
|
|
43
43
|
}
|
|
44
44
|
/** The pool has to be able to lend what the plan means to draw. */
|
|
45
45
|
function assertCanBorrow(sdk, suite, amount) {
|
|
46
|
-
const
|
|
46
|
+
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
47
47
|
raise(checkBorrowLimit({
|
|
48
48
|
requested: amount,
|
|
49
|
-
available: value,
|
|
50
|
-
limit,
|
|
49
|
+
available: maxBorrowAmount.amount.value,
|
|
50
|
+
limit: maxBorrowAmount.limit,
|
|
51
51
|
underlying: toToken(sdk, suite.market.pool.underlying)
|
|
52
|
-
}), `borrow: ${amount} exceeds what the pool can lend now (${value})`);
|
|
52
|
+
}), `borrow: ${amount} exceeds what the pool can lend now (${maxBorrowAmount.amount.value})`);
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* What the account is allowed to end up holding more of than it started with.
|
|
@@ -9,13 +9,13 @@ import "../../utils/index.js";
|
|
|
9
9
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
10
10
|
import "../../base/index.js";
|
|
11
11
|
import { usdToNumber } from "../../market/math.js";
|
|
12
|
-
import { dominantCollateral } from "../../market/credit/collateralUtils.js";
|
|
13
12
|
import { matchesLiquidatableAccountFilter } from "../../../model/liquidations.js";
|
|
14
13
|
import "../../../model/index.js";
|
|
15
14
|
import { RWA_LIQUIDATOR_MIDAS } from "../../market/rwa/midas/constants.js";
|
|
15
|
+
import { RWA_LIQUIDATOR_SECURITIZE } from "../../market/rwa/securitize/constants.js";
|
|
16
|
+
import { dominantCollateral } from "../../market/credit/collateralUtils.js";
|
|
16
17
|
import { MidasLiquidatorContract } from "../../market/rwa/midas/MidasLiquidatorContract.js";
|
|
17
18
|
import "../../market/rwa/midas/index.js";
|
|
18
|
-
import { RWA_LIQUIDATOR_SECURITIZE } from "../../market/rwa/securitize/constants.js";
|
|
19
19
|
import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/SecuritizeLiquidatorContract.js";
|
|
20
20
|
import "../../market/rwa/securitize/index.js";
|
|
21
21
|
import "../../market/index.js";
|
|
@@ -135,6 +135,9 @@ import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./mark
|
|
|
135
135
|
import { CreditFacadeV310Contract } from "./market/credit/CreditFacadeV310Contract.js";
|
|
136
136
|
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./market/math.js";
|
|
137
137
|
import { CreditManagerV310Contract } from "./market/credit/CreditManagerV310Contract.js";
|
|
138
|
+
import { DEGEN_NFT_MIDAS, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./market/rwa/midas/constants.js";
|
|
139
|
+
import { MidasDegenNFT } from "./market/rwa/midas/MidasDegenNFT.js";
|
|
140
|
+
import { DEGEN_NFT_SECURITIZE, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE } from "./market/rwa/securitize/constants.js";
|
|
138
141
|
import { strategyName } from "./market/strategyName.js";
|
|
139
142
|
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./market/credit/collateralUtils.js";
|
|
140
143
|
import { CreditSuite } from "./market/credit/CreditSuite.js";
|
|
@@ -181,9 +184,8 @@ import { IERC20ZapperContract } from "./market/zapper/IERC20ZapperContract.js";
|
|
|
181
184
|
import { IETHZapperContract } from "./market/zapper/IETHZapperContract.js";
|
|
182
185
|
import { createZapper } from "./market/zapper/createZapper.js";
|
|
183
186
|
import { MarketRegister } from "./market/MarketRegister.js";
|
|
184
|
-
import { PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./market/rwa/midas/constants.js";
|
|
185
187
|
import { MidasLiquidatorContract } from "./market/rwa/midas/MidasLiquidatorContract.js";
|
|
186
|
-
import {
|
|
188
|
+
import { SecuritizeDegenNFT } from "./market/rwa/securitize/SecuritizeDegenNFT.js";
|
|
187
189
|
import { SecuritizeLiquidatorContract } from "./market/rwa/securitize/SecuritizeLiquidatorContract.js";
|
|
188
190
|
import { SecuritizeRWAFactory } from "./market/rwa/securitize/SecuritizeRWAFactory.js";
|
|
189
191
|
import { RWARegistry } from "./market/rwa/RWARegistry.js";
|
|
@@ -296,4 +298,4 @@ import { replayMulticall } from "./preview/preview/replayMulticall.js";
|
|
|
296
298
|
import { previewOperation } from "./preview/preview/previewOperation.js";
|
|
297
299
|
import "./preview/index.js";
|
|
298
300
|
import "./types/index.js";
|
|
299
|
-
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, CreditAccountState, 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_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, 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, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkDraw, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, 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, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, 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 };
|
|
301
|
+
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, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, 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, MidasDegenNFT, 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_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, 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, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkDraw, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, 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, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, 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 };
|
|
@@ -4,12 +4,12 @@ import "../utils/index.js";
|
|
|
4
4
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
5
5
|
import "../base/index.js";
|
|
6
6
|
import { rayToBps } from "./math.js";
|
|
7
|
-
import { CreditSuite } from "./credit/CreditSuite.js";
|
|
8
|
-
import "./credit/index.js";
|
|
9
|
-
import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
10
7
|
import { isFilterSet } from "../../model/filters.js";
|
|
11
8
|
import { matchesOpportunityFilter } from "../../model/opportunities.js";
|
|
12
9
|
import "../../model/index.js";
|
|
10
|
+
import { CreditSuite } from "./credit/CreditSuite.js";
|
|
11
|
+
import "./credit/index.js";
|
|
12
|
+
import { MarketConfiguratorContract } from "./MarketConfiguratorContract.js";
|
|
13
13
|
import { createLossPolicy } from "./loss-policy/createLossPolicy.js";
|
|
14
14
|
import "./loss-policy/index.js";
|
|
15
15
|
import { createPriceOracle } from "./oracle/createPriceOracle.js";
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
2
2
|
import { getAccountTargetCollateral, getLegacyStrategyTarget, isSunsetStrategy } from "../../chain/chains.js";
|
|
3
|
+
import "../../constants/addresses.js";
|
|
3
4
|
import { PERCENTAGE_FACTOR, RAY } from "../../constants/math.js";
|
|
4
5
|
import "../../constants/index.js";
|
|
5
6
|
import "../../utils/index.js";
|
|
6
7
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
7
8
|
import "../../base/index.js";
|
|
8
9
|
import { calcBorrowApy, calcQuotaRate, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount } from "../math.js";
|
|
10
|
+
import { KYC_REGISTRATION_LINKS } from "../../../model/rwa.js";
|
|
11
|
+
import "../../../model/index.js";
|
|
12
|
+
import { createDegenNFT } from "../rwa/createDegenNFT.js";
|
|
9
13
|
import { strategyName } from "../strategyName.js";
|
|
10
14
|
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
|
|
11
15
|
import createCreditConfigurator from "./createCreditConfigurator.js";
|
|
@@ -55,6 +59,7 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
55
59
|
* parameters, collateral tokens, adapter permissions, and facade settings.
|
|
56
60
|
*/
|
|
57
61
|
creditConfigurator;
|
|
62
|
+
#degenNFT;
|
|
58
63
|
/**
|
|
59
64
|
* Original compressor contract snapshot for this credit suite.
|
|
60
65
|
*/
|
|
@@ -114,6 +119,31 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
114
119
|
return this.market.rwaFactory;
|
|
115
120
|
}
|
|
116
121
|
/**
|
|
122
|
+
* KYC-gated degen NFT on this suite's facade, loaded on first use.
|
|
123
|
+
* `undefined` when the facade has none, or when the NFT is not a KYC gate.
|
|
124
|
+
*/
|
|
125
|
+
degenNFT() {
|
|
126
|
+
const address = this.creditFacade.degenNFT;
|
|
127
|
+
if (isAddressEqual(address, "0x0000000000000000000000000000000000000000")) return Promise.resolve(void 0);
|
|
128
|
+
if (!this.#degenNFT) this.#degenNFT = createDegenNFT(this.sdk, address);
|
|
129
|
+
return this.#degenNFT;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* What `wallet` still has to do before the facade lets it open an account;
|
|
133
|
+
* `null` when nothing (no degen NFT, not a KYC gate, or already eligible).
|
|
134
|
+
*/
|
|
135
|
+
async kycRequirement(wallet, targetCollateral) {
|
|
136
|
+
const nft = await this.degenNFT();
|
|
137
|
+
if (!nft) return null;
|
|
138
|
+
const { eligible, token } = await nft.checkKyc(wallet, targetCollateral);
|
|
139
|
+
if (eligible) return null;
|
|
140
|
+
return {
|
|
141
|
+
protocol: nft.protocol,
|
|
142
|
+
token: this.tokensMeta.getToken(token),
|
|
143
|
+
registrationLink: KYC_REGISTRATION_LINKS[nft.protocol]
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
117
147
|
* Builds a transaction that executes a multicall on one of this suite's
|
|
118
148
|
* credit accounts.
|
|
119
149
|
*
|
|
@@ -248,11 +278,11 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
248
278
|
const { pool } = this.market.pool;
|
|
249
279
|
const { maxDebtPerBlockMultiplier, maxDebt } = this.creditFacade;
|
|
250
280
|
if (maxDebtPerBlockMultiplier === 0) return {
|
|
251
|
-
|
|
281
|
+
amount: this.market.toUnderlyingAmount(0n),
|
|
252
282
|
limit: "debtPerBlockLimit"
|
|
253
283
|
};
|
|
254
284
|
const available = pool.creditManagerDebtParams.get(this.creditManager.address)?.available;
|
|
255
|
-
|
|
285
|
+
const { value, limit } = [
|
|
256
286
|
{
|
|
257
287
|
value: pool.availableLiquidity,
|
|
258
288
|
limit: "poolAvailableLiquidity"
|
|
@@ -266,6 +296,10 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
266
296
|
limit: "maxDebt"
|
|
267
297
|
}
|
|
268
298
|
].reduce((a, b) => b.value < a.value ? b : a);
|
|
299
|
+
return {
|
|
300
|
+
amount: this.market.toUnderlyingAmount(value),
|
|
301
|
+
limit
|
|
302
|
+
};
|
|
269
303
|
}
|
|
270
304
|
/**
|
|
271
305
|
* The single target collateral of this suite's strategy, or `undefined` when
|
|
@@ -324,7 +358,7 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
324
358
|
* or `undefined` when credit suite does not offer a strategy opportunity.
|
|
325
359
|
*/
|
|
326
360
|
strategyOpportunity() {
|
|
327
|
-
const maxBorrowAmount = this.maxBorrowAmount().value;
|
|
361
|
+
const maxBorrowAmount = this.maxBorrowAmount().amount.value;
|
|
328
362
|
if (maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return;
|
|
329
363
|
const collateral = this.strategyTargetCollateral;
|
|
330
364
|
if (!collateral) return;
|
|
@@ -89,6 +89,9 @@ import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./cred
|
|
|
89
89
|
import { CreditFacadeV310Contract } from "./credit/CreditFacadeV310Contract.js";
|
|
90
90
|
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./math.js";
|
|
91
91
|
import { CreditManagerV310Contract } from "./credit/CreditManagerV310Contract.js";
|
|
92
|
+
import { DEGEN_NFT_MIDAS, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./rwa/midas/constants.js";
|
|
93
|
+
import { MidasDegenNFT } from "./rwa/midas/MidasDegenNFT.js";
|
|
94
|
+
import { DEGEN_NFT_SECURITIZE, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE } from "./rwa/securitize/constants.js";
|
|
92
95
|
import { strategyName } from "./strategyName.js";
|
|
93
96
|
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./credit/collateralUtils.js";
|
|
94
97
|
import { CreditSuite } from "./credit/CreditSuite.js";
|
|
@@ -134,13 +137,12 @@ import { IETHZapperContract } from "./zapper/IETHZapperContract.js";
|
|
|
134
137
|
import { createZapper } from "./zapper/createZapper.js";
|
|
135
138
|
import "./zapper/index.js";
|
|
136
139
|
import { MarketRegister } from "./MarketRegister.js";
|
|
137
|
-
import { PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./rwa/midas/constants.js";
|
|
138
140
|
import { MidasLiquidatorContract } from "./rwa/midas/MidasLiquidatorContract.js";
|
|
139
|
-
import {
|
|
141
|
+
import { SecuritizeDegenNFT } from "./rwa/securitize/SecuritizeDegenNFT.js";
|
|
140
142
|
import { SecuritizeLiquidatorContract } from "./rwa/securitize/SecuritizeLiquidatorContract.js";
|
|
141
143
|
import { SecuritizeRWAFactory } from "./rwa/securitize/SecuritizeRWAFactory.js";
|
|
142
144
|
import { RWARegistry } from "./rwa/RWARegistry.js";
|
|
143
145
|
import { isRWAFactory } from "./rwa/types.js";
|
|
144
146
|
import "./rwa/index.js";
|
|
145
147
|
import "./types.js";
|
|
146
|
-
export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RWARegistry, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, classifyCurveOperation, collateralPriceInUnderlying, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fetchRedstonePayloads, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, 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, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, usdToNumber };
|
|
148
|
+
export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RWARegistry, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, classifyCurveOperation, collateralPriceInUnderlying, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fetchRedstonePayloads, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, 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, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, usdToNumber };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { iVersionAbi } from "../../../abi/iVersion.js";
|
|
2
|
+
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
|
+
import "../../utils/index.js";
|
|
4
|
+
import { iMidasDegenNFTAbi } from "../../../abi/rwa/iMidasDegenNFT.js";
|
|
5
|
+
import { DEGEN_NFT_MIDAS } from "./midas/constants.js";
|
|
6
|
+
import { MidasDegenNFT } from "./midas/MidasDegenNFT.js";
|
|
7
|
+
import { DEGEN_NFT_SECURITIZE } from "./securitize/constants.js";
|
|
8
|
+
import { decodeAbiParameters, isAddressEqual } from "viem";
|
|
9
|
+
//#region src/onchain/market/rwa/createDegenNFT.ts
|
|
10
|
+
/**
|
|
11
|
+
* Determines the KYC provider behind a degen NFT.
|
|
12
|
+
* Returns `undefined` for an allowlist, a legacy degen NFT, or a Securitize
|
|
13
|
+
* factory that is not loaded on this SDK.
|
|
14
|
+
*/
|
|
15
|
+
async function createDegenNFT(sdk, address) {
|
|
16
|
+
const [contractType, version, serialized] = await sdk.client.multicall({
|
|
17
|
+
allowFailure: true,
|
|
18
|
+
contracts: [
|
|
19
|
+
{
|
|
20
|
+
abi: iVersionAbi,
|
|
21
|
+
address,
|
|
22
|
+
functionName: "contractType"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
abi: iVersionAbi,
|
|
26
|
+
address,
|
|
27
|
+
functionName: "version"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
abi: iMidasDegenNFTAbi,
|
|
31
|
+
address,
|
|
32
|
+
functionName: "serialize"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
if (contractType.status !== "success" || version.status !== "success" || serialized.status !== "success") return;
|
|
37
|
+
switch (bytes32ToString(contractType.result)) {
|
|
38
|
+
case DEGEN_NFT_MIDAS: return new MidasDegenNFT(sdk, {
|
|
39
|
+
addr: address,
|
|
40
|
+
version: version.result,
|
|
41
|
+
contractType: contractType.result,
|
|
42
|
+
serializedParams: serialized.result
|
|
43
|
+
});
|
|
44
|
+
case DEGEN_NFT_SECURITIZE: {
|
|
45
|
+
const [factoryAddress] = decodeAbiParameters([{ type: "address" }], serialized.result);
|
|
46
|
+
return sdk.rwa.factories.find((f) => isAddressEqual(f.address, factoryAddress))?.degenNFT;
|
|
47
|
+
}
|
|
48
|
+
default: return;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { createDegenNFT };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./midas/constants.js";
|
|
1
|
+
import { DEGEN_NFT_MIDAS, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./midas/constants.js";
|
|
2
|
+
import { MidasDegenNFT } from "./midas/MidasDegenNFT.js";
|
|
3
|
+
import { DEGEN_NFT_SECURITIZE, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE } from "./securitize/constants.js";
|
|
2
4
|
import { MidasLiquidatorContract } from "./midas/MidasLiquidatorContract.js";
|
|
3
5
|
import "./midas/index.js";
|
|
4
|
-
import {
|
|
6
|
+
import { SecuritizeDegenNFT } from "./securitize/SecuritizeDegenNFT.js";
|
|
5
7
|
import { SecuritizeLiquidatorContract } from "./securitize/SecuritizeLiquidatorContract.js";
|
|
6
8
|
import { SecuritizeRWAFactory } from "./securitize/SecuritizeRWAFactory.js";
|
|
7
9
|
import "./securitize/index.js";
|
|
8
10
|
import { RWARegistry } from "./RWARegistry.js";
|
|
9
11
|
import { isRWAFactory } from "./types.js";
|
|
10
|
-
export { MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWARegistry, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, SecuritizeLiquidatorContract, SecuritizeRWAFactory, isRWAFactory };
|
|
12
|
+
export { DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, MidasDegenNFT, MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWARegistry, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeRWAFactory, isRWAFactory };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BaseContract } from "../../../base/BaseContract.js";
|
|
2
|
+
import "../../../base/index.js";
|
|
3
|
+
import { iMidasGatewayV311Abi } from "../../adapters/abi/midas/iMidasGatewayV311.js";
|
|
4
|
+
import "../../adapters/abi/index.js";
|
|
5
|
+
import { iMidasDegenNFTAbi } from "../../../../abi/rwa/iMidasDegenNFT.js";
|
|
6
|
+
import "./constants.js";
|
|
7
|
+
import { iMidasAccessControlAbi } from "../../../../abi/rwa/iMidasAccessControl.js";
|
|
8
|
+
import { decodeAbiParameters } from "viem";
|
|
9
|
+
//#region src/onchain/market/rwa/midas/MidasDegenNFT.ts
|
|
10
|
+
const abi = iMidasDegenNFTAbi;
|
|
11
|
+
var MidasDegenNFT = class extends BaseContract {
|
|
12
|
+
protocol = "midas";
|
|
13
|
+
gateway;
|
|
14
|
+
accessControl;
|
|
15
|
+
greenlistedRole;
|
|
16
|
+
constructor(sdk, baseParams) {
|
|
17
|
+
super(sdk, {
|
|
18
|
+
...baseParams,
|
|
19
|
+
contractType: baseParams.contractType || "DEGEN_NFT::MIDAS",
|
|
20
|
+
name: "MidasDegenNFT",
|
|
21
|
+
abi
|
|
22
|
+
});
|
|
23
|
+
if (!baseParams.serializedParams) throw new Error(`MidasDegenNFT at ${baseParams.addr} is missing serializedParams`);
|
|
24
|
+
const [gateway, accessControl, greenlistedRole] = decodeAbiParameters([
|
|
25
|
+
{ type: "address" },
|
|
26
|
+
{ type: "address" },
|
|
27
|
+
{ type: "bytes32" }
|
|
28
|
+
], baseParams.serializedParams);
|
|
29
|
+
this.gateway = gateway;
|
|
30
|
+
this.accessControl = accessControl;
|
|
31
|
+
this.greenlistedRole = greenlistedRole;
|
|
32
|
+
}
|
|
33
|
+
/** Same predicate `MidasDegenNFT.burn` reverts on; the mToken rides along in the batch. */
|
|
34
|
+
async checkKyc(wallet, _targetCollateral) {
|
|
35
|
+
const [eligible, token] = await this.client.multicall({
|
|
36
|
+
allowFailure: false,
|
|
37
|
+
contracts: [{
|
|
38
|
+
abi: iMidasAccessControlAbi,
|
|
39
|
+
address: this.accessControl,
|
|
40
|
+
functionName: "hasRole",
|
|
41
|
+
args: [this.greenlistedRole, wallet]
|
|
42
|
+
}, {
|
|
43
|
+
abi: iMidasGatewayV311Abi,
|
|
44
|
+
address: this.gateway,
|
|
45
|
+
functionName: "mToken"
|
|
46
|
+
}]
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
eligible,
|
|
50
|
+
token
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { MidasDegenNFT };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/onchain/market/rwa/midas/constants.ts
|
|
2
2
|
const RWA_LIQUIDATOR_MIDAS = "RWA_LIQUIDATOR::MIDAS";
|
|
3
3
|
const PHANTOM_TOKEN_MIDAS_REDEMPTION = "PHANTOM_TOKEN::MIDAS_REDEMPTION";
|
|
4
|
+
const DEGEN_NFT_MIDAS = "DEGEN_NFT::MIDAS";
|
|
4
5
|
//#endregion
|
|
5
|
-
export { PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS };
|
|
6
|
+
export { DEGEN_NFT_MIDAS, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./constants.js";
|
|
1
|
+
import { DEGEN_NFT_MIDAS, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./constants.js";
|
|
2
|
+
import { MidasDegenNFT } from "./MidasDegenNFT.js";
|
|
2
3
|
import { MidasLiquidatorContract } from "./MidasLiquidatorContract.js";
|
|
3
|
-
export { MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS };
|
|
4
|
+
export { DEGEN_NFT_MIDAS, MidasDegenNFT, MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS };
|
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
import { BaseContract } from "../../../base/BaseContract.js";
|
|
2
2
|
import "../../../base/index.js";
|
|
3
|
+
import { DEGEN_NFT_SECURITIZE } from "./constants.js";
|
|
3
4
|
import { iSecuritizeDegenNFTAbi } from "../../../../abi/rwa/iSecuritizeDegenNFT.js";
|
|
5
|
+
import { isAddressEqual } from "viem";
|
|
4
6
|
//#region src/onchain/market/rwa/securitize/SecuritizeDegenNFT.ts
|
|
5
7
|
const abi = iSecuritizeDegenNFTAbi;
|
|
6
8
|
var SecuritizeDegenNFT = class extends BaseContract {
|
|
7
|
-
|
|
9
|
+
protocol = "securitize";
|
|
10
|
+
factory;
|
|
11
|
+
constructor(sdk, address, factory) {
|
|
8
12
|
super(sdk, {
|
|
9
13
|
addr: address,
|
|
10
|
-
contractType:
|
|
14
|
+
contractType: DEGEN_NFT_SECURITIZE,
|
|
11
15
|
version: 310,
|
|
12
16
|
name: "SecuritizeDegenNFT",
|
|
13
17
|
abi
|
|
14
18
|
});
|
|
19
|
+
this.factory = factory;
|
|
20
|
+
}
|
|
21
|
+
/** Registration on Securitize is the only KYC step; pending EIP-712 signatures are not. */
|
|
22
|
+
async checkKyc(wallet, targetCollateral) {
|
|
23
|
+
const { factory } = this;
|
|
24
|
+
if (!factory.getTokens().some((t) => isAddressEqual(t, targetCollateral))) return {
|
|
25
|
+
eligible: true,
|
|
26
|
+
token: targetCollateral
|
|
27
|
+
};
|
|
28
|
+
const req = await factory.getOpenAccountRequirements(wallet, { tokenOutAddress: targetCollateral });
|
|
29
|
+
return {
|
|
30
|
+
eligible: !req || req.securitizeTokensToRegister.length === 0,
|
|
31
|
+
token: req?.securitizeTokensToRegister[0] ?? targetCollateral
|
|
32
|
+
};
|
|
15
33
|
}
|
|
16
34
|
};
|
|
17
35
|
//#endregion
|
|
@@ -5,8 +5,8 @@ import { BaseContract } from "../../../base/BaseContract.js";
|
|
|
5
5
|
import "../../../base/index.js";
|
|
6
6
|
import { RWA_FACTORY_SECURITIZE, SECURITIZE_REGISTER_VAULT_TYPES } from "../../../../model/rwa.js";
|
|
7
7
|
import "../../../../model/index.js";
|
|
8
|
-
import { iSecuritizeRWAFactoryAbi } from "../../../../abi/rwa/iSecuritizeRWAFactory.js";
|
|
9
8
|
import { SecuritizeDegenNFT } from "./SecuritizeDegenNFT.js";
|
|
9
|
+
import { iSecuritizeRWAFactoryAbi } from "../../../../abi/rwa/iSecuritizeRWAFactory.js";
|
|
10
10
|
import { decodeAbiParameters } from "viem";
|
|
11
11
|
//#region src/onchain/market/rwa/securitize/SecuritizeRWAFactory.ts
|
|
12
12
|
const abi = iSecuritizeRWAFactoryAbi;
|
|
@@ -53,7 +53,7 @@ var SecuritizeRWAFactory = class extends BaseContract {
|
|
|
53
53
|
}
|
|
54
54
|
], data.baseParams.serializedParams);
|
|
55
55
|
this.owner = decoded[0];
|
|
56
|
-
this.degenNFT = new SecuritizeDegenNFT(sdk, decoded[1]);
|
|
56
|
+
this.degenNFT = new SecuritizeDegenNFT(sdk, decoded[1], this);
|
|
57
57
|
for (const t of data.tokens) this.tokensMeta.upsert(t.addr, t);
|
|
58
58
|
this.dsTokens = decoded[2].map((t) => ({
|
|
59
59
|
address: t.token,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/onchain/market/rwa/securitize/constants.ts
|
|
2
2
|
const RWA_LIQUIDATOR_SECURITIZE = "RWA_LIQUIDATOR::SECURITIZE";
|
|
3
3
|
const PHANTOM_TOKEN_SECURITIZE_REDEMPTION = "PHANTOM_TOKEN::SECURITIZE_RD";
|
|
4
|
+
const DEGEN_NFT_SECURITIZE = "DEGEN_NFT::SECURITIZE";
|
|
4
5
|
//#endregion
|
|
5
|
-
export { PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE };
|
|
6
|
+
export { DEGEN_NFT_SECURITIZE, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE } from "./constants.js";
|
|
1
|
+
import { DEGEN_NFT_SECURITIZE, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE } from "./constants.js";
|
|
2
|
+
import { SecuritizeDegenNFT } from "./SecuritizeDegenNFT.js";
|
|
2
3
|
import { SecuritizeLiquidatorContract } from "./SecuritizeLiquidatorContract.js";
|
|
3
4
|
import { SecuritizeRWAFactory } from "./SecuritizeRWAFactory.js";
|
|
4
5
|
import "./types.js";
|
|
5
|
-
export { PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE, SecuritizeLiquidatorContract, SecuritizeRWAFactory };
|
|
6
|
+
export { DEGEN_NFT_SECURITIZE, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeRWAFactory };
|
|
@@ -37,10 +37,10 @@ var MultichainOpportunitiesService = class extends MultichainConstruct {
|
|
|
37
37
|
*
|
|
38
38
|
* See {@link MultichainOpportunitiesService.getPool}.
|
|
39
39
|
**/
|
|
40
|
-
async getStrategy(key) {
|
|
40
|
+
async getStrategy(key, wallet) {
|
|
41
41
|
return this.queryChain({
|
|
42
42
|
network: key.chainId,
|
|
43
|
-
run: (sdk) => sdk.opportunities.getStrategy(key)
|
|
43
|
+
run: (sdk) => sdk.opportunities.getStrategy(key, wallet)
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
};
|
|
@@ -36,13 +36,21 @@ var OpportunitiesService = class extends SDKConstruct {
|
|
|
36
36
|
* A single strategy opportunity plus the rate curve of the pool it borrows
|
|
37
37
|
* from and the price feeds its liquidation price depends on.
|
|
38
38
|
*
|
|
39
|
+
* @param wallet - When given, `kyc` says whether this wallet must register
|
|
40
|
+
* with the strategy's KYC provider first; `null` otherwise.
|
|
41
|
+
*
|
|
39
42
|
* @throws If the credit manager is unknown, or does not currently offer a
|
|
40
43
|
* strategy.
|
|
41
44
|
**/
|
|
42
|
-
async getStrategy(key) {
|
|
43
|
-
const
|
|
45
|
+
async getStrategy(key, wallet) {
|
|
46
|
+
const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
|
|
47
|
+
const detail = suite.strategyOpportunityDetail();
|
|
44
48
|
if (!detail) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
|
|
45
|
-
|
|
49
|
+
const kyc = wallet ? await suite.kycRequirement(wallet, detail.targetCollateral.address) : null;
|
|
50
|
+
return {
|
|
51
|
+
...detail,
|
|
52
|
+
kyc
|
|
53
|
+
};
|
|
46
54
|
}
|
|
47
55
|
};
|
|
48
56
|
//#endregion
|
|
@@ -32,7 +32,8 @@ async function checkCreditOperation(args) {
|
|
|
32
32
|
minDebt: suite.creditFacade.minDebt,
|
|
33
33
|
maxDebt: suite.creditFacade.maxDebt,
|
|
34
34
|
underlying,
|
|
35
|
-
allowZero: !isOpening
|
|
35
|
+
allowZero: !isOpening,
|
|
36
|
+
maxBorrowAmount: suite.maxBorrowAmount()
|
|
36
37
|
}),
|
|
37
38
|
...checkDraw(suite, preview, underlying),
|
|
38
39
|
...checkObtained(suite, preview),
|
|
@@ -15,11 +15,11 @@ import "../checks/index.js";
|
|
|
15
15
|
function checkDraw(suite, preview, underlying) {
|
|
16
16
|
const drawn = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
|
|
17
17
|
if (drawn <= 0n) return [];
|
|
18
|
-
const
|
|
18
|
+
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
19
19
|
return checkBorrowLimit({
|
|
20
20
|
requested: drawn,
|
|
21
|
-
available: value,
|
|
22
|
-
limit,
|
|
21
|
+
available: maxBorrowAmount.amount.value,
|
|
22
|
+
limit: maxBorrowAmount.limit,
|
|
23
23
|
underlying
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { toToken } from "./helpers/token.js";
|
|
2
2
|
import "./helpers/index.js";
|
|
3
3
|
import { checkDebtLimits } from "./checks/checkDebtLimits.js";
|
|
4
|
+
import { checkQuotaCount } from "./checks/checkQuotaCount.js";
|
|
4
5
|
import "./checks/index.js";
|
|
5
6
|
import { checkAccountQuotas } from "./bundles/checkAccountQuotas.js";
|
|
6
7
|
import { checkHealthFactors } from "./bundles/checkHealthFactors.js";
|
|
7
8
|
import { checkMarket } from "./bundles/checkMarket.js";
|
|
8
|
-
import { checkPoolOperation } from "./bundles/checkPoolOperation.js";
|
|
9
9
|
//#region src/onchain/validation/checkSimulation.ts
|
|
10
10
|
/**
|
|
11
11
|
* Whether a simulated operation clears the caller's own thresholds.
|
|
@@ -27,19 +27,12 @@ import { checkPoolOperation } from "./bundles/checkPoolOperation.js";
|
|
|
27
27
|
* touched. The engine performed all three during the walk, so a simulation that
|
|
28
28
|
* came back `ok` has already passed them.
|
|
29
29
|
*
|
|
30
|
-
* A
|
|
31
|
-
*
|
|
30
|
+
* A credit account only, opened or adjusted: a pool operation has no account
|
|
31
|
+
* to weigh, and the three things its own state decides are read by `prepare`
|
|
32
|
+
* before it answers. An opening names its quotas `averageQuota` — the branch
|
|
33
|
+
* the planner already weighed it as.
|
|
32
34
|
*/
|
|
33
35
|
function checkSimulation(sdk, input, options = {}) {
|
|
34
|
-
if ("pool" in input) {
|
|
35
|
-
const { pool, state, isDeposit } = input;
|
|
36
|
-
return checkPoolOperation({
|
|
37
|
-
sdk,
|
|
38
|
-
pool,
|
|
39
|
-
isDeposit,
|
|
40
|
-
tokenOut: state.tokenOut
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
36
|
const { state } = input;
|
|
44
37
|
const suite = sdk.marketRegister.findCreditManager(state.creditManager);
|
|
45
38
|
return [
|
|
@@ -49,9 +42,13 @@ function checkSimulation(sdk, input, options = {}) {
|
|
|
49
42
|
minDebt: suite.creditFacade.minDebt,
|
|
50
43
|
maxDebt: suite.creditFacade.maxDebt,
|
|
51
44
|
underlying: toToken(sdk, suite.market.pool.underlying),
|
|
52
|
-
allowZero: true
|
|
45
|
+
allowZero: true,
|
|
46
|
+
maxBorrowAmount: suite.maxBorrowAmount()
|
|
53
47
|
}),
|
|
54
|
-
...
|
|
48
|
+
..."averageQuota" in state ? checkQuotaCount({
|
|
49
|
+
count: state.averageQuota.filter((q) => q.balance > 0n).length,
|
|
50
|
+
max: suite.creditManager.maxEnabledTokens
|
|
51
|
+
}) : checkAccountQuotas(suite, state),
|
|
55
52
|
...checkHealthFactors(state, options)
|
|
56
53
|
];
|
|
57
54
|
}
|
|
@@ -5,12 +5,13 @@ import "../helpers/index.js";
|
|
|
5
5
|
//#region src/onchain/validation/checks/checkDebtLimits.ts
|
|
6
6
|
/** A debt the facade would revert on. */
|
|
7
7
|
function checkDebtLimits(args) {
|
|
8
|
-
const { debt, minDebt, maxDebt, underlying, allowZero } = args;
|
|
8
|
+
const { debt, minDebt, maxDebt, underlying, allowZero, maxBorrowAmount } = args;
|
|
9
9
|
if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return [];
|
|
10
10
|
return [debtOutOfRange({
|
|
11
11
|
requested: amountOf(underlying, debt),
|
|
12
12
|
minDebt: amountOf(underlying, minDebt),
|
|
13
|
-
maxDebt: amountOf(underlying, maxDebt)
|
|
13
|
+
maxDebt: amountOf(underlying, maxDebt),
|
|
14
|
+
maxBorrowAmount
|
|
14
15
|
})];
|
|
15
16
|
}
|
|
16
17
|
//#endregion
|