@gearbox-protocol/sdk 14.12.0-next.73 → 14.12.0-next.75
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/dev/AccountOpener.js +2 -5
- package/dist/cjs/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +118 -974
- package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +280 -0
- package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.js +141 -0
- package/dist/cjs/sdk/accounts/credit-account-compressor/index.js +6 -0
- package/dist/cjs/sdk/accounts/credit-account-compressor/types.js +1 -0
- package/dist/cjs/sdk/accounts/index.js +5 -4
- package/dist/cjs/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +1 -1
- package/dist/cjs/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +1 -1
- package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +2 -2
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +3 -3
- package/dist/cjs/sdk/accounts/liquidations/constants.js +0 -2
- package/dist/cjs/sdk/accounts/liquidations/index.js +0 -2
- package/dist/cjs/sdk/constants/index.js +1 -0
- package/dist/cjs/sdk/constants/math.js +5 -0
- package/dist/cjs/sdk/index.js +12 -4
- package/dist/cjs/sdk/market/MarketRegister.js +10 -0
- package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +181 -0
- package/dist/cjs/sdk/market/credit/CreditSuite.js +107 -1
- package/dist/cjs/sdk/{accounts → market/credit}/dominantCollateral.js +18 -4
- package/dist/cjs/sdk/market/credit/index.js +3 -0
- package/dist/cjs/sdk/market/index.js +3 -0
- package/dist/cjs/sdk/market/math.js +59 -0
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +41 -1
- package/dist/cjs/sdk/market/oracle/PriceOracleV310Contract.js +0 -30
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +1 -1
- package/dist/cjs/sdk/opportunities/index.js +4 -0
- package/dist/esm/dev/AccountOpener.js +2 -5
- package/dist/esm/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +121 -977
- package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +279 -0
- package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.js +141 -0
- package/dist/esm/sdk/accounts/credit-account-compressor/index.js +4 -0
- package/dist/esm/sdk/accounts/credit-account-compressor/types.js +1 -0
- package/dist/esm/sdk/accounts/index.js +4 -3
- package/dist/esm/sdk/accounts/intents/operations/unwrap-rwa-collateral/index.js +1 -1
- package/dist/esm/sdk/accounts/intents/operations/wrap-rwa-collateral/index.js +1 -1
- package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/constants.js +1 -2
- package/dist/esm/sdk/accounts/liquidations/index.js +1 -2
- package/dist/esm/sdk/constants/index.js +2 -2
- package/dist/esm/sdk/constants/math.js +5 -1
- package/dist/esm/sdk/index.js +6 -5
- package/dist/esm/sdk/market/MarketRegister.js +10 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +181 -0
- package/dist/esm/sdk/market/credit/CreditSuite.js +108 -2
- package/dist/esm/sdk/{accounts → market/credit}/dominantCollateral.js +18 -5
- package/dist/esm/sdk/market/credit/index.js +2 -1
- package/dist/esm/sdk/market/index.js +2 -1
- package/dist/esm/sdk/market/math.js +56 -1
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +41 -1
- package/dist/esm/sdk/market/oracle/PriceOracleV310Contract.js +1 -31
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +1 -1
- package/dist/esm/sdk/opportunities/index.js +2 -2
- package/dist/types/plugins/accounts/AccountsPlugin.d.ts +1 -1
- package/dist/types/sdk/OnchainSDK.d.ts +1 -1
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +23 -124
- package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressor.d.ts +60 -0
- package/dist/types/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.d.ts +879 -0
- package/dist/types/sdk/accounts/credit-account-compressor/index.d.ts +4 -0
- package/dist/types/sdk/accounts/credit-account-compressor/types.d.ts +164 -0
- package/dist/types/sdk/accounts/index.d.ts +7 -5
- package/dist/types/sdk/accounts/liquidations/constants.d.ts +1 -2
- package/dist/types/sdk/accounts/liquidations/index.d.ts +1 -2
- package/dist/types/sdk/accounts/types.d.ts +46 -457
- package/dist/types/sdk/base/index.d.ts +2 -2
- package/dist/types/sdk/base/types.d.ts +6 -1
- package/dist/types/sdk/constants/index.d.ts +2 -2
- package/dist/types/sdk/constants/math.d.ts +5 -1
- package/dist/types/sdk/index.d.ts +16 -14
- package/dist/types/sdk/market/MarketRegister.d.ts +7 -0
- package/dist/types/sdk/market/credit/CreditFacadeV310Contract.d.ts +47 -2
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +24 -2
- package/dist/types/sdk/{accounts → market/credit}/dominantCollateral.d.ts +13 -6
- package/dist/types/sdk/market/credit/index.d.ts +3 -2
- package/dist/types/sdk/market/credit/types.d.ts +112 -2
- package/dist/types/sdk/market/index.d.ts +4 -3
- package/dist/types/sdk/market/math.d.ts +60 -1
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +15 -4
- package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +0 -10
- package/dist/types/sdk/market/oracle/index.d.ts +2 -2
- package/dist/types/sdk/market/oracle/types.d.ts +30 -14
- package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +1 -1
- package/dist/types/sdk/market/rwa/types.d.ts +1 -1
- package/dist/types/sdk/opportunities/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/cjs/sdk/accounts/constants.js +0 -12
- package/dist/esm/sdk/accounts/constants.js +0 -11
- package/dist/types/sdk/accounts/constants.d.ts +0 -11
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sdk_utils_AddressMap = require("../../utils/AddressMap.js");
|
|
3
|
+
const require_sdk_utils_AddressSet = require("../../utils/AddressSet.js");
|
|
4
|
+
const require_sdk_constants_address_provider = require("../../constants/address-provider.js");
|
|
5
|
+
const require_sdk_constants_addresses = require("../../constants/addresses.js");
|
|
6
|
+
const require_sdk_constants_math = require("../../constants/math.js");
|
|
7
|
+
const require_sdk_constants_versions = require("../../constants/versions.js");
|
|
8
|
+
require("../../constants/index.js");
|
|
9
|
+
const require_sdk_utils_hex = require("../../utils/hex.js");
|
|
10
|
+
require("../../utils/index.js");
|
|
11
|
+
const require_sdk_base_SDKConstruct = require("../../base/SDKConstruct.js");
|
|
12
|
+
require("../../base/index.js");
|
|
13
|
+
const require_abi_rwa_iRWAFactory = require("../../../abi/rwa/iRWAFactory.js");
|
|
14
|
+
const require_sdk_market_math = require("../../market/math.js");
|
|
15
|
+
const require_sdk_market_credit_dominantCollateral = require("../../market/credit/dominantCollateral.js");
|
|
16
|
+
const require_sdk_utils_viem_simulateWithPriceUpdates = require("../../utils/viem/simulateWithPriceUpdates.js");
|
|
17
|
+
require("../../utils/viem/index.js");
|
|
18
|
+
require("../../market/index.js");
|
|
19
|
+
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract = require("./CreditAccountCompressorV310Contract.js");
|
|
20
|
+
//#region src/sdk/accounts/credit-account-compressor/CreditAccountCompressor.ts
|
|
21
|
+
/**
|
|
22
|
+
* Reads credit accounts of the current chain.
|
|
23
|
+
*
|
|
24
|
+
* Stitches the credit account compressor together with the RWA factories (for
|
|
25
|
+
* accounts owned via an investor EOA) and with the withdrawal compressor (for
|
|
26
|
+
* assets that are on their way out of an account), and describes the result
|
|
27
|
+
* either as raw account data or as {@link StrategyPosition}s.
|
|
28
|
+
*
|
|
29
|
+
* TODO: create and deploy new compressor contract onchain to avoid all this stitching
|
|
30
|
+
**/
|
|
31
|
+
var CreditAccountCompressor = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
32
|
+
/**
|
|
33
|
+
* Reads data of a single credit account.
|
|
34
|
+
*
|
|
35
|
+
* When the compressor cannot value the account with current prices, the read
|
|
36
|
+
* is retried with price feed updates applied.
|
|
37
|
+
*
|
|
38
|
+
* @param account - Credit account address.
|
|
39
|
+
* @param blockNumber - Block to read at, defaults to the latest block.
|
|
40
|
+
* @returns Account data, or `undefined` if the account does not exist.
|
|
41
|
+
**/
|
|
42
|
+
async getCreditAccountData(account, blockNumber) {
|
|
43
|
+
const contract = this.#contract;
|
|
44
|
+
const raw = await contract.getCreditAccountData(account, blockNumber);
|
|
45
|
+
if (!raw) return;
|
|
46
|
+
const marketSuite = this.sdk.marketRegister.findByCreditManager(raw.creditManager);
|
|
47
|
+
const factory = marketSuite.rwaFactory;
|
|
48
|
+
let ca;
|
|
49
|
+
let investor;
|
|
50
|
+
if (raw.success) {
|
|
51
|
+
ca = raw;
|
|
52
|
+
investor = await factory?.getInvestor(raw.creditAccount, false);
|
|
53
|
+
} else {
|
|
54
|
+
const { txs: priceUpdateTxs } = await marketSuite.priceOracle.priceUpdateTxsForAccount(raw);
|
|
55
|
+
[ca, investor] = await require_sdk_utils_viem_simulateWithPriceUpdates.simulateWithPriceUpdates(this.client, {
|
|
56
|
+
priceUpdates: priceUpdateTxs,
|
|
57
|
+
contracts: [contract.dataCall(account), ...factory ? [{
|
|
58
|
+
abi: require_abi_rwa_iRWAFactory.iRWAFactoryAbi,
|
|
59
|
+
address: factory.address,
|
|
60
|
+
functionName: "getInvestor",
|
|
61
|
+
args: [raw.creditAccount]
|
|
62
|
+
}] : []],
|
|
63
|
+
blockNumber,
|
|
64
|
+
gas: this.sdk.gasLimit
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
...ca,
|
|
69
|
+
investor
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reads all credit accounts matching the options, sorted by health factor
|
|
74
|
+
* ascending.
|
|
75
|
+
*
|
|
76
|
+
* @param options - {@link GetCreditAccountsOptions}
|
|
77
|
+
* @param blockNumber - Block to read at, defaults to the latest block.
|
|
78
|
+
**/
|
|
79
|
+
async getCreditAccounts(options, blockNumber) {
|
|
80
|
+
const { creditManager, includeZeroDebt = false, maxHealthFactor = require_sdk_constants_math.MAX_UINT256, minHealthFactor = 0n, owner = require_sdk_constants_addresses.ADDRESS_0X0, ignoreReservePrices = false } = options ?? {};
|
|
81
|
+
const target = creditManager ?? {
|
|
82
|
+
configurators: this.#marketConfigurators,
|
|
83
|
+
creditManagers: [],
|
|
84
|
+
pools: [],
|
|
85
|
+
underlying: "0x0000000000000000000000000000000000000000"
|
|
86
|
+
};
|
|
87
|
+
const { txs: priceUpdateTxs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(ignoreReservePrices ? { main: true } : void 0);
|
|
88
|
+
return (await this.#contract.getCreditAccounts(target, {
|
|
89
|
+
owner,
|
|
90
|
+
includeZeroDebt,
|
|
91
|
+
minHealthFactor,
|
|
92
|
+
maxHealthFactor
|
|
93
|
+
}, {
|
|
94
|
+
blockNumber,
|
|
95
|
+
priceUpdateTxs
|
|
96
|
+
})).sort((a, b) => Number(a.healthFactor - b.healthFactor));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Reads all credit accounts of a borrower, sorted by health factor
|
|
100
|
+
* ascending.
|
|
101
|
+
*
|
|
102
|
+
* Covers accounts the borrower owns directly and RWA accounts they own as an
|
|
103
|
+
* investor, which are owned on-chain by an RWA factory.
|
|
104
|
+
*
|
|
105
|
+
* @param borrower - Wallet address.
|
|
106
|
+
* @param options - {@link GetCreditAccountsOptions}
|
|
107
|
+
* @param blockNumber - Block to read at, defaults to the latest block.
|
|
108
|
+
**/
|
|
109
|
+
async getBorrowerCreditAccounts(borrower, options, blockNumber) {
|
|
110
|
+
const { creditManager, includeZeroDebt = false, maxHealthFactor = require_sdk_constants_math.MAX_UINT256, minHealthFactor = 0n, ignoreReservePrices = false } = options ?? {};
|
|
111
|
+
const { txs: priceUpdateTxs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(ignoreReservePrices ? { main: true } : void 0);
|
|
112
|
+
const rwaAccountAddresses = (await this.sdk.rwa.getInvestorData(borrower)).flatMap((d) => d.creditAccounts.map((ca) => ca.creditAccount));
|
|
113
|
+
const cmFilter = creditManager ? {
|
|
114
|
+
configurators: [],
|
|
115
|
+
creditManagers: [creditManager],
|
|
116
|
+
pools: [],
|
|
117
|
+
underlying: require_sdk_constants_addresses.ADDRESS_0X0
|
|
118
|
+
} : {
|
|
119
|
+
configurators: this.#marketConfigurators,
|
|
120
|
+
creditManagers: [],
|
|
121
|
+
pools: [],
|
|
122
|
+
underlying: require_sdk_constants_addresses.ADDRESS_0X0
|
|
123
|
+
};
|
|
124
|
+
const permissiveFilter = {
|
|
125
|
+
owner: borrower,
|
|
126
|
+
includeZeroDebt: true,
|
|
127
|
+
minHealthFactor: 0n,
|
|
128
|
+
maxHealthFactor: require_sdk_constants_math.MAX_UINT256,
|
|
129
|
+
reverting: false
|
|
130
|
+
};
|
|
131
|
+
const contract = this.#contract;
|
|
132
|
+
const rwaContracts = rwaAccountAddresses.map((account) => contract.dataCall(account));
|
|
133
|
+
const getCreditAccountsContracts = [false, true].map((reverting) => contract.accountsCall([
|
|
134
|
+
cmFilter,
|
|
135
|
+
{
|
|
136
|
+
...permissiveFilter,
|
|
137
|
+
reverting
|
|
138
|
+
},
|
|
139
|
+
0n
|
|
140
|
+
]));
|
|
141
|
+
const allContracts = [...rwaContracts, ...getCreditAccountsContracts];
|
|
142
|
+
const results = await require_sdk_utils_viem_simulateWithPriceUpdates.simulateWithPriceUpdates(this.client, {
|
|
143
|
+
priceUpdates: priceUpdateTxs,
|
|
144
|
+
contracts: allContracts,
|
|
145
|
+
blockNumber,
|
|
146
|
+
gas: this.sdk.gasLimit
|
|
147
|
+
});
|
|
148
|
+
const rwaResults = results.slice(0, rwaAccountAddresses.length);
|
|
149
|
+
const normalResults = results.slice(rwaAccountAddresses.length);
|
|
150
|
+
const seen = new require_sdk_utils_AddressSet.AddressSet();
|
|
151
|
+
const allCAs = [];
|
|
152
|
+
for (const ca of rwaResults) if (!seen.has(ca.creditAccount)) {
|
|
153
|
+
seen.add(ca.creditAccount);
|
|
154
|
+
allCAs.push({
|
|
155
|
+
...ca,
|
|
156
|
+
investor: borrower
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
for (const [accounts] of normalResults) for (const ca of accounts) if (!seen.has(ca.creditAccount)) {
|
|
160
|
+
seen.add(ca.creditAccount);
|
|
161
|
+
allCAs.push({
|
|
162
|
+
...ca,
|
|
163
|
+
investor: void 0
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const filtered = allCAs.filter((ca) => {
|
|
167
|
+
if (!includeZeroDebt && ca.debt === 0n) return false;
|
|
168
|
+
if (ca.healthFactor < minHealthFactor) return false;
|
|
169
|
+
if (ca.healthFactor > maxHealthFactor) return false;
|
|
170
|
+
if (creditManager && !require_sdk_utils_hex.hexEq(ca.creditManager, creditManager)) return false;
|
|
171
|
+
return true;
|
|
172
|
+
});
|
|
173
|
+
this.logger?.debug(`loaded ${allCAs.length} borrower credit accounts (${rwaResults.length} RWA, ${filtered.length} after filter)`);
|
|
174
|
+
return filtered.sort((a, b) => Number(a.healthFactor - b.healthFactor));
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Describes all credit accounts of a wallet as strategy positions.
|
|
178
|
+
*
|
|
179
|
+
* @param props - {@link ListStrategyPositionsProps}
|
|
180
|
+
**/
|
|
181
|
+
async listPositions(props) {
|
|
182
|
+
const { owner, includeZeroDebt } = props;
|
|
183
|
+
const [accounts] = await Promise.all([this.getBorrowerCreditAccounts(owner, { includeZeroDebt }), this.sdk.withdrawalCompressor?.loadWithdrawableAssets()]);
|
|
184
|
+
const describable = accounts.filter((ca) => {
|
|
185
|
+
if (!ca.success) this.logger?.warn(`cannot describe position of ${this.labelAddress(ca.creditAccount)}: collateral computation failed`);
|
|
186
|
+
return ca.success;
|
|
187
|
+
});
|
|
188
|
+
const withdrawals = await Promise.all(describable.map((ca) => this.#accountWithdrawals(ca)));
|
|
189
|
+
return describable.map((ca, i) => this.#toStrategyPosition(ca, withdrawals[i] ?? new require_sdk_utils_AddressMap.AddressMap()));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Builds one strategy position from an account snapshot.
|
|
193
|
+
*
|
|
194
|
+
* @param withdrawals - Delayed withdrawals of the account, keyed by the
|
|
195
|
+
* phantom token that represents them on it.
|
|
196
|
+
**/
|
|
197
|
+
#toStrategyPosition(ca, withdrawals) {
|
|
198
|
+
const suite = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
199
|
+
const { market } = suite;
|
|
200
|
+
const { priceOracle } = market;
|
|
201
|
+
const { pool } = market.pool;
|
|
202
|
+
const token = this.sdk.tokensMeta.mustGetToken(market.unwrappedUnderlying);
|
|
203
|
+
const totalDebtValue = ca.debt + ca.accruedInterest + ca.accruedFees;
|
|
204
|
+
const collateral = require_sdk_market_credit_dominantCollateral.dominantCollateral(ca, market);
|
|
205
|
+
return {
|
|
206
|
+
kind: "strategy",
|
|
207
|
+
chainId: this.sdk.chainId,
|
|
208
|
+
creditManager: ca.creditManager,
|
|
209
|
+
creditAccount: ca.creditAccount,
|
|
210
|
+
name: collateral ? suite.strategyName(collateral) : token.symbol,
|
|
211
|
+
targetCollateral: collateral ? this.sdk.tokensMeta.mustGetToken(collateral) : null,
|
|
212
|
+
leverage: require_sdk_market_math.positionLeverage(totalDebtValue, ca.totalValue),
|
|
213
|
+
borrowApy: require_sdk_market_math.borrowApyBps(pool.baseInterestRate, suite.creditManager.feeInterest),
|
|
214
|
+
totalDebt: {
|
|
215
|
+
token,
|
|
216
|
+
value: totalDebtValue,
|
|
217
|
+
valueUsd: require_sdk_market_math.usdToNumber(ca.totalDebtUSD)
|
|
218
|
+
},
|
|
219
|
+
totalValue: {
|
|
220
|
+
token,
|
|
221
|
+
value: ca.totalValue,
|
|
222
|
+
valueUsd: require_sdk_market_math.usdToNumber(ca.totalValueUSD)
|
|
223
|
+
},
|
|
224
|
+
healthFactor: require_sdk_market_math.healthFactorBps(ca.healthFactor),
|
|
225
|
+
collaterals: ca.tokens.flatMap((t) => {
|
|
226
|
+
if ((t.mask & ca.enabledTokensMask) === 0n || t.balance <= 10n) return [];
|
|
227
|
+
return [{
|
|
228
|
+
collateral: priceOracle.toTokenAmount(t.token, t.balance),
|
|
229
|
+
quota: priceOracle.toTokenAmount(market.underlying, t.quota),
|
|
230
|
+
withdrawals: withdrawals.get(t.token) ?? []
|
|
231
|
+
}];
|
|
232
|
+
})
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Delayed withdrawals of one account, keyed by the phantom token that
|
|
237
|
+
* represents them on it, so that each collateral row can pick up its own.
|
|
238
|
+
**/
|
|
239
|
+
async #accountWithdrawals(ca) {
|
|
240
|
+
const compressor = this.sdk.withdrawalCompressor;
|
|
241
|
+
const byPhantomToken = new require_sdk_utils_AddressMap.AddressMap(void 0, "accountWithdrawals");
|
|
242
|
+
const holdsPhantomToken = ca.tokens.some((t) => t.balance > 10n && compressor?.getWithdrawalSourceToken(t.token) !== void 0);
|
|
243
|
+
if (!compressor || !holdsPhantomToken) return byPhantomToken;
|
|
244
|
+
const { priceOracle } = this.sdk.marketRegister.findByCreditManager(ca.creditManager);
|
|
245
|
+
const { claimable, pending } = await compressor.getCurrentWithdrawals(ca.creditAccount);
|
|
246
|
+
const add = (w, outputs, claimableAt) => {
|
|
247
|
+
const assets = outputs.map((o) => ({
|
|
248
|
+
isDelayed: true,
|
|
249
|
+
...priceOracle.toTokenAmount(o.token, o.amount),
|
|
250
|
+
redeemer: w.redeemer,
|
|
251
|
+
claimableAt: claimableAt === void 0 ? void 0 : Number(claimableAt)
|
|
252
|
+
}));
|
|
253
|
+
byPhantomToken.upsert(w.withdrawalPhantomToken, [...byPhantomToken.get(w.withdrawalPhantomToken) ?? [], ...assets]);
|
|
254
|
+
};
|
|
255
|
+
for (const w of claimable) add(w, w.outputs);
|
|
256
|
+
for (const w of pending) add(w, w.expectedOutputs, w.claimableAt);
|
|
257
|
+
return byPhantomToken;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Credit account compressor contract of the current chain.
|
|
261
|
+
*
|
|
262
|
+
* Resolved on every access, because the address provider is only populated
|
|
263
|
+
* once the SDK is attached or hydrated. The contracts register acts as the
|
|
264
|
+
* cache: instances register themselves there on construction, and a
|
|
265
|
+
* re-hydrated SDK with a different compressor address simply misses and
|
|
266
|
+
* builds a new wrapper.
|
|
267
|
+
**/
|
|
268
|
+
get #contract() {
|
|
269
|
+
const [address] = this.sdk.addressProvider.mustGetLatest(require_sdk_constants_address_provider.AP_CREDIT_ACCOUNT_COMPRESSOR, require_sdk_constants_versions.VERSION_RANGE_310);
|
|
270
|
+
return this.sdk.getContract(address) ?? new require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract.CreditAccountCompressorV310Contract(this.sdk, address);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Addresses of market configurators the SDK is attached to.
|
|
274
|
+
**/
|
|
275
|
+
get #marketConfigurators() {
|
|
276
|
+
return this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
//#endregion
|
|
280
|
+
exports.CreditAccountCompressor = CreditAccountCompressor;
|
package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sdk_base_BaseContract = require("../../base/BaseContract.js");
|
|
3
|
+
require("../../base/index.js");
|
|
4
|
+
const require_sdk_utils_viem_simulateWithPriceUpdates = require("../../utils/viem/simulateWithPriceUpdates.js");
|
|
5
|
+
require("../../utils/viem/index.js");
|
|
6
|
+
//#region src/sdk/accounts/credit-account-compressor/CreditAccountCompressorV310Contract.ts
|
|
7
|
+
const abi = require("../../../abi/compressors/creditAccountCompressor.js").creditAccountCompressorAbi;
|
|
8
|
+
/**
|
|
9
|
+
* V3.10 credit account compressor.
|
|
10
|
+
*
|
|
11
|
+
* Wraps the compressor ABI and nothing else: single-account reads, paginated
|
|
12
|
+
* multi-account reads, and call descriptors for callers that need to batch
|
|
13
|
+
* these reads with calls to other contracts.
|
|
14
|
+
**/
|
|
15
|
+
var CreditAccountCompressorV310Contract = class extends require_sdk_base_BaseContract.BaseContract {
|
|
16
|
+
#sdk;
|
|
17
|
+
constructor(sdk, address) {
|
|
18
|
+
super(sdk, {
|
|
19
|
+
addr: address,
|
|
20
|
+
name: "CreditAccountCompressorV310",
|
|
21
|
+
abi,
|
|
22
|
+
version: 310
|
|
23
|
+
});
|
|
24
|
+
this.#sdk = sdk;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Reads data of a single credit account.
|
|
28
|
+
*
|
|
29
|
+
* @param account - Credit account address.
|
|
30
|
+
* @param blockNumber - Block to read at, defaults to the latest block.
|
|
31
|
+
* @returns Account data, or `undefined` if the compressor reverted, which it
|
|
32
|
+
* does when the account does not exist.
|
|
33
|
+
**/
|
|
34
|
+
async getCreditAccountData(account, blockNumber) {
|
|
35
|
+
try {
|
|
36
|
+
return await this.client.readContract({
|
|
37
|
+
abi,
|
|
38
|
+
address: this.address,
|
|
39
|
+
functionName: "getCreditAccountData",
|
|
40
|
+
args: [account],
|
|
41
|
+
blockNumber,
|
|
42
|
+
gas: this.#sdk.gasLimit
|
|
43
|
+
});
|
|
44
|
+
} catch (_e) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Reads all credit accounts matching the filters, in the order the
|
|
50
|
+
* compressor returns them.
|
|
51
|
+
*
|
|
52
|
+
* Two compressor quirks are handled here: results are paginated, and the
|
|
53
|
+
* `reverting` account filter is exclusive, so accounts whose collateral
|
|
54
|
+
* computation reverts are only returned by a second pass.
|
|
55
|
+
*
|
|
56
|
+
* @param target - Credit managers to query.
|
|
57
|
+
* @param query - Account-level filters, without `reverting`.
|
|
58
|
+
* @param options - Block, price updates and page size.
|
|
59
|
+
**/
|
|
60
|
+
async getCreditAccounts(target, query, options) {
|
|
61
|
+
const { batchSize, blockNumber, priceUpdateTxs } = options ?? {};
|
|
62
|
+
const allCAs = [];
|
|
63
|
+
let revertingOffset = 0;
|
|
64
|
+
for (const reverting of [false, true]) {
|
|
65
|
+
let offset = 0n;
|
|
66
|
+
revertingOffset = allCAs.length;
|
|
67
|
+
do {
|
|
68
|
+
const [accounts, newOffset] = await this.#getCreditAccounts(batchSize ? [
|
|
69
|
+
target,
|
|
70
|
+
{
|
|
71
|
+
...query,
|
|
72
|
+
reverting
|
|
73
|
+
},
|
|
74
|
+
offset,
|
|
75
|
+
batchSize
|
|
76
|
+
] : [
|
|
77
|
+
target,
|
|
78
|
+
{
|
|
79
|
+
...query,
|
|
80
|
+
reverting
|
|
81
|
+
},
|
|
82
|
+
offset
|
|
83
|
+
], priceUpdateTxs, blockNumber);
|
|
84
|
+
allCAs.push(...accounts);
|
|
85
|
+
offset = newOffset;
|
|
86
|
+
} while (offset !== 0n);
|
|
87
|
+
}
|
|
88
|
+
this.logger?.debug(`loaded ${allCAs.length} credit accounts (${allCAs.length - revertingOffset} reverting)`);
|
|
89
|
+
return allCAs;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Descriptor of a `getCreditAccountData` call on this compressor.
|
|
93
|
+
**/
|
|
94
|
+
dataCall(account) {
|
|
95
|
+
return {
|
|
96
|
+
abi,
|
|
97
|
+
address: this.address,
|
|
98
|
+
functionName: "getCreditAccountData",
|
|
99
|
+
args: [account]
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Descriptor of a `getCreditAccounts` call on this compressor.
|
|
104
|
+
**/
|
|
105
|
+
accountsCall(args) {
|
|
106
|
+
return {
|
|
107
|
+
abi,
|
|
108
|
+
address: this.address,
|
|
109
|
+
functionName: "getCreditAccounts",
|
|
110
|
+
args
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* One page of `getCreditAccounts`, with price updates applied when the
|
|
115
|
+
* accounts hold tokens with on-demand price feeds.
|
|
116
|
+
**/
|
|
117
|
+
async #getCreditAccounts(args, priceUpdateTxs, blockNumber) {
|
|
118
|
+
let resp;
|
|
119
|
+
if (priceUpdateTxs?.length) [resp] = await require_sdk_utils_viem_simulateWithPriceUpdates.simulateWithPriceUpdates(this.client, {
|
|
120
|
+
priceUpdates: priceUpdateTxs,
|
|
121
|
+
contracts: [this.accountsCall(args)],
|
|
122
|
+
blockNumber,
|
|
123
|
+
gas: this.#sdk.gasLimit
|
|
124
|
+
});
|
|
125
|
+
else resp = await this.client.readContract({
|
|
126
|
+
abi,
|
|
127
|
+
address: this.address,
|
|
128
|
+
functionName: "getCreditAccounts",
|
|
129
|
+
args,
|
|
130
|
+
blockNumber,
|
|
131
|
+
gas: this.#sdk.gasLimit
|
|
132
|
+
});
|
|
133
|
+
this.logger?.debug({
|
|
134
|
+
accounts: resp[0]?.length ?? 0,
|
|
135
|
+
nextOffset: Number(resp[1])
|
|
136
|
+
}, "got credit accounts");
|
|
137
|
+
return resp;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
exports.CreditAccountCompressorV310Contract = CreditAccountCompressorV310Contract;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract = require("./CreditAccountCompressorV310Contract.js");
|
|
3
|
+
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressor = require("./CreditAccountCompressor.js");
|
|
4
|
+
require("./types.js");
|
|
5
|
+
exports.CreditAccountCompressor = require_sdk_accounts_credit_account_compressor_CreditAccountCompressor.CreditAccountCompressor;
|
|
6
|
+
exports.CreditAccountCompressorV310Contract = require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract.CreditAccountCompressorV310Contract;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract = require("./credit-account-compressor/CreditAccountCompressorV310Contract.js");
|
|
3
|
+
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressor = require("./credit-account-compressor/CreditAccountCompressor.js");
|
|
4
|
+
require("./credit-account-compressor/index.js");
|
|
4
5
|
const require_sdk_accounts_CreditAccountsServiceV310 = require("./CreditAccountsServiceV310.js");
|
|
5
6
|
const require_sdk_accounts_intents_operations_claim_delayed_index = require("./intents/operations/claim-delayed/index.js");
|
|
6
7
|
const require_sdk_accounts_intents_index = require("./intents/index.js");
|
|
@@ -22,11 +23,12 @@ const require_sdk_accounts_withdrawal_compressor_WithdrawalCompressorV313Contrac
|
|
|
22
23
|
const require_sdk_accounts_withdrawal_compressor_createWithdrawalCompressor = require("./withdrawal-compressor/createWithdrawalCompressor.js");
|
|
23
24
|
require("./withdrawal-compressor/index.js");
|
|
24
25
|
exports.AbstractWithdrawalCompressorContract = require_sdk_accounts_withdrawal_compressor_AbstractWithdrawalCompressorContract.AbstractWithdrawalCompressorContract;
|
|
26
|
+
exports.CreditAccountCompressor = require_sdk_accounts_credit_account_compressor_CreditAccountCompressor.CreditAccountCompressor;
|
|
27
|
+
exports.CreditAccountCompressorV310Contract = require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract.CreditAccountCompressorV310Contract;
|
|
25
28
|
exports.CreditAccountOperationsService = require_sdk_accounts_intents_index.CreditAccountOperationsService;
|
|
26
29
|
exports.CreditAccountsServiceV310 = require_sdk_accounts_CreditAccountsServiceV310.CreditAccountsServiceV310;
|
|
27
30
|
exports.DELAYED_INTENT_TYPES = require_sdk_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_TYPES;
|
|
28
31
|
exports.DELAYED_INTENT_VERSION = require_sdk_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_VERSION;
|
|
29
|
-
exports.DUST_THRESHOLD = require_sdk_accounts_constants.DUST_THRESHOLD;
|
|
30
32
|
exports.InvalidDelayedIntentError = require_sdk_accounts_withdrawal_compressor_errors.InvalidDelayedIntentError;
|
|
31
33
|
exports.LIQUIDATION_APPROVAL_BUFFER = require_sdk_accounts_liquidations_constants.LIQUIDATION_APPROVAL_BUFFER;
|
|
32
34
|
exports.LIQUIDATION_COMPRESSOR_V313_ADDRESS = require_sdk_accounts_liquidations_constants.LIQUIDATION_COMPRESSOR_V313_ADDRESS;
|
|
@@ -39,7 +41,6 @@ exports.WithdrawalCompressorV313Contract = require_sdk_accounts_withdrawal_compr
|
|
|
39
41
|
exports.createRedemptionLogger = require_sdk_accounts_withdrawal_compressor_createRedemptionLogger.createRedemptionLogger;
|
|
40
42
|
exports.createWithdrawalCompressor = require_sdk_accounts_withdrawal_compressor_createWithdrawalCompressor.createWithdrawalCompressor;
|
|
41
43
|
exports.decodeDelayedIntent = require_sdk_accounts_withdrawal_compressor_intent_codec.decodeDelayedIntent;
|
|
42
|
-
exports.dominantCollateral = require_sdk_accounts_dominantCollateral.dominantCollateral;
|
|
43
44
|
exports.encodeDelayedIntent = require_sdk_accounts_withdrawal_compressor_intent_codec.encodeDelayedIntent;
|
|
44
45
|
exports.getWithdrawalCompressorAddress = require_sdk_accounts_withdrawal_compressor_addresses.getWithdrawalCompressorAddress;
|
|
45
46
|
exports.iCreditAccountAbi = require_sdk_accounts_withdrawal_compressor_AbstractWithdrawalCompressorContract.iCreditAccountAbi;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
/** One-to-one swap op (withdraw resume conversion legs). */
|
|
4
4
|
async function buildUnwrapRwaCollateralOperation(input, option) {
|
|
5
5
|
if (option.kind === "onchain") {
|
|
6
|
-
const calls = await input.sdk.accounts.
|
|
6
|
+
const calls = await input.sdk.accounts.assembleRWAUnwrapCalls(input.amountIn, input.creditAccount.creditManager);
|
|
7
7
|
if (!calls) throw new Error("unwrapRwaCollateral: no wrap calls found");
|
|
8
8
|
return {
|
|
9
9
|
type: "unwrapRwaCollateral",
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
/** One-to-one wrap op (decrease-leverage resume repay from rwa.asset). */
|
|
4
4
|
async function buildWrapRwaCollateralOperation(input, option) {
|
|
5
5
|
if (option.kind === "onchain") {
|
|
6
|
-
const calls = await input.sdk.accounts.
|
|
6
|
+
const calls = await input.sdk.accounts.assembleRWAWrapCalls(input.amountIn, input.creditAccount.creditManager);
|
|
7
7
|
if (!calls) throw new Error("wrapRwaCollateral: no wrap calls found");
|
|
8
8
|
return {
|
|
9
9
|
type: "wrapRwaCollateral",
|
|
@@ -164,8 +164,8 @@ function buildMockSdk(args) {
|
|
|
164
164
|
prepareUpdateQuotas: vitest.vi.fn(() => [CA_OP_CALLS.changeQuota]),
|
|
165
165
|
assembleClaimDelayedCalls: vitest.vi.fn(({ claimableNow }) => [...claimableNow.claimCalls]),
|
|
166
166
|
assembleCloseCreditAccountCalls: vitest.vi.fn(async () => [MOCK_CLOSE_CALL]),
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
assembleRWAWrapCalls: vitest.vi.fn(async () => [MOCK_RWA_WRAP_CALL]),
|
|
168
|
+
assembleRWAUnwrapCalls: vitest.vi.fn(async () => [MOCK_RWA_UNWRAP_CALL])
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
171
|
}
|
|
@@ -10,6 +10,7 @@ require("../../utils/index.js");
|
|
|
10
10
|
const require_sdk_base_SDKConstruct = require("../../base/SDKConstruct.js");
|
|
11
11
|
require("../../base/index.js");
|
|
12
12
|
const require_sdk_market_math = require("../../market/math.js");
|
|
13
|
+
const require_sdk_market_credit_dominantCollateral = require("../../market/credit/dominantCollateral.js");
|
|
13
14
|
const require_model_liquidations = require("../../../model/liquidations.js");
|
|
14
15
|
require("../../../model/index.js");
|
|
15
16
|
const require_sdk_market_rwa_midas_constants = require("../../market/rwa/midas/constants.js");
|
|
@@ -18,8 +19,7 @@ require("../../market/rwa/midas/index.js");
|
|
|
18
19
|
const require_sdk_market_rwa_securitize_constants = require("../../market/rwa/securitize/constants.js");
|
|
19
20
|
const require_sdk_market_rwa_securitize_SecuritizeLiquidatorContract = require("../../market/rwa/securitize/SecuritizeLiquidatorContract.js");
|
|
20
21
|
require("../../market/rwa/securitize/index.js");
|
|
21
|
-
require("
|
|
22
|
-
const require_sdk_accounts_dominantCollateral = require("../dominantCollateral.js");
|
|
22
|
+
require("../../market/index.js");
|
|
23
23
|
const require_sdk_accounts_liquidations_constants = require("./constants.js");
|
|
24
24
|
//#region src/sdk/accounts/liquidations/LiquidationsService.ts
|
|
25
25
|
/**
|
|
@@ -282,7 +282,7 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
|
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
#mainAsset(ca, market, fallback) {
|
|
285
|
-
const asset =
|
|
285
|
+
const asset = require_sdk_market_credit_dominantCollateral.dominantCollateral(ca, market);
|
|
286
286
|
if (!asset) return fallback;
|
|
287
287
|
return this.sdk.withdrawalCompressor?.getWithdrawalSourceToken(asset) ?? asset;
|
|
288
288
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sdk_accounts_constants = require("../constants.js");
|
|
3
2
|
//#region src/sdk/accounts/liquidations/constants.ts
|
|
4
3
|
const LIQUIDATION_COMPRESSOR_V313_ADDRESS = "0xB70C4500a0afF02107eB983a348F22492fB6dC94";
|
|
5
4
|
/**
|
|
@@ -9,6 +8,5 @@ const LIQUIDATION_COMPRESSOR_V313_ADDRESS = "0xB70C4500a0afF02107eB983a348F22492
|
|
|
9
8
|
**/
|
|
10
9
|
const LIQUIDATION_APPROVAL_BUFFER = 50n;
|
|
11
10
|
//#endregion
|
|
12
|
-
exports.DUST_THRESHOLD = require_sdk_accounts_constants.DUST_THRESHOLD;
|
|
13
11
|
exports.LIQUIDATION_APPROVAL_BUFFER = LIQUIDATION_APPROVAL_BUFFER;
|
|
14
12
|
exports.LIQUIDATION_COMPRESSOR_V313_ADDRESS = LIQUIDATION_COMPRESSOR_V313_ADDRESS;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sdk_accounts_constants = require("../constants.js");
|
|
3
2
|
const require_sdk_accounts_liquidations_constants = require("./constants.js");
|
|
4
3
|
const require_sdk_accounts_liquidations_LiquidationsService = require("./LiquidationsService.js");
|
|
5
4
|
const require_sdk_accounts_liquidations_MultichainLiquidationsService = require("./MultichainLiquidationsService.js");
|
|
6
5
|
require("./types.js");
|
|
7
|
-
exports.DUST_THRESHOLD = require_sdk_accounts_constants.DUST_THRESHOLD;
|
|
8
6
|
exports.LIQUIDATION_APPROVAL_BUFFER = require_sdk_accounts_liquidations_constants.LIQUIDATION_APPROVAL_BUFFER;
|
|
9
7
|
exports.LIQUIDATION_COMPRESSOR_V313_ADDRESS = require_sdk_accounts_liquidations_constants.LIQUIDATION_COMPRESSOR_V313_ADDRESS;
|
|
10
8
|
exports.LiquidationsService = require_sdk_accounts_liquidations_LiquidationsService.LiquidationsService;
|
|
@@ -44,6 +44,7 @@ exports.AP_ZAPPER_REGISTER = require_sdk_constants_address_provider.AP_ZAPPER_RE
|
|
|
44
44
|
exports.AP_ZERO_PRICE_FEED = require_sdk_constants_address_provider.AP_ZERO_PRICE_FEED;
|
|
45
45
|
exports.BLOCKS_PER_WEEK_BY_NETWORK = require_sdk_constants_networks.BLOCKS_PER_WEEK_BY_NETWORK;
|
|
46
46
|
exports.BotPermissions = require_sdk_constants_bot_permissions.BotPermissions;
|
|
47
|
+
exports.DUST_THRESHOLD = require_sdk_constants_math.DUST_THRESHOLD;
|
|
47
48
|
exports.LEVERAGE_DECIMALS = require_sdk_constants_math.LEVERAGE_DECIMALS;
|
|
48
49
|
exports.MAX_INT = require_sdk_constants_math.MAX_INT;
|
|
49
50
|
exports.MAX_UINT16 = require_sdk_constants_math.MAX_UINT16;
|
|
@@ -17,7 +17,12 @@ const PERCENTAGE_FACTOR = 10000n;
|
|
|
17
17
|
const PERCENTAGE_FACTOR_1KK = PERCENTAGE_FACTOR * PERCENTAGE_DECIMALS;
|
|
18
18
|
const LEVERAGE_DECIMALS = 100n;
|
|
19
19
|
const SLIPPAGE_DECIMALS = 100n;
|
|
20
|
+
/**
|
|
21
|
+
* Token balances at or below this threshold are treated as dust and ignored.
|
|
22
|
+
**/
|
|
23
|
+
const DUST_THRESHOLD = 10n;
|
|
20
24
|
//#endregion
|
|
25
|
+
exports.DUST_THRESHOLD = DUST_THRESHOLD;
|
|
21
26
|
exports.LEVERAGE_DECIMALS = LEVERAGE_DECIMALS;
|
|
22
27
|
exports.MAX_INT = MAX_INT;
|
|
23
28
|
exports.MAX_UINT16 = MAX_UINT16;
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -50,6 +50,7 @@ const require_sdk_market_credit_CreditFacadeV310BaseContract = require("./market
|
|
|
50
50
|
const require_sdk_market_credit_CreditFacadeV310Contract = require("./market/credit/CreditFacadeV310Contract.js");
|
|
51
51
|
const require_sdk_market_math = require("./market/math.js");
|
|
52
52
|
const require_sdk_market_credit_CreditManagerV310Contract = require("./market/credit/CreditManagerV310Contract.js");
|
|
53
|
+
const require_sdk_market_credit_dominantCollateral = require("./market/credit/dominantCollateral.js");
|
|
53
54
|
const require_sdk_market_credit_CreditSuite = require("./market/credit/CreditSuite.js");
|
|
54
55
|
const require_sdk_utils_viem_simulateMulticall = require("./utils/viem/simulateMulticall.js");
|
|
55
56
|
const require_sdk_utils_viem_simulateWithPriceUpdates = require("./utils/viem/simulateWithPriceUpdates.js");
|
|
@@ -103,8 +104,8 @@ const require_sdk_market_rwa_securitize_SecuritizeRWAFactory = require("./market
|
|
|
103
104
|
const require_sdk_market_rwa_RWARegistry = require("./market/rwa/RWARegistry.js");
|
|
104
105
|
const require_sdk_market_rwa_types = require("./market/rwa/types.js");
|
|
105
106
|
require("./market/index.js");
|
|
106
|
-
const
|
|
107
|
-
const
|
|
107
|
+
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract = require("./accounts/credit-account-compressor/CreditAccountCompressorV310Contract.js");
|
|
108
|
+
const require_sdk_accounts_credit_account_compressor_CreditAccountCompressor = require("./accounts/credit-account-compressor/CreditAccountCompressor.js");
|
|
108
109
|
const require_sdk_accounts_CreditAccountsServiceV310 = require("./accounts/CreditAccountsServiceV310.js");
|
|
109
110
|
const require_sdk_accounts_intents_operations_claim_delayed_index = require("./accounts/intents/operations/claim-delayed/index.js");
|
|
110
111
|
const require_sdk_accounts_intents_index = require("./accounts/intents/index.js");
|
|
@@ -201,6 +202,8 @@ exports.ChainNotConfiguredError = require_sdk_core_errors.ChainNotConfiguredErro
|
|
|
201
202
|
exports.CompositePriceFeedContract = require_sdk_market_pricefeeds_CompositePriceFeed.CompositePriceFeedContract;
|
|
202
203
|
exports.Construct = require_sdk_base_Construct.Construct;
|
|
203
204
|
exports.ContractParseError = require_sdk_base_BaseContract.ContractParseError;
|
|
205
|
+
exports.CreditAccountCompressor = require_sdk_accounts_credit_account_compressor_CreditAccountCompressor.CreditAccountCompressor;
|
|
206
|
+
exports.CreditAccountCompressorV310Contract = require_sdk_accounts_credit_account_compressor_CreditAccountCompressorV310Contract.CreditAccountCompressorV310Contract;
|
|
204
207
|
exports.CreditAccountOperationsService = require_sdk_accounts_intents_index.CreditAccountOperationsService;
|
|
205
208
|
exports.CreditAccountsServiceV310 = require_sdk_accounts_CreditAccountsServiceV310.CreditAccountsServiceV310;
|
|
206
209
|
exports.CreditConfiguratorV310Contract = require_sdk_market_credit_CreditConfiguratorV310Contract.CreditConfiguratorV310Contract;
|
|
@@ -213,7 +216,7 @@ exports.CurveStablePriceFeedContract = require_sdk_market_pricefeeds_CurveStable
|
|
|
213
216
|
exports.CurveUSDPriceFeedContract = require_sdk_market_pricefeeds_CurveUSDPriceFeed.CurveUSDPriceFeedContract;
|
|
214
217
|
exports.DELAYED_INTENT_TYPES = require_sdk_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_TYPES;
|
|
215
218
|
exports.DELAYED_INTENT_VERSION = require_sdk_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_VERSION;
|
|
216
|
-
exports.DUST_THRESHOLD =
|
|
219
|
+
exports.DUST_THRESHOLD = require_sdk_constants_math.DUST_THRESHOLD;
|
|
217
220
|
exports.Erc4626PriceFeedContract = require_sdk_market_pricefeeds_Erc4626PriceFeed.Erc4626PriceFeedContract;
|
|
218
221
|
exports.ExternalPriceFeedContract = require_sdk_market_pricefeeds_ExternalPriceFeed.ExternalPriceFeedContract;
|
|
219
222
|
exports.GaugeContract = require_sdk_market_pool_GaugeContract.GaugeContract;
|
|
@@ -246,6 +249,7 @@ exports.NO_VERSION = require_sdk_constants_address_provider.NO_VERSION;
|
|
|
246
249
|
exports.NetworkType = require_sdk_chain_chains.NetworkType;
|
|
247
250
|
exports.OnchainSDK = require_sdk_OnchainSDK.OnchainSDK;
|
|
248
251
|
exports.OpportunitiesService = require_sdk_opportunities_OpportunitiesService.OpportunitiesService;
|
|
252
|
+
exports.PARTIAL_LIQUIDATION_BUFFER_BPS = require_sdk_market_math.PARTIAL_LIQUIDATION_BUFFER_BPS;
|
|
249
253
|
exports.PERCENTAGE_DECIMALS = require_sdk_constants_math.PERCENTAGE_DECIMALS;
|
|
250
254
|
exports.PERCENTAGE_FACTOR = require_sdk_constants_math.PERCENTAGE_FACTOR;
|
|
251
255
|
exports.PERCENTAGE_FACTOR_1KK = require_sdk_constants_math.PERCENTAGE_FACTOR_1KK;
|
|
@@ -333,7 +337,7 @@ exports.createZapper = require_sdk_market_zapper_createZapper.createZapper;
|
|
|
333
337
|
exports.creditFacadeV310Abi = require_sdk_market_credit_CreditFacadeV310BaseContract.creditFacadeV310Abi;
|
|
334
338
|
exports.decodeDelayedIntent = require_sdk_accounts_withdrawal_compressor_intent_codec.decodeDelayedIntent;
|
|
335
339
|
exports.detectNetwork = require_sdk_chain_detectNetwork.detectNetwork;
|
|
336
|
-
exports.dominantCollateral =
|
|
340
|
+
exports.dominantCollateral = require_sdk_market_credit_dominantCollateral.dominantCollateral;
|
|
337
341
|
exports.encodeDelayedIntent = require_sdk_accounts_withdrawal_compressor_intent_codec.encodeDelayedIntent;
|
|
338
342
|
exports.estimateRawTxGas = require_sdk_utils_viem_sendRawTx.estimateRawTxGas;
|
|
339
343
|
exports.etherscanApiUrl = require_sdk_utils_etherscan.etherscanApiUrl;
|
|
@@ -383,8 +387,12 @@ exports.isVersionRange = require_sdk_constants_versions.isVersionRange;
|
|
|
383
387
|
exports.json_parse = require_sdk_utils_json.json_parse;
|
|
384
388
|
exports.json_stringify = require_sdk_utils_json.json_stringify;
|
|
385
389
|
exports.maxLeverage = require_sdk_market_math.maxLeverage;
|
|
390
|
+
exports.minSeizedAmount = require_sdk_market_math.minSeizedAmount;
|
|
391
|
+
exports.mustGetDominantCollateral = require_sdk_market_credit_dominantCollateral.mustGetDominantCollateral;
|
|
386
392
|
exports.numberWithCommas = require_sdk_utils_formatter.numberWithCommas;
|
|
387
393
|
exports.onchainSDKOptionsSchema = require_sdk_options.onchainSDKOptionsSchema;
|
|
394
|
+
exports.optimalHFForPartialLiquidation = require_sdk_market_math.optimalHFForPartialLiquidation;
|
|
395
|
+
exports.optimalRepaidAmount = require_sdk_market_math.optimalRepaidAmount;
|
|
388
396
|
exports.percentFmt = require_sdk_utils_formatter.percentFmt;
|
|
389
397
|
exports.positionLeverage = require_sdk_market_math.positionLeverage;
|
|
390
398
|
exports.primaryInstantOutput = require_sdk_accounts_intents_operations_claim_delayed_index.primaryInstantOutput;
|