@gearbox-protocol/sdk 3.0.0-vfour.13 → 3.0.0-vfour.14
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/sdk/index.cjs +54 -42
- package/dist/cjs/sdk/index.d.ts +22 -3
- package/dist/esm/sdk/index.d.mts +22 -3
- package/dist/esm/sdk/index.mjs +54 -42
- package/package.json +1 -1
package/dist/cjs/sdk/index.cjs
CHANGED
|
@@ -13305,19 +13305,12 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
13305
13305
|
*/
|
|
13306
13306
|
async fullyLiquidate(account, to, slippage = 50n) {
|
|
13307
13307
|
const cm = this.sdk.marketRegister.findCreditManager(account.creditManager);
|
|
13308
|
-
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13309
|
-
account.creditManager
|
|
13310
|
-
);
|
|
13311
13308
|
const preview = await this.sdk.router.findBestClosePath(
|
|
13312
13309
|
account,
|
|
13313
13310
|
cm.creditManager,
|
|
13314
13311
|
slippage
|
|
13315
13312
|
);
|
|
13316
|
-
const priceUpdates = await this
|
|
13317
|
-
const priceUpdateCalls = market.priceOracle.onDemandPriceUpdates(
|
|
13318
|
-
cm.creditFacade.address,
|
|
13319
|
-
priceUpdates
|
|
13320
|
-
);
|
|
13313
|
+
const priceUpdates = await this.getPriceUpdatesForFacade(account);
|
|
13321
13314
|
const recipient = to ?? this.sdk.provider.account;
|
|
13322
13315
|
if (!recipient) {
|
|
13323
13316
|
throw new Error("liquidate account: assets recipient not specied");
|
|
@@ -13327,7 +13320,7 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
13327
13320
|
args: [
|
|
13328
13321
|
account.creditAccount,
|
|
13329
13322
|
recipient,
|
|
13330
|
-
[...
|
|
13323
|
+
[...priceUpdates, ...preview.calls]
|
|
13331
13324
|
]
|
|
13332
13325
|
});
|
|
13333
13326
|
}
|
|
@@ -13398,26 +13391,24 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
13398
13391
|
* @param accounts
|
|
13399
13392
|
* @returns
|
|
13400
13393
|
*/
|
|
13401
|
-
async #
|
|
13394
|
+
async #getUpdateForAccount(acc, blockNumber) {
|
|
13402
13395
|
const tokensByPool = /* @__PURE__ */ new Map();
|
|
13403
13396
|
const oracleByPool = /* @__PURE__ */ new Map();
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
tokensByPool.set(pool, tokens);
|
|
13415
|
-
}
|
|
13397
|
+
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13398
|
+
acc.creditManager
|
|
13399
|
+
);
|
|
13400
|
+
const pool = market.state.pool.pool.address;
|
|
13401
|
+
oracleByPool.set(pool, market.priceOracle);
|
|
13402
|
+
for (const t of acc.tokens) {
|
|
13403
|
+
if (t.balance > 10n) {
|
|
13404
|
+
const tokens = tokensByPool.get(pool) ?? /* @__PURE__ */ new Set();
|
|
13405
|
+
tokens.add(t.token);
|
|
13406
|
+
tokensByPool.set(pool, tokens);
|
|
13416
13407
|
}
|
|
13417
13408
|
}
|
|
13418
13409
|
const priceFeeds = [];
|
|
13419
|
-
for (const [
|
|
13420
|
-
const tokens = Array.from(tokensByPool.get(
|
|
13410
|
+
for (const [pool2, priceFeedFactory] of oracleByPool.entries()) {
|
|
13411
|
+
const tokens = Array.from(tokensByPool.get(pool2) ?? []);
|
|
13421
13412
|
priceFeeds.push(...priceFeedFactory.priceFeedsForTokens(tokens));
|
|
13422
13413
|
}
|
|
13423
13414
|
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
|
|
@@ -13425,22 +13416,46 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
13425
13416
|
blockNumber
|
|
13426
13417
|
);
|
|
13427
13418
|
}
|
|
13428
|
-
|
|
13419
|
+
/**
|
|
13420
|
+
* Returns account price updates in a non-encoded format
|
|
13421
|
+
* @param acc
|
|
13422
|
+
* @param blockNumber
|
|
13423
|
+
* @returns
|
|
13424
|
+
*/
|
|
13425
|
+
async getOnDemandPriceUpdates(acc, blockNumber) {
|
|
13429
13426
|
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13430
|
-
|
|
13427
|
+
acc.creditManager
|
|
13431
13428
|
);
|
|
13429
|
+
const update = await this.#getUpdateForAccount(acc, blockNumber);
|
|
13430
|
+
return market.priceOracle.onDemandPriceUpdates(update);
|
|
13431
|
+
}
|
|
13432
|
+
/**
|
|
13433
|
+
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...)
|
|
13434
|
+
* @param acc
|
|
13435
|
+
* @param blockNumber
|
|
13436
|
+
* @returns
|
|
13437
|
+
*/
|
|
13438
|
+
async getPriceUpdatesForFacade(acc, blockNumber) {
|
|
13439
|
+
const cm = this.sdk.marketRegister.findCreditManager(acc.creditManager);
|
|
13440
|
+
const updates = await this.getOnDemandPriceUpdates(acc, blockNumber);
|
|
13441
|
+
return updates.map(({ token, reserve, data }) => ({
|
|
13442
|
+
target: cm.creditFacade.address,
|
|
13443
|
+
callData: viem.encodeFunctionData({
|
|
13444
|
+
abi: iCreditFacadeV3MulticallAbi,
|
|
13445
|
+
functionName: "onDemandPriceUpdate",
|
|
13446
|
+
args: [token, reserve, data]
|
|
13447
|
+
})
|
|
13448
|
+
}));
|
|
13449
|
+
}
|
|
13450
|
+
async #prepareCloseCreditAccount(ca, cm, assetsToKeep, to, slippage = 50n) {
|
|
13432
13451
|
const closePath = await this.sdk.router.findBestClosePath(
|
|
13433
13452
|
ca,
|
|
13434
13453
|
cm.creditManager,
|
|
13435
13454
|
slippage
|
|
13436
13455
|
);
|
|
13437
|
-
const priceUpdates = await this
|
|
13438
|
-
const priceUpdateCalls = market.priceOracle.onDemandPriceUpdates(
|
|
13439
|
-
cm.creditFacade.address,
|
|
13440
|
-
priceUpdates
|
|
13441
|
-
);
|
|
13456
|
+
const priceUpdates = await this.getPriceUpdatesForFacade(ca);
|
|
13442
13457
|
return [
|
|
13443
|
-
...
|
|
13458
|
+
...priceUpdates,
|
|
13444
13459
|
...closePath.calls,
|
|
13445
13460
|
...this.#prepareDisableQuotas(ca),
|
|
13446
13461
|
...this.#prepareDecreaseDebt(ca),
|
|
@@ -14997,15 +15012,15 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
14997
15012
|
/**
|
|
14998
15013
|
* Converts previously obtained price updates into CreditFacade multicall entries
|
|
14999
15014
|
* @param creditFacade
|
|
15000
|
-
* @param
|
|
15015
|
+
* @param updates
|
|
15001
15016
|
* @returns
|
|
15002
15017
|
*/
|
|
15003
|
-
onDemandPriceUpdates(
|
|
15018
|
+
onDemandPriceUpdates(updates) {
|
|
15004
15019
|
const result = [];
|
|
15005
|
-
if (!
|
|
15020
|
+
if (!updates) {
|
|
15006
15021
|
return result;
|
|
15007
15022
|
}
|
|
15008
|
-
const { txs } =
|
|
15023
|
+
const { txs } = updates;
|
|
15009
15024
|
for (const tx of txs) {
|
|
15010
15025
|
const { to: priceFeed, callData } = tx;
|
|
15011
15026
|
const [token, reserve] = this.#findTokenForPriceFeed(priceFeed);
|
|
@@ -15015,12 +15030,9 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
15015
15030
|
});
|
|
15016
15031
|
const data = args[0];
|
|
15017
15032
|
result.push({
|
|
15018
|
-
|
|
15019
|
-
|
|
15020
|
-
|
|
15021
|
-
functionName: "onDemandPriceUpdate",
|
|
15022
|
-
args: [token, reserve, data]
|
|
15023
|
-
})
|
|
15033
|
+
token,
|
|
15034
|
+
reserve,
|
|
15035
|
+
data
|
|
15024
15036
|
});
|
|
15025
15037
|
}
|
|
15026
15038
|
return result;
|
package/dist/cjs/sdk/index.d.ts
CHANGED
|
@@ -16830,6 +16830,11 @@ interface PriceFeedsForTokensOptions {
|
|
|
16830
16830
|
main?: boolean;
|
|
16831
16831
|
reserve?: boolean;
|
|
16832
16832
|
}
|
|
16833
|
+
interface OnDemandPriceUpdate {
|
|
16834
|
+
token: Address;
|
|
16835
|
+
reserve: boolean;
|
|
16836
|
+
data: Hex;
|
|
16837
|
+
}
|
|
16833
16838
|
declare class PriceOracleContract extends BaseContract<abi$1> {
|
|
16834
16839
|
#private;
|
|
16835
16840
|
/**
|
|
@@ -16868,10 +16873,10 @@ declare class PriceOracleContract extends BaseContract<abi$1> {
|
|
|
16868
16873
|
/**
|
|
16869
16874
|
* Converts previously obtained price updates into CreditFacade multicall entries
|
|
16870
16875
|
* @param creditFacade
|
|
16871
|
-
* @param
|
|
16876
|
+
* @param updates
|
|
16872
16877
|
* @returns
|
|
16873
16878
|
*/
|
|
16874
|
-
onDemandPriceUpdates(
|
|
16879
|
+
onDemandPriceUpdates(updates?: UpdatePriceFeedsResult): OnDemandPriceUpdate[];
|
|
16875
16880
|
/**
|
|
16876
16881
|
* Tries to convert amount of token into underlying of current market
|
|
16877
16882
|
* @param token
|
|
@@ -17214,6 +17219,20 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
17214
17219
|
* @returns
|
|
17215
17220
|
*/
|
|
17216
17221
|
closeCreditAccount(operation: "close" | "zeroDebt", ca: CreditAccountData, assetsToKeep: Address[], to?: Address, slippage?: bigint): Promise<RawTx>;
|
|
17222
|
+
/**
|
|
17223
|
+
* Returns account price updates in a non-encoded format
|
|
17224
|
+
* @param acc
|
|
17225
|
+
* @param blockNumber
|
|
17226
|
+
* @returns
|
|
17227
|
+
*/
|
|
17228
|
+
getOnDemandPriceUpdates(acc: CreditAccountData, blockNumber?: bigint): Promise<OnDemandPriceUpdate[]>;
|
|
17229
|
+
/**
|
|
17230
|
+
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...)
|
|
17231
|
+
* @param acc
|
|
17232
|
+
* @param blockNumber
|
|
17233
|
+
* @returns
|
|
17234
|
+
*/
|
|
17235
|
+
getPriceUpdatesForFacade(acc: CreditAccountData, blockNumber?: bigint): Promise<MultiCall[]>;
|
|
17217
17236
|
/**
|
|
17218
17237
|
* Returns addresses of pools of attached markets
|
|
17219
17238
|
*/
|
|
@@ -17369,4 +17388,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
|
|
|
17369
17388
|
*/
|
|
17370
17389
|
declare function simulateMulticall<const contracts extends readonly unknown[], chain extends Chain | undefined, allowFailure extends boolean = true>(client: Client<Transport, chain>, parameters: MulticallParameters<contracts, allowFailure>): Promise<MulticallReturnType<contracts, allowFailure>>;
|
|
17371
17390
|
|
|
17372
|
-
export { type ACLState, type ACLStateHuman, ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AccountFactoryStateHuman, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3State, type AddressProviderV3StateHuman, type AnvilActions, type AnvilClient, type AnvilClientConfig, type Asset, type AssetPriceFeedState, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractState, type BaseContractStateHuman, type BasePriceFeedState, type BasePriceFeedStateHuman, BotListContract, type BotListState, type BotListStateHuman, BotPermissions, type BoundedOracleState, type BoundedOracleStateHuman, BoundedPriceFeedContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ContractMethod, type ContractsRegisterState, type ContractsRegisterStateHuman, type ControllerTimelockV3State, type ControllerTimelockV3StateHuman, type CoreState, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditFacadeContract, type CreditFacadeState, type CreditFacadeStateHuman, CreditFactory, type CreditFactoryState, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerDebtParamsStruct, type CreditManagerState, type CreditManagerStateHuman, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, type DataCompressorV3State, type DegenDistributorState, type DegenDistributorStateHuman, type DegenNFT2State, type DegenNFT2StateHuman, Erc4626PriceFeedContract, type EtherscanURLParam, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeState, type GaugeStateHuman, GearStakingContract, type GearStakingV3State, type GearStakingV3StateHuman, GearboxSDK, type GearboxState, type GearboxStateHuman, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelState, type LinearModelStateHuman, type LogFn, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketState, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MultiPauseState, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkType, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, type PeripheryState, type PeripheryStateHuman, type PolicyStruct, type PolicyStructHuman, PoolContract, type PoolData, PoolFactory, type PoolFactoryState, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperState, type PoolQuotaKeeperStateHuman, type PoolState, type PoolStateHuman, type PriceFactoryStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedState, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleState, type PriceOracleV3State, type PriceOracleV3StateHuman, Provider, type ProviderOptions, type QuotaParams, type QuotaParamsHuman, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, type ReadContractOptions, RedstonePriceFeedContract, type RedstonePriceFeedState, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterComponentRegisterHuman, type RouterResult, type RouterState, type RouterStateHuman, RouterV3Contract, type RouterV3ContractState, type RouterV3ContractStateHuman, type SDKAttachOptions, SDKConstruct, type SDKEventsMap, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, TIMELOCK, type TVL, type TokenMetaData, type TokenTypeToResolverHuman, USDC, type UpdatePriceFeedsResult, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, YearnPriceFeedContract, type ZapperInfo, type ZapperInfoHuman, type ZapperRegisterState, type ZapperRegisterStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, convertBaseContractState, convertCoreStateToHuman, convertCreditFactoryStateToHuman, convertGaugeStateToHuman, convertGearboxStateToHuman, convertGearboxStateToHumanLA, convertLinearModelStateToHuman, convertPeripheryStateToHuman, convertPoolFactoryStateToHuman, convertPoolQuotaKeeperStateToHuman, convertPoolStateToHuman, convertPriceFeedStateToHuman, convertPriceOracleStateToHuman, convertRouterStateToHuman, convertRouterV3StateToHuman, convertZapperRegisterStateToHuman, createAnvilClient, createRawTx, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, isAnvil, json_parse, json_stringify, numberWithCommas, percentFmt, simulateMulticall, toHumanFormat };
|
|
17391
|
+
export { type ACLState, type ACLStateHuman, ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AccountFactoryStateHuman, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3State, type AddressProviderV3StateHuman, type AnvilActions, type AnvilClient, type AnvilClientConfig, type Asset, type AssetPriceFeedState, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractState, type BaseContractStateHuman, type BasePriceFeedState, type BasePriceFeedStateHuman, BotListContract, type BotListState, type BotListStateHuman, BotPermissions, type BoundedOracleState, type BoundedOracleStateHuman, BoundedPriceFeedContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ContractMethod, type ContractsRegisterState, type ContractsRegisterStateHuman, type ControllerTimelockV3State, type ControllerTimelockV3StateHuman, type CoreState, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditFacadeContract, type CreditFacadeState, type CreditFacadeStateHuman, CreditFactory, type CreditFactoryState, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerDebtParamsStruct, type CreditManagerState, type CreditManagerStateHuman, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, type DataCompressorV3State, type DegenDistributorState, type DegenDistributorStateHuman, type DegenNFT2State, type DegenNFT2StateHuman, Erc4626PriceFeedContract, type EtherscanURLParam, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeState, type GaugeStateHuman, GearStakingContract, type GearStakingV3State, type GearStakingV3StateHuman, GearboxSDK, type GearboxState, type GearboxStateHuman, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelState, type LinearModelStateHuman, type LogFn, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketState, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MultiPauseState, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, type PeripheryState, type PeripheryStateHuman, type PolicyStruct, type PolicyStructHuman, PoolContract, type PoolData, PoolFactory, type PoolFactoryState, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperState, type PoolQuotaKeeperStateHuman, type PoolState, type PoolStateHuman, type PriceFactoryStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedState, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleState, type PriceOracleV3State, type PriceOracleV3StateHuman, Provider, type ProviderOptions, type QuotaParams, type QuotaParamsHuman, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, type ReadContractOptions, RedstonePriceFeedContract, type RedstonePriceFeedState, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterComponentRegisterHuman, type RouterResult, type RouterState, type RouterStateHuman, RouterV3Contract, type RouterV3ContractState, type RouterV3ContractStateHuman, type SDKAttachOptions, SDKConstruct, type SDKEventsMap, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, TIMELOCK, type TVL, type TokenMetaData, type TokenTypeToResolverHuman, USDC, type UpdatePriceFeedsResult, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, YearnPriceFeedContract, type ZapperInfo, type ZapperInfoHuman, type ZapperRegisterState, type ZapperRegisterStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, convertBaseContractState, convertCoreStateToHuman, convertCreditFactoryStateToHuman, convertGaugeStateToHuman, convertGearboxStateToHuman, convertGearboxStateToHumanLA, convertLinearModelStateToHuman, convertPeripheryStateToHuman, convertPoolFactoryStateToHuman, convertPoolQuotaKeeperStateToHuman, convertPoolStateToHuman, convertPriceFeedStateToHuman, convertPriceOracleStateToHuman, convertRouterStateToHuman, convertRouterV3StateToHuman, convertZapperRegisterStateToHuman, createAnvilClient, createRawTx, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, isAnvil, json_parse, json_stringify, numberWithCommas, percentFmt, simulateMulticall, toHumanFormat };
|
package/dist/esm/sdk/index.d.mts
CHANGED
|
@@ -16830,6 +16830,11 @@ interface PriceFeedsForTokensOptions {
|
|
|
16830
16830
|
main?: boolean;
|
|
16831
16831
|
reserve?: boolean;
|
|
16832
16832
|
}
|
|
16833
|
+
interface OnDemandPriceUpdate {
|
|
16834
|
+
token: Address;
|
|
16835
|
+
reserve: boolean;
|
|
16836
|
+
data: Hex;
|
|
16837
|
+
}
|
|
16833
16838
|
declare class PriceOracleContract extends BaseContract<abi$1> {
|
|
16834
16839
|
#private;
|
|
16835
16840
|
/**
|
|
@@ -16868,10 +16873,10 @@ declare class PriceOracleContract extends BaseContract<abi$1> {
|
|
|
16868
16873
|
/**
|
|
16869
16874
|
* Converts previously obtained price updates into CreditFacade multicall entries
|
|
16870
16875
|
* @param creditFacade
|
|
16871
|
-
* @param
|
|
16876
|
+
* @param updates
|
|
16872
16877
|
* @returns
|
|
16873
16878
|
*/
|
|
16874
|
-
onDemandPriceUpdates(
|
|
16879
|
+
onDemandPriceUpdates(updates?: UpdatePriceFeedsResult): OnDemandPriceUpdate[];
|
|
16875
16880
|
/**
|
|
16876
16881
|
* Tries to convert amount of token into underlying of current market
|
|
16877
16882
|
* @param token
|
|
@@ -17214,6 +17219,20 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
17214
17219
|
* @returns
|
|
17215
17220
|
*/
|
|
17216
17221
|
closeCreditAccount(operation: "close" | "zeroDebt", ca: CreditAccountData, assetsToKeep: Address[], to?: Address, slippage?: bigint): Promise<RawTx>;
|
|
17222
|
+
/**
|
|
17223
|
+
* Returns account price updates in a non-encoded format
|
|
17224
|
+
* @param acc
|
|
17225
|
+
* @param blockNumber
|
|
17226
|
+
* @returns
|
|
17227
|
+
*/
|
|
17228
|
+
getOnDemandPriceUpdates(acc: CreditAccountData, blockNumber?: bigint): Promise<OnDemandPriceUpdate[]>;
|
|
17229
|
+
/**
|
|
17230
|
+
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...)
|
|
17231
|
+
* @param acc
|
|
17232
|
+
* @param blockNumber
|
|
17233
|
+
* @returns
|
|
17234
|
+
*/
|
|
17235
|
+
getPriceUpdatesForFacade(acc: CreditAccountData, blockNumber?: bigint): Promise<MultiCall[]>;
|
|
17217
17236
|
/**
|
|
17218
17237
|
* Returns addresses of pools of attached markets
|
|
17219
17238
|
*/
|
|
@@ -17369,4 +17388,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
|
|
|
17369
17388
|
*/
|
|
17370
17389
|
declare function simulateMulticall<const contracts extends readonly unknown[], chain extends Chain | undefined, allowFailure extends boolean = true>(client: Client<Transport, chain>, parameters: MulticallParameters<contracts, allowFailure>): Promise<MulticallReturnType<contracts, allowFailure>>;
|
|
17371
17390
|
|
|
17372
|
-
export { type ACLState, type ACLStateHuman, ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AccountFactoryStateHuman, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3State, type AddressProviderV3StateHuman, type AnvilActions, type AnvilClient, type AnvilClientConfig, type Asset, type AssetPriceFeedState, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractState, type BaseContractStateHuman, type BasePriceFeedState, type BasePriceFeedStateHuman, BotListContract, type BotListState, type BotListStateHuman, BotPermissions, type BoundedOracleState, type BoundedOracleStateHuman, BoundedPriceFeedContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ContractMethod, type ContractsRegisterState, type ContractsRegisterStateHuman, type ControllerTimelockV3State, type ControllerTimelockV3StateHuman, type CoreState, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditFacadeContract, type CreditFacadeState, type CreditFacadeStateHuman, CreditFactory, type CreditFactoryState, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerDebtParamsStruct, type CreditManagerState, type CreditManagerStateHuman, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, type DataCompressorV3State, type DegenDistributorState, type DegenDistributorStateHuman, type DegenNFT2State, type DegenNFT2StateHuman, Erc4626PriceFeedContract, type EtherscanURLParam, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeState, type GaugeStateHuman, GearStakingContract, type GearStakingV3State, type GearStakingV3StateHuman, GearboxSDK, type GearboxState, type GearboxStateHuman, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelState, type LinearModelStateHuman, type LogFn, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketState, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MultiPauseState, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkType, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, type PeripheryState, type PeripheryStateHuman, type PolicyStruct, type PolicyStructHuman, PoolContract, type PoolData, PoolFactory, type PoolFactoryState, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperState, type PoolQuotaKeeperStateHuman, type PoolState, type PoolStateHuman, type PriceFactoryStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedState, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleState, type PriceOracleV3State, type PriceOracleV3StateHuman, Provider, type ProviderOptions, type QuotaParams, type QuotaParamsHuman, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, type ReadContractOptions, RedstonePriceFeedContract, type RedstonePriceFeedState, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterComponentRegisterHuman, type RouterResult, type RouterState, type RouterStateHuman, RouterV3Contract, type RouterV3ContractState, type RouterV3ContractStateHuman, type SDKAttachOptions, SDKConstruct, type SDKEventsMap, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, TIMELOCK, type TVL, type TokenMetaData, type TokenTypeToResolverHuman, USDC, type UpdatePriceFeedsResult, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, YearnPriceFeedContract, type ZapperInfo, type ZapperInfoHuman, type ZapperRegisterState, type ZapperRegisterStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, convertBaseContractState, convertCoreStateToHuman, convertCreditFactoryStateToHuman, convertGaugeStateToHuman, convertGearboxStateToHuman, convertGearboxStateToHumanLA, convertLinearModelStateToHuman, convertPeripheryStateToHuman, convertPoolFactoryStateToHuman, convertPoolQuotaKeeperStateToHuman, convertPoolStateToHuman, convertPriceFeedStateToHuman, convertPriceOracleStateToHuman, convertRouterStateToHuman, convertRouterV3StateToHuman, convertZapperRegisterStateToHuman, createAnvilClient, createRawTx, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, isAnvil, json_parse, json_stringify, numberWithCommas, percentFmt, simulateMulticall, toHumanFormat };
|
|
17391
|
+
export { type ACLState, type ACLStateHuman, ADDRESS_0X0, ADDRESS_PROVIDER, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DEGEN_DISTRIBUTOR, AP_DEGEN_NFT, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AccountFactoryStateHuman, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3State, type AddressProviderV3StateHuman, type AnvilActions, type AnvilClient, type AnvilClientConfig, type Asset, type AssetPriceFeedState, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractState, type BaseContractStateHuman, type BasePriceFeedState, type BasePriceFeedStateHuman, BotListContract, type BotListState, type BotListStateHuman, BotPermissions, type BoundedOracleState, type BoundedOracleStateHuman, BoundedPriceFeedContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ContractMethod, type ContractsRegisterState, type ContractsRegisterStateHuman, type ControllerTimelockV3State, type ControllerTimelockV3StateHuman, type CoreState, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditFacadeContract, type CreditFacadeState, type CreditFacadeStateHuman, CreditFactory, type CreditFactoryState, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerDebtParamsStruct, type CreditManagerState, type CreditManagerStateHuman, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, type DataCompressorV3State, type DegenDistributorState, type DegenDistributorStateHuman, type DegenNFT2State, type DegenNFT2StateHuman, Erc4626PriceFeedContract, type EtherscanURLParam, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeState, type GaugeStateHuman, GearStakingContract, type GearStakingV3State, type GearStakingV3StateHuman, GearboxSDK, type GearboxState, type GearboxStateHuman, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelState, type LinearModelStateHuman, type LogFn, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketState, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MultiPauseState, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PathOption, type PathOptionSerie, type PeripheryState, type PeripheryStateHuman, type PolicyStruct, type PolicyStructHuman, PoolContract, type PoolData, PoolFactory, type PoolFactoryState, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperState, type PoolQuotaKeeperStateHuman, type PoolState, type PoolStateHuman, type PriceFactoryStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedState, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleState, type PriceOracleV3State, type PriceOracleV3StateHuman, Provider, type ProviderOptions, type QuotaParams, type QuotaParamsHuman, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, type ReadContractOptions, RedstonePriceFeedContract, type RedstonePriceFeedState, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterComponentRegisterHuman, type RouterResult, type RouterState, type RouterStateHuman, RouterV3Contract, type RouterV3ContractState, type RouterV3ContractStateHuman, type SDKAttachOptions, SDKConstruct, type SDKEventsMap, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, TIMELOCK, type TVL, type TokenMetaData, type TokenTypeToResolverHuman, USDC, type UpdatePriceFeedsResult, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, YearnPriceFeedContract, type ZapperInfo, type ZapperInfoHuman, type ZapperRegisterState, type ZapperRegisterStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, convertBaseContractState, convertCoreStateToHuman, convertCreditFactoryStateToHuman, convertGaugeStateToHuman, convertGearboxStateToHuman, convertGearboxStateToHumanLA, convertLinearModelStateToHuman, convertPeripheryStateToHuman, convertPoolFactoryStateToHuman, convertPoolQuotaKeeperStateToHuman, convertPoolStateToHuman, convertPriceFeedStateToHuman, convertPriceOracleStateToHuman, convertRouterStateToHuman, convertRouterV3StateToHuman, convertZapperRegisterStateToHuman, createAnvilClient, createRawTx, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, isAnvil, json_parse, json_stringify, numberWithCommas, percentFmt, simulateMulticall, toHumanFormat };
|
package/dist/esm/sdk/index.mjs
CHANGED
|
@@ -13303,19 +13303,12 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
13303
13303
|
*/
|
|
13304
13304
|
async fullyLiquidate(account, to, slippage = 50n) {
|
|
13305
13305
|
const cm = this.sdk.marketRegister.findCreditManager(account.creditManager);
|
|
13306
|
-
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13307
|
-
account.creditManager
|
|
13308
|
-
);
|
|
13309
13306
|
const preview = await this.sdk.router.findBestClosePath(
|
|
13310
13307
|
account,
|
|
13311
13308
|
cm.creditManager,
|
|
13312
13309
|
slippage
|
|
13313
13310
|
);
|
|
13314
|
-
const priceUpdates = await this
|
|
13315
|
-
const priceUpdateCalls = market.priceOracle.onDemandPriceUpdates(
|
|
13316
|
-
cm.creditFacade.address,
|
|
13317
|
-
priceUpdates
|
|
13318
|
-
);
|
|
13311
|
+
const priceUpdates = await this.getPriceUpdatesForFacade(account);
|
|
13319
13312
|
const recipient = to ?? this.sdk.provider.account;
|
|
13320
13313
|
if (!recipient) {
|
|
13321
13314
|
throw new Error("liquidate account: assets recipient not specied");
|
|
@@ -13325,7 +13318,7 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
13325
13318
|
args: [
|
|
13326
13319
|
account.creditAccount,
|
|
13327
13320
|
recipient,
|
|
13328
|
-
[...
|
|
13321
|
+
[...priceUpdates, ...preview.calls]
|
|
13329
13322
|
]
|
|
13330
13323
|
});
|
|
13331
13324
|
}
|
|
@@ -13396,26 +13389,24 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
13396
13389
|
* @param accounts
|
|
13397
13390
|
* @returns
|
|
13398
13391
|
*/
|
|
13399
|
-
async #
|
|
13392
|
+
async #getUpdateForAccount(acc, blockNumber) {
|
|
13400
13393
|
const tokensByPool = /* @__PURE__ */ new Map();
|
|
13401
13394
|
const oracleByPool = /* @__PURE__ */ new Map();
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
tokensByPool.set(pool, tokens);
|
|
13413
|
-
}
|
|
13395
|
+
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13396
|
+
acc.creditManager
|
|
13397
|
+
);
|
|
13398
|
+
const pool = market.state.pool.pool.address;
|
|
13399
|
+
oracleByPool.set(pool, market.priceOracle);
|
|
13400
|
+
for (const t of acc.tokens) {
|
|
13401
|
+
if (t.balance > 10n) {
|
|
13402
|
+
const tokens = tokensByPool.get(pool) ?? /* @__PURE__ */ new Set();
|
|
13403
|
+
tokens.add(t.token);
|
|
13404
|
+
tokensByPool.set(pool, tokens);
|
|
13414
13405
|
}
|
|
13415
13406
|
}
|
|
13416
13407
|
const priceFeeds = [];
|
|
13417
|
-
for (const [
|
|
13418
|
-
const tokens = Array.from(tokensByPool.get(
|
|
13408
|
+
for (const [pool2, priceFeedFactory] of oracleByPool.entries()) {
|
|
13409
|
+
const tokens = Array.from(tokensByPool.get(pool2) ?? []);
|
|
13419
13410
|
priceFeeds.push(...priceFeedFactory.priceFeedsForTokens(tokens));
|
|
13420
13411
|
}
|
|
13421
13412
|
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
|
|
@@ -13423,22 +13414,46 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
13423
13414
|
blockNumber
|
|
13424
13415
|
);
|
|
13425
13416
|
}
|
|
13426
|
-
|
|
13417
|
+
/**
|
|
13418
|
+
* Returns account price updates in a non-encoded format
|
|
13419
|
+
* @param acc
|
|
13420
|
+
* @param blockNumber
|
|
13421
|
+
* @returns
|
|
13422
|
+
*/
|
|
13423
|
+
async getOnDemandPriceUpdates(acc, blockNumber) {
|
|
13427
13424
|
const market = this.sdk.marketRegister.findByCreditManager(
|
|
13428
|
-
|
|
13425
|
+
acc.creditManager
|
|
13429
13426
|
);
|
|
13427
|
+
const update = await this.#getUpdateForAccount(acc, blockNumber);
|
|
13428
|
+
return market.priceOracle.onDemandPriceUpdates(update);
|
|
13429
|
+
}
|
|
13430
|
+
/**
|
|
13431
|
+
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...)
|
|
13432
|
+
* @param acc
|
|
13433
|
+
* @param blockNumber
|
|
13434
|
+
* @returns
|
|
13435
|
+
*/
|
|
13436
|
+
async getPriceUpdatesForFacade(acc, blockNumber) {
|
|
13437
|
+
const cm = this.sdk.marketRegister.findCreditManager(acc.creditManager);
|
|
13438
|
+
const updates = await this.getOnDemandPriceUpdates(acc, blockNumber);
|
|
13439
|
+
return updates.map(({ token, reserve, data }) => ({
|
|
13440
|
+
target: cm.creditFacade.address,
|
|
13441
|
+
callData: encodeFunctionData({
|
|
13442
|
+
abi: iCreditFacadeV3MulticallAbi,
|
|
13443
|
+
functionName: "onDemandPriceUpdate",
|
|
13444
|
+
args: [token, reserve, data]
|
|
13445
|
+
})
|
|
13446
|
+
}));
|
|
13447
|
+
}
|
|
13448
|
+
async #prepareCloseCreditAccount(ca, cm, assetsToKeep, to, slippage = 50n) {
|
|
13430
13449
|
const closePath = await this.sdk.router.findBestClosePath(
|
|
13431
13450
|
ca,
|
|
13432
13451
|
cm.creditManager,
|
|
13433
13452
|
slippage
|
|
13434
13453
|
);
|
|
13435
|
-
const priceUpdates = await this
|
|
13436
|
-
const priceUpdateCalls = market.priceOracle.onDemandPriceUpdates(
|
|
13437
|
-
cm.creditFacade.address,
|
|
13438
|
-
priceUpdates
|
|
13439
|
-
);
|
|
13454
|
+
const priceUpdates = await this.getPriceUpdatesForFacade(ca);
|
|
13440
13455
|
return [
|
|
13441
|
-
...
|
|
13456
|
+
...priceUpdates,
|
|
13442
13457
|
...closePath.calls,
|
|
13443
13458
|
...this.#prepareDisableQuotas(ca),
|
|
13444
13459
|
...this.#prepareDecreaseDebt(ca),
|
|
@@ -14995,15 +15010,15 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
14995
15010
|
/**
|
|
14996
15011
|
* Converts previously obtained price updates into CreditFacade multicall entries
|
|
14997
15012
|
* @param creditFacade
|
|
14998
|
-
* @param
|
|
15013
|
+
* @param updates
|
|
14999
15014
|
* @returns
|
|
15000
15015
|
*/
|
|
15001
|
-
onDemandPriceUpdates(
|
|
15016
|
+
onDemandPriceUpdates(updates) {
|
|
15002
15017
|
const result = [];
|
|
15003
|
-
if (!
|
|
15018
|
+
if (!updates) {
|
|
15004
15019
|
return result;
|
|
15005
15020
|
}
|
|
15006
|
-
const { txs } =
|
|
15021
|
+
const { txs } = updates;
|
|
15007
15022
|
for (const tx of txs) {
|
|
15008
15023
|
const { to: priceFeed, callData } = tx;
|
|
15009
15024
|
const [token, reserve] = this.#findTokenForPriceFeed(priceFeed);
|
|
@@ -15013,12 +15028,9 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
15013
15028
|
});
|
|
15014
15029
|
const data = args[0];
|
|
15015
15030
|
result.push({
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
functionName: "onDemandPriceUpdate",
|
|
15020
|
-
args: [token, reserve, data]
|
|
15021
|
-
})
|
|
15031
|
+
token,
|
|
15032
|
+
reserve,
|
|
15033
|
+
data
|
|
15022
15034
|
});
|
|
15023
15035
|
}
|
|
15024
15036
|
return result;
|