@gearbox-protocol/sdk 16.3.0-next.3 → 16.3.0-next.4
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/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 +1 -1
- package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +6 -5
- 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/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 +1 -1
- package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +6 -5
- 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 +6 -4
- package/dist/types/model/index.d.ts +3 -3
- package/dist/types/model/opportunities.d.ts +4 -5
- 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 +2 -2
- 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/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/checkRWAOpenRequirements.d.ts +2 -2
- package/dist/types/onchain/validation/bundles/checkRWAOpening.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
|
@@ -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");
|
|
@@ -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
|
};
|
|
@@ -51,7 +51,7 @@ async function checkCreditOperation(args) {
|
|
|
51
51
|
preview,
|
|
52
52
|
sender,
|
|
53
53
|
blockNumber
|
|
54
|
-
}), preview.operation === "RWAOpenCreditAccount" ? require_onchain_validation_bundles_checkRWAOpening.checkRWAOpening({
|
|
54
|
+
}), preview.operation === "OpenCreditAccount" || preview.operation === "RWAOpenCreditAccount" ? require_onchain_validation_bundles_checkRWAOpening.checkRWAOpening({
|
|
55
55
|
sdk,
|
|
56
56
|
preview,
|
|
57
57
|
sender
|
|
@@ -6,24 +6,24 @@ const require_onchain_validation_helpers_token = require("../helpers/token.js");
|
|
|
6
6
|
require("../helpers/index.js");
|
|
7
7
|
//#region src/onchain/validation/bundles/checkRWAOpenRequirements.ts
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
9
|
+
* The degen NFT is satisfied that `wallet` may open on `token` with the
|
|
10
10
|
* registration args already on the transaction.
|
|
11
11
|
*/
|
|
12
12
|
async function checkRWAOpenRequirements(input) {
|
|
13
13
|
const { sdk, wallet, creditManager, token, providedArgs } = input;
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!missing && requirements.securitizeTokensToRegister.length === 0) return [];
|
|
15
|
+
const nft = await sdk.marketRegister.findCreditManager(creditManager).degenNFT();
|
|
16
|
+
if (!nft) return [];
|
|
17
|
+
const requirements = await nft.getOpenAccountRequirements(wallet, { tokenOutAddress: token });
|
|
18
|
+
const missing = nft.getMissingRequirements(requirements, providedArgs);
|
|
19
|
+
if (!missing && nft.isRegistered(requirements)) return [];
|
|
21
20
|
return [require_model_errors_operation_errors.rwaOpenRequirementsNotMet({
|
|
22
21
|
token: require_onchain_validation_helpers_token.toToken(sdk, token),
|
|
23
22
|
creditManager,
|
|
24
|
-
|
|
23
|
+
protocol: nft.protocol,
|
|
24
|
+
registrationLink: nft.registrationLink,
|
|
25
25
|
requirements,
|
|
26
|
-
|
|
26
|
+
missing
|
|
27
27
|
})];
|
|
28
28
|
} catch (cause) {
|
|
29
29
|
return [require_model_errors_prepare_errors.unexpectedFailure(cause, "read the RWA opening requirements")];
|
|
@@ -3,21 +3,22 @@ const require_onchain_utils_AddressSet = require("../../utils/AddressSet.js");
|
|
|
3
3
|
const require_onchain_validation_bundles_checkRWAOpenRequirements = require("./checkRWAOpenRequirements.js");
|
|
4
4
|
//#region src/onchain/validation/bundles/checkRWAOpening.ts
|
|
5
5
|
/**
|
|
6
|
-
* Per
|
|
6
|
+
* Per KYC-gated token among `collateralAdded ∪ quotas`, whether the
|
|
7
7
|
* borrower still has to register or sign before this opening can land.
|
|
8
8
|
*/
|
|
9
9
|
async function checkRWAOpening(input) {
|
|
10
10
|
const { sdk, preview, sender } = input;
|
|
11
|
-
const
|
|
12
|
-
if (!
|
|
13
|
-
const gated = new require_onchain_utils_AddressSet.AddressSet(
|
|
11
|
+
const nft = await sdk.marketRegister.findCreditManager(preview.creditManager).degenNFT();
|
|
12
|
+
if (!nft) return [];
|
|
13
|
+
const gated = new require_onchain_utils_AddressSet.AddressSet(await nft.getTokens());
|
|
14
14
|
const candidates = new require_onchain_utils_AddressSet.AddressSet([...preview.collateralAdded.map((a) => a.token.address), ...preview.quotas.map((q) => q.token.address)]);
|
|
15
|
+
const providedArgs = preview.operation === "RWAOpenCreditAccount" ? preview.rwaArgs : void 0;
|
|
15
16
|
return (await Promise.all([...candidates].filter((token) => gated.has(token)).map((token) => require_onchain_validation_bundles_checkRWAOpenRequirements.checkRWAOpenRequirements({
|
|
16
17
|
sdk,
|
|
17
18
|
wallet: sender,
|
|
18
19
|
creditManager: preview.creditManager,
|
|
19
20
|
token,
|
|
20
|
-
providedArgs
|
|
21
|
+
providedArgs
|
|
21
22
|
})))).flat();
|
|
22
23
|
}
|
|
23
24
|
//#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 (
|
|
77
|
+
if (requirements?.protocol !== "securitize") return;
|
|
78
78
|
return {
|
|
79
|
-
|
|
79
|
+
protocol: "securitize",
|
|
80
80
|
tokensToRegister: requirements.tokensToRegister,
|
|
81
81
|
signaturesToCache: request.signaturesToCache ?? []
|
|
82
82
|
};
|
|
@@ -71,15 +71,21 @@ 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) {
|
|
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),
|
|
78
|
+
fromBackend: (source) => source.getStrategy(key),
|
|
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
|
+
/**
|
|
83
89
|
* {@inheritDoc IOpportunitiesBase.filter}
|
|
84
90
|
**/
|
|
85
91
|
filter(response, filter) {
|
|
@@ -113,7 +113,7 @@ function insufficientAllowance(args) {
|
|
|
113
113
|
function rwaOpenRequirementsNotMet(args) {
|
|
114
114
|
return {
|
|
115
115
|
code: "rwaOpenRequirementsNotMet",
|
|
116
|
-
message:
|
|
116
|
+
message: `${args.protocol} still wants something from the borrower before ${args.token.symbol} can be opened on.`,
|
|
117
117
|
...args
|
|
118
118
|
};
|
|
119
119
|
}
|