@gearbox-protocol/sdk 16.3.0-next.3 → 16.3.0-next.5
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 +1 -3
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/cjs/onchain/index.js +4 -4
- package/dist/cjs/onchain/market/credit/CreditSuite.js +19 -9
- package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +56 -12
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
- package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
- package/dist/cjs/onchain/opportunities/OpportunitiesService.js +16 -4
- package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +8 -7
- package/dist/cjs/onchain/validation/bundles/{checkDraw.js → checkIncreaseDebt.js} +10 -10
- package/dist/cjs/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
- package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +6 -5
- package/dist/cjs/onchain/validation/bundles/index.js +4 -4
- package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +1 -1
- package/dist/cjs/onchain/validation/index.js +4 -4
- package/dist/cjs/sdk/execute/ExecuteApi.js +2 -2
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -3
- 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 +1 -3
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/index.js +3 -3
- package/dist/esm/onchain/market/credit/CreditSuite.js +19 -9
- package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +55 -10
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
- package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
- package/dist/esm/onchain/opportunities/OpportunitiesService.js +16 -4
- package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +8 -7
- package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +27 -0
- package/dist/esm/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
- package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +6 -5
- package/dist/esm/onchain/validation/bundles/index.js +3 -3
- package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +1 -1
- package/dist/esm/onchain/validation/index.js +3 -3
- package/dist/esm/sdk/execute/ExecuteApi.js +2 -2
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -3
- package/dist/types/model/errors/operation-errors.d.ts +8 -6
- package/dist/types/model/index.d.ts +3 -3
- package/dist/types/model/opportunities.d.ts +6 -7
- package/dist/types/model/rwa.d.ts +47 -27
- package/dist/types/model/rwa.schema.d.ts +3 -3
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -2
- package/dist/types/offchain/opportunities/types.d.ts +1 -4
- package/dist/types/onchain/accounts/types.d.ts +4 -2
- package/dist/types/onchain/index.d.ts +4 -4
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +8 -3
- package/dist/types/onchain/market/index.d.ts +2 -2
- package/dist/types/onchain/market/pool/types.d.ts +1 -1
- package/dist/types/onchain/market/rwa/index.d.ts +2 -2
- package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +19 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +24 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -14
- package/dist/types/onchain/market/rwa/types.d.ts +39 -37
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +5 -1
- package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +10 -3
- package/dist/types/onchain/opportunities/types.d.ts +6 -1
- package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +3 -2
- package/dist/types/onchain/validation/bundles/{checkDraw.d.ts → checkIncreaseDebt.d.ts} +7 -7
- package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts} +3 -3
- 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/bundles/index.d.ts +3 -3
- package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
- package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -1
- package/dist/types/onchain/validation/index.d.ts +3 -3
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
- package/dist/types/sdk/opportunities/types.d.ts +9 -3
- package/package.json +1 -1
- package/dist/esm/onchain/validation/bundles/checkDraw.js +0 -27
|
@@ -114,7 +114,7 @@ function insufficientAllowance(args) {
|
|
|
114
114
|
function rwaOpenRequirementsNotMet(args) {
|
|
115
115
|
return {
|
|
116
116
|
code: "rwaOpenRequirementsNotMet",
|
|
117
|
-
message:
|
|
117
|
+
message: `${args.protocol} still wants something from the borrower before ${args.token.symbol} can be opened on.`,
|
|
118
118
|
...args
|
|
119
119
|
};
|
|
120
120
|
}
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -39,13 +39,13 @@ exports.CHART_METRIC_UNITS = require_model_charts.CHART_METRIC_UNITS;
|
|
|
39
39
|
exports.CHART_RANGES = require_model_charts.CHART_RANGES;
|
|
40
40
|
exports.CHART_UNAVAILABLE_CODES = require_model_charts.CHART_UNAVAILABLE_CODES;
|
|
41
41
|
exports.FILTER_ALL = require_model_filters.FILTER_ALL;
|
|
42
|
-
exports.KYC_PROTOCOLS = require_model_rwa.KYC_PROTOCOLS;
|
|
43
42
|
exports.KYC_REGISTRATION_LINKS = require_model_rwa.KYC_REGISTRATION_LINKS;
|
|
44
43
|
exports.POOL_OPPORTUNITY_CHART_METRICS = require_model_charts.POOL_OPPORTUNITY_CHART_METRICS;
|
|
45
44
|
exports.POOL_POSITION_CHART_METRICS = require_model_charts.POOL_POSITION_CHART_METRICS;
|
|
46
45
|
exports.PROTOCOL_CHART_METRICS = require_model_charts.PROTOCOL_CHART_METRICS;
|
|
47
46
|
exports.RWA_FACTORY_SECURITIZE = require_model_rwa.RWA_FACTORY_SECURITIZE;
|
|
48
47
|
exports.RWA_FACTORY_TYPES = require_model_rwa.RWA_FACTORY_TYPES;
|
|
48
|
+
exports.RWA_PROTOCOLS = require_model_rwa.RWA_PROTOCOLS;
|
|
49
49
|
exports.SECURITIZE_REGISTER_VAULT_TYPES = require_model_rwa.SECURITIZE_REGISTER_VAULT_TYPES;
|
|
50
50
|
exports.STRATEGY_OPPORTUNITY_CHART_METRICS = require_model_charts.STRATEGY_OPPORTUNITY_CHART_METRICS;
|
|
51
51
|
exports.STRATEGY_POSITION_CHART_METRICS = require_model_charts.STRATEGY_POSITION_CHART_METRICS;
|
|
@@ -102,7 +102,6 @@ exports.insufficientBalance = require_model_errors_operation_errors.insufficient
|
|
|
102
102
|
exports.insufficientCollateral = require_model_errors_operation_errors.insufficientCollateral;
|
|
103
103
|
exports.insufficientPoolLiquidity = require_model_errors_operation_errors.insufficientPoolLiquidity;
|
|
104
104
|
exports.isFilterSet = require_model_filters.isFilterSet;
|
|
105
|
-
exports.kycProtocolSchema = require_model_rwa_schema.kycProtocolSchema;
|
|
106
105
|
exports.kycRequirementSchema = require_model_rwa_schema.kycRequirementSchema;
|
|
107
106
|
exports.leverageOutOfRange = require_model_errors_operation_errors.leverageOutOfRange;
|
|
108
107
|
exports.leverageSchema = require_model_primitives_schema.leverageSchema;
|
|
@@ -181,6 +180,7 @@ exports.responseSchema = require_model_response_schema.responseSchema;
|
|
|
181
180
|
exports.rewardsPnLSchema = require_model_positions_schema.rewardsPnLSchema;
|
|
182
181
|
exports.rewardsSchema = require_model_opportunities_schema.rewardsSchema;
|
|
183
182
|
exports.rwaOpenRequirementsNotMet = require_model_errors_operation_errors.rwaOpenRequirementsNotMet;
|
|
183
|
+
exports.rwaProtocolSchema = require_model_rwa_schema.rwaProtocolSchema;
|
|
184
184
|
exports.safeValue = require_model_result.safeValue;
|
|
185
185
|
exports.sdkErr = require_model_result.sdkErr;
|
|
186
186
|
exports.sdkOk = require_model_result.sdkOk;
|
package/dist/cjs/model/rwa.js
CHANGED
|
@@ -35,19 +35,19 @@ const SECURITIZE_REGISTER_VAULT_TYPES = { RegisterVault: [
|
|
|
35
35
|
}
|
|
36
36
|
] };
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* RWA protocols that require dedicated flows
|
|
39
39
|
**/
|
|
40
|
-
const
|
|
40
|
+
const RWA_PROTOCOLS = ["securitize", "midas"];
|
|
41
41
|
/**
|
|
42
|
-
* Hardcoded registration URLs for each {@link
|
|
42
|
+
* Hardcoded registration URLs for each {@link RWAProtocol}.
|
|
43
43
|
**/
|
|
44
44
|
const KYC_REGISTRATION_LINKS = {
|
|
45
45
|
securitize: "https://securitize.io/",
|
|
46
46
|
midas: "https://form.typeform.com/to/DqZaw6kr"
|
|
47
47
|
};
|
|
48
48
|
//#endregion
|
|
49
|
-
exports.KYC_PROTOCOLS = KYC_PROTOCOLS;
|
|
50
49
|
exports.KYC_REGISTRATION_LINKS = KYC_REGISTRATION_LINKS;
|
|
51
50
|
exports.RWA_FACTORY_SECURITIZE = RWA_FACTORY_SECURITIZE;
|
|
52
51
|
exports.RWA_FACTORY_TYPES = RWA_FACTORY_TYPES;
|
|
52
|
+
exports.RWA_PROTOCOLS = RWA_PROTOCOLS;
|
|
53
53
|
exports.SECURITIZE_REGISTER_VAULT_TYPES = SECURITIZE_REGISTER_VAULT_TYPES;
|
|
@@ -4,17 +4,17 @@ const require_model_rwa = require("./rwa.js");
|
|
|
4
4
|
let zod_v4 = require("zod/v4");
|
|
5
5
|
//#region src/model/rwa.schema.ts
|
|
6
6
|
/**
|
|
7
|
-
* {@link ./rwa.js#
|
|
7
|
+
* {@link ./rwa.js#RWAProtocol}
|
|
8
8
|
**/
|
|
9
|
-
const
|
|
9
|
+
const rwaProtocolSchema = zod_v4.z.enum(require_model_rwa.RWA_PROTOCOLS);
|
|
10
10
|
/**
|
|
11
11
|
* {@link ./rwa.js#KycRequirement}
|
|
12
12
|
**/
|
|
13
13
|
const kycRequirementSchema = zod_v4.z.object({
|
|
14
|
-
protocol:
|
|
14
|
+
protocol: rwaProtocolSchema,
|
|
15
15
|
token: require_model_primitives_schema.tokenSchema.optional(),
|
|
16
16
|
registrationLink: zod_v4.z.string()
|
|
17
17
|
});
|
|
18
18
|
//#endregion
|
|
19
|
-
exports.kycProtocolSchema = kycProtocolSchema;
|
|
20
19
|
exports.kycRequirementSchema = kycRequirementSchema;
|
|
20
|
+
exports.rwaProtocolSchema = rwaProtocolSchema;
|
|
@@ -36,7 +36,7 @@ var OffchainOpportunities = class extends require_offchain_AbstractOffchainNames
|
|
|
36
36
|
/**
|
|
37
37
|
* {@inheritDoc IOffchainOpportunities.getStrategy}
|
|
38
38
|
**/
|
|
39
|
-
async getStrategy(key
|
|
39
|
+
async getStrategy(key) {
|
|
40
40
|
return this.get({
|
|
41
41
|
path: this.#strategyPath(key),
|
|
42
42
|
schema: require_model_opportunities_schema.strategyOpportunityDetailSchema
|
|
@@ -189,9 +189,7 @@ var CreditAccountsServiceV310 = class extends require_onchain_base_SDKConstruct.
|
|
|
189
189
|
* {@inheritDoc ICreditAccountsService.getOpenAccountRequirements}
|
|
190
190
|
*/
|
|
191
191
|
async getOpenAccountRequirements(borrower, creditManager, props) {
|
|
192
|
-
|
|
193
|
-
if (!rwaFactory) return;
|
|
194
|
-
return rwaFactory.getOpenAccountRequirements(borrower, props);
|
|
192
|
+
return (await this.sdk.marketRegister.findCreditManager(creditManager).degenNFT())?.getOpenAccountRequirements(borrower, props);
|
|
195
193
|
}
|
|
196
194
|
/**
|
|
197
195
|
* {@inheritDoc ICreditAccountsService.openCA}
|
|
@@ -10,9 +10,9 @@ require("../../utils/index.js");
|
|
|
10
10
|
const require_onchain_base_SDKConstruct = require("../../base/SDKConstruct.js");
|
|
11
11
|
require("../../base/index.js");
|
|
12
12
|
const require_onchain_market_math = require("../../market/math.js");
|
|
13
|
+
const require_onchain_market_rwa_midas_constants = require("../../market/rwa/midas/constants.js");
|
|
13
14
|
const require_model_liquidations = require("../../../model/liquidations.js");
|
|
14
15
|
require("../../../model/index.js");
|
|
15
|
-
const require_onchain_market_rwa_midas_constants = require("../../market/rwa/midas/constants.js");
|
|
16
16
|
const require_onchain_market_rwa_securitize_constants = require("../../market/rwa/securitize/constants.js");
|
|
17
17
|
const require_onchain_market_credit_collateralUtils = require("../../market/credit/collateralUtils.js");
|
|
18
18
|
const require_onchain_market_rwa_midas_MidasLiquidatorContract = require("../../market/rwa/midas/MidasLiquidatorContract.js");
|
|
@@ -217,11 +217,11 @@ const require_onchain_validation_bundles_checkAccountQuotas = require("./validat
|
|
|
217
217
|
const require_onchain_validation_bundles_checkWalletAllowance = require("./validation/bundles/checkWalletAllowance.js");
|
|
218
218
|
const require_onchain_validation_bundles_checkWalletBalance = require("./validation/bundles/checkWalletBalance.js");
|
|
219
219
|
const require_onchain_validation_bundles_checkCollateralFunding = require("./validation/bundles/checkCollateralFunding.js");
|
|
220
|
-
const require_onchain_validation_bundles_checkDraw = require("./validation/bundles/checkDraw.js");
|
|
221
220
|
const require_onchain_validation_bundles_checkHealthFactors = require("./validation/bundles/checkHealthFactors.js");
|
|
221
|
+
const require_onchain_validation_bundles_checkIncreaseDebt = require("./validation/bundles/checkIncreaseDebt.js");
|
|
222
|
+
const require_onchain_validation_bundles_checkIncreaseQuota = require("./validation/bundles/checkIncreaseQuota.js");
|
|
222
223
|
const require_onchain_validation_bundles_checkMarket = require("./validation/bundles/checkMarket.js");
|
|
223
224
|
const require_onchain_validation_bundles_checkObtained = require("./validation/bundles/checkObtained.js");
|
|
224
|
-
const require_onchain_validation_bundles_checkQuotasAsked = require("./validation/bundles/checkQuotasAsked.js");
|
|
225
225
|
const require_onchain_validation_bundles_checkRWAOpenRequirements = require("./validation/bundles/checkRWAOpenRequirements.js");
|
|
226
226
|
const require_onchain_validation_bundles_checkRWAOpening = require("./validation/bundles/checkRWAOpening.js");
|
|
227
227
|
const require_onchain_validation_bundles_checkCreditOperation = require("./validation/bundles/checkCreditOperation.js");
|
|
@@ -563,10 +563,11 @@ exports.checkCreditAccountFrozen = require_onchain_validation_checks_checkCredit
|
|
|
563
563
|
exports.checkCreditManagerPaused = require_onchain_validation_checks_checkCreditManagerPaused.checkCreditManagerPaused;
|
|
564
564
|
exports.checkCreditOperation = require_onchain_validation_bundles_checkCreditOperation.checkCreditOperation;
|
|
565
565
|
exports.checkDebtLimits = require_onchain_validation_checks_checkDebtLimits.checkDebtLimits;
|
|
566
|
-
exports.checkDraw = require_onchain_validation_bundles_checkDraw.checkDraw;
|
|
567
566
|
exports.checkEmergencyLiquidator = require_onchain_validation_checks_checkEmergencyLiquidator.checkEmergencyLiquidator;
|
|
568
567
|
exports.checkForbiddenToken = require_onchain_validation_checks_checkForbiddenToken.checkForbiddenToken;
|
|
569
568
|
exports.checkHealthFactors = require_onchain_validation_bundles_checkHealthFactors.checkHealthFactors;
|
|
569
|
+
exports.checkIncreaseDebt = require_onchain_validation_bundles_checkIncreaseDebt.checkIncreaseDebt;
|
|
570
|
+
exports.checkIncreaseQuota = require_onchain_validation_bundles_checkIncreaseQuota.checkIncreaseQuota;
|
|
570
571
|
exports.checkLeverage = require_onchain_validation_checks_checkLeverage.checkLeverage;
|
|
571
572
|
exports.checkLiquidation = require_onchain_validation_checkLiquidation.checkLiquidation;
|
|
572
573
|
exports.checkLiquidationEligibility = require_onchain_validation_bundles_checkLiquidationEligibility.checkLiquidationEligibility;
|
|
@@ -583,7 +584,6 @@ exports.checkPoolPaused = require_onchain_validation_checks_checkPoolPaused.chec
|
|
|
583
584
|
exports.checkPoolSunset = require_onchain_validation_checks_checkPoolSunset.checkPoolSunset;
|
|
584
585
|
exports.checkQuotaCount = require_onchain_validation_checks_checkQuotaCount.checkQuotaCount;
|
|
585
586
|
exports.checkQuotaLimit = require_onchain_validation_checks_checkQuotaLimit.checkQuotaLimit;
|
|
586
|
-
exports.checkQuotasAsked = require_onchain_validation_bundles_checkQuotasAsked.checkQuotasAsked;
|
|
587
587
|
exports.checkRWAOpenRequirements = require_onchain_validation_bundles_checkRWAOpenRequirements.checkRWAOpenRequirements;
|
|
588
588
|
exports.checkRWAOpening = require_onchain_validation_bundles_checkRWAOpening.checkRWAOpening;
|
|
589
589
|
exports.checkSimulation = require_onchain_validation_checkSimulation.checkSimulation;
|
|
@@ -8,8 +8,6 @@ require("../../utils/index.js");
|
|
|
8
8
|
const require_onchain_base_SDKConstruct = require("../../base/SDKConstruct.js");
|
|
9
9
|
require("../../base/index.js");
|
|
10
10
|
const require_onchain_market_math = require("../math.js");
|
|
11
|
-
const require_model_rwa = require("../../../model/rwa.js");
|
|
12
|
-
require("../../../model/index.js");
|
|
13
11
|
const require_onchain_market_rwa_createDegenNFT = require("../rwa/createDegenNFT.js");
|
|
14
12
|
const require_onchain_market_strategyName = require("../strategyName.js");
|
|
15
13
|
const require_onchain_market_credit_collateralUtils = require("./collateralUtils.js");
|
|
@@ -126,25 +124,37 @@ var CreditSuite = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
|
126
124
|
degenNFT() {
|
|
127
125
|
const address = this.creditFacade.degenNFT;
|
|
128
126
|
if ((0, viem.isAddressEqual)(address, "0x0000000000000000000000000000000000000000")) return Promise.resolve(void 0);
|
|
127
|
+
const factoryNft = this.rwaFactory?.degenNFT;
|
|
128
|
+
if (factoryNft && (0, viem.isAddressEqual)(factoryNft.address, address)) return Promise.resolve(factoryNft);
|
|
129
129
|
if (!this.#degenNFT) this.#degenNFT = require_onchain_market_rwa_createDegenNFT.createDegenNFT(this.sdk, address);
|
|
130
130
|
return this.#degenNFT;
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
133
|
+
* The KYC gate of this suite's strategy; `null` when there is none.
|
|
134
|
+
* Wallet-independent.
|
|
135
135
|
*/
|
|
136
|
-
async kycRequirement(
|
|
136
|
+
async kycRequirement(targetCollateral) {
|
|
137
137
|
const nft = await this.degenNFT();
|
|
138
138
|
if (!nft) return null;
|
|
139
|
-
const
|
|
140
|
-
|
|
139
|
+
const tokens = await nft.getTokens();
|
|
140
|
+
const token = tokens.find((t) => (0, viem.isAddressEqual)(t, targetCollateral)) ?? tokens[0];
|
|
141
141
|
return {
|
|
142
142
|
protocol: nft.protocol,
|
|
143
|
-
token: this.tokensMeta.getToken(token),
|
|
144
|
-
registrationLink:
|
|
143
|
+
token: token ? this.tokensMeta.getToken(token) : void 0,
|
|
144
|
+
registrationLink: nft.registrationLink
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
/**
|
|
148
|
+
* Whether `wallet` may open this suite's strategy today; `true` when there
|
|
149
|
+
* is no KYC gate.
|
|
150
|
+
*/
|
|
151
|
+
async isEligibleForStrategy(wallet, targetCollateral) {
|
|
152
|
+
const nft = await this.degenNFT();
|
|
153
|
+
if (!nft) return true;
|
|
154
|
+
const requirements = await nft.getOpenAccountRequirements(wallet, { tokenOutAddress: targetCollateral });
|
|
155
|
+
return nft.isRegistered(requirements);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
148
158
|
* Builds a transaction that executes a multicall on one of this suite's
|
|
149
159
|
* credit accounts.
|
|
150
160
|
*
|
|
@@ -6,14 +6,23 @@ require("../../adapters/abi/index.js");
|
|
|
6
6
|
const require_abi_rwa_iMidasDegenNFT = require("../../../../abi/rwa/iMidasDegenNFT.js");
|
|
7
7
|
require("./constants.js");
|
|
8
8
|
const require_abi_rwa_iMidasAccessControl = require("../../../../abi/rwa/iMidasAccessControl.js");
|
|
9
|
+
const require_model_rwa = require("../../../../model/rwa.js");
|
|
10
|
+
require("../../../../model/index.js");
|
|
9
11
|
let viem = require("viem");
|
|
10
12
|
//#region src/onchain/market/rwa/midas/MidasDegenNFT.ts
|
|
11
13
|
const abi = require_abi_rwa_iMidasDegenNFT.iMidasDegenNFTAbi;
|
|
14
|
+
/**
|
|
15
|
+
* Midas is an RWA protocol without a factory: accounts open through the plain
|
|
16
|
+
* facade. Only a Permissioned-mode gateway deploys a degen NFT, so a Midas
|
|
17
|
+
* strategy that does not require KYC has no NFT at all.
|
|
18
|
+
*/
|
|
12
19
|
var MidasDegenNFT = class extends require_onchain_base_BaseContract.BaseContract {
|
|
13
20
|
protocol = "midas";
|
|
21
|
+
registrationLink = require_model_rwa.KYC_REGISTRATION_LINKS.midas;
|
|
14
22
|
gateway;
|
|
15
23
|
accessControl;
|
|
16
24
|
greenlistedRole;
|
|
25
|
+
#mToken;
|
|
17
26
|
constructor(sdk, baseParams) {
|
|
18
27
|
super(sdk, {
|
|
19
28
|
...baseParams,
|
|
@@ -31,9 +40,26 @@ var MidasDegenNFT = class extends require_onchain_base_BaseContract.BaseContract
|
|
|
31
40
|
this.accessControl = accessControl;
|
|
32
41
|
this.greenlistedRole = greenlistedRole;
|
|
33
42
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
async getTokens() {
|
|
44
|
+
return [await this.#mTokenAddress()];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Same predicate `MidasDegenNFT.burn` reverts on; the mToken rides along in
|
|
48
|
+
* the batch until it is cached.
|
|
49
|
+
*/
|
|
50
|
+
async getOpenAccountRequirements(wallet, _props) {
|
|
51
|
+
const token = this.#mToken;
|
|
52
|
+
if (token !== void 0) return {
|
|
53
|
+
protocol: "midas",
|
|
54
|
+
token,
|
|
55
|
+
greenlisted: await this.client.readContract({
|
|
56
|
+
abi: require_abi_rwa_iMidasAccessControl.iMidasAccessControlAbi,
|
|
57
|
+
address: this.accessControl,
|
|
58
|
+
functionName: "hasRole",
|
|
59
|
+
args: [this.greenlistedRole, wallet]
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
const [greenlisted, mToken] = await this.client.multicall({
|
|
37
63
|
allowFailure: false,
|
|
38
64
|
contracts: [{
|
|
39
65
|
abi: require_abi_rwa_iMidasAccessControl.iMidasAccessControlAbi,
|
|
@@ -46,11 +72,25 @@ var MidasDegenNFT = class extends require_onchain_base_BaseContract.BaseContract
|
|
|
46
72
|
functionName: "mToken"
|
|
47
73
|
}]
|
|
48
74
|
});
|
|
75
|
+
this.#mToken = mToken;
|
|
49
76
|
return {
|
|
50
|
-
|
|
51
|
-
token
|
|
77
|
+
protocol: "midas",
|
|
78
|
+
token: mToken,
|
|
79
|
+
greenlisted
|
|
52
80
|
};
|
|
53
81
|
}
|
|
82
|
+
isRegistered(requirements) {
|
|
83
|
+
return requirements.greenlisted;
|
|
84
|
+
}
|
|
85
|
+
getMissingRequirements() {}
|
|
86
|
+
async #mTokenAddress() {
|
|
87
|
+
if (this.#mToken === void 0) this.#mToken = await this.client.readContract({
|
|
88
|
+
abi: require_onchain_market_adapters_abi_midas_iMidasGatewayV311.iMidasGatewayV311Abi,
|
|
89
|
+
address: this.gateway,
|
|
90
|
+
functionName: "mToken"
|
|
91
|
+
});
|
|
92
|
+
return this.#mToken;
|
|
93
|
+
}
|
|
54
94
|
};
|
|
55
95
|
//#endregion
|
|
56
96
|
exports.MidasDegenNFT = MidasDegenNFT;
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_onchain_utils_AddressSet = require("../../../utils/AddressSet.js");
|
|
3
|
+
require("../../../utils/index.js");
|
|
2
4
|
const require_onchain_base_BaseContract = require("../../../base/BaseContract.js");
|
|
3
5
|
require("../../../base/index.js");
|
|
6
|
+
const require_model_rwa = require("../../../../model/rwa.js");
|
|
7
|
+
require("../../../../model/index.js");
|
|
4
8
|
const require_onchain_market_rwa_securitize_constants = require("./constants.js");
|
|
5
|
-
const require_abi_rwa_iSecuritizeDegenNFT = require("../../../../abi/rwa/iSecuritizeDegenNFT.js");
|
|
6
|
-
let viem = require("viem");
|
|
7
9
|
//#region src/onchain/market/rwa/securitize/SecuritizeDegenNFT.ts
|
|
8
|
-
const abi =
|
|
10
|
+
const abi = require("../../../../abi/rwa/iSecuritizeDegenNFT.js").iSecuritizeDegenNFTAbi;
|
|
11
|
+
/**
|
|
12
|
+
* Securitize always has a factory, which deploys this NFT. DS-token data,
|
|
13
|
+
* registrars and cached signatures live here; the factory only builds txs
|
|
14
|
+
* and looks up investor/wallet addresses.
|
|
15
|
+
*/
|
|
9
16
|
var SecuritizeDegenNFT = class extends require_onchain_base_BaseContract.BaseContract {
|
|
10
17
|
protocol = "securitize";
|
|
18
|
+
registrationLink = require_model_rwa.KYC_REGISTRATION_LINKS.securitize;
|
|
11
19
|
factory;
|
|
20
|
+
#sdk;
|
|
12
21
|
constructor(sdk, address, factory) {
|
|
13
22
|
super(sdk, {
|
|
14
23
|
addr: address,
|
|
@@ -17,19 +26,54 @@ var SecuritizeDegenNFT = class extends require_onchain_base_BaseContract.BaseCon
|
|
|
17
26
|
name: "SecuritizeDegenNFT",
|
|
18
27
|
abi
|
|
19
28
|
});
|
|
29
|
+
this.#sdk = sdk;
|
|
20
30
|
this.factory = factory;
|
|
21
31
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
async getTokens() {
|
|
33
|
+
return this.factory.getTokens();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Registration on Securitize is the protocol-side KYC step; pending
|
|
37
|
+
* EIP-712 signatures are tx-side leftover, not KYC.
|
|
38
|
+
*/
|
|
39
|
+
async getOpenAccountRequirements(wallet, props) {
|
|
40
|
+
const tokensToRegister = new require_onchain_utils_AddressSet.AddressSet(this.factory.getTokens()).has(props.tokenOutAddress) ? new require_onchain_utils_AddressSet.AddressSet([props.tokenOutAddress]) : new require_onchain_utils_AddressSet.AddressSet();
|
|
41
|
+
if (tokensToRegister.size === 0) return {
|
|
42
|
+
protocol: "securitize",
|
|
43
|
+
factory: this.factory.address,
|
|
44
|
+
securitizeTokensToRegister: [],
|
|
45
|
+
tokensToRegister: [],
|
|
46
|
+
requiredSignatures: []
|
|
47
|
+
};
|
|
48
|
+
const [investorData] = await this.#sdk.rwa.getInvestorData(wallet, [this.factory.address]);
|
|
49
|
+
const registredTokens = new require_onchain_utils_AddressSet.AddressSet(investorData.registeredTokens);
|
|
50
|
+
const signedTokens = new require_onchain_utils_AddressSet.AddressSet(investorData.cachedSignatures.map((s) => s.token));
|
|
51
|
+
const unsignedTokens = tokensToRegister.difference(signedTokens);
|
|
52
|
+
const securitizeTokensToRegister = tokensToRegister.difference(registredTokens);
|
|
53
|
+
const requiredSignatures = investorData.registerVaultMessages.filter((m) => unsignedTokens.has(m.message.token));
|
|
54
|
+
return {
|
|
55
|
+
protocol: "securitize",
|
|
56
|
+
factory: this.factory.address,
|
|
57
|
+
securitizeTokensToRegister: Array.from(securitizeTokensToRegister),
|
|
58
|
+
tokensToRegister: Array.from(tokensToRegister),
|
|
59
|
+
requiredSignatures
|
|
28
60
|
};
|
|
29
|
-
|
|
61
|
+
}
|
|
62
|
+
isRegistered(requirements) {
|
|
63
|
+
return requirements.securitizeTokensToRegister.length === 0;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A required signature is omitted when `providedArgs.signaturesToCache`
|
|
67
|
+
* already carries a signature for the same token: the transaction caches it
|
|
68
|
+
* on-chain as part of the operation.
|
|
69
|
+
*/
|
|
70
|
+
getMissingRequirements(requirements, providedArgs) {
|
|
71
|
+
const providedTokens = new require_onchain_utils_AddressSet.AddressSet((providedArgs?.signaturesToCache ?? []).map((s) => s.token));
|
|
72
|
+
const requiredSignatures = requirements.requiredSignatures.filter((message) => !providedTokens.has(message.message.token));
|
|
73
|
+
if (requiredSignatures.length === 0) return;
|
|
30
74
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
75
|
+
protocol: "securitize",
|
|
76
|
+
requiredSignatures
|
|
33
77
|
};
|
|
34
78
|
}
|
|
35
79
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_utils_AddressMap = require("../../../utils/AddressMap.js");
|
|
3
|
-
const require_onchain_utils_AddressSet = require("../../../utils/AddressSet.js");
|
|
4
3
|
require("../../../utils/index.js");
|
|
5
4
|
const require_onchain_base_BaseContract = require("../../../base/BaseContract.js");
|
|
6
5
|
require("../../../base/index.js");
|
|
@@ -12,7 +11,6 @@ let viem = require("viem");
|
|
|
12
11
|
//#region src/onchain/market/rwa/securitize/SecuritizeRWAFactory.ts
|
|
13
12
|
const abi = require_abi_rwa_iSecuritizeRWAFactory.iSecuritizeRWAFactoryAbi;
|
|
14
13
|
var SecuritizeRWAFactory = class extends require_onchain_base_BaseContract.BaseContract {
|
|
15
|
-
#sdk;
|
|
16
14
|
#investorCache = new require_onchain_utils_AddressMap.AddressMap();
|
|
17
15
|
degenNFT;
|
|
18
16
|
owner;
|
|
@@ -24,7 +22,6 @@ var SecuritizeRWAFactory = class extends require_onchain_base_BaseContract.BaseC
|
|
|
24
22
|
name: "SecuritizeRWAFactory",
|
|
25
23
|
abi
|
|
26
24
|
});
|
|
27
|
-
this.#sdk = sdk;
|
|
28
25
|
const decoded = (0, viem.decodeAbiParameters)([
|
|
29
26
|
{
|
|
30
27
|
name: "owner",
|
|
@@ -185,40 +182,6 @@ var SecuritizeRWAFactory = class extends require_onchain_base_BaseContract.BaseC
|
|
|
185
182
|
});
|
|
186
183
|
}
|
|
187
184
|
/**
|
|
188
|
-
* {@inheritDoc IRWAFactory.getOpenAccountRequirements}
|
|
189
|
-
*/
|
|
190
|
-
async getOpenAccountRequirements(investor, props) {
|
|
191
|
-
const [investorData] = await this.#sdk.rwa.getInvestorData(investor, [this.address]);
|
|
192
|
-
const tokensToRegister = new require_onchain_utils_AddressSet.AddressSet([props.tokenOutAddress]);
|
|
193
|
-
const registredTokens = new require_onchain_utils_AddressSet.AddressSet(investorData.registeredTokens);
|
|
194
|
-
const signedTokens = new require_onchain_utils_AddressSet.AddressSet(investorData.cachedSignatures.map((s) => s.token));
|
|
195
|
-
const unsignedTokens = tokensToRegister.difference(signedTokens);
|
|
196
|
-
const securitizeTokensToRegister = tokensToRegister.difference(registredTokens);
|
|
197
|
-
const requiredSignatures = investorData.registerVaultMessages.filter((m) => unsignedTokens.has(m.message.token));
|
|
198
|
-
return {
|
|
199
|
-
type: require_model_rwa.RWA_FACTORY_SECURITIZE,
|
|
200
|
-
securitizeTokensToRegister: Array.from(securitizeTokensToRegister),
|
|
201
|
-
tokensToRegister: Array.from(tokensToRegister),
|
|
202
|
-
requiredSignatures
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* {@inheritDoc IRWAFactory.getMissingRequirements}
|
|
207
|
-
*
|
|
208
|
-
* A required signature is omitted when `providedArgs.signaturesToCache`
|
|
209
|
-
* already carries a signature for the same token: the transaction caches it
|
|
210
|
-
* on-chain as part of the operation.
|
|
211
|
-
*/
|
|
212
|
-
getMissingRequirements(requirements, providedArgs) {
|
|
213
|
-
const providedTokens = new require_onchain_utils_AddressSet.AddressSet((providedArgs?.signaturesToCache ?? []).map((s) => s.token));
|
|
214
|
-
const requiredSignatures = requirements.requiredSignatures.filter((message) => !providedTokens.has(message.message.token));
|
|
215
|
-
if (requiredSignatures.length === 0) return;
|
|
216
|
-
return {
|
|
217
|
-
type: require_model_rwa.RWA_FACTORY_SECURITIZE,
|
|
218
|
-
requiredSignatures
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
185
|
* {@inheritDoc IRWAFactory.openCreditAccount}
|
|
223
186
|
*/
|
|
224
187
|
openCreditAccount(creditManager, calls, args) {
|
|
@@ -38,12 +38,18 @@ var MultichainOpportunitiesService = class extends require_onchain_base_Multicha
|
|
|
38
38
|
*
|
|
39
39
|
* See {@link MultichainOpportunitiesService.getPool}.
|
|
40
40
|
**/
|
|
41
|
-
async getStrategy(key
|
|
41
|
+
async getStrategy(key) {
|
|
42
42
|
return this.queryChain({
|
|
43
43
|
network: key.chainId,
|
|
44
|
-
run: (sdk) => sdk.opportunities.getStrategy(key
|
|
44
|
+
run: (sdk) => sdk.opportunities.getStrategy(key)
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritDoc OpportunitiesService.isEligibleForStrategy}
|
|
49
|
+
**/
|
|
50
|
+
async isEligibleForStrategy(key, wallet) {
|
|
51
|
+
return this.sdk.chain(key.chainId).opportunities.isEligibleForStrategy(key, wallet);
|
|
52
|
+
}
|
|
47
53
|
};
|
|
48
54
|
//#endregion
|
|
49
55
|
exports.MultichainOpportunitiesService = MultichainOpportunitiesService;
|
|
@@ -37,22 +37,34 @@ var OpportunitiesService = class extends require_onchain_base_SDKConstruct.SDKCo
|
|
|
37
37
|
* A single strategy opportunity plus the rate curve of the pool it borrows
|
|
38
38
|
* from and the price feeds its liquidation price depends on.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
41
|
-
* with the strategy's KYC provider first; `null` otherwise.
|
|
40
|
+
* `kyc` is the strategy's KYC gate, independent of any wallet.
|
|
42
41
|
*
|
|
43
42
|
* @throws If the credit manager is unknown, or does not currently offer a
|
|
44
43
|
* strategy.
|
|
45
44
|
**/
|
|
46
|
-
async getStrategy(key
|
|
45
|
+
async getStrategy(key) {
|
|
47
46
|
const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
|
|
48
47
|
const detail = suite.strategyOpportunityDetail();
|
|
49
48
|
if (!detail) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
|
|
50
|
-
const kyc =
|
|
49
|
+
const kyc = await suite.kycRequirement(detail.targetCollateral.address);
|
|
51
50
|
return {
|
|
52
51
|
...detail,
|
|
53
52
|
kyc
|
|
54
53
|
};
|
|
55
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether `wallet` may open this strategy today: `true` when it is not
|
|
57
|
+
* KYC-gated or the wallet already passed the gate.
|
|
58
|
+
*
|
|
59
|
+
* @throws If the credit manager is unknown, or does not currently offer a
|
|
60
|
+
* strategy.
|
|
61
|
+
**/
|
|
62
|
+
async isEligibleForStrategy(key, wallet) {
|
|
63
|
+
const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
|
|
64
|
+
const opportunity = suite.strategyOpportunity();
|
|
65
|
+
if (!opportunity) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
|
|
66
|
+
return suite.isEligibleForStrategy(wallet, opportunity.targetCollateral.address);
|
|
67
|
+
}
|
|
56
68
|
};
|
|
57
69
|
//#endregion
|
|
58
70
|
exports.OpportunitiesService = OpportunitiesService;
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_onchain_utils_hex = require("../../utils/hex.js");
|
|
3
3
|
const require_onchain_market_adapters_contracts_AbstractAdapter = require("../../market/adapters/contracts/AbstractAdapter.js");
|
|
4
4
|
const require_onchain_market_credit_CreditFacadeV310Contract = require("../../market/credit/CreditFacadeV310Contract.js");
|
|
5
|
-
|
|
5
|
+
require("../../../model/rwa.js");
|
|
6
6
|
require("../../../model/index.js");
|
|
7
7
|
const require_onchain_market_rwa_types = require("../../market/rwa/types.js");
|
|
8
8
|
const require_onchain_preview_parse_classifyInnerOperations = require("./classifyInnerOperations.js");
|
|
@@ -33,7 +33,7 @@ function parseSecuritizeOperationCalldata(sdk, factory, calldata) {
|
|
|
33
33
|
const { rawArgs } = parsed;
|
|
34
34
|
const innerCalls = rawArgs.calls ?? [];
|
|
35
35
|
const args = {
|
|
36
|
-
|
|
36
|
+
protocol: "securitize",
|
|
37
37
|
tokensToRegister: [...rawArgs.tokensToRegister ?? []],
|
|
38
38
|
signaturesToCache: [...rawArgs.signaturesToCache ?? []]
|
|
39
39
|
};
|
|
@@ -5,11 +5,11 @@ const require_onchain_validation_checks_checkDebtLimits = require("../checks/che
|
|
|
5
5
|
require("../checks/index.js");
|
|
6
6
|
const require_onchain_validation_bundles_checkAccountQuotas = require("./checkAccountQuotas.js");
|
|
7
7
|
const require_onchain_validation_bundles_checkCollateralFunding = require("./checkCollateralFunding.js");
|
|
8
|
-
const require_onchain_validation_bundles_checkDraw = require("./checkDraw.js");
|
|
9
8
|
const require_onchain_validation_bundles_checkHealthFactors = require("./checkHealthFactors.js");
|
|
9
|
+
const require_onchain_validation_bundles_checkIncreaseDebt = require("./checkIncreaseDebt.js");
|
|
10
|
+
const require_onchain_validation_bundles_checkIncreaseQuota = require("./checkIncreaseQuota.js");
|
|
10
11
|
const require_onchain_validation_bundles_checkMarket = require("./checkMarket.js");
|
|
11
12
|
const require_onchain_validation_bundles_checkObtained = require("./checkObtained.js");
|
|
12
|
-
const require_onchain_validation_bundles_checkQuotasAsked = require("./checkQuotasAsked.js");
|
|
13
13
|
const require_onchain_validation_bundles_checkRWAOpening = require("./checkRWAOpening.js");
|
|
14
14
|
//#region src/onchain/validation/bundles/checkCreditOperation.ts
|
|
15
15
|
/**
|
|
@@ -17,8 +17,9 @@ const require_onchain_validation_bundles_checkRWAOpening = require("./checkRWAOp
|
|
|
17
17
|
* has to hold, approve or sign.
|
|
18
18
|
*
|
|
19
19
|
* The array is in check order, most fundamental first: the market's own state,
|
|
20
|
-
* then what the facade would revert on, then what the operation
|
|
21
|
-
*
|
|
20
|
+
* then what the facade would revert on, then what the operation borrows and the
|
|
21
|
+
* quota it increases, then the account it leaves behind, and last the wallet's
|
|
22
|
+
* side.
|
|
22
23
|
*/
|
|
23
24
|
async function checkCreditOperation(args) {
|
|
24
25
|
const { sdk, preview, sender, blockNumber, ...thresholds } = args;
|
|
@@ -36,10 +37,10 @@ async function checkCreditOperation(args) {
|
|
|
36
37
|
allowZero: !isOpening,
|
|
37
38
|
maxBorrowAmount: suite.maxBorrowAmount()
|
|
38
39
|
}),
|
|
39
|
-
...
|
|
40
|
+
...require_onchain_validation_bundles_checkIncreaseDebt.checkIncreaseDebt(suite, preview, underlying),
|
|
40
41
|
...require_onchain_validation_bundles_checkObtained.checkObtained(suite, preview),
|
|
41
42
|
...require_onchain_validation_bundles_checkAccountQuotas.checkAccountQuotas(suite, preview),
|
|
42
|
-
...
|
|
43
|
+
...require_onchain_validation_bundles_checkIncreaseQuota.checkIncreaseQuota(market, preview, underlying),
|
|
43
44
|
...require_onchain_validation_bundles_checkHealthFactors.checkHealthFactors({
|
|
44
45
|
totalDebt: preview.totalDebt,
|
|
45
46
|
healthFactor: preview.estHealthFactor,
|
|
@@ -51,7 +52,7 @@ async function checkCreditOperation(args) {
|
|
|
51
52
|
preview,
|
|
52
53
|
sender,
|
|
53
54
|
blockNumber
|
|
54
|
-
}), preview.operation === "RWAOpenCreditAccount" ? require_onchain_validation_bundles_checkRWAOpening.checkRWAOpening({
|
|
55
|
+
}), preview.operation === "OpenCreditAccount" || preview.operation === "RWAOpenCreditAccount" ? require_onchain_validation_bundles_checkRWAOpening.checkRWAOpening({
|
|
55
56
|
sdk,
|
|
56
57
|
preview,
|
|
57
58
|
sender
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_validation_checks_checkBorrowLimit = require("../checks/checkBorrowLimit.js");
|
|
3
3
|
require("../checks/index.js");
|
|
4
|
-
//#region src/onchain/validation/bundles/
|
|
4
|
+
//#region src/onchain/validation/bundles/checkIncreaseDebt.ts
|
|
5
5
|
/**
|
|
6
|
-
* What the transaction
|
|
6
|
+
* What the transaction borrows, against what the market can lend right now.
|
|
7
7
|
*
|
|
8
|
-
* Only a
|
|
9
|
-
*
|
|
10
|
-
* `totalDebtChange`.
|
|
8
|
+
* Only a debt increase is weighed: repaying, or leaving the debt alone, can
|
|
9
|
+
* never exceed the borrow limit. Opening borrows the whole debt; adjusting
|
|
10
|
+
* borrows `totalDebtChange`.
|
|
11
11
|
*
|
|
12
12
|
* The engine holds every simulation to this already (`assertCanBorrow`), so
|
|
13
13
|
* this is here for the transactions it never saw — a pasted calldata reaches
|
|
14
14
|
* the confirm screen with nothing else standing between it and a revert.
|
|
15
15
|
*/
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
16
|
+
function checkIncreaseDebt(suite, preview, underlying) {
|
|
17
|
+
const debtIncrease = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
|
|
18
|
+
if (debtIncrease <= 0n) return [];
|
|
19
19
|
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
20
20
|
return require_onchain_validation_checks_checkBorrowLimit.checkBorrowLimit({
|
|
21
|
-
requested:
|
|
21
|
+
requested: debtIncrease,
|
|
22
22
|
available: maxBorrowAmount.amount.value,
|
|
23
23
|
limit: maxBorrowAmount.limit,
|
|
24
24
|
underlying
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
|
-
exports.
|
|
28
|
+
exports.checkIncreaseDebt = checkIncreaseDebt;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_validation_checks_checkQuotaLimit = require("../checks/checkQuotaLimit.js");
|
|
3
3
|
require("../checks/index.js");
|
|
4
|
-
//#region src/onchain/validation/bundles/
|
|
4
|
+
//#region src/onchain/validation/bundles/checkIncreaseQuota.ts
|
|
5
5
|
/** Every quota the operation raises, against the room the keeper has left. */
|
|
6
|
-
function
|
|
6
|
+
function checkIncreaseQuota(market, preview, underlying) {
|
|
7
7
|
const increases = preview.operation === "AdjustCreditAccount" ? preview.quotasChange : preview.quotas;
|
|
8
8
|
const { pqk } = market.pool;
|
|
9
9
|
return increases.filter((q) => q.value > 0n).flatMap((q) => {
|
|
@@ -17,4 +17,4 @@ function checkQuotasAsked(market, preview, underlying) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
|
-
exports.
|
|
20
|
+
exports.checkIncreaseQuota = checkIncreaseQuota;
|