@gearbox-protocol/sdk 3.0.0-vfour.96 → 3.0.0-vfour.98
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 +70 -11
- package/dist/cjs/sdk/index.d.ts +18 -14
- package/dist/esm/sdk/index.d.mts +18 -14
- package/dist/esm/sdk/index.mjs +70 -11
- package/package.json +4 -4
package/dist/cjs/sdk/index.cjs
CHANGED
|
@@ -20163,6 +20163,12 @@ var CreditFacadeV300Contract = class extends BaseContract {
|
|
|
20163
20163
|
args: [ca, calls]
|
|
20164
20164
|
});
|
|
20165
20165
|
}
|
|
20166
|
+
openCreditAccount(to, calls, referralCode) {
|
|
20167
|
+
return this.createRawTx({
|
|
20168
|
+
functionName: "openCreditAccount",
|
|
20169
|
+
args: [to, calls, referralCode]
|
|
20170
|
+
});
|
|
20171
|
+
}
|
|
20166
20172
|
parseFunctionParams(params) {
|
|
20167
20173
|
switch (params.functionName) {
|
|
20168
20174
|
case "openCreditAccount": {
|
|
@@ -20292,6 +20298,12 @@ var CreditFacadeV310Contract = class extends BaseContract {
|
|
|
20292
20298
|
args: [ca, calls]
|
|
20293
20299
|
});
|
|
20294
20300
|
}
|
|
20301
|
+
openCreditAccount(to, calls, referralCode) {
|
|
20302
|
+
return this.createRawTx({
|
|
20303
|
+
functionName: "openCreditAccount",
|
|
20304
|
+
args: [to, calls, referralCode]
|
|
20305
|
+
});
|
|
20306
|
+
}
|
|
20295
20307
|
parseFunctionParams(params) {
|
|
20296
20308
|
switch (params.functionName) {
|
|
20297
20309
|
case "openCreditAccount": {
|
|
@@ -22838,12 +22850,13 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22838
22850
|
account,
|
|
22839
22851
|
void 0
|
|
22840
22852
|
);
|
|
22853
|
+
const calls = [...priceUpdates, ...routerCloseResult.calls];
|
|
22841
22854
|
const tx = cm.creditFacade.liquidateCreditAccount(
|
|
22842
22855
|
account.creditAccount,
|
|
22843
22856
|
to,
|
|
22844
|
-
|
|
22857
|
+
calls
|
|
22845
22858
|
);
|
|
22846
|
-
return { tx, routerCloseResult };
|
|
22859
|
+
return { tx, calls, routerCloseResult };
|
|
22847
22860
|
}
|
|
22848
22861
|
/**
|
|
22849
22862
|
* Closes credit account or sets debt to zero (but keep account)
|
|
@@ -23072,27 +23085,63 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
23072
23085
|
return { tx, calls };
|
|
23073
23086
|
}
|
|
23074
23087
|
async claimFarmRewards(props) {
|
|
23075
|
-
const { tokensToDisable, calls: claimCalls, creditAccount } = props;
|
|
23088
|
+
const { tokensToDisable, calls: claimCalls, creditAccount: ca } = props;
|
|
23076
23089
|
if (claimCalls.length === 0) throw new Error("No path to execute");
|
|
23077
|
-
const cm = this.sdk.marketRegister.findCreditManager(
|
|
23078
|
-
creditAccount.creditManager
|
|
23079
|
-
);
|
|
23090
|
+
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
23080
23091
|
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
23081
|
-
|
|
23082
|
-
|
|
23092
|
+
ca.creditManager,
|
|
23093
|
+
ca,
|
|
23083
23094
|
props.averageQuota
|
|
23084
23095
|
);
|
|
23085
23096
|
const calls = [
|
|
23086
23097
|
...priceUpdatesCalls,
|
|
23087
23098
|
...claimCalls,
|
|
23088
23099
|
...tokensToDisable.map(
|
|
23089
|
-
(a) => this.#prepareDisableToken(
|
|
23100
|
+
(a) => this.#prepareDisableToken(ca.creditFacade, a.token)
|
|
23090
23101
|
),
|
|
23091
|
-
...this.#prepareUpdateQuotas(
|
|
23102
|
+
...this.#prepareUpdateQuotas(ca.creditFacade, props)
|
|
23092
23103
|
];
|
|
23093
|
-
const tx = cm.creditFacade.multicall(
|
|
23104
|
+
const tx = cm.creditFacade.multicall(ca.creditAccount, calls);
|
|
23094
23105
|
return { tx, calls };
|
|
23095
23106
|
}
|
|
23107
|
+
async openCA(props) {
|
|
23108
|
+
const {
|
|
23109
|
+
ethAmount,
|
|
23110
|
+
creditManager,
|
|
23111
|
+
collateral,
|
|
23112
|
+
permits,
|
|
23113
|
+
debt,
|
|
23114
|
+
withdrawDebt,
|
|
23115
|
+
referralCode,
|
|
23116
|
+
to,
|
|
23117
|
+
calls: openPathCalls
|
|
23118
|
+
} = props;
|
|
23119
|
+
const cmFactory = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
23120
|
+
const cm = cmFactory.creditManager;
|
|
23121
|
+
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
23122
|
+
cm.address,
|
|
23123
|
+
void 0,
|
|
23124
|
+
props.averageQuota
|
|
23125
|
+
);
|
|
23126
|
+
const calls = [
|
|
23127
|
+
...priceUpdatesCalls,
|
|
23128
|
+
this.#prepareIncreaseDebt(cm.creditFacade, debt),
|
|
23129
|
+
...this.#prepareAddCollateral(cm.creditFacade, collateral, permits),
|
|
23130
|
+
...this.#prepareUpdateQuotas(cm.creditFacade, props),
|
|
23131
|
+
...openPathCalls,
|
|
23132
|
+
...withdrawDebt ? [this.#prepareWithdrawToken(cm.creditFacade, cm.underlying, debt, to)] : []
|
|
23133
|
+
];
|
|
23134
|
+
const tx = cmFactory.creditFacade.openCreditAccount(
|
|
23135
|
+
to,
|
|
23136
|
+
calls,
|
|
23137
|
+
referralCode
|
|
23138
|
+
);
|
|
23139
|
+
tx.value = ethAmount.toString(10);
|
|
23140
|
+
return {
|
|
23141
|
+
calls,
|
|
23142
|
+
tx
|
|
23143
|
+
};
|
|
23144
|
+
}
|
|
23096
23145
|
/**
|
|
23097
23146
|
* Internal wrapper for CreditAccountCompressor.getCreditAccounts + price updates wrapped into multicall
|
|
23098
23147
|
* @param args
|
|
@@ -23319,6 +23368,16 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
23319
23368
|
})
|
|
23320
23369
|
};
|
|
23321
23370
|
}
|
|
23371
|
+
#prepareIncreaseDebt(creditFacade, debt) {
|
|
23372
|
+
return {
|
|
23373
|
+
target: creditFacade,
|
|
23374
|
+
callData: viem.encodeFunctionData({
|
|
23375
|
+
abi: iCreditFacadeV3MulticallAbi,
|
|
23376
|
+
functionName: "increaseDebt",
|
|
23377
|
+
args: [debt]
|
|
23378
|
+
})
|
|
23379
|
+
};
|
|
23380
|
+
}
|
|
23322
23381
|
#prepareChangeDebt(creditFacade, change, isDecrease) {
|
|
23323
23382
|
return {
|
|
23324
23383
|
target: creditFacade,
|
package/dist/cjs/sdk/index.d.ts
CHANGED
|
@@ -22935,6 +22935,7 @@ declare class CreditFacadeV300Contract extends BaseContract<abi$b> {
|
|
|
22935
22935
|
liquidateCreditAccount(ca: Address, to: Address, calls: MultiCall[]): RawTx;
|
|
22936
22936
|
closeCreditAccount(ca: Address, calls: MultiCall[]): RawTx;
|
|
22937
22937
|
multicall(ca: Address, calls: MultiCall[]): RawTx;
|
|
22938
|
+
openCreditAccount(to: Address, calls: MultiCall[], referralCode: bigint): RawTx;
|
|
22938
22939
|
parseFunctionParams(params: DecodeFunctionDataReturnType<abi$b>): string[] | undefined;
|
|
22939
22940
|
}
|
|
22940
22941
|
|
|
@@ -22950,6 +22951,7 @@ declare class CreditFacadeV310Contract extends BaseContract<abi$a> {
|
|
|
22950
22951
|
liquidateCreditAccount(ca: Address, to: Address, calls: MultiCall[]): RawTx;
|
|
22951
22952
|
closeCreditAccount(ca: Address, calls: MultiCall[]): RawTx;
|
|
22952
22953
|
multicall(ca: Address, calls: MultiCall[]): RawTx;
|
|
22954
|
+
openCreditAccount(to: Address, calls: MultiCall[], referralCode: bigint): RawTx;
|
|
22953
22955
|
parseFunctionParams(params: DecodeFunctionDataReturnType<abi$a>): string[] | undefined;
|
|
22954
22956
|
}
|
|
22955
22957
|
|
|
@@ -25247,10 +25249,6 @@ interface CreditAccountFilter {
|
|
|
25247
25249
|
minHealthFactor?: number;
|
|
25248
25250
|
maxHealthFactor?: number;
|
|
25249
25251
|
}
|
|
25250
|
-
interface FullyLiquidateAccountResult {
|
|
25251
|
-
tx: RawTx;
|
|
25252
|
-
routerCloseResult: RouterCloseResult;
|
|
25253
|
-
}
|
|
25254
25252
|
interface CloseCreditAccountResult extends CommonResult {
|
|
25255
25253
|
routerCloseResult: RouterCloseResult;
|
|
25256
25254
|
}
|
|
@@ -25304,6 +25302,17 @@ interface ClaimFarmRewardsProps extends PrepareUpdateQuotasProps {
|
|
|
25304
25302
|
calls: Array<MultiCall>;
|
|
25305
25303
|
creditAccount: CreditAccountDataSlice;
|
|
25306
25304
|
}
|
|
25305
|
+
interface OpenCAProps extends PrepareUpdateQuotasProps {
|
|
25306
|
+
ethAmount: bigint;
|
|
25307
|
+
collateral: Array<Asset>;
|
|
25308
|
+
debt: bigint;
|
|
25309
|
+
withdrawDebt?: boolean;
|
|
25310
|
+
permits: Record<string, PermitResult>;
|
|
25311
|
+
calls: Array<MultiCall>;
|
|
25312
|
+
creditManager: Address;
|
|
25313
|
+
to: Address;
|
|
25314
|
+
referralCode: bigint;
|
|
25315
|
+
}
|
|
25307
25316
|
interface ChangeDeptProps {
|
|
25308
25317
|
creditAccount: CreditAccountDataSlice;
|
|
25309
25318
|
amount: bigint;
|
|
@@ -25349,7 +25358,7 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
25349
25358
|
* @param slippage
|
|
25350
25359
|
* @returns
|
|
25351
25360
|
*/
|
|
25352
|
-
fullyLiquidate(account: CreditAccountDataSlice, to: Address, slippage?: bigint): Promise<
|
|
25361
|
+
fullyLiquidate(account: CreditAccountDataSlice, to: Address, slippage?: bigint): Promise<CloseCreditAccountResult>;
|
|
25353
25362
|
/**
|
|
25354
25363
|
* Closes credit account or sets debt to zero (but keep account)
|
|
25355
25364
|
* @param operation
|
|
@@ -25386,18 +25395,13 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
25386
25395
|
updateQuotas(props: UpdateQuotasProps): Promise<CommonResult>;
|
|
25387
25396
|
addCollateral(props: AddCollateralProps): Promise<CommonResult>;
|
|
25388
25397
|
changeDebt({ creditAccount, amount, }: ChangeDeptProps): Promise<CommonResult>;
|
|
25389
|
-
withdrawCollateral(props: WithdrawCollateralProps): Promise<
|
|
25390
|
-
|
|
25391
|
-
calls: MultiCall[];
|
|
25392
|
-
}>;
|
|
25393
|
-
executeSwap(props: ExecuteSwapProps): Promise<{
|
|
25394
|
-
tx: RawTx;
|
|
25395
|
-
calls: MultiCall[];
|
|
25396
|
-
}>;
|
|
25398
|
+
withdrawCollateral(props: WithdrawCollateralProps): Promise<CommonResult>;
|
|
25399
|
+
executeSwap(props: ExecuteSwapProps): Promise<CommonResult>;
|
|
25397
25400
|
claimFarmRewards(props: ClaimFarmRewardsProps): Promise<{
|
|
25398
25401
|
tx: RawTx;
|
|
25399
25402
|
calls: MultiCall[];
|
|
25400
25403
|
}>;
|
|
25404
|
+
openCA(props: OpenCAProps): Promise<CommonResult>;
|
|
25401
25405
|
/**
|
|
25402
25406
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
25403
25407
|
* @param accounts
|
|
@@ -25530,4 +25534,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
|
|
|
25530
25534
|
*/
|
|
25531
25535
|
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>>;
|
|
25532
25536
|
|
|
25533
|
-
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 ClaimFarmRewardsProps, type CloseCreditAccountResult, type ClosePathBalances, type CommonResult, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountDataSlice, 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,
|
|
25537
|
+
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 ClaimFarmRewardsProps, type CloseCreditAccountResult, type ClosePathBalances, type CommonResult, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountDataSlice, 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, type PermitResult, 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, assetsMap, balancesMap, 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, tokenToTicker };
|
package/dist/esm/sdk/index.d.mts
CHANGED
|
@@ -22935,6 +22935,7 @@ declare class CreditFacadeV300Contract extends BaseContract<abi$b> {
|
|
|
22935
22935
|
liquidateCreditAccount(ca: Address, to: Address, calls: MultiCall[]): RawTx;
|
|
22936
22936
|
closeCreditAccount(ca: Address, calls: MultiCall[]): RawTx;
|
|
22937
22937
|
multicall(ca: Address, calls: MultiCall[]): RawTx;
|
|
22938
|
+
openCreditAccount(to: Address, calls: MultiCall[], referralCode: bigint): RawTx;
|
|
22938
22939
|
parseFunctionParams(params: DecodeFunctionDataReturnType<abi$b>): string[] | undefined;
|
|
22939
22940
|
}
|
|
22940
22941
|
|
|
@@ -22950,6 +22951,7 @@ declare class CreditFacadeV310Contract extends BaseContract<abi$a> {
|
|
|
22950
22951
|
liquidateCreditAccount(ca: Address, to: Address, calls: MultiCall[]): RawTx;
|
|
22951
22952
|
closeCreditAccount(ca: Address, calls: MultiCall[]): RawTx;
|
|
22952
22953
|
multicall(ca: Address, calls: MultiCall[]): RawTx;
|
|
22954
|
+
openCreditAccount(to: Address, calls: MultiCall[], referralCode: bigint): RawTx;
|
|
22953
22955
|
parseFunctionParams(params: DecodeFunctionDataReturnType<abi$a>): string[] | undefined;
|
|
22954
22956
|
}
|
|
22955
22957
|
|
|
@@ -25247,10 +25249,6 @@ interface CreditAccountFilter {
|
|
|
25247
25249
|
minHealthFactor?: number;
|
|
25248
25250
|
maxHealthFactor?: number;
|
|
25249
25251
|
}
|
|
25250
|
-
interface FullyLiquidateAccountResult {
|
|
25251
|
-
tx: RawTx;
|
|
25252
|
-
routerCloseResult: RouterCloseResult;
|
|
25253
|
-
}
|
|
25254
25252
|
interface CloseCreditAccountResult extends CommonResult {
|
|
25255
25253
|
routerCloseResult: RouterCloseResult;
|
|
25256
25254
|
}
|
|
@@ -25304,6 +25302,17 @@ interface ClaimFarmRewardsProps extends PrepareUpdateQuotasProps {
|
|
|
25304
25302
|
calls: Array<MultiCall>;
|
|
25305
25303
|
creditAccount: CreditAccountDataSlice;
|
|
25306
25304
|
}
|
|
25305
|
+
interface OpenCAProps extends PrepareUpdateQuotasProps {
|
|
25306
|
+
ethAmount: bigint;
|
|
25307
|
+
collateral: Array<Asset>;
|
|
25308
|
+
debt: bigint;
|
|
25309
|
+
withdrawDebt?: boolean;
|
|
25310
|
+
permits: Record<string, PermitResult>;
|
|
25311
|
+
calls: Array<MultiCall>;
|
|
25312
|
+
creditManager: Address;
|
|
25313
|
+
to: Address;
|
|
25314
|
+
referralCode: bigint;
|
|
25315
|
+
}
|
|
25307
25316
|
interface ChangeDeptProps {
|
|
25308
25317
|
creditAccount: CreditAccountDataSlice;
|
|
25309
25318
|
amount: bigint;
|
|
@@ -25349,7 +25358,7 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
25349
25358
|
* @param slippage
|
|
25350
25359
|
* @returns
|
|
25351
25360
|
*/
|
|
25352
|
-
fullyLiquidate(account: CreditAccountDataSlice, to: Address, slippage?: bigint): Promise<
|
|
25361
|
+
fullyLiquidate(account: CreditAccountDataSlice, to: Address, slippage?: bigint): Promise<CloseCreditAccountResult>;
|
|
25353
25362
|
/**
|
|
25354
25363
|
* Closes credit account or sets debt to zero (but keep account)
|
|
25355
25364
|
* @param operation
|
|
@@ -25386,18 +25395,13 @@ declare class CreditAccountsService extends SDKConstruct {
|
|
|
25386
25395
|
updateQuotas(props: UpdateQuotasProps): Promise<CommonResult>;
|
|
25387
25396
|
addCollateral(props: AddCollateralProps): Promise<CommonResult>;
|
|
25388
25397
|
changeDebt({ creditAccount, amount, }: ChangeDeptProps): Promise<CommonResult>;
|
|
25389
|
-
withdrawCollateral(props: WithdrawCollateralProps): Promise<
|
|
25390
|
-
|
|
25391
|
-
calls: MultiCall[];
|
|
25392
|
-
}>;
|
|
25393
|
-
executeSwap(props: ExecuteSwapProps): Promise<{
|
|
25394
|
-
tx: RawTx;
|
|
25395
|
-
calls: MultiCall[];
|
|
25396
|
-
}>;
|
|
25398
|
+
withdrawCollateral(props: WithdrawCollateralProps): Promise<CommonResult>;
|
|
25399
|
+
executeSwap(props: ExecuteSwapProps): Promise<CommonResult>;
|
|
25397
25400
|
claimFarmRewards(props: ClaimFarmRewardsProps): Promise<{
|
|
25398
25401
|
tx: RawTx;
|
|
25399
25402
|
calls: MultiCall[];
|
|
25400
25403
|
}>;
|
|
25404
|
+
openCA(props: OpenCAProps): Promise<CommonResult>;
|
|
25401
25405
|
/**
|
|
25402
25406
|
* Returns raw txs that are needed to update all price feeds so that all credit accounts (possibly from different markets) compute
|
|
25403
25407
|
* @param accounts
|
|
@@ -25530,4 +25534,4 @@ type MulticallErrorType = GetChainContractAddressErrorType | ReadContractErrorTy
|
|
|
25530
25534
|
*/
|
|
25531
25535
|
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>>;
|
|
25532
25536
|
|
|
25533
|
-
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 ClaimFarmRewardsProps, type CloseCreditAccountResult, type ClosePathBalances, type CommonResult, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountDataSlice, 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,
|
|
25537
|
+
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 ClaimFarmRewardsProps, type CloseCreditAccountResult, type ClosePathBalances, type CommonResult, CompositePriceFeedContract, type ConnectionOptions, type ContractMethod, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, type CoreStateHuman, type CreditAccountData, type CreditAccountDataSlice, 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, type PermitResult, 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, assetsMap, balancesMap, 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, tokenToTicker };
|
package/dist/esm/sdk/index.mjs
CHANGED
|
@@ -20161,6 +20161,12 @@ var CreditFacadeV300Contract = class extends BaseContract {
|
|
|
20161
20161
|
args: [ca, calls]
|
|
20162
20162
|
});
|
|
20163
20163
|
}
|
|
20164
|
+
openCreditAccount(to, calls, referralCode) {
|
|
20165
|
+
return this.createRawTx({
|
|
20166
|
+
functionName: "openCreditAccount",
|
|
20167
|
+
args: [to, calls, referralCode]
|
|
20168
|
+
});
|
|
20169
|
+
}
|
|
20164
20170
|
parseFunctionParams(params) {
|
|
20165
20171
|
switch (params.functionName) {
|
|
20166
20172
|
case "openCreditAccount": {
|
|
@@ -20290,6 +20296,12 @@ var CreditFacadeV310Contract = class extends BaseContract {
|
|
|
20290
20296
|
args: [ca, calls]
|
|
20291
20297
|
});
|
|
20292
20298
|
}
|
|
20299
|
+
openCreditAccount(to, calls, referralCode) {
|
|
20300
|
+
return this.createRawTx({
|
|
20301
|
+
functionName: "openCreditAccount",
|
|
20302
|
+
args: [to, calls, referralCode]
|
|
20303
|
+
});
|
|
20304
|
+
}
|
|
20293
20305
|
parseFunctionParams(params) {
|
|
20294
20306
|
switch (params.functionName) {
|
|
20295
20307
|
case "openCreditAccount": {
|
|
@@ -22836,12 +22848,13 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
22836
22848
|
account,
|
|
22837
22849
|
void 0
|
|
22838
22850
|
);
|
|
22851
|
+
const calls = [...priceUpdates, ...routerCloseResult.calls];
|
|
22839
22852
|
const tx = cm.creditFacade.liquidateCreditAccount(
|
|
22840
22853
|
account.creditAccount,
|
|
22841
22854
|
to,
|
|
22842
|
-
|
|
22855
|
+
calls
|
|
22843
22856
|
);
|
|
22844
|
-
return { tx, routerCloseResult };
|
|
22857
|
+
return { tx, calls, routerCloseResult };
|
|
22845
22858
|
}
|
|
22846
22859
|
/**
|
|
22847
22860
|
* Closes credit account or sets debt to zero (but keep account)
|
|
@@ -23070,27 +23083,63 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
23070
23083
|
return { tx, calls };
|
|
23071
23084
|
}
|
|
23072
23085
|
async claimFarmRewards(props) {
|
|
23073
|
-
const { tokensToDisable, calls: claimCalls, creditAccount } = props;
|
|
23086
|
+
const { tokensToDisable, calls: claimCalls, creditAccount: ca } = props;
|
|
23074
23087
|
if (claimCalls.length === 0) throw new Error("No path to execute");
|
|
23075
|
-
const cm = this.sdk.marketRegister.findCreditManager(
|
|
23076
|
-
creditAccount.creditManager
|
|
23077
|
-
);
|
|
23088
|
+
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
23078
23089
|
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
23079
|
-
|
|
23080
|
-
|
|
23090
|
+
ca.creditManager,
|
|
23091
|
+
ca,
|
|
23081
23092
|
props.averageQuota
|
|
23082
23093
|
);
|
|
23083
23094
|
const calls = [
|
|
23084
23095
|
...priceUpdatesCalls,
|
|
23085
23096
|
...claimCalls,
|
|
23086
23097
|
...tokensToDisable.map(
|
|
23087
|
-
(a) => this.#prepareDisableToken(
|
|
23098
|
+
(a) => this.#prepareDisableToken(ca.creditFacade, a.token)
|
|
23088
23099
|
),
|
|
23089
|
-
...this.#prepareUpdateQuotas(
|
|
23100
|
+
...this.#prepareUpdateQuotas(ca.creditFacade, props)
|
|
23090
23101
|
];
|
|
23091
|
-
const tx = cm.creditFacade.multicall(
|
|
23102
|
+
const tx = cm.creditFacade.multicall(ca.creditAccount, calls);
|
|
23092
23103
|
return { tx, calls };
|
|
23093
23104
|
}
|
|
23105
|
+
async openCA(props) {
|
|
23106
|
+
const {
|
|
23107
|
+
ethAmount,
|
|
23108
|
+
creditManager,
|
|
23109
|
+
collateral,
|
|
23110
|
+
permits,
|
|
23111
|
+
debt,
|
|
23112
|
+
withdrawDebt,
|
|
23113
|
+
referralCode,
|
|
23114
|
+
to,
|
|
23115
|
+
calls: openPathCalls
|
|
23116
|
+
} = props;
|
|
23117
|
+
const cmFactory = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
23118
|
+
const cm = cmFactory.creditManager;
|
|
23119
|
+
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
23120
|
+
cm.address,
|
|
23121
|
+
void 0,
|
|
23122
|
+
props.averageQuota
|
|
23123
|
+
);
|
|
23124
|
+
const calls = [
|
|
23125
|
+
...priceUpdatesCalls,
|
|
23126
|
+
this.#prepareIncreaseDebt(cm.creditFacade, debt),
|
|
23127
|
+
...this.#prepareAddCollateral(cm.creditFacade, collateral, permits),
|
|
23128
|
+
...this.#prepareUpdateQuotas(cm.creditFacade, props),
|
|
23129
|
+
...openPathCalls,
|
|
23130
|
+
...withdrawDebt ? [this.#prepareWithdrawToken(cm.creditFacade, cm.underlying, debt, to)] : []
|
|
23131
|
+
];
|
|
23132
|
+
const tx = cmFactory.creditFacade.openCreditAccount(
|
|
23133
|
+
to,
|
|
23134
|
+
calls,
|
|
23135
|
+
referralCode
|
|
23136
|
+
);
|
|
23137
|
+
tx.value = ethAmount.toString(10);
|
|
23138
|
+
return {
|
|
23139
|
+
calls,
|
|
23140
|
+
tx
|
|
23141
|
+
};
|
|
23142
|
+
}
|
|
23094
23143
|
/**
|
|
23095
23144
|
* Internal wrapper for CreditAccountCompressor.getCreditAccounts + price updates wrapped into multicall
|
|
23096
23145
|
* @param args
|
|
@@ -23317,6 +23366,16 @@ var CreditAccountsService = class extends SDKConstruct {
|
|
|
23317
23366
|
})
|
|
23318
23367
|
};
|
|
23319
23368
|
}
|
|
23369
|
+
#prepareIncreaseDebt(creditFacade, debt) {
|
|
23370
|
+
return {
|
|
23371
|
+
target: creditFacade,
|
|
23372
|
+
callData: encodeFunctionData({
|
|
23373
|
+
abi: iCreditFacadeV3MulticallAbi,
|
|
23374
|
+
functionName: "increaseDebt",
|
|
23375
|
+
args: [debt]
|
|
23376
|
+
})
|
|
23377
|
+
};
|
|
23378
|
+
}
|
|
23320
23379
|
#prepareChangeDebt(creditFacade, change, isDecrease) {
|
|
23321
23380
|
return {
|
|
23322
23381
|
target: creditFacade,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-vfour.
|
|
3
|
+
"version": "3.0.0-vfour.98",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.cjs",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"typecheck:ci": "tsc --noEmit"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@gearbox-protocol/sdk-gov": "^2.
|
|
50
|
+
"@gearbox-protocol/sdk-gov": "^2.25.0",
|
|
51
51
|
"@redstone-finance/evm-connector": "^0.6.2",
|
|
52
52
|
"abitype": "^1.0.6",
|
|
53
53
|
"date-fns": "^4.1.0",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"pino": "^9.5.0",
|
|
66
66
|
"pino-pretty": "^11.3.0",
|
|
67
67
|
"prettier": "^3.3.3",
|
|
68
|
-
"tsup": "^8.3.
|
|
69
|
-
"tsx": "^4.19.
|
|
68
|
+
"tsup": "^8.3.5",
|
|
69
|
+
"tsx": "^4.19.2",
|
|
70
70
|
"typescript": "^5.6.3"
|
|
71
71
|
},
|
|
72
72
|
"commitlint": {
|