@gearbox-protocol/sdk 14.0.0 → 14.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/abi/kyc/iDSRegistryService.js +149 -0
- package/dist/cjs/abi/kyc/iDSToken.js +71 -0
- package/dist/cjs/abi/kyc/iKYCCompressor.js +196 -0
- package/dist/cjs/abi/kyc/iKYCFactory.js +122 -0
- package/dist/cjs/abi/kyc/iKYCUnderlying.js +401 -0
- package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +326 -0
- package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +319 -0
- package/dist/cjs/dev/AccountOpener.js +45 -5
- package/dist/cjs/sdk/OnchainSDK.js +55 -5
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +335 -21
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +7 -1
- package/dist/cjs/sdk/base/TokensMeta.js +22 -42
- package/dist/cjs/sdk/base/token-types.js +9 -0
- package/dist/cjs/sdk/chain/chains.js +18 -1
- package/dist/cjs/sdk/constants/address-provider.js +3 -0
- package/dist/cjs/sdk/market/MarketRegister.js +70 -116
- package/dist/cjs/sdk/market/MarketSuite.js +3 -0
- package/dist/cjs/sdk/market/index.js +2 -0
- package/dist/cjs/sdk/market/kyc/KYCRegistry.js +269 -0
- package/dist/cjs/sdk/market/kyc/index.js +26 -0
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +242 -0
- package/dist/cjs/sdk/market/kyc/securitize/constants.js +28 -0
- package/dist/cjs/sdk/market/kyc/securitize/index.js +26 -0
- package/dist/cjs/sdk/market/kyc/securitize/types.js +16 -0
- package/dist/cjs/sdk/{accounts/utils.js → market/kyc/types.js} +11 -15
- package/dist/cjs/sdk/market/pool/PoolSuite.js +3 -0
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +11 -2
- package/dist/cjs/sdk/market/pool/index.js +2 -0
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
- package/dist/cjs/sdk/options.js +6 -0
- package/dist/cjs/sdk/pools/PoolService.js +104 -12
- package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +38 -0
- package/dist/cjs/sdk/utils/viem/index.js +2 -0
- package/dist/esm/abi/kyc/iDSRegistryService.js +125 -0
- package/dist/esm/abi/kyc/iDSToken.js +47 -0
- package/dist/esm/abi/kyc/iKYCCompressor.js +172 -0
- package/dist/esm/abi/kyc/iKYCFactory.js +98 -0
- package/dist/esm/abi/kyc/iKYCUnderlying.js +377 -0
- package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +302 -0
- package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +295 -0
- package/dist/esm/dev/AccountOpener.js +47 -6
- package/dist/esm/sdk/OnchainSDK.js +57 -5
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +336 -22
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +7 -1
- package/dist/esm/sdk/base/TokensMeta.js +22 -44
- package/dist/esm/sdk/base/token-types.js +6 -0
- package/dist/esm/sdk/chain/chains.js +18 -1
- package/dist/esm/sdk/constants/address-provider.js +2 -0
- package/dist/esm/sdk/market/MarketRegister.js +74 -118
- package/dist/esm/sdk/market/MarketSuite.js +3 -0
- package/dist/esm/sdk/market/index.js +1 -0
- package/dist/esm/sdk/market/kyc/KYCRegistry.js +253 -0
- package/dist/esm/sdk/market/kyc/index.js +3 -0
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +218 -0
- package/dist/esm/sdk/market/kyc/securitize/constants.js +4 -0
- package/dist/esm/sdk/market/kyc/securitize/index.js +3 -0
- package/dist/esm/sdk/market/kyc/securitize/types.js +0 -0
- package/dist/esm/sdk/market/kyc/types.js +9 -0
- package/dist/esm/sdk/market/pool/PoolSuite.js +3 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +11 -2
- package/dist/esm/sdk/market/pool/index.js +1 -0
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
- package/dist/esm/sdk/options.js +6 -0
- package/dist/esm/sdk/pools/PoolService.js +109 -13
- package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +14 -0
- package/dist/esm/sdk/utils/viem/index.js +1 -0
- package/dist/types/abi/kyc/iDSRegistryService.d.ts +191 -0
- package/dist/types/abi/kyc/iDSToken.d.ts +67 -0
- package/dist/types/abi/kyc/iKYCCompressor.d.ts +228 -0
- package/dist/types/abi/kyc/iKYCFactory.d.ts +139 -0
- package/dist/types/abi/kyc/iKYCUnderlying.d.ts +548 -0
- package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +404 -0
- package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +376 -0
- package/dist/types/sdk/OnchainSDK.d.ts +19 -1
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +59 -6
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +114 -14
- package/dist/types/sdk/base/TokensMeta.d.ts +14 -3
- package/dist/types/sdk/base/token-types.d.ts +44 -4
- package/dist/types/sdk/base/types.d.ts +116 -2
- package/dist/types/sdk/chain/chains.d.ts +5 -1
- package/dist/types/sdk/constants/address-provider.d.ts +1 -0
- package/dist/types/sdk/market/MarketRegister.d.ts +6 -9
- package/dist/types/sdk/market/MarketSuite.d.ts +2 -0
- package/dist/types/sdk/market/index.d.ts +1 -0
- package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +52 -0
- package/dist/types/sdk/market/kyc/index.d.ts +3 -0
- package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +429 -0
- package/dist/types/sdk/market/kyc/securitize/constants.d.ts +1 -0
- package/dist/types/sdk/market/kyc/securitize/index.d.ts +3 -0
- package/dist/types/sdk/market/kyc/securitize/types.d.ts +136 -0
- package/dist/types/sdk/market/kyc/types.d.ts +171 -0
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +3 -2
- package/dist/types/sdk/market/oracle/types.d.ts +3 -10
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -0
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +6 -2
- package/dist/types/sdk/market/pool/index.d.ts +1 -0
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -1
- package/dist/types/sdk/market/types.d.ts +1 -1
- package/dist/types/sdk/options.d.ts +1 -0
- package/dist/types/sdk/pools/PoolService.d.ts +8 -8
- package/dist/types/sdk/pools/types.d.ts +1 -1
- package/dist/types/sdk/types/state-human.d.ts +2 -0
- package/dist/types/sdk/types/state.d.ts +5 -0
- package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +28 -0
- package/dist/types/sdk/utils/viem/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/esm/sdk/accounts/utils.js +0 -14
- package/dist/types/sdk/accounts/utils.d.ts +0 -2
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var KYCRegistry_exports = {};
|
|
20
|
+
__export(KYCRegistry_exports, {
|
|
21
|
+
KYCRegistry: () => KYCRegistry
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(KYCRegistry_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_iKYCCompressor = require("../../../abi/kyc/iKYCCompressor.js");
|
|
26
|
+
var import_base = require("../../base/index.js");
|
|
27
|
+
var import_constants = require("../../constants/index.js");
|
|
28
|
+
var import_utils = require("../../utils/index.js");
|
|
29
|
+
var import_securitize = require("./securitize/index.js");
|
|
30
|
+
class KYCRegistry extends import_base.SDKConstruct {
|
|
31
|
+
#state;
|
|
32
|
+
#factories = new import_utils.AddressMap();
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
*
|
|
36
|
+
* Returns delegated multicalls for loading all KYC underlying tokens from the on-chain KYC compressor.
|
|
37
|
+
* Used by the SDK to compose batched RPC calls.
|
|
38
|
+
*
|
|
39
|
+
* @param configurators - Market configurators to query.
|
|
40
|
+
* @param kycFactories - KYC factory contracts to query.
|
|
41
|
+
*/
|
|
42
|
+
getLoadMulticalls(configurators, kycFactories = []) {
|
|
43
|
+
if (!kycFactories.length) return [];
|
|
44
|
+
const [kycCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
45
|
+
import_constants.AP_KYC_COMPRESSOR,
|
|
46
|
+
import_constants.VERSION_RANGE_310
|
|
47
|
+
);
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
call: {
|
|
51
|
+
abi: import_iKYCCompressor.iKYCCompressorAbi,
|
|
52
|
+
address: kycCompressorAddress,
|
|
53
|
+
functionName: "getKYCMarketsData",
|
|
54
|
+
args: [configurators, kycFactories]
|
|
55
|
+
},
|
|
56
|
+
onResult: (resp) => this.setState(resp)
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fetches decoded investor data from the on-chain KYC compressor.
|
|
62
|
+
*
|
|
63
|
+
* Each factory produces its own investor data (e.g. registered tokens,
|
|
64
|
+
* cached signatures, EIP-712 messages to sign).
|
|
65
|
+
*
|
|
66
|
+
* @param investor - Investor EOA address.
|
|
67
|
+
* @param factories_ - Optional subset of factory addresses to query.
|
|
68
|
+
* When omitted, all loaded factories are used.
|
|
69
|
+
*/
|
|
70
|
+
async getInvestorData(investor, factories_) {
|
|
71
|
+
const [kycCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
72
|
+
import_constants.AP_KYC_COMPRESSOR,
|
|
73
|
+
import_constants.VERSION_RANGE_310
|
|
74
|
+
);
|
|
75
|
+
let factories = this.#factories.values();
|
|
76
|
+
if (factories_?.length) {
|
|
77
|
+
factories = factories_.map((f) => this.#factories.mustGet(f));
|
|
78
|
+
}
|
|
79
|
+
const resp = await this.client.readContract({
|
|
80
|
+
abi: import_iKYCCompressor.iKYCCompressorAbi,
|
|
81
|
+
address: kycCompressorAddress,
|
|
82
|
+
functionName: "getKYCInvestorData",
|
|
83
|
+
args: [investor, factories.map((f) => f.address)]
|
|
84
|
+
});
|
|
85
|
+
const result = [];
|
|
86
|
+
for (let i = 0; i < factories.length; i++) {
|
|
87
|
+
const factory = factories[i];
|
|
88
|
+
const factoryData = resp[i];
|
|
89
|
+
const investorData = factory.decodeInvestorData(factoryData);
|
|
90
|
+
result.push(investorData);
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
/** All loaded KYC factory instances. */
|
|
95
|
+
get factories() {
|
|
96
|
+
return this.#factories.values();
|
|
97
|
+
}
|
|
98
|
+
/** Raw KYC compressor response, or `undefined` before attach/hydrate. */
|
|
99
|
+
get state() {
|
|
100
|
+
return this.#state;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns a human-readable snapshot of the KYC state.
|
|
104
|
+
*/
|
|
105
|
+
stateHuman(raw) {
|
|
106
|
+
return {
|
|
107
|
+
factories: this.factories.map((f) => f.stateHuman(raw))
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @internal
|
|
112
|
+
*
|
|
113
|
+
* Replaces the internal state with a new KYC compressor response.
|
|
114
|
+
* Rebuilds token metadata for KYC underlyings and re-instantiates factory
|
|
115
|
+
* wrappers.
|
|
116
|
+
*/
|
|
117
|
+
setState(resp) {
|
|
118
|
+
this.#state = resp;
|
|
119
|
+
for (const u of resp?.[0] ?? []) {
|
|
120
|
+
this.#loadUnderlyingTokenData(u);
|
|
121
|
+
}
|
|
122
|
+
this.#factories.clear();
|
|
123
|
+
for (const f of resp?.[1] ?? []) {
|
|
124
|
+
this.#loadKYCFactoryData(f);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
#loadUnderlyingTokenData(u) {
|
|
128
|
+
const contractType = (0, import_utils.bytes32ToString)(u.baseParams.contractType);
|
|
129
|
+
const meta = this.tokensMeta.get(u.baseParams.addr);
|
|
130
|
+
if (!meta) {
|
|
131
|
+
throw new Error(
|
|
132
|
+
`KYC underlying token ${contractType} (${u.baseParams.addr}) not found in tokensMeta`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
switch (contractType) {
|
|
136
|
+
case import_base.KYC_UNDERLYING_DEFAULT:
|
|
137
|
+
this.#loadKYCUnderlyingDefault(meta, u);
|
|
138
|
+
break;
|
|
139
|
+
case import_base.KYC_UNDERLYING_ON_DEMAND:
|
|
140
|
+
this.#loadKYCUnderlyingOnDemand(meta, u);
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
if (this.sdk.strictContractTypes) {
|
|
144
|
+
throw new Error(`Unknown KYC underlying type: ${contractType}`);
|
|
145
|
+
}
|
|
146
|
+
this.logger?.warn(`unknown KYC underlying type: ${contractType}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
#loadKYCUnderlyingDefault(meta, data) {
|
|
150
|
+
const decoded = (0, import_viem.decodeAbiParameters)(
|
|
151
|
+
[
|
|
152
|
+
{ name: "factory", type: "address" },
|
|
153
|
+
{ name: "asset", type: "address" }
|
|
154
|
+
],
|
|
155
|
+
data.baseParams.serializedParams
|
|
156
|
+
);
|
|
157
|
+
this.tokensMeta.upsert(data.baseParams.addr, {
|
|
158
|
+
...meta,
|
|
159
|
+
contractType: import_base.KYC_UNDERLYING_DEFAULT,
|
|
160
|
+
kycFactory: decoded[0],
|
|
161
|
+
asset: decoded[1]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
#loadKYCUnderlyingOnDemand(meta, data) {
|
|
165
|
+
const decoded = (0, import_viem.decodeAbiParameters)(
|
|
166
|
+
[
|
|
167
|
+
{ name: "factory", type: "address" },
|
|
168
|
+
{ name: "asset", type: "address" },
|
|
169
|
+
{ name: "pool", type: "address" },
|
|
170
|
+
{ name: "liquidityProvider", type: "address" },
|
|
171
|
+
{ name: "marketConfigurator", type: "address" },
|
|
172
|
+
{ name: "allowedDepositors", type: "address[]" }
|
|
173
|
+
],
|
|
174
|
+
data.baseParams.serializedParams
|
|
175
|
+
);
|
|
176
|
+
const lpMeta = this.#getOnDemandLPMeta(data.extraDetails);
|
|
177
|
+
if (decoded[3] !== lpMeta.addr) {
|
|
178
|
+
throw new Error(
|
|
179
|
+
`Liquidity provider mismatch: ${decoded[3]} !== ${lpMeta.addr} for on-demand underlying ${data.baseParams.addr}`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
this.tokensMeta.upsert(data.baseParams.addr, {
|
|
183
|
+
...meta,
|
|
184
|
+
contractType: import_base.KYC_UNDERLYING_ON_DEMAND,
|
|
185
|
+
kycFactory: decoded[0],
|
|
186
|
+
asset: decoded[1],
|
|
187
|
+
pool: decoded[2],
|
|
188
|
+
marketConfigurator: decoded[4],
|
|
189
|
+
allowedDepositors: decoded[5],
|
|
190
|
+
// liquidityProvider: decoded[3],
|
|
191
|
+
liquidityProvider: lpMeta
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
#getOnDemandLPMeta(extraDetails) {
|
|
195
|
+
const [decoded] = (0, import_viem.decodeAbiParameters)(
|
|
196
|
+
[
|
|
197
|
+
{
|
|
198
|
+
name: "baseParams",
|
|
199
|
+
type: "tuple",
|
|
200
|
+
components: [
|
|
201
|
+
{ name: "addr", type: "address" },
|
|
202
|
+
{ name: "version", type: "uint256" },
|
|
203
|
+
{ name: "contractType", type: "bytes32" },
|
|
204
|
+
{ name: "serializedParams", type: "bytes" }
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
extraDetails
|
|
209
|
+
);
|
|
210
|
+
const contractType = (0, import_utils.bytes32ToString)(decoded.contractType);
|
|
211
|
+
switch (contractType) {
|
|
212
|
+
case import_base.KYC_ON_DEMAND_LP_MONOPOLIZED:
|
|
213
|
+
return this.#getOnDemandLPMonopolizedMeta(
|
|
214
|
+
decoded.addr,
|
|
215
|
+
decoded.version,
|
|
216
|
+
decoded.serializedParams
|
|
217
|
+
);
|
|
218
|
+
default:
|
|
219
|
+
throw new Error(`Unknown on-demand LP contract type: ${contractType}`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
#getOnDemandLPMonopolizedMeta(addr, version, serializedParams) {
|
|
223
|
+
const [marketConfigurator, depositor, pools] = (0, import_viem.decodeAbiParameters)(
|
|
224
|
+
[
|
|
225
|
+
{ name: "marketConfigurator", type: "address" },
|
|
226
|
+
{ name: "depositor", type: "address" },
|
|
227
|
+
{
|
|
228
|
+
name: "pools",
|
|
229
|
+
type: "tuple[]",
|
|
230
|
+
components: [
|
|
231
|
+
{ name: "pool", type: "address" },
|
|
232
|
+
{ name: "wrappedUnderlying", type: "address" },
|
|
233
|
+
{ name: "unwrappedUnderlying", type: "address" },
|
|
234
|
+
{ name: "depositAllowance", type: "uint256" },
|
|
235
|
+
{ name: "claimableAmount", type: "uint256" }
|
|
236
|
+
]
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
serializedParams
|
|
240
|
+
);
|
|
241
|
+
return {
|
|
242
|
+
addr,
|
|
243
|
+
version,
|
|
244
|
+
contractType: import_base.KYC_ON_DEMAND_LP_MONOPOLIZED,
|
|
245
|
+
marketConfigurator,
|
|
246
|
+
depositor,
|
|
247
|
+
pools: [...pools]
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
#loadKYCFactoryData(data) {
|
|
251
|
+
const contractType = (0, import_utils.bytes32ToString)(data.baseParams.contractType);
|
|
252
|
+
switch (contractType) {
|
|
253
|
+
case import_securitize.KYC_FACTORY_SECURITIZE:
|
|
254
|
+
this.#factories.upsert(
|
|
255
|
+
data.baseParams.addr,
|
|
256
|
+
new import_securitize.SecuritizeKYCFactory(this.sdk, data)
|
|
257
|
+
);
|
|
258
|
+
break;
|
|
259
|
+
default:
|
|
260
|
+
throw new Error(
|
|
261
|
+
`Unknown KYC factory type: ${contractType} for ${data.baseParams.addr}`
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
267
|
+
0 && (module.exports = {
|
|
268
|
+
KYCRegistry
|
|
269
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var kyc_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(kyc_exports);
|
|
18
|
+
__reExport(kyc_exports, require("./KYCRegistry.js"), module.exports);
|
|
19
|
+
__reExport(kyc_exports, require("./securitize/index.js"), module.exports);
|
|
20
|
+
__reExport(kyc_exports, require("./types.js"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./KYCRegistry.js"),
|
|
24
|
+
...require("./securitize/index.js"),
|
|
25
|
+
...require("./types.js")
|
|
26
|
+
});
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var SecuritizeKYCFactory_exports = {};
|
|
20
|
+
__export(SecuritizeKYCFactory_exports, {
|
|
21
|
+
SecuritizeKYCFactory: () => SecuritizeKYCFactory
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(SecuritizeKYCFactory_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_iSecuritizeKYCFactory = require("../../../../abi/kyc/iSecuritizeKYCFactory.js");
|
|
26
|
+
var import_base = require("../../../base/index.js");
|
|
27
|
+
var import_utils = require("../../../utils/index.js");
|
|
28
|
+
var import_constants = require("./constants.js");
|
|
29
|
+
const abi = import_iSecuritizeKYCFactory.iSecuritizeKYCFactoryAbi;
|
|
30
|
+
class SecuritizeKYCFactory extends import_base.BaseContract {
|
|
31
|
+
#sdk;
|
|
32
|
+
#investorCache = new import_utils.AddressMap();
|
|
33
|
+
degenNFT;
|
|
34
|
+
owner;
|
|
35
|
+
dsTokens;
|
|
36
|
+
contractType = import_constants.KYC_FACTORY_SECURITIZE;
|
|
37
|
+
constructor(sdk, data) {
|
|
38
|
+
super(sdk, {
|
|
39
|
+
...data.baseParams,
|
|
40
|
+
name: "SecuritizeKYCFactory",
|
|
41
|
+
abi
|
|
42
|
+
});
|
|
43
|
+
this.#sdk = sdk;
|
|
44
|
+
const decoded = (0, import_viem.decodeAbiParameters)(
|
|
45
|
+
[
|
|
46
|
+
{ name: "owner", type: "address" },
|
|
47
|
+
{ name: "degenNFT", type: "address" },
|
|
48
|
+
{
|
|
49
|
+
name: "dsTokensData",
|
|
50
|
+
type: "tuple[]",
|
|
51
|
+
components: [
|
|
52
|
+
{ name: "token", type: "address" },
|
|
53
|
+
{ name: "registrar", type: "address" },
|
|
54
|
+
{ name: "operators", type: "address[]" }
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
data.baseParams.serializedParams
|
|
59
|
+
);
|
|
60
|
+
this.owner = decoded[0];
|
|
61
|
+
this.degenNFT = decoded[1];
|
|
62
|
+
for (const t of data.tokens) {
|
|
63
|
+
this.tokensMeta.upsert(t.addr, t);
|
|
64
|
+
}
|
|
65
|
+
this.dsTokens = decoded[2].map((t) => ({
|
|
66
|
+
address: t.token,
|
|
67
|
+
registrar: t.registrar,
|
|
68
|
+
operators: [...t.operators]
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* {@inheritDoc IKYCFactory.decodeInvestorData}
|
|
73
|
+
*/
|
|
74
|
+
decodeInvestorData(data) {
|
|
75
|
+
const { creditAccounts, extraDetails } = data;
|
|
76
|
+
const [registeredTokens, cachedSignatures, registerVaultMessages] = (0, import_viem.decodeAbiParameters)(
|
|
77
|
+
[
|
|
78
|
+
{ name: "registeredTokens", type: "address[]" },
|
|
79
|
+
{
|
|
80
|
+
name: "cachedSignatures",
|
|
81
|
+
type: "tuple[]",
|
|
82
|
+
components: [...registerMessageTuple]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: "registerVaultMessages",
|
|
86
|
+
type: "tuple[]",
|
|
87
|
+
components: [...registerVaultMessageTuple]
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
extraDetails
|
|
91
|
+
);
|
|
92
|
+
return {
|
|
93
|
+
type: import_constants.KYC_FACTORY_SECURITIZE,
|
|
94
|
+
factory: this.address,
|
|
95
|
+
cachedSignatures: [...cachedSignatures],
|
|
96
|
+
registerVaultMessages: [...registerVaultMessages],
|
|
97
|
+
registeredTokens: [...registeredTokens],
|
|
98
|
+
creditAccounts: creditAccounts.map((ca) => {
|
|
99
|
+
const [registeredTokens2] = (0, import_viem.decodeAbiParameters)(
|
|
100
|
+
[{ name: "registeredTokens", type: "address[]" }],
|
|
101
|
+
ca.extraDetails
|
|
102
|
+
);
|
|
103
|
+
return {
|
|
104
|
+
...ca,
|
|
105
|
+
registeredTokens: [...registeredTokens2]
|
|
106
|
+
};
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* {@inheritDoc IKYCFactory.getInvestor}
|
|
112
|
+
*/
|
|
113
|
+
async getInvestor(creditAccount, fromCache) {
|
|
114
|
+
if (fromCache && this.#investorCache.has(creditAccount)) {
|
|
115
|
+
return this.#investorCache.mustGet(creditAccount);
|
|
116
|
+
}
|
|
117
|
+
const investor = await this.contract.read.getInvestor([creditAccount]);
|
|
118
|
+
if (fromCache) {
|
|
119
|
+
this.#investorCache.upsert(creditAccount, investor);
|
|
120
|
+
}
|
|
121
|
+
return investor;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* {@inheritDoc IKYCFactory.getApprovalAddress}
|
|
125
|
+
*/
|
|
126
|
+
async getApprovalAddress(options) {
|
|
127
|
+
if ("creditAccount" in options) {
|
|
128
|
+
return this.getWallet(options.creditAccount);
|
|
129
|
+
}
|
|
130
|
+
return this.#precomputeWalletAddress(
|
|
131
|
+
options.creditManager,
|
|
132
|
+
options.borrower
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* {@inheritDoc IKYCFactory.getWallet}
|
|
137
|
+
*/
|
|
138
|
+
async getWallet(creditAccount) {
|
|
139
|
+
return this.contract.read.getWallet([creditAccount]);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* {@inheritDoc IKYCFactory.multicall}
|
|
143
|
+
*/
|
|
144
|
+
multicall(creditAccount, calls, options) {
|
|
145
|
+
const { tokensToRegister = [], signaturesToCache = [] } = options ?? {};
|
|
146
|
+
return this.createRawTx({
|
|
147
|
+
functionName: "multicall",
|
|
148
|
+
args: [creditAccount, calls, tokensToRegister, signaturesToCache]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* {@inheritDoc IKYCFactory.getOpenAccountRequirements}
|
|
153
|
+
*/
|
|
154
|
+
async getOpenAccountRequirements(investor, props) {
|
|
155
|
+
const [investorData] = await this.#sdk.kyc.getInvestorData(investor, [
|
|
156
|
+
this.address
|
|
157
|
+
]);
|
|
158
|
+
const tokensToRegister = new import_utils.AddressSet([props.tokenOutAddress]);
|
|
159
|
+
const registredTokens = new import_utils.AddressSet(investorData.registeredTokens);
|
|
160
|
+
const signedTokens = new import_utils.AddressSet(
|
|
161
|
+
investorData.cachedSignatures.map((s) => s.token)
|
|
162
|
+
);
|
|
163
|
+
const unsignedTokens = tokensToRegister.difference(signedTokens);
|
|
164
|
+
const securitizeTokensToRegister = tokensToRegister.difference(registredTokens);
|
|
165
|
+
const requiredSignatures = investorData.registerVaultMessages.filter(
|
|
166
|
+
(m) => unsignedTokens.has(m.token)
|
|
167
|
+
);
|
|
168
|
+
return {
|
|
169
|
+
type: import_constants.KYC_FACTORY_SECURITIZE,
|
|
170
|
+
securitizeTokensToRegister: Array.from(securitizeTokensToRegister),
|
|
171
|
+
tokensToRegister: Array.from(tokensToRegister),
|
|
172
|
+
requiredSignatures
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* {@inheritDoc IKYCFactory.openCreditAccount}
|
|
177
|
+
*/
|
|
178
|
+
openCreditAccount(creditManager, calls, options) {
|
|
179
|
+
const { tokensToRegister = [], signaturesToCache = [] } = options ?? {};
|
|
180
|
+
return this.createRawTx({
|
|
181
|
+
functionName: "openCreditAccount",
|
|
182
|
+
args: [creditManager, calls, tokensToRegister, signaturesToCache]
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
stateHuman(_raw) {
|
|
186
|
+
return {
|
|
187
|
+
...super.stateHuman(_raw),
|
|
188
|
+
owner: this.labelAddress(this.owner),
|
|
189
|
+
degenNFT: this.labelAddress(this.degenNFT),
|
|
190
|
+
dsTokens: this.dsTokens.map((t) => ({
|
|
191
|
+
...this.tokensMeta.mustGet(t.address),
|
|
192
|
+
registrar: this.labelAddress(t.registrar),
|
|
193
|
+
operators: t.operators.map((o) => this.labelAddress(o))
|
|
194
|
+
}))
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Precomputes the wallet address that will own a new credit account
|
|
199
|
+
* for the given investor in the given credit manager.
|
|
200
|
+
*
|
|
201
|
+
* @param creditManager - credit manager address
|
|
202
|
+
* @param investor - investor address
|
|
203
|
+
**/
|
|
204
|
+
async #precomputeWalletAddress(creditManager, investor) {
|
|
205
|
+
return this.contract.read.precomputeWalletAddress([
|
|
206
|
+
creditManager,
|
|
207
|
+
investor
|
|
208
|
+
]);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const registerMessageTuple = [
|
|
212
|
+
{ name: "token", type: "address" },
|
|
213
|
+
{
|
|
214
|
+
name: "signature",
|
|
215
|
+
type: "tuple",
|
|
216
|
+
components: [
|
|
217
|
+
{ name: "deadline", type: "uint256" },
|
|
218
|
+
{ name: "signature", type: "bytes" }
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
];
|
|
222
|
+
const registerVaultMessageTuple = [
|
|
223
|
+
{
|
|
224
|
+
name: "domain",
|
|
225
|
+
type: "tuple",
|
|
226
|
+
components: [
|
|
227
|
+
{ name: "name", type: "string" },
|
|
228
|
+
{ name: "version", type: "string" },
|
|
229
|
+
{ name: "chainId", type: "uint256" },
|
|
230
|
+
{ name: "verifyingContract", type: "address" }
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
{ name: "investor", type: "address" },
|
|
234
|
+
{ name: "operator", type: "address" },
|
|
235
|
+
{ name: "token", type: "address" },
|
|
236
|
+
{ name: "nonce", type: "uint256" },
|
|
237
|
+
{ name: "deadline", type: "uint256" }
|
|
238
|
+
];
|
|
239
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
240
|
+
0 && (module.exports = {
|
|
241
|
+
SecuritizeKYCFactory
|
|
242
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
KYC_FACTORY_SECURITIZE: () => KYC_FACTORY_SECURITIZE
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(constants_exports);
|
|
24
|
+
const KYC_FACTORY_SECURITIZE = "KYC_FACTORY::SECURITIZE";
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
KYC_FACTORY_SECURITIZE
|
|
28
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var securitize_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(securitize_exports);
|
|
18
|
+
__reExport(securitize_exports, require("./constants.js"), module.exports);
|
|
19
|
+
__reExport(securitize_exports, require("./SecuritizeKYCFactory.js"), module.exports);
|
|
20
|
+
__reExport(securitize_exports, require("./types.js"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./constants.js"),
|
|
24
|
+
...require("./SecuritizeKYCFactory.js"),
|
|
25
|
+
...require("./types.js")
|
|
26
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -16,23 +16,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
KYC_FACTORY_TYPES: () => KYC_FACTORY_TYPES,
|
|
22
|
+
isKYCFactory: () => isKYCFactory
|
|
22
23
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function replacer(_key, value) {
|
|
29
|
-
if (typeof value === "bigint") {
|
|
30
|
-
return value.toString();
|
|
31
|
-
} else {
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
|
25
|
+
var import_securitize = require("./securitize/index.js");
|
|
26
|
+
const KYC_FACTORY_TYPES = [import_securitize.KYC_FACTORY_SECURITIZE];
|
|
27
|
+
function isKYCFactory(factory, type) {
|
|
28
|
+
return factory.contractType === type;
|
|
34
29
|
}
|
|
35
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
31
|
0 && (module.exports = {
|
|
37
|
-
|
|
32
|
+
KYC_FACTORY_TYPES,
|
|
33
|
+
isKYCFactory
|
|
38
34
|
});
|
|
@@ -88,6 +88,9 @@ class PoolSuite extends import_base.SDKConstruct {
|
|
|
88
88
|
get underlying() {
|
|
89
89
|
return this.pool.underlying;
|
|
90
90
|
}
|
|
91
|
+
get kycFactory() {
|
|
92
|
+
return this.pool.kycFactory;
|
|
93
|
+
}
|
|
91
94
|
get dirty() {
|
|
92
95
|
return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
|
|
93
96
|
}
|
|
@@ -28,13 +28,15 @@ var import_utils = require("../../utils/index.js");
|
|
|
28
28
|
const abi = [...import_generated.iPoolV310Abi, ...import_iPausable.iPausableAbi];
|
|
29
29
|
class PoolV310Contract extends import_base.BaseContract {
|
|
30
30
|
creditManagerDebtParams;
|
|
31
|
-
|
|
31
|
+
#sdk;
|
|
32
|
+
constructor(sdk, data) {
|
|
32
33
|
const { baseParams, creditManagerDebtParams, ...rest } = data;
|
|
33
|
-
super(
|
|
34
|
+
super(sdk, {
|
|
34
35
|
...data.baseParams,
|
|
35
36
|
name: `PoolV3(${data.name})`,
|
|
36
37
|
abi
|
|
37
38
|
});
|
|
39
|
+
this.#sdk = sdk;
|
|
38
40
|
Object.assign(this, rest);
|
|
39
41
|
this.creditManagerDebtParams = new import_utils.AddressMap(
|
|
40
42
|
creditManagerDebtParams.map((p) => [p.creditManager, p])
|
|
@@ -46,6 +48,13 @@ class PoolV310Contract extends import_base.BaseContract {
|
|
|
46
48
|
symbol: data.symbol
|
|
47
49
|
});
|
|
48
50
|
}
|
|
51
|
+
get kycFactory() {
|
|
52
|
+
const meta = this.#sdk.tokensMeta.mustGet(this.underlying);
|
|
53
|
+
if (this.#sdk.tokensMeta.isKYCUnderlying(meta)) {
|
|
54
|
+
return this.#sdk.mustGetContract(meta.kycFactory);
|
|
55
|
+
}
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
49
58
|
stateHuman(raw = true) {
|
|
50
59
|
return {
|
|
51
60
|
...super.stateHuman(raw),
|