@gearbox-protocol/sdk 14.7.0 → 14.8.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/abi/compressors/{kycCompressor.js → rwaCompressor.js} +13 -13
- package/dist/cjs/abi/compressors/subcompressors/{kyc/onDemandKYCUnderlyingSubcompressor.js → rwa/onDemandRWAUnderlyingSubcompressor.js} +6 -6
- package/dist/cjs/abi/compressors/subcompressors/{kyc/securitizeKYCFactorySubcompressor.js → rwa/securitizeRWAFactorySubcompressor.js} +6 -6
- package/dist/cjs/abi/{kyc/iKYCCompressor.js → rwa/iRWACompressor.js} +13 -13
- package/dist/cjs/abi/{kyc/iKYCFactory.js → rwa/iRWAFactory.js} +6 -6
- package/dist/cjs/abi/{kyc/iKYCUnderlying.js → rwa/iRWAUnderlying.js} +7 -7
- package/dist/cjs/abi/{kyc/iSecuritizeKYCFactory.js → rwa/iSecuritizeRWAFactory.js} +7 -7
- package/dist/cjs/dev/claimDSToken.js +4 -4
- package/dist/cjs/sdk/OnchainSDK.js +12 -12
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +59 -59
- package/dist/cjs/sdk/base/TokensMeta.js +6 -6
- package/dist/cjs/sdk/base/token-types.js +11 -11
- package/dist/cjs/sdk/chain/chains.js +16 -16
- package/dist/cjs/sdk/constants/address-provider.js +3 -3
- package/dist/cjs/sdk/market/MarketSuite.js +2 -2
- package/dist/cjs/sdk/market/index.js +2 -2
- package/dist/cjs/sdk/market/pool/PoolSuite.js +2 -2
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +3 -3
- package/dist/cjs/sdk/market/{kyc/KYCRegistry.js → rwa/RWARegistry.js} +48 -48
- package/dist/cjs/sdk/market/{kyc → rwa}/index.js +6 -6
- package/dist/cjs/sdk/market/{kyc → rwa}/securitize/SecuritizeDegenNFT.js +1 -1
- package/dist/cjs/sdk/market/{kyc/securitize/SecuritizeKYCFactory.js → rwa/securitize/SecuritizeRWAFactory.js} +20 -20
- package/dist/cjs/sdk/market/{kyc → rwa}/securitize/constants.js +3 -3
- package/dist/cjs/sdk/market/{kyc → rwa}/securitize/index.js +2 -2
- package/dist/cjs/sdk/market/{kyc → rwa}/types.js +6 -6
- package/dist/cjs/sdk/options.js +4 -4
- package/dist/cjs/sdk/pools/PoolService.js +26 -26
- package/dist/esm/abi/compressors/{kycCompressor.js → rwaCompressor.js} +9 -9
- package/dist/esm/abi/compressors/subcompressors/{kyc/onDemandKYCUnderlyingSubcompressor.js → rwa/onDemandRWAUnderlyingSubcompressor.js} +2 -2
- package/dist/esm/abi/compressors/subcompressors/{kyc/securitizeKYCFactorySubcompressor.js → rwa/securitizeRWAFactorySubcompressor.js} +2 -2
- package/dist/esm/abi/{kyc/iKYCCompressor.js → rwa/iRWACompressor.js} +9 -9
- package/dist/esm/abi/{kyc/iKYCFactory.js → rwa/iRWAFactory.js} +2 -2
- package/dist/esm/abi/{kyc/iKYCUnderlying.js → rwa/iRWAUnderlying.js} +3 -3
- package/dist/esm/abi/{kyc/iSecuritizeKYCFactory.js → rwa/iSecuritizeRWAFactory.js} +3 -3
- package/dist/esm/dev/claimDSToken.js +4 -4
- package/dist/esm/sdk/OnchainSDK.js +13 -13
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +59 -59
- package/dist/esm/sdk/base/TokensMeta.js +6 -6
- package/dist/esm/sdk/base/token-types.js +7 -7
- package/dist/esm/sdk/chain/chains.js +16 -16
- package/dist/esm/sdk/constants/address-provider.js +2 -2
- package/dist/esm/sdk/market/MarketSuite.js +2 -2
- package/dist/esm/sdk/market/index.js +1 -1
- package/dist/esm/sdk/market/pool/PoolSuite.js +2 -2
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +3 -3
- package/dist/esm/sdk/market/{kyc/KYCRegistry.js → rwa/RWARegistry.js} +50 -50
- package/dist/esm/sdk/market/{kyc → rwa}/index.js +1 -1
- package/dist/esm/sdk/market/{kyc → rwa}/securitize/SecuritizeDegenNFT.js +1 -1
- package/dist/esm/sdk/market/{kyc/securitize/SecuritizeKYCFactory.js → rwa/securitize/SecuritizeRWAFactory.js} +17 -17
- package/dist/esm/sdk/market/rwa/securitize/constants.js +4 -0
- package/dist/esm/sdk/market/{kyc → rwa}/securitize/index.js +1 -1
- package/dist/esm/sdk/market/rwa/types.js +9 -0
- package/dist/esm/sdk/options.js +4 -4
- package/dist/esm/sdk/pools/PoolService.js +28 -28
- package/dist/types/abi/compressors/{kycCompressor.d.ts → rwaCompressor.d.ts} +8 -8
- package/dist/types/abi/compressors/subcompressors/{kyc/onDemandKYCUnderlyingSubcompressor.d.ts → rwa/onDemandRWAUnderlyingSubcompressor.d.ts} +1 -1
- package/dist/types/abi/compressors/subcompressors/{kyc/securitizeKYCFactorySubcompressor.d.ts → rwa/securitizeRWAFactorySubcompressor.d.ts} +1 -1
- package/dist/types/abi/{kyc/iKYCCompressor.d.ts → rwa/iRWACompressor.d.ts} +8 -8
- package/dist/types/abi/{kyc/iKYCFactory.d.ts → rwa/iRWAFactory.d.ts} +1 -1
- package/dist/types/abi/{kyc/iKYCUnderlying.d.ts → rwa/iRWAUnderlying.d.ts} +2 -2
- package/dist/types/abi/{kyc/iSecuritizeKYCFactory.d.ts → rwa/iSecuritizeRWAFactory.d.ts} +2 -2
- package/dist/types/dev/claimDSToken.d.ts +1 -1
- package/dist/types/sdk/OnchainSDK.d.ts +5 -5
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +19 -19
- package/dist/types/sdk/accounts/types.d.ts +26 -26
- package/dist/types/sdk/base/TokensMeta.d.ts +5 -5
- package/dist/types/sdk/base/token-types.d.ts +17 -17
- package/dist/types/sdk/base/types.d.ts +2 -2
- package/dist/types/sdk/chain/chains.d.ts +2 -2
- package/dist/types/sdk/constants/address-provider.d.ts +1 -1
- package/dist/types/sdk/market/MarketSuite.d.ts +2 -2
- package/dist/types/sdk/market/index.d.ts +1 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -2
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -2
- package/dist/types/sdk/market/rwa/RWARegistry.d.ts +52 -0
- package/dist/types/sdk/market/{kyc → rwa}/index.d.ts +1 -1
- package/dist/types/sdk/market/{kyc/securitize/SecuritizeKYCFactory.d.ts → rwa/securitize/SecuritizeRWAFactory.d.ts} +16 -16
- package/dist/types/sdk/market/rwa/securitize/constants.d.ts +1 -0
- package/dist/types/sdk/market/{kyc → rwa}/securitize/index.d.ts +1 -1
- package/dist/types/sdk/market/{kyc → rwa}/securitize/types.d.ts +12 -12
- package/dist/types/sdk/market/{kyc → rwa}/types.d.ts +48 -48
- package/dist/types/sdk/market/types.d.ts +1 -1
- package/dist/types/sdk/options.d.ts +1 -1
- package/dist/types/sdk/pools/types.d.ts +4 -4
- package/dist/types/sdk/types/state-human.d.ts +2 -2
- package/dist/types/sdk/types/state.d.ts +3 -3
- package/package.json +1 -1
- package/dist/esm/sdk/market/kyc/securitize/constants.js +0 -4
- package/dist/esm/sdk/market/kyc/types.js +0 -9
- package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +0 -52
- package/dist/types/sdk/market/kyc/securitize/constants.d.ts +0 -1
- /package/dist/cjs/abi/{kyc → rwa}/iDSRegistryService.js +0 -0
- /package/dist/cjs/abi/{kyc → rwa}/iDSToken.js +0 -0
- /package/dist/cjs/abi/{kyc → rwa}/iSecuritizeDegenNFT.js +0 -0
- /package/dist/cjs/sdk/market/{kyc → rwa}/securitize/types.js +0 -0
- /package/dist/esm/abi/{kyc → rwa}/iDSRegistryService.js +0 -0
- /package/dist/esm/abi/{kyc → rwa}/iDSToken.js +0 -0
- /package/dist/esm/abi/{kyc → rwa}/iSecuritizeDegenNFT.js +0 -0
- /package/dist/esm/sdk/market/{kyc → rwa}/securitize/types.js +0 -0
- /package/dist/types/abi/{kyc → rwa}/iDSRegistryService.d.ts +0 -0
- /package/dist/types/abi/{kyc → rwa}/iDSToken.d.ts +0 -0
- /package/dist/types/abi/{kyc → rwa}/iSecuritizeDegenNFT.d.ts +0 -0
- /package/dist/types/sdk/market/{kyc → rwa}/securitize/SecuritizeDegenNFT.d.ts +0 -0
|
@@ -9,7 +9,7 @@ import { peripheryCompressorAbi } from "../../abi/compressors/peripheryCompresso
|
|
|
9
9
|
import { rewardsCompressorAbi } from "../../abi/compressors/rewardsCompressor.js";
|
|
10
10
|
import { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
|
|
11
11
|
import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
|
|
12
|
-
import {
|
|
12
|
+
import { iRWAFactoryAbi } from "../../abi/rwa/iRWAFactory.js";
|
|
13
13
|
import { SDKConstruct } from "../base/index.js";
|
|
14
14
|
import { chains } from "../chain/chains.js";
|
|
15
15
|
import {
|
|
@@ -72,7 +72,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
72
72
|
const marketSuite = this.sdk.marketRegister.findByCreditManager(
|
|
73
73
|
raw.creditManager
|
|
74
74
|
);
|
|
75
|
-
const factory = marketSuite.
|
|
75
|
+
const factory = marketSuite.rwaFactory;
|
|
76
76
|
let ca;
|
|
77
77
|
let investor;
|
|
78
78
|
if (raw.success) {
|
|
@@ -91,7 +91,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
91
91
|
},
|
|
92
92
|
...factory ? [
|
|
93
93
|
{
|
|
94
|
-
abi:
|
|
94
|
+
abi: iRWAFactoryAbi,
|
|
95
95
|
address: factory.address,
|
|
96
96
|
functionName: "getInvestor",
|
|
97
97
|
args: [raw.creditAccount]
|
|
@@ -172,8 +172,8 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
172
172
|
const { txs: priceUpdateTxs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
|
|
173
173
|
ignoreReservePrices ? { main: true } : void 0
|
|
174
174
|
);
|
|
175
|
-
const investorDataList = await this.sdk.
|
|
176
|
-
const
|
|
175
|
+
const investorDataList = await this.sdk.rwa.getInvestorData(borrower);
|
|
176
|
+
const rwaAccountAddresses = investorDataList.flatMap(
|
|
177
177
|
(d) => d.creditAccounts.map((ca) => ca.creditAccount)
|
|
178
178
|
);
|
|
179
179
|
const cmFilter = creditManager ? {
|
|
@@ -194,7 +194,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
194
194
|
maxHealthFactor: MAX_UINT256,
|
|
195
195
|
reverting: false
|
|
196
196
|
};
|
|
197
|
-
const
|
|
197
|
+
const rwaContracts = rwaAccountAddresses.map(
|
|
198
198
|
(account) => ({
|
|
199
199
|
abi: creditAccountCompressorAbi,
|
|
200
200
|
address: this.compressor,
|
|
@@ -210,21 +210,21 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
210
210
|
args: [cmFilter, { ...permissiveFilter, reverting }, 0n]
|
|
211
211
|
})
|
|
212
212
|
);
|
|
213
|
-
const allContracts = [...
|
|
213
|
+
const allContracts = [...rwaContracts, ...getCreditAccountsContracts];
|
|
214
214
|
const results = await simulateWithPriceUpdates(this.client, {
|
|
215
215
|
priceUpdates: priceUpdateTxs,
|
|
216
216
|
contracts: allContracts,
|
|
217
217
|
blockNumber,
|
|
218
218
|
gas: this.sdk.gasLimit
|
|
219
219
|
});
|
|
220
|
-
const
|
|
220
|
+
const rwaResults = results.slice(
|
|
221
221
|
0,
|
|
222
|
-
|
|
222
|
+
rwaAccountAddresses.length
|
|
223
223
|
);
|
|
224
|
-
const normalResults = results.slice(
|
|
224
|
+
const normalResults = results.slice(rwaAccountAddresses.length);
|
|
225
225
|
const seen = new AddressSet();
|
|
226
226
|
const allCAs = [];
|
|
227
|
-
for (const ca of
|
|
227
|
+
for (const ca of rwaResults) {
|
|
228
228
|
if (!seen.has(ca.creditAccount)) {
|
|
229
229
|
seen.add(ca.creditAccount);
|
|
230
230
|
allCAs.push({ ...ca, investor: borrower });
|
|
@@ -247,7 +247,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
247
247
|
return true;
|
|
248
248
|
});
|
|
249
249
|
this.logger?.debug(
|
|
250
|
-
`loaded ${allCAs.length} borrower credit accounts (${
|
|
250
|
+
`loaded ${allCAs.length} borrower credit accounts (${rwaResults.length} RWA, ${filtered.length} after filter)`
|
|
251
251
|
);
|
|
252
252
|
return filtered.sort((a, b) => Number(a.healthFactor - b.healthFactor));
|
|
253
253
|
}
|
|
@@ -599,9 +599,9 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
599
599
|
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
600
600
|
await this.sdk.tokensMeta.loadTokenData(cm.underlying);
|
|
601
601
|
const underlying = this.sdk.tokensMeta.mustGet(cm.underlying);
|
|
602
|
-
if (this.sdk.tokensMeta.
|
|
602
|
+
if (this.sdk.tokensMeta.isRWAUnderlying(underlying)) {
|
|
603
603
|
throw new Error(
|
|
604
|
-
"closeCreditAccount is not supported for
|
|
604
|
+
"closeCreditAccount is not supported for RWA underlying credit accounts"
|
|
605
605
|
);
|
|
606
606
|
}
|
|
607
607
|
const routerCloseResult = closePath || await this.sdk.routerFor(ca).findBestClosePath({
|
|
@@ -709,13 +709,13 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
709
709
|
],
|
|
710
710
|
{}
|
|
711
711
|
) : [];
|
|
712
|
-
const unwrapCalls = collateral && isDecrease ? await this.
|
|
712
|
+
const unwrapCalls = collateral && isDecrease ? await this.getRWAUnwrapCalls(
|
|
713
713
|
collateral[0].balance,
|
|
714
714
|
creditAccount.creditManager
|
|
715
715
|
) || [] : [];
|
|
716
716
|
if (addCollateralCalls.length > 0 && unwrapCalls.length === 0 && collateral && collateral?.[0].token !== creditAccount.underlying) {
|
|
717
717
|
throw new Error(
|
|
718
|
-
"Can't use collateral other than underlying for non
|
|
718
|
+
"Can't use collateral other than underlying for non RWA market"
|
|
719
719
|
);
|
|
720
720
|
}
|
|
721
721
|
const operationCalls = [
|
|
@@ -935,7 +935,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
935
935
|
const { creditManager } = options;
|
|
936
936
|
const suite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
937
937
|
const marketSuite = this.sdk.marketRegister.findByPool(suite.pool);
|
|
938
|
-
const factory = marketSuite.
|
|
938
|
+
const factory = marketSuite.rwaFactory;
|
|
939
939
|
if (factory) {
|
|
940
940
|
return factory.getApprovalAddress(options);
|
|
941
941
|
}
|
|
@@ -945,11 +945,11 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
945
945
|
* {@inheritDoc ICreditAccountsService.getOpenAccountRequirements}
|
|
946
946
|
*/
|
|
947
947
|
async getOpenAccountRequirements(borrower, creditManager, props) {
|
|
948
|
-
const {
|
|
949
|
-
if (!
|
|
948
|
+
const { rwaFactory } = this.sdk.marketRegister.findByCreditManager(creditManager);
|
|
949
|
+
if (!rwaFactory) {
|
|
950
950
|
return void 0;
|
|
951
951
|
}
|
|
952
|
-
return
|
|
952
|
+
return rwaFactory.getOpenAccountRequirements(borrower, props);
|
|
953
953
|
}
|
|
954
954
|
/**
|
|
955
955
|
* {@inheritDoc ICreditAccountsService.openCA}
|
|
@@ -969,7 +969,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
969
969
|
callsAfter,
|
|
970
970
|
minQuota,
|
|
971
971
|
averageQuota,
|
|
972
|
-
|
|
972
|
+
rwaOptions
|
|
973
973
|
} = props;
|
|
974
974
|
const cmSuite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
975
975
|
const cm = cmSuite.creditManager;
|
|
@@ -1008,7 +1008,7 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1008
1008
|
to,
|
|
1009
1009
|
calls,
|
|
1010
1010
|
referralCode,
|
|
1011
|
-
|
|
1011
|
+
rwaOptions
|
|
1012
1012
|
);
|
|
1013
1013
|
}
|
|
1014
1014
|
tx.value = ethAmount.toString(10);
|
|
@@ -1092,17 +1092,17 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1092
1092
|
return resp;
|
|
1093
1093
|
}
|
|
1094
1094
|
/**
|
|
1095
|
-
* Returns multicall entries to redeem (unwrap)
|
|
1096
|
-
* Used when withdrawing debt from a
|
|
1097
|
-
* Only applies when the credit manager's underlying is
|
|
1095
|
+
* Returns multicall entries to redeem (unwrap) RWA ERC-4626 vault shares into underlying for the given credit manager.
|
|
1096
|
+
* Used when withdrawing debt from a RWA market: redeems adapter vault shares so the underlying can be withdrawn.
|
|
1097
|
+
* Only applies when the credit manager's underlying is RWA-gated and has an ERC-4626 adapter configured.
|
|
1098
1098
|
* @param amount - Number of vault shares (adapter tokens) to redeem
|
|
1099
1099
|
* @param creditManager - Credit manager address
|
|
1100
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not
|
|
1100
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
|
|
1101
1101
|
*/
|
|
1102
|
-
async
|
|
1102
|
+
async getRWAUnwrapCalls(amount, creditManager) {
|
|
1103
1103
|
const suite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
1104
1104
|
const meta = this.sdk.tokensMeta.mustGet(suite.underlying);
|
|
1105
|
-
if (!this.sdk.tokensMeta.
|
|
1105
|
+
if (!this.sdk.tokensMeta.isRWAUnderlying(meta)) {
|
|
1106
1106
|
return void 0;
|
|
1107
1107
|
}
|
|
1108
1108
|
const adapter = suite.creditManager.adapters.get(meta.addr);
|
|
@@ -1123,17 +1123,17 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1123
1123
|
return mc;
|
|
1124
1124
|
}
|
|
1125
1125
|
/**
|
|
1126
|
-
* Returns multicall entries to deposit (wrap) underlying into
|
|
1127
|
-
* Used when adding debt on a
|
|
1128
|
-
* Only applies when the credit manager's underlying is
|
|
1126
|
+
* Returns multicall entries to deposit (wrap) underlying into RWA ERC-4626 vault shares for the given credit manager.
|
|
1127
|
+
* Used when adding debt on a RWA market: deposits underlying into the adapter vault so shares are minted on the account.
|
|
1128
|
+
* Only applies when the credit manager's underlying is RWA-gated and has an ERC-4626 adapter configured.
|
|
1129
1129
|
* @param amount - Amount of underlying assets to deposit into the vault (in underlying decimals)
|
|
1130
1130
|
* @param creditManager - Credit manager address
|
|
1131
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not
|
|
1131
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
|
|
1132
1132
|
*/
|
|
1133
|
-
async
|
|
1133
|
+
async getRWAWrapCalls(amount, creditManager) {
|
|
1134
1134
|
const suite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
1135
1135
|
const meta = this.sdk.tokensMeta.mustGet(suite.underlying);
|
|
1136
|
-
if (!this.sdk.tokensMeta.
|
|
1136
|
+
if (!this.sdk.tokensMeta.isRWAUnderlying(meta)) {
|
|
1137
1137
|
return void 0;
|
|
1138
1138
|
}
|
|
1139
1139
|
const adapter = suite.creditManager.adapters.get(meta.addr);
|
|
@@ -1154,17 +1154,17 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1154
1154
|
return mc;
|
|
1155
1155
|
}
|
|
1156
1156
|
/**
|
|
1157
|
-
* Returns multicall entries to call redeemDiff on the
|
|
1158
|
-
* Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess
|
|
1159
|
-
* Only applies when the credit manager's underlying is
|
|
1157
|
+
* Returns multicall entries to call redeemDiff on the RWA ERC-4626 adapter for the given credit manager.
|
|
1158
|
+
* Redeems the leftover vault shares (e.g. after repaying debt) so the account does not hold excess RWA vault tokens.
|
|
1159
|
+
* Only applies when the credit manager's underlying is RWA-gated and has an ERC-4626 adapter configured.
|
|
1160
1160
|
* @param amount - Leftover vault share amount to redeem (in adapter/vault decimals)
|
|
1161
1161
|
* @param creditManager - Credit manager address
|
|
1162
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not
|
|
1162
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
|
|
1163
1163
|
*/
|
|
1164
1164
|
async getRedeemDiffCalls(amount, creditManager) {
|
|
1165
1165
|
const suite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
1166
1166
|
const meta = this.sdk.tokensMeta.mustGet(suite.underlying);
|
|
1167
|
-
if (!this.sdk.tokensMeta.
|
|
1167
|
+
if (!this.sdk.tokensMeta.isRWAUnderlying(meta)) {
|
|
1168
1168
|
return void 0;
|
|
1169
1169
|
}
|
|
1170
1170
|
const adapter = suite.creditManager.adapters.get(meta.addr);
|
|
@@ -1185,17 +1185,17 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1185
1185
|
return mc;
|
|
1186
1186
|
}
|
|
1187
1187
|
/**
|
|
1188
|
-
* Returns multicall entries to call depositDiff on the
|
|
1188
|
+
* Returns multicall entries to call depositDiff on the RWA ERC-4626 adapter for the given credit manager.
|
|
1189
1189
|
* Deposits the leftover underlying (e.g. after decreasing debt) into the vault so the account does not hold excess underlying.
|
|
1190
|
-
* Only applies when the credit manager's underlying is
|
|
1190
|
+
* Only applies when the credit manager's underlying is RWA-gated and has an ERC-4626 adapter configured.
|
|
1191
1191
|
* @param amount - Leftover underlying amount to deposit into the vault (in underlying decimals)
|
|
1192
1192
|
* @param creditManager - Credit manager address
|
|
1193
|
-
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not
|
|
1193
|
+
* @returns Array of MultiCall to pass to credit facade multicall, or undefined if underlying is not RWA or no adapter is configured
|
|
1194
1194
|
*/
|
|
1195
1195
|
async getDepositDiffCalls(amount, creditManager) {
|
|
1196
1196
|
const suite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
1197
1197
|
const meta = this.sdk.tokensMeta.mustGet(suite.underlying);
|
|
1198
|
-
if (!this.sdk.tokensMeta.
|
|
1198
|
+
if (!this.sdk.tokensMeta.isRWAUnderlying(meta)) {
|
|
1199
1199
|
return void 0;
|
|
1200
1200
|
}
|
|
1201
1201
|
const adapter = suite.creditManager.adapters.get(meta.addr);
|
|
@@ -1672,68 +1672,68 @@ class CreditAccountsServiceV310 extends SDKConstruct {
|
|
|
1672
1672
|
return this.#compressor;
|
|
1673
1673
|
}
|
|
1674
1674
|
/**
|
|
1675
|
-
* Wrapper that selects between credit facade and
|
|
1675
|
+
* Wrapper that selects between credit facade and RWA factory
|
|
1676
1676
|
* @param suite
|
|
1677
1677
|
* @param to
|
|
1678
1678
|
* @param calls
|
|
1679
1679
|
* @param referralCode
|
|
1680
|
-
* @param
|
|
1680
|
+
* @param rwaOptions
|
|
1681
1681
|
* @returns
|
|
1682
1682
|
*/
|
|
1683
|
-
async #openCreditAccountTx(suite, to, calls, referralCode,
|
|
1683
|
+
async #openCreditAccountTx(suite, to, calls, referralCode, rwaOptions) {
|
|
1684
1684
|
const marketSuite = this.sdk.marketRegister.findByPool(suite.pool);
|
|
1685
|
-
const factory = marketSuite.
|
|
1685
|
+
const factory = marketSuite.rwaFactory;
|
|
1686
1686
|
if (factory) {
|
|
1687
1687
|
return factory.openCreditAccount(
|
|
1688
1688
|
suite.creditManager.address,
|
|
1689
1689
|
calls,
|
|
1690
|
-
|
|
1690
|
+
rwaOptions
|
|
1691
1691
|
);
|
|
1692
1692
|
}
|
|
1693
1693
|
return suite.creditFacade.openCreditAccount(to, calls, referralCode ?? 0n);
|
|
1694
1694
|
}
|
|
1695
1695
|
/**
|
|
1696
|
-
* Wrapper that selects between credit facade and
|
|
1696
|
+
* Wrapper that selects between credit facade and RWA factory
|
|
1697
1697
|
* @param suite
|
|
1698
1698
|
* @param creditAccount
|
|
1699
1699
|
* @param calls
|
|
1700
|
-
* @param
|
|
1700
|
+
* @param rwaOptions
|
|
1701
1701
|
* @returns
|
|
1702
1702
|
*/
|
|
1703
|
-
async #multicallTx(suite, creditAccount, calls,
|
|
1703
|
+
async #multicallTx(suite, creditAccount, calls, rwaOptions) {
|
|
1704
1704
|
const marketSuite = this.sdk.marketRegister.findByCreditManager(
|
|
1705
1705
|
suite.creditManager.address
|
|
1706
1706
|
);
|
|
1707
|
-
const factory = marketSuite.
|
|
1707
|
+
const factory = marketSuite.rwaFactory;
|
|
1708
1708
|
if (factory) {
|
|
1709
|
-
return factory.multicall(creditAccount, calls,
|
|
1709
|
+
return factory.multicall(creditAccount, calls, rwaOptions);
|
|
1710
1710
|
}
|
|
1711
1711
|
return suite.creditFacade.multicall(creditAccount, calls);
|
|
1712
1712
|
}
|
|
1713
1713
|
/**
|
|
1714
|
-
* Wrapper that selects between credit facade and
|
|
1714
|
+
* Wrapper that selects between credit facade and RWA factory
|
|
1715
1715
|
* @param suite
|
|
1716
1716
|
* @param creditAccount
|
|
1717
1717
|
* @param calls
|
|
1718
1718
|
* @param operation
|
|
1719
|
-
* @param
|
|
1719
|
+
* @param rwaOptions
|
|
1720
1720
|
* @returns
|
|
1721
1721
|
*/
|
|
1722
|
-
async #closeCreditAccountTx(suite, creditAccount, calls, operation,
|
|
1722
|
+
async #closeCreditAccountTx(suite, creditAccount, calls, operation, rwaOptions) {
|
|
1723
1723
|
const marketSuite = this.sdk.marketRegister.findByCreditManager(
|
|
1724
1724
|
suite.creditManager.address
|
|
1725
1725
|
);
|
|
1726
|
-
const factory = marketSuite.
|
|
1726
|
+
const factory = marketSuite.rwaFactory;
|
|
1727
1727
|
if (operation === "close") {
|
|
1728
1728
|
if (factory) {
|
|
1729
1729
|
throw new Error(
|
|
1730
|
-
"CloseOptions=close is not supported for
|
|
1730
|
+
"CloseOptions=close is not supported for RWA underlying credit accounts"
|
|
1731
1731
|
);
|
|
1732
1732
|
}
|
|
1733
1733
|
return suite.creditFacade.closeCreditAccount(creditAccount, calls);
|
|
1734
1734
|
}
|
|
1735
1735
|
if (factory) {
|
|
1736
|
-
return factory.multicall(creditAccount, calls,
|
|
1736
|
+
return factory.multicall(creditAccount, calls, rwaOptions);
|
|
1737
1737
|
}
|
|
1738
1738
|
return suite.creditFacade.multicall(creditAccount, calls);
|
|
1739
1739
|
}
|
|
@@ -63,12 +63,12 @@ class TokensMeta extends AddressMap {
|
|
|
63
63
|
return !!t.contractType?.startsWith("PHANTOM_TOKEN::");
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Returns true if the token is a
|
|
66
|
+
* Returns true if the token is a RWA underlying token, throws if the token data is not loaded
|
|
67
67
|
* @param t
|
|
68
68
|
* @returns
|
|
69
69
|
*/
|
|
70
|
-
|
|
71
|
-
return !!t.contractType?.startsWith("
|
|
70
|
+
isRWAUnderlying(t) {
|
|
71
|
+
return !!t.contractType?.startsWith("RWA_UNDERLYING::");
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* Returns a map of all phantom tokens
|
|
@@ -84,13 +84,13 @@ class TokensMeta extends AddressMap {
|
|
|
84
84
|
return result;
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
* Returns a map of all
|
|
87
|
+
* Returns a map of all RWA underlying tokens
|
|
88
88
|
* Throws if token data is not loaded
|
|
89
89
|
*/
|
|
90
|
-
get
|
|
90
|
+
get rwaUnderlyings() {
|
|
91
91
|
const result = new AddressMap();
|
|
92
92
|
for (const [token, meta] of this.entries()) {
|
|
93
|
-
if (this.
|
|
93
|
+
if (this.isRWAUnderlying(meta)) {
|
|
94
94
|
result.upsert(token, meta);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -7,12 +7,12 @@ const PHANTOM_TOKEN_CONTRACT_TYPES = [
|
|
|
7
7
|
"PHANTOM_TOKEN::STAKING_REWARDS",
|
|
8
8
|
"PHANTOM_TOKEN::UPSHIFT_WITHDRAW"
|
|
9
9
|
];
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const RWA_UNDERLYING_DEFAULT = "RWA_UNDERLYING::DEFAULT";
|
|
11
|
+
const RWA_UNDERLYING_ON_DEMAND = "RWA_UNDERLYING::ON_DEMAND";
|
|
12
|
+
const RWA_ON_DEMAND_LP_MONOPOLIZED = "ON_DEMAND_LP::MONOPOLIZED";
|
|
13
13
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
PHANTOM_TOKEN_CONTRACT_TYPES,
|
|
15
|
+
RWA_ON_DEMAND_LP_MONOPOLIZED,
|
|
16
|
+
RWA_UNDERLYING_DEFAULT,
|
|
17
|
+
RWA_UNDERLYING_ON_DEMAND
|
|
18
18
|
};
|
|
@@ -68,7 +68,7 @@ const chains = {
|
|
|
68
68
|
"0x99df7330bf42d596af2e9d9836d4fc2077c574aa": "M11 Credit",
|
|
69
69
|
"0x610627d8d01a413bdd9b0a0b60070da7dd1e54ad": "Securitize"
|
|
70
70
|
},
|
|
71
|
-
|
|
71
|
+
rwaFactories: [],
|
|
72
72
|
isPublic: true,
|
|
73
73
|
wellKnownToken: {
|
|
74
74
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
@@ -86,7 +86,7 @@ const chains = {
|
|
|
86
86
|
defaultMarketConfigurators: {
|
|
87
87
|
"0x01023850b360b88de0d0f84015bbba1eba57fe7e": "Chaos Labs"
|
|
88
88
|
},
|
|
89
|
-
|
|
89
|
+
rwaFactories: [],
|
|
90
90
|
isPublic: true,
|
|
91
91
|
wellKnownToken: {
|
|
92
92
|
address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
@@ -105,7 +105,7 @@ const chains = {
|
|
|
105
105
|
"0x2a15969CE5320868eb609680751cF8896DD92De5": "Chaos Labs",
|
|
106
106
|
"0x9dddd1b9ce0ac8aa0c80e4ec141600b9bf0101c3": "UltraYield"
|
|
107
107
|
},
|
|
108
|
-
|
|
108
|
+
rwaFactories: [],
|
|
109
109
|
isPublic: true,
|
|
110
110
|
wellKnownToken: {
|
|
111
111
|
address: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
@@ -121,7 +121,7 @@ const chains = {
|
|
|
121
121
|
...base,
|
|
122
122
|
network: "Base",
|
|
123
123
|
defaultMarketConfigurators: {},
|
|
124
|
-
|
|
124
|
+
rwaFactories: [],
|
|
125
125
|
isPublic: false,
|
|
126
126
|
wellKnownToken: {
|
|
127
127
|
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
@@ -138,7 +138,7 @@ const chains = {
|
|
|
138
138
|
defaultMarketConfigurators: {
|
|
139
139
|
"0x8FFDd1F1433674516f83645a768E8900A2A5D076": "Chaos Labs"
|
|
140
140
|
},
|
|
141
|
-
|
|
141
|
+
rwaFactories: [],
|
|
142
142
|
isPublic: true,
|
|
143
143
|
blockExplorers: {
|
|
144
144
|
default: {
|
|
@@ -160,7 +160,7 @@ const chains = {
|
|
|
160
160
|
...megaeth,
|
|
161
161
|
network: "MegaETH",
|
|
162
162
|
defaultMarketConfigurators: {},
|
|
163
|
-
|
|
163
|
+
rwaFactories: [],
|
|
164
164
|
isPublic: false,
|
|
165
165
|
wellKnownToken: {
|
|
166
166
|
address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
|
|
@@ -182,7 +182,7 @@ const chains = {
|
|
|
182
182
|
"0x16956912813ab9a38d95730b52a8cf53e860a7c5": "Tulipa",
|
|
183
183
|
"0x7c6ee1bf9c1eb3ee55bdbdc1e8d0317aab718e0a": "UltraYield"
|
|
184
184
|
},
|
|
185
|
-
|
|
185
|
+
rwaFactories: [],
|
|
186
186
|
isPublic: true,
|
|
187
187
|
wellKnownToken: {
|
|
188
188
|
address: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
|
|
@@ -196,7 +196,7 @@ const chains = {
|
|
|
196
196
|
...berachain,
|
|
197
197
|
network: "Berachain",
|
|
198
198
|
defaultMarketConfigurators: {},
|
|
199
|
-
|
|
199
|
+
rwaFactories: [],
|
|
200
200
|
isPublic: false,
|
|
201
201
|
blockExplorers: {
|
|
202
202
|
default: {
|
|
@@ -218,7 +218,7 @@ const chains = {
|
|
|
218
218
|
...avalanche,
|
|
219
219
|
network: "Avalanche",
|
|
220
220
|
defaultMarketConfigurators: {},
|
|
221
|
-
|
|
221
|
+
rwaFactories: [],
|
|
222
222
|
isPublic: false,
|
|
223
223
|
wellKnownToken: {
|
|
224
224
|
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
@@ -237,7 +237,7 @@ const chains = {
|
|
|
237
237
|
"0x92dc4ee43e9b207e16fbf3fd1a6933563c0a0d35": "Re7"
|
|
238
238
|
},
|
|
239
239
|
testMarketConfigurators: {},
|
|
240
|
-
|
|
240
|
+
rwaFactories: [],
|
|
241
241
|
isPublic: true,
|
|
242
242
|
wellKnownToken: {
|
|
243
243
|
address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
@@ -252,7 +252,7 @@ const chains = {
|
|
|
252
252
|
...worldchain,
|
|
253
253
|
network: "WorldChain",
|
|
254
254
|
defaultMarketConfigurators: {},
|
|
255
|
-
|
|
255
|
+
rwaFactories: [],
|
|
256
256
|
isPublic: false,
|
|
257
257
|
wellKnownToken: {
|
|
258
258
|
address: "0x79a02482a880bce3f13e09da970dc34db4cd24d1",
|
|
@@ -267,7 +267,7 @@ const chains = {
|
|
|
267
267
|
defaultMarketConfigurators: {
|
|
268
268
|
"0x577424f0e6f50db668cc1bc76babb87e36732291": "Re7"
|
|
269
269
|
},
|
|
270
|
-
|
|
270
|
+
rwaFactories: [],
|
|
271
271
|
isPublic: true,
|
|
272
272
|
wellKnownToken: {
|
|
273
273
|
address: "0x796Ea11Fa2dD751eD01b53C372fFDB4AAa8f00F9",
|
|
@@ -282,7 +282,7 @@ const chains = {
|
|
|
282
282
|
defaultMarketConfigurators: {
|
|
283
283
|
"0xc9961b8a0c763779690577f2c76962c086af2fe3": "Invariant Group"
|
|
284
284
|
},
|
|
285
|
-
|
|
285
|
+
rwaFactories: [],
|
|
286
286
|
isPublic: true,
|
|
287
287
|
wellKnownToken: {
|
|
288
288
|
address: "0xad11a8BEb98bbf61dbb1aa0F6d6F2ECD87b35afA",
|
|
@@ -302,7 +302,7 @@ const chains = {
|
|
|
302
302
|
defaultMarketConfigurators: {
|
|
303
303
|
"0x25778dbf0e56b7feb8358c4aa2f6f9e19a1c145a": "Re7"
|
|
304
304
|
},
|
|
305
|
-
|
|
305
|
+
rwaFactories: [],
|
|
306
306
|
isPublic: true,
|
|
307
307
|
wellKnownToken: {
|
|
308
308
|
address: "0xF242275d3a6527d877f2c927a82D9b057609cc71",
|
|
@@ -319,7 +319,7 @@ const chains = {
|
|
|
319
319
|
"0xce1cf71a28837daaa7b92d00ca4ef2fd649c2a67": "Hyperithm",
|
|
320
320
|
"0x9655f82b585b11cee8a05576ed8efcf755cec04b": "TelosC"
|
|
321
321
|
},
|
|
322
|
-
|
|
322
|
+
rwaFactories: [],
|
|
323
323
|
isPublic: true,
|
|
324
324
|
wellKnownToken: {
|
|
325
325
|
address: "0x5d72a9d9a9510cd8cbdba12ac62593a58930a948",
|
|
@@ -346,7 +346,7 @@ const chains = {
|
|
|
346
346
|
defaultMarketConfigurators: {
|
|
347
347
|
"0x1ca8b92aa7233a9f8f7ba031ac45c878141adff0": "Invariant Group"
|
|
348
348
|
},
|
|
349
|
-
|
|
349
|
+
rwaFactories: [],
|
|
350
350
|
isPublic: true,
|
|
351
351
|
wellKnownToken: {
|
|
352
352
|
address: "0x67B302E35Aef5EEE8c32D934F5856869EF428330",
|
|
@@ -31,7 +31,7 @@ const AP_WETH_GATEWAY = "WETH_GATEWAY";
|
|
|
31
31
|
const AP_WETH_TOKEN = "WETH_TOKEN";
|
|
32
32
|
const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
33
33
|
const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
34
|
-
const
|
|
34
|
+
const AP_RWA_COMPRESSOR = "GLOBAL::RWA_COMPRESSOR";
|
|
35
35
|
const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
|
|
36
36
|
export {
|
|
37
37
|
ADDRESS_PROVIDER_V310,
|
|
@@ -52,7 +52,6 @@ export {
|
|
|
52
52
|
AP_GEAR_TOKEN,
|
|
53
53
|
AP_INFLATION_ATTACK_BLOCKER,
|
|
54
54
|
AP_INSOLVENCY_CHECKER,
|
|
55
|
-
AP_KYC_COMPRESSOR,
|
|
56
55
|
AP_MARKET_COMPRESSOR,
|
|
57
56
|
AP_MARKET_CONFIGURATOR,
|
|
58
57
|
AP_PARTIAL_LIQUIDATION_BOT,
|
|
@@ -62,6 +61,7 @@ export {
|
|
|
62
61
|
AP_PRICE_ORACLE,
|
|
63
62
|
AP_REWARDS_COMPRESSOR,
|
|
64
63
|
AP_ROUTER,
|
|
64
|
+
AP_RWA_COMPRESSOR,
|
|
65
65
|
AP_TOKEN_COMPRESSOR,
|
|
66
66
|
AP_TREASURY,
|
|
67
67
|
AP_WETH_GATEWAY,
|
|
@@ -44,8 +44,8 @@ class MarketSuite extends SDKConstruct {
|
|
|
44
44
|
get underlying() {
|
|
45
45
|
return this.pool.underlying;
|
|
46
46
|
}
|
|
47
|
-
get
|
|
48
|
-
return this.pool.
|
|
47
|
+
get rwaFactory() {
|
|
48
|
+
return this.pool.rwaFactory;
|
|
49
49
|
}
|
|
50
50
|
get dirty() {
|
|
51
51
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from "./adapters/index.js";
|
|
2
2
|
export * from "./credit/index.js";
|
|
3
|
-
export * from "./kyc/index.js";
|
|
4
3
|
export * from "./MarketRegister.js";
|
|
5
4
|
export * from "./MarketSuite.js";
|
|
6
5
|
export * from "./oracle/index.js";
|
|
7
6
|
export * from "./pool/index.js";
|
|
8
7
|
export * from "./pricefeeds/index.js";
|
|
8
|
+
export * from "./rwa/index.js";
|
|
9
9
|
export * from "./types.js";
|
|
@@ -55,8 +55,8 @@ class PoolSuite extends SDKConstruct {
|
|
|
55
55
|
get underlying() {
|
|
56
56
|
return this.pool.underlying;
|
|
57
57
|
}
|
|
58
|
-
get
|
|
59
|
-
return this.pool.
|
|
58
|
+
get rwaFactory() {
|
|
59
|
+
return this.pool.rwaFactory;
|
|
60
60
|
}
|
|
61
61
|
get dirty() {
|
|
62
62
|
return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
|
|
@@ -30,10 +30,10 @@ class PoolV310Contract extends BaseContract {
|
|
|
30
30
|
symbol: data.symbol
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
get
|
|
33
|
+
get rwaFactory() {
|
|
34
34
|
const meta = this.#sdk.tokensMeta.mustGet(this.underlying);
|
|
35
|
-
if (this.#sdk.tokensMeta.
|
|
36
|
-
return this.#sdk.mustGetContract(meta.
|
|
35
|
+
if (this.#sdk.tokensMeta.isRWAUnderlying(meta)) {
|
|
36
|
+
return this.#sdk.mustGetContract(meta.rwaFactory);
|
|
37
37
|
}
|
|
38
38
|
return void 0;
|
|
39
39
|
}
|