@gearbox-protocol/sdk 3.0.0-vfour.79 → 3.0.0-vfour.80
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 +14 -14
- package/dist/cjs/sdk/index.d.ts +13 -17
- package/dist/esm/sdk/index.d.mts +13 -17
- package/dist/esm/sdk/index.mjs +14 -14
- package/package.json +1 -1
package/dist/cjs/sdk/index.cjs
CHANGED
|
@@ -22415,16 +22415,18 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22415
22415
|
*/
|
|
22416
22416
|
async fullyLiquidate(account, to, slippage = 50n) {
|
|
22417
22417
|
const cm = this.sdk.marketRegister.findCreditManager(account.creditManager);
|
|
22418
|
-
const
|
|
22418
|
+
const routerCloseResult = await this.sdk.router.findBestClosePath(
|
|
22419
22419
|
account,
|
|
22420
22420
|
cm.creditManager,
|
|
22421
22421
|
slippage
|
|
22422
22422
|
);
|
|
22423
22423
|
const priceUpdates = await this.getPriceUpdatesForFacade(account);
|
|
22424
|
-
|
|
22425
|
-
|
|
22426
|
-
|
|
22427
|
-
|
|
22424
|
+
const tx = cm.creditFacade.liquidateCreditAccount(
|
|
22425
|
+
account.creditAccount,
|
|
22426
|
+
to,
|
|
22427
|
+
[...priceUpdates, ...routerCloseResult.calls]
|
|
22428
|
+
);
|
|
22429
|
+
return { tx, routerCloseResult };
|
|
22428
22430
|
}
|
|
22429
22431
|
/**
|
|
22430
22432
|
* Closes credit account or sets debt to zero (but keep account)
|
|
@@ -22437,14 +22439,15 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22437
22439
|
*/
|
|
22438
22440
|
async closeCreditAccount(operation, ca, assetsToKeep, to, slippage = 50n) {
|
|
22439
22441
|
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
22440
|
-
const calls = await this.#prepareCloseCreditAccount(
|
|
22442
|
+
const { calls, routerCloseResult } = await this.#prepareCloseCreditAccount(
|
|
22441
22443
|
ca,
|
|
22442
22444
|
cm,
|
|
22443
22445
|
assetsToKeep,
|
|
22444
22446
|
to,
|
|
22445
22447
|
slippage
|
|
22446
22448
|
);
|
|
22447
|
-
|
|
22449
|
+
const tx = operation === "close" ? cm.creditFacade.closeCreditAccount(ca.creditAccount, calls) : cm.creditFacade.multicall(ca.creditAccount, calls);
|
|
22450
|
+
return { tx, routerCloseResult };
|
|
22448
22451
|
}
|
|
22449
22452
|
/**
|
|
22450
22453
|
* Internal wrapper for CreditAccountCompressor.getCreditAccounts + price updates wrapped into multicall
|
|
@@ -22535,15 +22538,15 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22535
22538
|
return cm.creditFacade.encodeOnDemandPriceUpdates(updates);
|
|
22536
22539
|
}
|
|
22537
22540
|
async #prepareCloseCreditAccount(ca, cm, assetsToKeep, to, slippage = 50n) {
|
|
22538
|
-
const
|
|
22541
|
+
const routerCloseResult = await this.sdk.router.findBestClosePath(
|
|
22539
22542
|
ca,
|
|
22540
22543
|
cm.creditManager,
|
|
22541
22544
|
slippage
|
|
22542
22545
|
);
|
|
22543
22546
|
const priceUpdates = await this.getPriceUpdatesForFacade(ca);
|
|
22544
|
-
|
|
22547
|
+
const calls = [
|
|
22545
22548
|
...priceUpdates,
|
|
22546
|
-
...
|
|
22549
|
+
...routerCloseResult.calls,
|
|
22547
22550
|
...this.#prepareDisableQuotas(ca),
|
|
22548
22551
|
...this.#prepareDecreaseDebt(ca),
|
|
22549
22552
|
...this.#prepareDisableTokens(ca),
|
|
@@ -22551,6 +22554,7 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22551
22554
|
(t) => this.#prepareWithdrawToken(ca, t, MAX_UINT256, to)
|
|
22552
22555
|
)
|
|
22553
22556
|
];
|
|
22557
|
+
return { calls, routerCloseResult };
|
|
22554
22558
|
}
|
|
22555
22559
|
#prepareDisableQuotas(ca) {
|
|
22556
22560
|
const calls = [];
|
|
@@ -23095,10 +23099,6 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
23095
23099
|
})),
|
|
23096
23100
|
underlyingBalance: underlyingBalance + bestResult.minAmount
|
|
23097
23101
|
};
|
|
23098
|
-
await this.#hooks.triggerHooks("foundBestClosePath", {
|
|
23099
|
-
creditAccount: ca.creditAccount,
|
|
23100
|
-
...result
|
|
23101
|
-
});
|
|
23102
23102
|
return result;
|
|
23103
23103
|
}
|
|
23104
23104
|
/**
|
package/dist/cjs/sdk/index.d.ts
CHANGED
|
@@ -24934,18 +24934,6 @@ type RouterHooks = {
|
|
|
24934
24934
|
foundPathOptions: [{
|
|
24935
24935
|
creditAccount: Address;
|
|
24936
24936
|
} & FindClosePathInput];
|
|
24937
|
-
/**
|
|
24938
|
-
* Internal router event
|
|
24939
|
-
*/
|
|
24940
|
-
foundBestClosePath: [
|
|
24941
|
-
{
|
|
24942
|
-
creditAccount: Address;
|
|
24943
|
-
amount: bigint;
|
|
24944
|
-
minAmount: bigint;
|
|
24945
|
-
calls: MultiCall[];
|
|
24946
|
-
underlyingBalance: bigint;
|
|
24947
|
-
}
|
|
24948
|
-
];
|
|
24949
24937
|
};
|
|
24950
24938
|
/**
|
|
24951
24939
|
* Slice of credit manager data required for router operations
|
|
@@ -24957,8 +24945,8 @@ interface CreditManagerSlice {
|
|
|
24957
24945
|
declare class RouterV3Contract extends BaseContract<abi> implements IHooks<RouterHooks> {
|
|
24958
24946
|
#private;
|
|
24959
24947
|
constructor(sdk: GearboxSDK, address: Address);
|
|
24960
|
-
addHook: <K extends
|
|
24961
|
-
removeHook: <K extends
|
|
24948
|
+
addHook: <K extends "foundPathOptions">(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
24949
|
+
removeHook: <K extends "foundPathOptions">(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
24962
24950
|
/**
|
|
24963
24951
|
* Finds all available swaps for NORMAL tokens
|
|
24964
24952
|
* @param ca
|
|
@@ -25181,6 +25169,14 @@ interface CreditAccountFilter {
|
|
|
25181
25169
|
minHealthFactor?: number;
|
|
25182
25170
|
maxHealthFactor?: number;
|
|
25183
25171
|
}
|
|
25172
|
+
interface FullyLiquidateAccountResult {
|
|
25173
|
+
tx: RawTx;
|
|
25174
|
+
routerCloseResult: RouterCloseResult;
|
|
25175
|
+
}
|
|
25176
|
+
interface CloseCreditAccountResult {
|
|
25177
|
+
tx: RawTx;
|
|
25178
|
+
routerCloseResult: RouterCloseResult;
|
|
25179
|
+
}
|
|
25184
25180
|
declare class CreditAccountsService extends SDKConstruct {
|
|
25185
25181
|
#private;
|
|
25186
25182
|
constructor(sdk: GearboxSDK);
|
|
@@ -25211,7 +25207,7 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
25211
25207
|
* @param slippage
|
|
25212
25208
|
* @returns
|
|
25213
25209
|
*/
|
|
25214
|
-
fullyLiquidate(account: CreditAccountData, to: Address, slippage?: bigint): Promise<
|
|
25210
|
+
fullyLiquidate(account: CreditAccountData, to: Address, slippage?: bigint): Promise<FullyLiquidateAccountResult>;
|
|
25215
25211
|
/**
|
|
25216
25212
|
* Closes credit account or sets debt to zero (but keep account)
|
|
25217
25213
|
* @param operation
|
|
@@ -25221,7 +25217,7 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
25221
25217
|
* @param slippage
|
|
25222
25218
|
* @returns
|
|
25223
25219
|
*/
|
|
25224
|
-
closeCreditAccount(operation: "close" | "zeroDebt", ca: CreditAccountData, assetsToKeep: Address[], to: Address, slippage?: bigint): Promise<
|
|
25220
|
+
closeCreditAccount(operation: "close" | "zeroDebt", ca: CreditAccountData, assetsToKeep: Address[], to: Address, slippage?: bigint): Promise<CloseCreditAccountResult>;
|
|
25225
25221
|
/**
|
|
25226
25222
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
25227
25223
|
* @param accounts
|
|
@@ -25353,4 +25349,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
|
|
|
25353
25349
|
*/
|
|
25354
25350
|
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>>;
|
|
25355
25351
|
|
|
25356
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER, ADDRESS_PROVIDER_BLOCK, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, 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_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AdapterContractType, type AdapterData, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3StateHuman, type Asset, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractStateHuman, type BaseParams, type BasePriceFeedStateHuman, BotListContract, type BotListStateHuman, BotPermissions, type BoundedOracleStateHuman, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, type CreditFacadeState, type CreditFacadeStateHuman, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerState, type CreditManagerStateHuman, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, GearStakingContract, type GearStakingV3StateHuman, GearboxSDK, type GearboxStateHuman, type IAdapterContract, type IBaseContract, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelStateHuman, type LogFn, MAX_UINT16, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkOptions, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PartialPriceFeedTreeNode, type PathOption, type PathOptionSerie, PoolContract, type PoolData, PoolFactory, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperStateHuman, type PoolStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleV3StateHuman, Provider, type QuotaParamsHuman, type QuotaState, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterHooks, type RouterResult, RouterV3Contract, SDKConstruct, type SDKHooks, type SDKOptions, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, type SyncStateOptions, TIMELOCK, type TVL, type TokenMetaData, TokensMeta, type TransportOptions, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, type UpdatePriceFeedsResult, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, type ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
|
|
25352
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER, ADDRESS_PROVIDER_BLOCK, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, 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_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AdapterContractType, type AdapterData, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3StateHuman, type Asset, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractStateHuman, type BaseParams, type BasePriceFeedStateHuman, BotListContract, type BotListStateHuman, BotPermissions, type BoundedOracleStateHuman, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, type CloseCreditAccountResult, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, type CreditFacadeState, type CreditFacadeStateHuman, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerState, type CreditManagerStateHuman, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, type FullyLiquidateAccountResult, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, GearStakingContract, type GearStakingV3StateHuman, GearboxSDK, type GearboxStateHuman, type IAdapterContract, type IBaseContract, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelStateHuman, type LogFn, MAX_UINT16, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkOptions, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PartialPriceFeedTreeNode, type PathOption, type PathOptionSerie, PoolContract, type PoolData, PoolFactory, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperStateHuman, type PoolStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleV3StateHuman, Provider, type QuotaParamsHuman, type QuotaState, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterHooks, type RouterResult, RouterV3Contract, SDKConstruct, type SDKHooks, type SDKOptions, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, type SyncStateOptions, TIMELOCK, type TVL, type TokenMetaData, TokensMeta, type TransportOptions, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, type UpdatePriceFeedsResult, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, type ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
|
package/dist/esm/sdk/index.d.mts
CHANGED
|
@@ -24934,18 +24934,6 @@ type RouterHooks = {
|
|
|
24934
24934
|
foundPathOptions: [{
|
|
24935
24935
|
creditAccount: Address;
|
|
24936
24936
|
} & FindClosePathInput];
|
|
24937
|
-
/**
|
|
24938
|
-
* Internal router event
|
|
24939
|
-
*/
|
|
24940
|
-
foundBestClosePath: [
|
|
24941
|
-
{
|
|
24942
|
-
creditAccount: Address;
|
|
24943
|
-
amount: bigint;
|
|
24944
|
-
minAmount: bigint;
|
|
24945
|
-
calls: MultiCall[];
|
|
24946
|
-
underlyingBalance: bigint;
|
|
24947
|
-
}
|
|
24948
|
-
];
|
|
24949
24937
|
};
|
|
24950
24938
|
/**
|
|
24951
24939
|
* Slice of credit manager data required for router operations
|
|
@@ -24957,8 +24945,8 @@ interface CreditManagerSlice {
|
|
|
24957
24945
|
declare class RouterV3Contract extends BaseContract<abi> implements IHooks<RouterHooks> {
|
|
24958
24946
|
#private;
|
|
24959
24947
|
constructor(sdk: GearboxSDK, address: Address);
|
|
24960
|
-
addHook: <K extends
|
|
24961
|
-
removeHook: <K extends
|
|
24948
|
+
addHook: <K extends "foundPathOptions">(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
24949
|
+
removeHook: <K extends "foundPathOptions">(hookName: K, fn: (...args: RouterHooks[K]) => void | Promise<void>) => void;
|
|
24962
24950
|
/**
|
|
24963
24951
|
* Finds all available swaps for NORMAL tokens
|
|
24964
24952
|
* @param ca
|
|
@@ -25181,6 +25169,14 @@ interface CreditAccountFilter {
|
|
|
25181
25169
|
minHealthFactor?: number;
|
|
25182
25170
|
maxHealthFactor?: number;
|
|
25183
25171
|
}
|
|
25172
|
+
interface FullyLiquidateAccountResult {
|
|
25173
|
+
tx: RawTx;
|
|
25174
|
+
routerCloseResult: RouterCloseResult;
|
|
25175
|
+
}
|
|
25176
|
+
interface CloseCreditAccountResult {
|
|
25177
|
+
tx: RawTx;
|
|
25178
|
+
routerCloseResult: RouterCloseResult;
|
|
25179
|
+
}
|
|
25184
25180
|
declare class CreditAccountsService extends SDKConstruct {
|
|
25185
25181
|
#private;
|
|
25186
25182
|
constructor(sdk: GearboxSDK);
|
|
@@ -25211,7 +25207,7 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
25211
25207
|
* @param slippage
|
|
25212
25208
|
* @returns
|
|
25213
25209
|
*/
|
|
25214
|
-
fullyLiquidate(account: CreditAccountData, to: Address, slippage?: bigint): Promise<
|
|
25210
|
+
fullyLiquidate(account: CreditAccountData, to: Address, slippage?: bigint): Promise<FullyLiquidateAccountResult>;
|
|
25215
25211
|
/**
|
|
25216
25212
|
* Closes credit account or sets debt to zero (but keep account)
|
|
25217
25213
|
* @param operation
|
|
@@ -25221,7 +25217,7 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
25221
25217
|
* @param slippage
|
|
25222
25218
|
* @returns
|
|
25223
25219
|
*/
|
|
25224
|
-
closeCreditAccount(operation: "close" | "zeroDebt", ca: CreditAccountData, assetsToKeep: Address[], to: Address, slippage?: bigint): Promise<
|
|
25220
|
+
closeCreditAccount(operation: "close" | "zeroDebt", ca: CreditAccountData, assetsToKeep: Address[], to: Address, slippage?: bigint): Promise<CloseCreditAccountResult>;
|
|
25225
25221
|
/**
|
|
25226
25222
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
25227
25223
|
* @param accounts
|
|
@@ -25353,4 +25349,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
|
|
|
25353
25349
|
*/
|
|
25354
25350
|
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>>;
|
|
25355
25351
|
|
|
25356
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER, ADDRESS_PROVIDER_BLOCK, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, 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_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AdapterContractType, type AdapterData, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3StateHuman, type Asset, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractStateHuman, type BaseParams, type BasePriceFeedStateHuman, BotListContract, type BotListStateHuman, BotPermissions, type BoundedOracleStateHuman, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, type CreditFacadeState, type CreditFacadeStateHuman, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerState, type CreditManagerStateHuman, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, GearStakingContract, type GearStakingV3StateHuman, GearboxSDK, type GearboxStateHuman, type IAdapterContract, type IBaseContract, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelStateHuman, type LogFn, MAX_UINT16, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkOptions, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PartialPriceFeedTreeNode, type PathOption, type PathOptionSerie, PoolContract, type PoolData, PoolFactory, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperStateHuman, type PoolStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleV3StateHuman, Provider, type QuotaParamsHuman, type QuotaState, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterHooks, type RouterResult, RouterV3Contract, SDKConstruct, type SDKHooks, type SDKOptions, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, type SyncStateOptions, TIMELOCK, type TVL, type TokenMetaData, TokensMeta, type TransportOptions, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, type UpdatePriceFeedsResult, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, type ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
|
|
25352
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER, ADDRESS_PROVIDER_BLOCK, AP_ACCOUNT_FACTORY, AP_ACL, AP_ADAPTER_COMPRESSOR, 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_MARKET_CONFIGURATOR, AP_MULTI_PAUSE, AP_PARTIAL_LIQUIDATION_BOT, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_ORACLE, AP_ROUTER, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractPriceFeedContract, type AdapterContractType, type AdapterData, AddressLabeller, AddressMap, AddressProviderContractV3_1, type AddressProviderV3StateHuman, type Asset, type AssetPriceFeedStateHuman, BalancerStablePriceFeedContract, BalancerV2VaultAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, type BaseContractOptions, type BaseContractStateHuman, type BaseParams, type BasePriceFeedStateHuman, BotListContract, type BotListStateHuman, BotPermissions, type BoundedOracleStateHuman, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainlinkPriceFeedContract, type CloseCreditAccountResult, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountFilter, CreditAccountsService, CreditConfiguratorContract, type CreditConfiguratorState, type CreditConfiguratorStateHuman, type CreditFacadeState, type CreditFacadeStateHuman, CreditFacadeV300Contract, CreditFacadeV310Contract, CreditFactory, type CreditFactoryStateHuman, CreditManagerContract, type CreditManagerData, type CreditManagerDebtParams, type CreditManagerDebtParamsHuman, type CreditManagerState, type CreditManagerStateHuman, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, type CurvePoolStruct, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1AdapterStableNGContract, ERC4626AdapterContract, Erc4626PriceFeedContract, type EtherscanURLParam, type FindClosePathInput, type FullyLiquidateAccountResult, GaugeContract, type GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, GearStakingContract, type GearStakingV3StateHuman, GearboxSDK, type GearboxStateHuman, type IAdapterContract, type IBaseContract, type ILPPriceFeedContract, type ILogger, type IPriceFeedContract, LinearModelContract, type LinearModelStateHuman, type LogFn, MAX_UINT16, MAX_UINT256, MIN_INT96, type MarketData, MarketFactory, MarketRegister, type MarketStateHuman, MellowLRTPriceFeedContract, type MultiCall, type MulticallErrorType, type MulticallParameters, type MulticallReturnType, NOT_DEPLOYED, NO_VERSION, type NetworkOptions, type NetworkType, type OnDemandPriceUpdate, type OpenStrategyResult, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PRICE_DECIMALS, PRICE_DECIMALS_POW, type PartialPriceFeedTreeNode, type PathOption, type PathOptionSerie, PoolContract, type PoolData, PoolFactory, type PoolFactoryStateHuman, PoolQuotaKeeperContract, type PoolQuotaKeeperData, type PoolQuotaKeeperStateHuman, type PoolStateHuman, type PriceFeedConstructorArgs, type PriceFeedContractType, type PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, type PriceFeedRegisterHooks, type PriceFeedStateHuman, type PriceFeedTreeNode, type PriceFeedUsageType, PriceOracleContract, type PriceOracleData, type PriceOracleV3StateHuman, Provider, type QuotaParamsHuman, type QuotaState, RAY, RAY_DECIMALS_POW, type RateKeeperData, type RawTx, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, type RouterCloseResult, type RouterHooks, type RouterResult, RouterV3Contract, SDKConstruct, type SDKHooks, type SDKOptions, SUPPORTED_CHAINS, type SwapOperation, type SwapTask, type SyncStateOptions, TIMELOCK, type TVL, type TokenMetaData, TokensMeta, type TransportOptions, USDC, UniswapV2AdapterContract, UniswapV3AdapterContract, type UpdatePriceFeedsResult, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, YearnV2RouterAdapterContract, type ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createRawTx, createTransport, detectNetwork, etherscanUrl, filterDust, fmtBinaryMask, formatBN, formatBNvalue, formatBn4dig, formatDuration, formatNumberToString_, halfRAY, json_parse, json_stringify, numberWithCommas, percentFmt, rawTxToMulticallPriceUpdate, simulateMulticall, toHumanFormat };
|
package/dist/esm/sdk/index.mjs
CHANGED
|
@@ -22413,16 +22413,18 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22413
22413
|
*/
|
|
22414
22414
|
async fullyLiquidate(account, to, slippage = 50n) {
|
|
22415
22415
|
const cm = this.sdk.marketRegister.findCreditManager(account.creditManager);
|
|
22416
|
-
const
|
|
22416
|
+
const routerCloseResult = await this.sdk.router.findBestClosePath(
|
|
22417
22417
|
account,
|
|
22418
22418
|
cm.creditManager,
|
|
22419
22419
|
slippage
|
|
22420
22420
|
);
|
|
22421
22421
|
const priceUpdates = await this.getPriceUpdatesForFacade(account);
|
|
22422
|
-
|
|
22423
|
-
|
|
22424
|
-
|
|
22425
|
-
|
|
22422
|
+
const tx = cm.creditFacade.liquidateCreditAccount(
|
|
22423
|
+
account.creditAccount,
|
|
22424
|
+
to,
|
|
22425
|
+
[...priceUpdates, ...routerCloseResult.calls]
|
|
22426
|
+
);
|
|
22427
|
+
return { tx, routerCloseResult };
|
|
22426
22428
|
}
|
|
22427
22429
|
/**
|
|
22428
22430
|
* Closes credit account or sets debt to zero (but keep account)
|
|
@@ -22435,14 +22437,15 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22435
22437
|
*/
|
|
22436
22438
|
async closeCreditAccount(operation, ca, assetsToKeep, to, slippage = 50n) {
|
|
22437
22439
|
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
22438
|
-
const calls = await this.#prepareCloseCreditAccount(
|
|
22440
|
+
const { calls, routerCloseResult } = await this.#prepareCloseCreditAccount(
|
|
22439
22441
|
ca,
|
|
22440
22442
|
cm,
|
|
22441
22443
|
assetsToKeep,
|
|
22442
22444
|
to,
|
|
22443
22445
|
slippage
|
|
22444
22446
|
);
|
|
22445
|
-
|
|
22447
|
+
const tx = operation === "close" ? cm.creditFacade.closeCreditAccount(ca.creditAccount, calls) : cm.creditFacade.multicall(ca.creditAccount, calls);
|
|
22448
|
+
return { tx, routerCloseResult };
|
|
22446
22449
|
}
|
|
22447
22450
|
/**
|
|
22448
22451
|
* Internal wrapper for CreditAccountCompressor.getCreditAccounts + price updates wrapped into multicall
|
|
@@ -22533,15 +22536,15 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22533
22536
|
return cm.creditFacade.encodeOnDemandPriceUpdates(updates);
|
|
22534
22537
|
}
|
|
22535
22538
|
async #prepareCloseCreditAccount(ca, cm, assetsToKeep, to, slippage = 50n) {
|
|
22536
|
-
const
|
|
22539
|
+
const routerCloseResult = await this.sdk.router.findBestClosePath(
|
|
22537
22540
|
ca,
|
|
22538
22541
|
cm.creditManager,
|
|
22539
22542
|
slippage
|
|
22540
22543
|
);
|
|
22541
22544
|
const priceUpdates = await this.getPriceUpdatesForFacade(ca);
|
|
22542
|
-
|
|
22545
|
+
const calls = [
|
|
22543
22546
|
...priceUpdates,
|
|
22544
|
-
...
|
|
22547
|
+
...routerCloseResult.calls,
|
|
22545
22548
|
...this.#prepareDisableQuotas(ca),
|
|
22546
22549
|
...this.#prepareDecreaseDebt(ca),
|
|
22547
22550
|
...this.#prepareDisableTokens(ca),
|
|
@@ -22549,6 +22552,7 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22549
22552
|
(t) => this.#prepareWithdrawToken(ca, t, MAX_UINT256, to)
|
|
22550
22553
|
)
|
|
22551
22554
|
];
|
|
22555
|
+
return { calls, routerCloseResult };
|
|
22552
22556
|
}
|
|
22553
22557
|
#prepareDisableQuotas(ca) {
|
|
22554
22558
|
const calls = [];
|
|
@@ -23093,10 +23097,6 @@ var RouterV3Contract = class extends BaseContract {
|
|
|
23093
23097
|
})),
|
|
23094
23098
|
underlyingBalance: underlyingBalance + bestResult.minAmount
|
|
23095
23099
|
};
|
|
23096
|
-
await this.#hooks.triggerHooks("foundBestClosePath", {
|
|
23097
|
-
creditAccount: ca.creditAccount,
|
|
23098
|
-
...result
|
|
23099
|
-
});
|
|
23100
23100
|
return result;
|
|
23101
23101
|
}
|
|
23102
23102
|
/**
|