@gearbox-protocol/sdk 13.6.0-kyc.7 → 13.6.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.
Files changed (152) hide show
  1. package/dist/cjs/dev/AccountOpener.js +5 -45
  2. package/dist/cjs/plugins/adapters/abi/actionAbi.js +1 -1
  3. package/dist/cjs/plugins/adapters/abi/conctructorAbi.js +1 -1
  4. package/dist/cjs/plugins/adapters/createAdapter.js +1 -1
  5. package/dist/cjs/plugins/adapters/types.js +1 -1
  6. package/dist/cjs/plugins/apy/ApyPlugin.js +266 -0
  7. package/dist/cjs/plugins/apy/apy-cache.js +120 -0
  8. package/dist/cjs/plugins/apy/apy-parser.js +169 -0
  9. package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/constants.js +6 -3
  10. package/dist/cjs/{sdk/market/kyc/securitize → plugins/apy}/index.js +14 -6
  11. package/dist/cjs/{sdk/market/kyc/securitize/types.js → plugins/apy/pool-apy-types.js} +2 -2
  12. package/dist/cjs/plugins/apy/pool-apy-utils.js +141 -0
  13. package/dist/cjs/rewards/rewards/extra-apy.js +10 -8
  14. package/dist/cjs/sdk/GearboxSDK.js +5 -52
  15. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +16 -324
  16. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -7
  17. package/dist/cjs/sdk/base/TokensMeta.js +43 -32
  18. package/dist/cjs/sdk/base/token-types.js +0 -9
  19. package/dist/cjs/sdk/chain/chains.js +32 -17
  20. package/dist/cjs/sdk/constants/address-provider.js +0 -3
  21. package/dist/cjs/sdk/market/MarketRegister.js +116 -70
  22. package/dist/cjs/sdk/market/MarketSuite.js +0 -3
  23. package/dist/cjs/sdk/market/index.js +0 -2
  24. package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
  25. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -11
  26. package/dist/cjs/sdk/market/pool/index.js +0 -2
  27. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
  28. package/dist/cjs/sdk/options.js +1 -7
  29. package/dist/cjs/sdk/pools/PoolService.js +12 -104
  30. package/dist/cjs/sdk/utils/viem/index.js +0 -2
  31. package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +39 -2
  32. package/dist/esm/dev/AccountOpener.js +6 -47
  33. package/dist/esm/plugins/adapters/abi/actionAbi.js +1 -1
  34. package/dist/esm/plugins/adapters/abi/conctructorAbi.js +1 -1
  35. package/dist/esm/plugins/adapters/createAdapter.js +1 -1
  36. package/dist/esm/plugins/adapters/types.js +1 -1
  37. package/dist/esm/plugins/apy/ApyPlugin.js +255 -0
  38. package/dist/esm/plugins/apy/apy-cache.js +86 -0
  39. package/dist/esm/plugins/apy/apy-parser.js +143 -0
  40. package/dist/esm/plugins/apy/constants.js +6 -0
  41. package/dist/esm/plugins/apy/index.js +7 -0
  42. package/dist/esm/plugins/apy/pool-apy-utils.js +113 -0
  43. package/dist/esm/rewards/rewards/extra-apy.js +10 -8
  44. package/dist/esm/sdk/GearboxSDK.js +6 -56
  45. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +17 -328
  46. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -7
  47. package/dist/esm/sdk/base/TokensMeta.js +45 -32
  48. package/dist/esm/sdk/base/token-types.js +0 -6
  49. package/dist/esm/sdk/chain/chains.js +32 -17
  50. package/dist/esm/sdk/constants/address-provider.js +0 -2
  51. package/dist/esm/sdk/market/MarketRegister.js +118 -74
  52. package/dist/esm/sdk/market/MarketSuite.js +0 -3
  53. package/dist/esm/sdk/market/index.js +0 -1
  54. package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
  55. package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -11
  56. package/dist/esm/sdk/market/pool/index.js +0 -1
  57. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +3 -3
  58. package/dist/esm/sdk/options.js +1 -7
  59. package/dist/esm/sdk/pools/PoolService.js +13 -109
  60. package/dist/esm/sdk/utils/viem/index.js +0 -1
  61. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +41 -2
  62. package/dist/types/plugins/adapters/types.d.ts +2 -2
  63. package/dist/types/plugins/apy/ApyPlugin.d.ts +46 -0
  64. package/dist/types/plugins/apy/apy-cache.d.ts +28 -0
  65. package/dist/types/plugins/apy/apy-parser.d.ts +5 -0
  66. package/dist/types/plugins/apy/constants.d.ts +2 -0
  67. package/dist/types/plugins/apy/index.d.ts +7 -0
  68. package/dist/types/plugins/apy/pool-apy-types.d.ts +41 -0
  69. package/dist/types/plugins/apy/pool-apy-utils.d.ts +73 -0
  70. package/dist/types/plugins/apy/types.d.ts +37 -0
  71. package/dist/types/rewards/rewards/api.d.ts +10 -1
  72. package/dist/types/rewards/rewards/common.d.ts +0 -10
  73. package/dist/types/rewards/rewards/extra-apy.d.ts +4 -6
  74. package/dist/types/sdk/GearboxSDK.d.ts +0 -7
  75. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +2 -52
  76. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
  77. package/dist/types/sdk/accounts/types.d.ts +13 -93
  78. package/dist/types/sdk/base/TokensMeta.d.ts +3 -14
  79. package/dist/types/sdk/base/token-types.d.ts +4 -44
  80. package/dist/types/sdk/base/types.d.ts +11 -116
  81. package/dist/types/sdk/chain/chains.d.ts +5 -5
  82. package/dist/types/sdk/constants/address-provider.d.ts +0 -1
  83. package/dist/types/sdk/market/MarketRegister.d.ts +9 -6
  84. package/dist/types/sdk/market/MarketSuite.d.ts +0 -2
  85. package/dist/types/sdk/market/index.d.ts +0 -1
  86. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -3
  87. package/dist/types/sdk/market/oracle/types.d.ts +10 -3
  88. package/dist/types/sdk/market/pool/PoolSuite.d.ts +0 -2
  89. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
  90. package/dist/types/sdk/market/pool/index.d.ts +0 -1
  91. package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -1
  92. package/dist/types/sdk/market/types.d.ts +1 -1
  93. package/dist/types/sdk/options.d.ts +0 -1
  94. package/dist/types/sdk/pools/PoolService.d.ts +8 -8
  95. package/dist/types/sdk/pools/types.d.ts +1 -1
  96. package/dist/types/sdk/types/state-human.d.ts +0 -2
  97. package/dist/types/sdk/types/state.d.ts +0 -5
  98. package/dist/types/sdk/utils/viem/index.d.ts +0 -1
  99. package/package.json +2 -3
  100. package/dist/cjs/abi/kyc/iDSRegistryService.js +0 -70
  101. package/dist/cjs/abi/kyc/iDSToken.js +0 -71
  102. package/dist/cjs/abi/kyc/iKYCCompressor.js +0 -196
  103. package/dist/cjs/abi/kyc/iKYCFactory.js +0 -122
  104. package/dist/cjs/abi/kyc/iKYCUnderlying.js +0 -401
  105. package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +0 -326
  106. package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +0 -319
  107. package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +0 -108
  108. package/dist/cjs/plugins/pools-history/index.js +0 -24
  109. package/dist/cjs/sdk/market/kyc/KYCRegistry.js +0 -269
  110. package/dist/cjs/sdk/market/kyc/index.js +0 -26
  111. package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -244
  112. package/dist/cjs/sdk/market/kyc/types.js +0 -34
  113. package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +0 -38
  114. package/dist/esm/abi/kyc/iDSRegistryService.js +0 -46
  115. package/dist/esm/abi/kyc/iDSToken.js +0 -47
  116. package/dist/esm/abi/kyc/iKYCCompressor.js +0 -172
  117. package/dist/esm/abi/kyc/iKYCFactory.js +0 -98
  118. package/dist/esm/abi/kyc/iKYCUnderlying.js +0 -377
  119. package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +0 -302
  120. package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +0 -295
  121. package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +0 -90
  122. package/dist/esm/plugins/pools-history/index.js +0 -2
  123. package/dist/esm/sdk/market/kyc/KYCRegistry.js +0 -253
  124. package/dist/esm/sdk/market/kyc/index.js +0 -3
  125. package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -220
  126. package/dist/esm/sdk/market/kyc/securitize/constants.js +0 -4
  127. package/dist/esm/sdk/market/kyc/securitize/index.js +0 -3
  128. package/dist/esm/sdk/market/kyc/types.js +0 -9
  129. package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +0 -14
  130. package/dist/types/abi/kyc/iDSRegistryService.d.ts +0 -71
  131. package/dist/types/abi/kyc/iDSToken.d.ts +0 -67
  132. package/dist/types/abi/kyc/iKYCCompressor.d.ts +0 -228
  133. package/dist/types/abi/kyc/iKYCFactory.d.ts +0 -139
  134. package/dist/types/abi/kyc/iKYCUnderlying.d.ts +0 -548
  135. package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +0 -404
  136. package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +0 -376
  137. package/dist/types/plugins/pools-history/Pools7DAgoPlugin.d.ts +0 -20
  138. package/dist/types/plugins/pools-history/index.d.ts +0 -2
  139. package/dist/types/plugins/pools-history/types.d.ts +0 -9
  140. package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +0 -52
  141. package/dist/types/sdk/market/kyc/index.d.ts +0 -3
  142. package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +0 -428
  143. package/dist/types/sdk/market/kyc/securitize/constants.d.ts +0 -1
  144. package/dist/types/sdk/market/kyc/securitize/index.d.ts +0 -3
  145. package/dist/types/sdk/market/kyc/securitize/types.d.ts +0 -127
  146. package/dist/types/sdk/market/kyc/types.d.ts +0 -170
  147. package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +0 -28
  148. /package/dist/cjs/plugins/{pools-history → apy}/package.json +0 -0
  149. /package/dist/cjs/plugins/{pools-history → apy}/types.js +0 -0
  150. /package/dist/esm/plugins/{pools-history → apy}/package.json +0 -0
  151. /package/dist/esm/plugins/{pools-history/types.js → apy/pool-apy-types.js} +0 -0
  152. /package/dist/esm/{sdk/market/kyc/securitize → plugins/apy}/types.js +0 -0
