@gearbox-protocol/sdk 16.3.0-next.4 → 17.0.0-next.1
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/errors/operation-errors.js +1 -1
- package/dist/cjs/model/index.js +2 -2
- package/dist/cjs/model/rwa.js +4 -4
- package/dist/cjs/model/rwa.schema.js +4 -4
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +3 -1
- package/dist/cjs/onchain/accounts/intents/guards.js +4 -4
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/cjs/onchain/market/credit/CreditSuite.js +12 -26
- package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +5 -45
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +12 -56
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +37 -0
- package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +2 -8
- package/dist/cjs/onchain/opportunities/OpportunitiesService.js +4 -16
- package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +2 -3
- package/dist/cjs/onchain/validation/bundles/checkDraw.js +3 -3
- package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +5 -6
- package/dist/cjs/onchain/validation/checkSimulation.js +4 -11
- package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +2 -3
- package/dist/cjs/sdk/execute/ExecuteApi.js +2 -2
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +3 -9
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/history/trace/extractTransfers.js +1 -1
- package/dist/esm/model/errors/operation-errors.js +1 -1
- package/dist/esm/model/index.js +3 -3
- package/dist/esm/model/rwa.js +4 -4
- package/dist/esm/model/rwa.schema.js +5 -5
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +5 -3
- package/dist/esm/onchain/accounts/intents/guards.js +4 -4
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +2 -2
- 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/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 +12 -26
- package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/onchain/market/rwa/createDegenNFT.js +1 -1
- package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +5 -45
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +10 -55
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +37 -0
- package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +2 -8
- package/dist/esm/onchain/opportunities/OpportunitiesService.js +4 -16
- package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/esm/onchain/preview/preview/previewPoolPositionOperation.js +2 -2
- package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +2 -3
- package/dist/esm/onchain/validation/bundles/checkDraw.js +3 -3
- package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +5 -6
- package/dist/esm/onchain/validation/checkSimulation.js +4 -11
- package/dist/esm/onchain/validation/checks/checkDebtLimits.js +2 -3
- package/dist/esm/sdk/execute/ExecuteApi.js +2 -2
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +3 -9
- package/dist/types/model/errors/operation-errors.d.ts +4 -10
- package/dist/types/model/index.d.ts +3 -3
- package/dist/types/model/opportunities.d.ts +5 -4
- package/dist/types/model/rwa.d.ts +27 -47
- package/dist/types/model/rwa.schema.d.ts +3 -3
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +2 -1
- package/dist/types/offchain/opportunities/types.d.ts +4 -1
- package/dist/types/onchain/accounts/types.d.ts +2 -4
- package/dist/types/onchain/index.d.ts +2 -2
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +3 -8
- package/dist/types/onchain/market/credit/types.d.ts +2 -2
- package/dist/types/onchain/market/index.d.ts +2 -2
- package/dist/types/onchain/market/rwa/index.d.ts +2 -2
- package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +4 -19
- package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +4 -24
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +14 -2
- package/dist/types/onchain/market/rwa/types.d.ts +37 -39
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +1 -5
- package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +3 -10
- package/dist/types/onchain/opportunities/types.d.ts +1 -6
- package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
- package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +3 -3
- package/dist/types/onchain/validation/checkSimulation.d.ts +3 -6
- package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +0 -4
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +1 -5
- package/dist/types/sdk/opportunities/types.d.ts +3 -9
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_onchain_validation_helpers_token = require("./helpers/token.js");
|
|
3
3
|
require("./helpers/index.js");
|
|
4
4
|
const require_onchain_validation_checks_checkDebtLimits = require("./checks/checkDebtLimits.js");
|
|
5
|
-
const require_onchain_validation_checks_checkQuotaCount = require("./checks/checkQuotaCount.js");
|
|
6
5
|
require("./checks/index.js");
|
|
7
6
|
const require_onchain_validation_bundles_checkAccountQuotas = require("./bundles/checkAccountQuotas.js");
|
|
8
7
|
const require_onchain_validation_bundles_checkHealthFactors = require("./bundles/checkHealthFactors.js");
|
|
@@ -28,10 +27,8 @@ const require_onchain_validation_bundles_checkMarket = require("./bundles/checkM
|
|
|
28
27
|
* touched. The engine performed all three during the walk, so a simulation that
|
|
29
28
|
* came back `ok` has already passed them.
|
|
30
29
|
*
|
|
31
|
-
* A credit account only
|
|
32
|
-
*
|
|
33
|
-
* before it answers. An opening names its quotas `averageQuota` — the branch
|
|
34
|
-
* the planner already weighed it as.
|
|
30
|
+
* A credit account only: a pool operation has no account to weigh, and the
|
|
31
|
+
* three things its own state decides are read by `prepare` before it answers.
|
|
35
32
|
*/
|
|
36
33
|
function checkSimulation(sdk, input, options = {}) {
|
|
37
34
|
const { state } = input;
|
|
@@ -43,13 +40,9 @@ function checkSimulation(sdk, input, options = {}) {
|
|
|
43
40
|
minDebt: suite.creditFacade.minDebt,
|
|
44
41
|
maxDebt: suite.creditFacade.maxDebt,
|
|
45
42
|
underlying: require_onchain_validation_helpers_token.toToken(sdk, suite.market.pool.underlying),
|
|
46
|
-
allowZero: true
|
|
47
|
-
maxBorrowAmount: suite.maxBorrowAmount()
|
|
43
|
+
allowZero: true
|
|
48
44
|
}),
|
|
49
|
-
...
|
|
50
|
-
count: state.averageQuota.filter((q) => q.balance > 0n).length,
|
|
51
|
-
max: suite.creditManager.maxEnabledTokens
|
|
52
|
-
}) : require_onchain_validation_bundles_checkAccountQuotas.checkAccountQuotas(suite, state),
|
|
45
|
+
...require_onchain_validation_bundles_checkAccountQuotas.checkAccountQuotas(suite, state),
|
|
53
46
|
...require_onchain_validation_bundles_checkHealthFactors.checkHealthFactors(state, options)
|
|
54
47
|
];
|
|
55
48
|
}
|
|
@@ -6,13 +6,12 @@ require("../helpers/index.js");
|
|
|
6
6
|
//#region src/onchain/validation/checks/checkDebtLimits.ts
|
|
7
7
|
/** A debt the facade would revert on. */
|
|
8
8
|
function checkDebtLimits(args) {
|
|
9
|
-
const { debt, minDebt, maxDebt, underlying, allowZero
|
|
9
|
+
const { debt, minDebt, maxDebt, underlying, allowZero } = args;
|
|
10
10
|
if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return [];
|
|
11
11
|
return [require_model_errors_operation_errors.debtOutOfRange({
|
|
12
12
|
requested: require_onchain_validation_helpers_amount.amountOf(underlying, debt),
|
|
13
13
|
minDebt: require_onchain_validation_helpers_amount.amountOf(underlying, minDebt),
|
|
14
|
-
maxDebt: require_onchain_validation_helpers_amount.amountOf(underlying, maxDebt)
|
|
15
|
-
maxBorrowAmount
|
|
14
|
+
maxDebt: require_onchain_validation_helpers_amount.amountOf(underlying, maxDebt)
|
|
16
15
|
})];
|
|
17
16
|
}
|
|
18
17
|
//#endregion
|
|
@@ -74,9 +74,9 @@ async function openTx(sdk, request) {
|
|
|
74
74
|
async function openRwaOptions(sdk, request) {
|
|
75
75
|
if (!request.targetToken) return;
|
|
76
76
|
const requirements = await sdk.accounts.getOpenAccountRequirements(request.wallet, request.creditManager, { tokenOutAddress: request.targetToken });
|
|
77
|
-
if (requirements
|
|
77
|
+
if (!requirements) return;
|
|
78
78
|
return {
|
|
79
|
-
|
|
79
|
+
type: requirements.type,
|
|
80
80
|
tokensToRegister: requirements.tokensToRegister,
|
|
81
81
|
signaturesToCache: request.signaturesToCache ?? []
|
|
82
82
|
};
|
|
@@ -71,21 +71,15 @@ var OpportunitiesNamespace = class extends require_sdk_AbstractNamespace.Abstrac
|
|
|
71
71
|
/**
|
|
72
72
|
* {@inheritDoc IOpportunitiesBase.getStrategy}
|
|
73
73
|
**/
|
|
74
|
-
async getStrategy(key) {
|
|
74
|
+
async getStrategy(key, wallet) {
|
|
75
75
|
return this.merged("get strategy opportunity", {
|
|
76
76
|
chainIds: [key.chainId],
|
|
77
|
-
fromChain: (source) => source.getStrategy(key),
|
|
78
|
-
fromBackend: (source) => source.getStrategy(key),
|
|
77
|
+
fromChain: (source) => source.getStrategy(key, wallet),
|
|
78
|
+
fromBackend: (source) => source.getStrategy(key, wallet),
|
|
79
79
|
merge: this.merge.strategy
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* {@inheritDoc IOpportunitiesOnchainOnly.isEligibleForStrategy}
|
|
84
|
-
**/
|
|
85
|
-
async isEligibleForStrategy(key, wallet) {
|
|
86
|
-
return this.onchain.isEligibleForStrategy(key, wallet);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
83
|
* {@inheritDoc IOpportunitiesBase.filter}
|
|
90
84
|
**/
|
|
91
85
|
filter(response, filter) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ierc20Abi } from "../abi/iERC20.js";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
2
|
+
import { ierc20Abi } from "../abi/iERC20.js";
|
|
3
3
|
import { AddressMap } from "../onchain/utils/AddressMap.js";
|
|
4
4
|
import { AddressSet } from "../onchain/utils/AddressSet.js";
|
|
5
5
|
import { AssetsMap } from "../onchain/utils/AssetsMap.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
2
1
|
import { getNetworkType } from "../onchain/chain/chains.js";
|
|
3
2
|
import { getWithdrawalCompressorAddress } from "../onchain/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../onchain/index.js";
|
|
5
5
|
import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
|
|
6
6
|
import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
|
|
@@ -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";
|
|
@@ -113,7 +113,7 @@ function insufficientAllowance(args) {
|
|
|
113
113
|
function rwaOpenRequirementsNotMet(args) {
|
|
114
114
|
return {
|
|
115
115
|
code: "rwaOpenRequirementsNotMet",
|
|
116
|
-
message:
|
|
116
|
+
message: `The RWA factory still wants something from the borrower before ${args.token.symbol} can be opened on.`,
|
|
117
117
|
...args
|
|
118
118
|
};
|
|
119
119
|
}
|
package/dist/esm/model/index.js
CHANGED
|
@@ -7,8 +7,8 @@ import { FILTER_ALL, isFilterSet } from "./filters.js";
|
|
|
7
7
|
import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
|
|
8
8
|
import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
|
|
9
9
|
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
10
|
-
import { KYC_REGISTRATION_LINKS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES,
|
|
11
|
-
import {
|
|
10
|
+
import { KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES } from "./rwa.js";
|
|
11
|
+
import { kycProtocolSchema, kycRequirementSchema } from "./rwa.schema.js";
|
|
12
12
|
import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
|
|
13
13
|
import { borrowRateBreakdownSchema, pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionsTotalsSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
14
14
|
import { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema } from "./analytics.schema.js";
|
|
@@ -32,4 +32,4 @@ import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourc
|
|
|
32
32
|
import { safeValue, sdkErr, sdkOk } from "./result.js";
|
|
33
33
|
import "./withdrawals.js";
|
|
34
34
|
import { positionClaimableWithdrawalSchema, positionPendingWithdrawalSchema, positionWithdrawalsSchema, withdrawalOutputAmountSchema } from "./withdrawals.schema.js";
|
|
35
|
-
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, KYC_REGISTRATION_LINKS, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES,
|
|
35
|
+
export { ANALYTICS_POSITIONS_DEFAULT_LIMIT, ANALYTICS_POSITIONS_MAX_LIMIT, CHART_METRIC_UNITS, CHART_RANGES, CHART_UNAVAILABLE_CODES, FILTER_ALL, KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, POOL_OPPORTUNITY_CHART_METRICS, POOL_POSITION_CHART_METRICS, PROTOCOL_CHART_METRICS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES, STRATEGY_OPPORTUNITY_CHART_METRICS, STRATEGY_POSITION_CHART_METRICS, STRATEGY_POSITION_COLLATERAL_ERROR, amountSchema, analyticsChartQueryOptionsSchema, analyticsChartQueryParamsSchema, analyticsChartQuerySchema, analyticsPositionListOptionsSchema, analyticsPositionListQueryParamsSchema, analyticsPositionListQuerySchema, analyticsPositionPageSchema, analyticsPositionSchema, analyticsPositionSortFieldSchema, analyticsSortDirectionSchema, apyBreakdownSchema, asEstimated, assetTypeSchema, backendPreferred, booleanParamSchema, borrowRateBreakdownSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, chartBundleSchemaFor, chartDenominationSchema, chartMetricSchema, chartQueryCodec, chartQueryParamsSchema, chartQuerySchema, chartRangeSchema, chartSeriesSchema, chartValueSchema, chartWindowSchema, compareTagOf, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, curatorNameSchema, curatorSchema, dataSourceSchema, debtOutOfRange, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, forbiddenToken, instantReceivedAssetSchema, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, isFilterSet, kycProtocolSchema, kycRequirementSchema, leverageOutOfRange, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, liquidatorNotEligible, malformedTransaction, marketExpired, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, noticeKindSchema, noticeSchema, offchainOnly, onchainOnly, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, opportunityTotalsSchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolOpportunityChartMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPaused, poolPositionChartMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, poolSunset, positionClaimableWithdrawalSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionId, positionKeySchema, positionKindSchema, positionPendingWithdrawalSchema, positionSchema, positionTransactionKindSchema, positionTransactionSchema, positionWithdrawalsSchema, positionsTotalsSchema, priceFeedDataSchema, priceFeedSummarySchema, protocolChartMetricSchema, quotaAssetSchema, quotaCountExceeded, quotaLimitReached, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, rwaOpenRequirementsNotMet, safeValue, sdkErr, sdkOk, strategyOpportunityChartMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionChartMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenQuotaRateSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, tolerance, txCallSchema, underlyingTokenSchema, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress, withdrawalOutputAmountSchema };
|
package/dist/esm/model/rwa.js
CHANGED
|
@@ -34,15 +34,15 @@ const SECURITIZE_REGISTER_VAULT_TYPES = { RegisterVault: [
|
|
|
34
34
|
}
|
|
35
35
|
] };
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* KYC providers a strategy may be gated by
|
|
38
38
|
**/
|
|
39
|
-
const
|
|
39
|
+
const KYC_PROTOCOLS = ["securitize", "midas"];
|
|
40
40
|
/**
|
|
41
|
-
* Hardcoded registration URLs for each {@link
|
|
41
|
+
* Hardcoded registration URLs for each {@link KycProtocol}.
|
|
42
42
|
**/
|
|
43
43
|
const KYC_REGISTRATION_LINKS = {
|
|
44
44
|
securitize: "https://securitize.io/",
|
|
45
45
|
midas: "https://form.typeform.com/to/DqZaw6kr"
|
|
46
46
|
};
|
|
47
47
|
//#endregion
|
|
48
|
-
export { KYC_REGISTRATION_LINKS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES,
|
|
48
|
+
export { KYC_PROTOCOLS, KYC_REGISTRATION_LINKS, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { tokenSchema } from "./primitives.schema.js";
|
|
2
|
-
import {
|
|
2
|
+
import { KYC_PROTOCOLS } from "./rwa.js";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/model/rwa.schema.ts
|
|
5
5
|
/**
|
|
6
|
-
* {@link ./rwa.js#
|
|
6
|
+
* {@link ./rwa.js#KycProtocol}
|
|
7
7
|
**/
|
|
8
|
-
const
|
|
8
|
+
const kycProtocolSchema = z.enum(KYC_PROTOCOLS);
|
|
9
9
|
/**
|
|
10
10
|
* {@link ./rwa.js#KycRequirement}
|
|
11
11
|
**/
|
|
12
12
|
const kycRequirementSchema = z.object({
|
|
13
|
-
protocol:
|
|
13
|
+
protocol: kycProtocolSchema,
|
|
14
14
|
token: tokenSchema.optional(),
|
|
15
15
|
registrationLink: z.string()
|
|
16
16
|
});
|
|
17
17
|
//#endregion
|
|
18
|
-
export {
|
|
18
|
+
export { kycProtocolSchema, kycRequirementSchema };
|
|
@@ -35,7 +35,7 @@ var OffchainOpportunities = class extends AbstractOffchainNamespace {
|
|
|
35
35
|
/**
|
|
36
36
|
* {@inheritDoc IOffchainOpportunities.getStrategy}
|
|
37
37
|
**/
|
|
38
|
-
async getStrategy(key) {
|
|
38
|
+
async getStrategy(key, _wallet) {
|
|
39
39
|
return this.get({
|
|
40
40
|
path: this.#strategyPath(key),
|
|
41
41
|
schema: strategyOpportunityDetailSchema
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
2
|
-
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
3
1
|
import { AP_REWARDS_COMPRESSOR } from "../constants/address-provider.js";
|
|
4
2
|
import { ADDRESS_0X0 } from "../constants/addresses.js";
|
|
5
3
|
import { MAX_UINT256 } from "../constants/math.js";
|
|
@@ -10,6 +8,8 @@ import "../base/index.js";
|
|
|
10
8
|
import { AccountBotsService } from "./bots/AccountBotsService.js";
|
|
11
9
|
import "./bots/index.js";
|
|
12
10
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
11
|
+
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
|
+
import { ierc4626AdapterAbi } from "../../abi/ierc4626Adapter.js";
|
|
13
13
|
import { expectedBalanceDeltas } from "../market/credit/expectedBalanceDeltas.js";
|
|
14
14
|
import "../market/index.js";
|
|
15
15
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
@@ -188,7 +188,9 @@ var CreditAccountsServiceV310 = class extends SDKConstruct {
|
|
|
188
188
|
* {@inheritDoc ICreditAccountsService.getOpenAccountRequirements}
|
|
189
189
|
*/
|
|
190
190
|
async getOpenAccountRequirements(borrower, creditManager, props) {
|
|
191
|
-
|
|
191
|
+
const { rwaFactory } = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
192
|
+
if (!rwaFactory) return;
|
|
193
|
+
return rwaFactory.getOpenAccountRequirements(borrower, props);
|
|
192
194
|
}
|
|
193
195
|
/**
|
|
194
196
|
* {@inheritDoc ICreditAccountsService.openCA}
|
|
@@ -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 { value, limit } = suite.maxBorrowAmount();
|
|
47
47
|
raise(checkBorrowLimit({
|
|
48
48
|
requested: amount,
|
|
49
|
-
available:
|
|
50
|
-
limit
|
|
49
|
+
available: value,
|
|
50
|
+
limit,
|
|
51
51
|
underlying: toToken(sdk, suite.market.pool.underlying)
|
|
52
|
-
}), `borrow: ${amount} exceeds what the pool can lend now (${
|
|
52
|
+
}), `borrow: ${amount} exceeds what the pool can lend now (${value})`);
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* What the account is allowed to end up holding more of than it started with.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
2
1
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
3
2
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
4
3
|
import { ADDRESS_0X0 } from "../../constants/addresses.js";
|
|
@@ -9,9 +8,9 @@ import "../../utils/index.js";
|
|
|
9
8
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
10
9
|
import "../../base/index.js";
|
|
11
10
|
import { usdToNumber } from "../../market/math.js";
|
|
12
|
-
import { RWA_LIQUIDATOR_MIDAS } from "../../market/rwa/midas/constants.js";
|
|
13
11
|
import { matchesLiquidatableAccountFilter } from "../../../model/liquidations.js";
|
|
14
12
|
import "../../../model/index.js";
|
|
13
|
+
import { RWA_LIQUIDATOR_MIDAS } from "../../market/rwa/midas/constants.js";
|
|
15
14
|
import { RWA_LIQUIDATOR_SECURITIZE } from "../../market/rwa/securitize/constants.js";
|
|
16
15
|
import { dominantCollateral } from "../../market/credit/collateralUtils.js";
|
|
17
16
|
import { MidasLiquidatorContract } from "../../market/rwa/midas/MidasLiquidatorContract.js";
|
|
@@ -20,6 +19,7 @@ import { SecuritizeLiquidatorContract } from "../../market/rwa/securitize/Securi
|
|
|
20
19
|
import "../../market/rwa/securitize/index.js";
|
|
21
20
|
import "../../market/index.js";
|
|
22
21
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
22
|
+
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
23
23
|
import { skipLiquidatableAccount } from "./skipLiquidatableAccount.js";
|
|
24
24
|
//#region src/onchain/accounts/liquidations/LiquidationsService.ts
|
|
25
25
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
2
1
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
2
|
import "../../base/index.js";
|
|
4
3
|
import { sdkErr, sdkOk } from "../../../model/result.js";
|
|
5
4
|
import "../../../model/index.js";
|
|
6
5
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
6
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
7
7
|
//#region src/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
8
8
|
const abi = iRedemptionLoggerV310Abi;
|
|
9
9
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
1
|
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
|
+
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
3
3
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
1
|
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
|
+
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
3
3
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
2
1
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
3
2
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
2
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
3
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
4
1
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
5
2
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
6
3
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
7
4
|
import { getAssetType } from "../chain/chains.js";
|
|
8
5
|
import { formatBN } from "../utils/formatter.js";
|
|
9
6
|
import "../utils/index.js";
|
|
7
|
+
import { iExpirableAbi } from "../../abi/iExpirable.js";
|
|
8
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
9
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
10
10
|
import { SdkRWADataNotLoadedError } from "../core/errors.js";
|
|
11
11
|
import { executeMulticallBatches } from "../utils/viem/executeMulticallBatches.js";
|
|
12
12
|
//#region src/onchain/base/TokensMeta.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
2
1
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
3
2
|
import { isV310 } from "../constants/versions.js";
|
|
4
3
|
import "../constants/index.js";
|
|
5
4
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/onchain/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
|
|
2
1
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
2
|
+
import { accountMigratorAbi } from "../../../../abi/AccountMigrator.js";
|
|
3
3
|
//#region src/onchain/market/adapters/contracts/AccountMigratorAdapterContract.ts
|
|
4
4
|
const abi = accountMigratorAbi;
|
|
5
5
|
const protocolAbi = accountMigratorAbi;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
|
|
2
1
|
import { MissingSerializedParamsError } from "../../../base/errors.js";
|
|
3
2
|
import "../../../base/index.js";
|
|
3
|
+
import { ierc4626AdapterAbi } from "../../../../abi/ierc4626Adapter.js";
|
|
4
4
|
import { iERC4626Abi } from "../abi/targetContractAbi.js";
|
|
5
5
|
import { fnSigToName, swapFromTransfers } from "../transferHelpers.js";
|
|
6
6
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
4
3
|
import "../../base/index.js";
|
|
4
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/onchain/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -7,6 +7,8 @@ import "../../utils/index.js";
|
|
|
7
7
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
8
8
|
import "../../base/index.js";
|
|
9
9
|
import { calcBorrowApy, calcQuotaRate, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount } from "../math.js";
|
|
10
|
+
import { KYC_REGISTRATION_LINKS } from "../../../model/rwa.js";
|
|
11
|
+
import "../../../model/index.js";
|
|
10
12
|
import { createDegenNFT } from "../rwa/createDegenNFT.js";
|
|
11
13
|
import { strategyName } from "../strategyName.js";
|
|
12
14
|
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
|
|
@@ -123,37 +125,25 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
123
125
|
degenNFT() {
|
|
124
126
|
const address = this.creditFacade.degenNFT;
|
|
125
127
|
if (isAddressEqual(address, "0x0000000000000000000000000000000000000000")) return Promise.resolve(void 0);
|
|
126
|
-
const factoryNft = this.rwaFactory?.degenNFT;
|
|
127
|
-
if (factoryNft && isAddressEqual(factoryNft.address, address)) return Promise.resolve(factoryNft);
|
|
128
128
|
if (!this.#degenNFT) this.#degenNFT = createDegenNFT(this.sdk, address);
|
|
129
129
|
return this.#degenNFT;
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
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
134
|
*/
|
|
135
|
-
async kycRequirement(targetCollateral) {
|
|
135
|
+
async kycRequirement(wallet, targetCollateral) {
|
|
136
136
|
const nft = await this.degenNFT();
|
|
137
137
|
if (!nft) return null;
|
|
138
|
-
const
|
|
139
|
-
|
|
138
|
+
const { eligible, token } = await nft.checkKyc(wallet, targetCollateral);
|
|
139
|
+
if (eligible) return null;
|
|
140
140
|
return {
|
|
141
141
|
protocol: nft.protocol,
|
|
142
|
-
token:
|
|
143
|
-
registrationLink: nft.
|
|
142
|
+
token: this.tokensMeta.getToken(token),
|
|
143
|
+
registrationLink: KYC_REGISTRATION_LINKS[nft.protocol]
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
|
-
* Whether `wallet` may open this suite's strategy today; `true` when there
|
|
148
|
-
* is no KYC gate.
|
|
149
|
-
*/
|
|
150
|
-
async isEligibleForStrategy(wallet, targetCollateral) {
|
|
151
|
-
const nft = await this.degenNFT();
|
|
152
|
-
if (!nft) return true;
|
|
153
|
-
const requirements = await nft.getOpenAccountRequirements(wallet, { tokenOutAddress: targetCollateral });
|
|
154
|
-
return nft.isRegistered(requirements);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
147
|
* Builds a transaction that executes a multicall on one of this suite's
|
|
158
148
|
* credit accounts.
|
|
159
149
|
*
|
|
@@ -288,11 +278,11 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
288
278
|
const { pool } = this.market.pool;
|
|
289
279
|
const { maxDebtPerBlockMultiplier, maxDebt } = this.creditFacade;
|
|
290
280
|
if (maxDebtPerBlockMultiplier === 0) return {
|
|
291
|
-
|
|
281
|
+
value: 0n,
|
|
292
282
|
limit: "debtPerBlockLimit"
|
|
293
283
|
};
|
|
294
284
|
const available = pool.creditManagerDebtParams.get(this.creditManager.address)?.available;
|
|
295
|
-
|
|
285
|
+
return [
|
|
296
286
|
{
|
|
297
287
|
value: pool.availableLiquidity,
|
|
298
288
|
limit: "poolAvailableLiquidity"
|
|
@@ -306,10 +296,6 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
306
296
|
limit: "maxDebt"
|
|
307
297
|
}
|
|
308
298
|
].reduce((a, b) => b.value < a.value ? b : a);
|
|
309
|
-
return {
|
|
310
|
-
amount: this.market.toUnderlyingAmount(value),
|
|
311
|
-
limit
|
|
312
|
-
};
|
|
313
299
|
}
|
|
314
300
|
/**
|
|
315
301
|
* The single target collateral of this suite's strategy, or `undefined` when
|
|
@@ -368,7 +354,7 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
368
354
|
* or `undefined` when credit suite does not offer a strategy opportunity.
|
|
369
355
|
*/
|
|
370
356
|
strategyOpportunity() {
|
|
371
|
-
const maxBorrowAmount = this.maxBorrowAmount().
|
|
357
|
+
const maxBorrowAmount = this.maxBorrowAmount().value;
|
|
372
358
|
if (maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return;
|
|
373
359
|
const collateral = this.strategyTargetCollateral;
|
|
374
360
|
if (!collateral) return;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
4
3
|
import { RAY } from "../../constants/math.js";
|
|
@@ -8,6 +7,7 @@ import "../../utils/index.js";
|
|
|
8
7
|
import { SdkRWADataNotLoadedError } from "../../core/errors.js";
|
|
9
8
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
10
9
|
import "../../base/index.js";
|
|
10
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
11
11
|
//#region src/onchain/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
13
13
|
var PoolV310Contract = class extends BaseContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iVersionAbi } from "../../../abi/iVersion.js";
|
|
2
1
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
2
|
import "../../utils/index.js";
|
|
3
|
+
import { iVersionAbi } from "../../../abi/iVersion.js";
|
|
4
4
|
import { iMidasDegenNFTAbi } from "../../../abi/rwa/iMidasDegenNFT.js";
|
|
5
5
|
import { DEGEN_NFT_MIDAS } from "./midas/constants.js";
|
|
6
6
|
import { MidasDegenNFT } from "./midas/MidasDegenNFT.js";
|
|
@@ -5,23 +5,14 @@ import "../../adapters/abi/index.js";
|
|
|
5
5
|
import { iMidasDegenNFTAbi } from "../../../../abi/rwa/iMidasDegenNFT.js";
|
|
6
6
|
import "./constants.js";
|
|
7
7
|
import { iMidasAccessControlAbi } from "../../../../abi/rwa/iMidasAccessControl.js";
|
|
8
|
-
import { KYC_REGISTRATION_LINKS } from "../../../../model/rwa.js";
|
|
9
|
-
import "../../../../model/index.js";
|
|
10
8
|
import { decodeAbiParameters } from "viem";
|
|
11
9
|
//#region src/onchain/market/rwa/midas/MidasDegenNFT.ts
|
|
12
10
|
const abi = iMidasDegenNFTAbi;
|
|
13
|
-
/**
|
|
14
|
-
* Midas is an RWA protocol without a factory: accounts open through the plain
|
|
15
|
-
* facade. Only a Permissioned-mode gateway deploys a degen NFT, so a Midas
|
|
16
|
-
* strategy that does not require KYC has no NFT at all.
|
|
17
|
-
*/
|
|
18
11
|
var MidasDegenNFT = class extends BaseContract {
|
|
19
12
|
protocol = "midas";
|
|
20
|
-
registrationLink = KYC_REGISTRATION_LINKS.midas;
|
|
21
13
|
gateway;
|
|
22
14
|
accessControl;
|
|
23
15
|
greenlistedRole;
|
|
24
|
-
#mToken;
|
|
25
16
|
constructor(sdk, baseParams) {
|
|
26
17
|
super(sdk, {
|
|
27
18
|
...baseParams,
|
|
@@ -39,26 +30,9 @@ var MidasDegenNFT = class extends BaseContract {
|
|
|
39
30
|
this.accessControl = accessControl;
|
|
40
31
|
this.greenlistedRole = greenlistedRole;
|
|
41
32
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Same predicate `MidasDegenNFT.burn` reverts on; the mToken rides along in
|
|
47
|
-
* the batch until it is cached.
|
|
48
|
-
*/
|
|
49
|
-
async getOpenAccountRequirements(wallet, _props) {
|
|
50
|
-
const token = this.#mToken;
|
|
51
|
-
if (token !== void 0) return {
|
|
52
|
-
protocol: "midas",
|
|
53
|
-
token,
|
|
54
|
-
greenlisted: await this.client.readContract({
|
|
55
|
-
abi: iMidasAccessControlAbi,
|
|
56
|
-
address: this.accessControl,
|
|
57
|
-
functionName: "hasRole",
|
|
58
|
-
args: [this.greenlistedRole, wallet]
|
|
59
|
-
})
|
|
60
|
-
};
|
|
61
|
-
const [greenlisted, mToken] = await this.client.multicall({
|
|
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({
|
|
62
36
|
allowFailure: false,
|
|
63
37
|
contracts: [{
|
|
64
38
|
abi: iMidasAccessControlAbi,
|
|
@@ -71,25 +45,11 @@ var MidasDegenNFT = class extends BaseContract {
|
|
|
71
45
|
functionName: "mToken"
|
|
72
46
|
}]
|
|
73
47
|
});
|
|
74
|
-
this.#mToken = mToken;
|
|
75
48
|
return {
|
|
76
|
-
|
|
77
|
-
token
|
|
78
|
-
greenlisted
|
|
49
|
+
eligible,
|
|
50
|
+
token
|
|
79
51
|
};
|
|
80
52
|
}
|
|
81
|
-
isRegistered(requirements) {
|
|
82
|
-
return requirements.greenlisted;
|
|
83
|
-
}
|
|
84
|
-
getMissingRequirements() {}
|
|
85
|
-
async #mTokenAddress() {
|
|
86
|
-
if (this.#mToken === void 0) this.#mToken = await this.client.readContract({
|
|
87
|
-
abi: iMidasGatewayV311Abi,
|
|
88
|
-
address: this.gateway,
|
|
89
|
-
functionName: "mToken"
|
|
90
|
-
});
|
|
91
|
-
return this.#mToken;
|
|
92
|
-
}
|
|
93
53
|
};
|
|
94
54
|
//#endregion
|
|
95
55
|
export { MidasDegenNFT };
|