@@ -1,108 +0,0 @@
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 Pools7DAgoPlugin_exports = {};
20
- __export(Pools7DAgoPlugin_exports, {
21
- Pools7DAgoPlugin: () => Pools7DAgoPlugin
22
- });
23
- module.exports = __toCommonJS(Pools7DAgoPlugin_exports);
24
- var import_marketCompressor = require("../../abi/compressors/marketCompressor.js");
25
- var import_sdk = require("../../sdk/index.js");
26
- const MAP_LABEL = "pools7DAgo";
27
- class Pools7DAgoPlugin extends import_sdk.BasePlugin {
28
- #pools7DAgo;
29
- async load(force) {
30
- if (!force && this.loaded) {
31
- return this.state;
32
- }
33
- const targetBlock = this.sdk.currentBlock - import_sdk.BLOCKS_PER_WEEK_BY_NETWORK[this.sdk.networkType];
34
- const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
35
- import_sdk.AP_MARKET_COMPRESSOR,
36
- import_sdk.VERSION_RANGE_310
37
- );
38
- this.sdk.logger?.debug(
39
- `loading pools 7d ago with market compressor ${marketCompressorAddress}`
40
- );
41
- const markets = this.sdk.marketRegister.markets;
42
- const resp = await this.client.multicall({
43
- allowFailure: true,
44
- contracts: markets.map(
45
- (m) => ({
46
- address: marketCompressorAddress,
47
- abi: import_marketCompressor.marketCompressorAbi,
48
- functionName: "getPoolState",
49
- args: [m.pool.pool.address]
50
- })
51
- ),
52
- blockNumber: targetBlock > 0n ? targetBlock : void 0,
53
- batchSize: 0
54
- });
55
- this.#pools7DAgo = new import_sdk.AddressMap(void 0, MAP_LABEL);
56
- resp.forEach((r, index) => {
57
- const m = markets[index];
58
- const cfg = m.configurator.address;
59
- const pool = m.pool.pool.address;
60
- if (r.status === "success") {
61
- this.#pools7DAgo?.upsert(m.pool.pool.address, {
62
- dieselRate: r.result.dieselRate,
63
- pool
64
- });
65
- } else {
66
- this.sdk.logger?.error(
67
- `failed to load pools 7d ago for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`
68
- );
69
- }
70
- });
71
- return this.state;
72
- }
73
- get loaded() {
74
- return !!this.#pools7DAgo;
75
- }
76
- /**
77
- * Returns a map of pool addresses to minified pool 7d ago state
78
- * @throws if pool 7d ago plugin is not attached
79
- */
80
- get pools7DAgo() {
81
- if (!this.#pools7DAgo) {
82
- throw new Error("pools 7d ago plugin not attached");
83
- }
84
- return this.#pools7DAgo;
85
- }
86
- stateHuman(_) {
87
- return this.pools7DAgo.values().flatMap((p) => ({
88
- address: p.pool,
89
- version: this.version,
90
- dieselRate: p.dieselRate
91
- }));
92
- }
93
- get state() {
94
- return {
95
- pools7DAgo: this.pools7DAgo.asRecord()
96
- };
97
- }
98
- hydrate(state) {
99
- this.#pools7DAgo = new import_sdk.AddressMap(
100
- Object.entries(state.pools7DAgo),
101
- MAP_LABEL
102
- );
103
- }
104
- }
105
- // Annotate the CommonJS export names for ESM import in node:
106
- 0 && (module.exports = {
107
- Pools7DAgoPlugin
108
- });
@@ -1,24 +0,0 @@
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 pools_history_exports = {};
17
- module.exports = __toCommonJS(pools_history_exports);
18
- __reExport(pools_history_exports, require("./Pools7DAgoPlugin.js"), module.exports);
19
- __reExport(pools_history_exports, require("./types.js"), module.exports);
20
- // Annotate the CommonJS export names for ESM import in node:
21
- 0 && (module.exports = {
22
- ...require("./Pools7DAgoPlugin.js"),
23
- ...require("./types.js")
24
- });
@@ -1,269 +0,0 @@
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
- });
@@ -1,26 +0,0 @@
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
- });
@@ -1,244 +0,0 @@
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
- factory: this.address,
94
- cachedSignatures: [...cachedSignatures],
95
- registerVaultMessages: [...registerVaultMessages],
96
- registeredTokens: [...registeredTokens],
97
- creditAccounts: creditAccounts.map((ca) => {
98
- const [registeredTokens2] = (0, import_viem.decodeAbiParameters)(
99
- [{ name: "registeredTokens", type: "address[]" }],
100
- ca.extraDetails
101
- );
102
- return {
103
- ...ca,
104
- registeredTokens: [...registeredTokens2]
105
- };
106
- })
107
- };
108
- }
109
- /**
110
- * {@inheritDoc IKYCFactory.getInvestor}
111
- */
112
- async getInvestor(creditAccount, fromCache) {
113
- if (fromCache && this.#investorCache.has(creditAccount)) {
114
- return this.#investorCache.mustGet(creditAccount);
115
- }
116
- const investor = await this.contract.read.getInvestor([creditAccount]);
117
- if (fromCache) {
118
- this.#investorCache.upsert(creditAccount, investor);
119
- }
120
- return investor;
121
- }
122
- /**
123
- * {@inheritDoc IKYCFactory.getApprovalAddress}
124
- */
125
- async getApprovalAddress(options) {
126
- if ("creditAccount" in options) {
127
- return this.getWallet(options.creditAccount);
128
- }
129
- return this.#precomputeWalletAddress(
130
- options.creditManager,
131
- options.borrower
132
- );
133
- }
134
- /**
135
- * {@inheritDoc IKYCFactory.getWallet}
136
- */
137
- async getWallet(creditAccount) {
138
- return this.contract.read.getWallet([creditAccount]);
139
- }
140
- /**
141
- * {@inheritDoc IKYCFactory.multicall}
142
- */
143
- multicall(creditAccount, calls, options) {
144
- const { tokensToRegister = [], signaturesToCache = [] } = options ?? {};
145
- return this.createRawTx({
146
- functionName: "multicall",
147
- args: [creditAccount, calls, tokensToRegister, signaturesToCache]
148
- });
149
- }
150
- /**
151
- * {@inheritDoc IKYCFactory.getOpenAccountRequirements}
152
- */
153
- async getOpenAccountRequirements(investor) {
154
- const [investorData] = await this.#sdk.kyc.getInvestorData(investor, [
155
- this.address
156
- ]);
157
- const dsTokens = new import_utils.AddressSet(this.dsTokens.map((t) => t.address));
158
- const desiredTokens = dsTokens;
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 = desiredTokens.difference(signedTokens);
164
- const tokensToRegister = desiredTokens.difference(registredTokens);
165
- const requiredSignatures = investorData.registerVaultMessages.filter(
166
- (m) => unsignedTokens.has(m.token)
167
- );
168
- if (tokensToRegister.size === 0 && requiredSignatures.length === 0) {
169
- return void 0;
170
- }
171
- return {
172
- type: import_constants.KYC_FACTORY_SECURITIZE,
173
- tokensToRegister: Array.from(tokensToRegister),
174
- requiredSignatures
175
- };
176
- }
177
- /**
178
- * {@inheritDoc IKYCFactory.openCreditAccount}
179
- */
180
- openCreditAccount(creditManager, calls, options) {
181
- const { tokensToRegister = [], signaturesToCache = [] } = options ?? {};
182
- return this.createRawTx({
183
- functionName: "openCreditAccount",
184
- args: [creditManager, calls, tokensToRegister, signaturesToCache]
185
- });
186
- }
187
- stateHuman(_raw) {
188
- return {
189
- ...super.stateHuman(_raw),
190
- owner: this.labelAddress(this.owner),
191
- degenNFT: this.labelAddress(this.degenNFT),
192
- dsTokens: this.dsTokens.map((t) => ({
193
- ...this.tokensMeta.mustGet(t.address),
194
- registrar: this.labelAddress(t.registrar),
195
- operators: t.operators.map((o) => this.labelAddress(o))
196
- }))
197
- };
198
- }
199
- /**
200
- * Precomputes the wallet address that will own a new credit account
201
- * for the given investor in the given credit manager.
202
- *
203
- * @param creditManager - credit manager address
204
- * @param investor - investor address
205
- **/
206
- async #precomputeWalletAddress(creditManager, investor) {
207
- return this.contract.read.precomputeWalletAddress([
208
- creditManager,
209
- investor
210
- ]);
211
- }
212
- }
213
- const registerMessageTuple = [
214
- { name: "token", type: "address" },
215
- {
216
- name: "signature",
217
- type: "tuple",
218
- components: [
219
- { name: "deadline", type: "uint256" },
220
- { name: "signature", type: "bytes" }
221
- ]
222
- }
223
- ];
224
- const registerVaultMessageTuple = [
225
- {
226
- name: "domain",
227
- type: "tuple",
228
- components: [
229
- { name: "name", type: "string" },
230
- { name: "version", type: "string" },
231
- { name: "chainId", type: "uint256" },
232
- { name: "verifyingContract", type: "address" }
233
- ]
234
- },
235
- { name: "investor", type: "address" },
236
- { name: "operator", type: "address" },
237
- { name: "token", type: "address" },
238
- { name: "nonce", type: "uint256" },
239
- { name: "deadline", type: "uint256" }
240
- ];
241
- // Annotate the CommonJS export names for ESM import in node:
242
- 0 && (module.exports = {
243
- SecuritizeKYCFactory
244
- });