@gearbox-protocol/sdk 13.0.0-beta.7 → 13.0.0-beta.9
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/accounts/CreditAccountsServiceV310.js +4 -5
- package/dist/cjs/sdk/constants/versions.js +0 -3
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +4 -5
- package/dist/esm/sdk/constants/versions.js +0 -2
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +2 -2
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +10 -18
- package/dist/types/sdk/constants/versions.d.ts +0 -1
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -2
- package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +2 -2
- package/dist/types/sdk/market/oracle/types.d.ts +5 -7
- package/package.json +7 -7
|
@@ -180,18 +180,17 @@ class CreditAccountServiceV310 extends import_AbstractCreditAccountsService.Abst
|
|
|
180
180
|
* Implements {@link ICreditAccountsService.claimFarmRewards}
|
|
181
181
|
*/
|
|
182
182
|
async claimFarmRewards({
|
|
183
|
-
calls:
|
|
183
|
+
calls: externalCalls,
|
|
184
184
|
creditAccount: ca,
|
|
185
185
|
minQuota,
|
|
186
186
|
averageQuota,
|
|
187
|
-
tokensToClaim
|
|
188
|
-
forceCalls
|
|
187
|
+
tokensToClaim
|
|
189
188
|
}) {
|
|
190
189
|
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
191
190
|
const router = this.sdk.routerFor(ca);
|
|
192
191
|
let claimPath;
|
|
193
|
-
if (
|
|
194
|
-
claimPath = { calls:
|
|
192
|
+
if (externalCalls) {
|
|
193
|
+
claimPath = { calls: externalCalls };
|
|
195
194
|
} else {
|
|
196
195
|
claimPath = await router.findClaimAllRewards({
|
|
197
196
|
tokensToClaim,
|
|
@@ -18,13 +18,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var versions_exports = {};
|
|
20
20
|
__export(versions_exports, {
|
|
21
|
-
VERSION_RANGE_300: () => VERSION_RANGE_300,
|
|
22
21
|
VERSION_RANGE_310: () => VERSION_RANGE_310,
|
|
23
22
|
isV310: () => isV310,
|
|
24
23
|
isVersionRange: () => isVersionRange
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(versions_exports);
|
|
27
|
-
const VERSION_RANGE_300 = [300, 309];
|
|
28
26
|
const VERSION_RANGE_310 = [310, 319];
|
|
29
27
|
function isV310(version) {
|
|
30
28
|
return isVersionRange(version, VERSION_RANGE_310);
|
|
@@ -34,7 +32,6 @@ function isVersionRange(version, range) {
|
|
|
34
32
|
}
|
|
35
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
34
|
0 && (module.exports = {
|
|
37
|
-
VERSION_RANGE_300,
|
|
38
35
|
VERSION_RANGE_310,
|
|
39
36
|
isV310,
|
|
40
37
|
isVersionRange
|
|
@@ -157,18 +157,17 @@ class CreditAccountServiceV310 extends AbstractCreditAccountService {
|
|
|
157
157
|
* Implements {@link ICreditAccountsService.claimFarmRewards}
|
|
158
158
|
*/
|
|
159
159
|
async claimFarmRewards({
|
|
160
|
-
calls:
|
|
160
|
+
calls: externalCalls,
|
|
161
161
|
creditAccount: ca,
|
|
162
162
|
minQuota,
|
|
163
163
|
averageQuota,
|
|
164
|
-
tokensToClaim
|
|
165
|
-
forceCalls
|
|
164
|
+
tokensToClaim
|
|
166
165
|
}) {
|
|
167
166
|
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
168
167
|
const router = this.sdk.routerFor(ca);
|
|
169
168
|
let claimPath;
|
|
170
|
-
if (
|
|
171
|
-
claimPath = { calls:
|
|
169
|
+
if (externalCalls) {
|
|
170
|
+
claimPath = { calls: externalCalls };
|
|
172
171
|
} else {
|
|
173
172
|
claimPath = await router.findClaimAllRewards({
|
|
174
173
|
tokensToClaim,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const VERSION_RANGE_300 = [300, 309];
|
|
2
1
|
const VERSION_RANGE_310 = [310, 319];
|
|
3
2
|
function isV310(version) {
|
|
4
3
|
return isVersionRange(version, VERSION_RANGE_310);
|
|
@@ -7,7 +6,6 @@ function isVersionRange(version, range) {
|
|
|
7
6
|
return Number(version) >= range[0] && Number(version) <= range[1];
|
|
8
7
|
}
|
|
9
8
|
export {
|
|
10
|
-
VERSION_RANGE_300,
|
|
11
9
|
VERSION_RANGE_310,
|
|
12
10
|
isV310,
|
|
13
11
|
isVersionRange
|
|
@@ -2,7 +2,7 @@ import type { Address } from "viem";
|
|
|
2
2
|
import type { CreditAccountData } from "../base/index.js";
|
|
3
3
|
import { SDKConstruct } from "../base/index.js";
|
|
4
4
|
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
5
|
-
import type { OnDemandPriceUpdates,
|
|
5
|
+
import type { OnDemandPriceUpdates, UpdatePriceFeedsResult } from "../market/index.js";
|
|
6
6
|
import { type Asset, type RouterCASlice } from "../router/index.js";
|
|
7
7
|
import type { MultiCall } from "../types/index.js";
|
|
8
8
|
import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, PriceUpdatesOptions, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
|
|
@@ -191,7 +191,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
191
191
|
* @param options
|
|
192
192
|
* @returns
|
|
193
193
|
*/
|
|
194
|
-
getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates
|
|
194
|
+
getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates>;
|
|
195
195
|
/**
|
|
196
196
|
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
|
|
197
197
|
* - If there are desiredQuotas and creditAccount update quotaBalance > 0 || (balance > 10n && isEnabled). Is used when account has both: balances and quota buys.
|
|
@@ -20,7 +20,7 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
|
|
|
20
20
|
/**
|
|
21
21
|
* Implements {@link ICreditAccountsService.claimFarmRewards}
|
|
22
22
|
*/
|
|
23
|
-
claimFarmRewards({ calls:
|
|
23
|
+
claimFarmRewards({ calls: externalCalls, creditAccount: ca, minQuota, averageQuota, tokensToClaim, }: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
|
|
24
24
|
previewWithdrawLlamathenaProportionally(_: PreviewWithdrawLlamathenaProportionallyProps): Promise<PreviewWithdrawLlamathenaProportionallyResult>;
|
|
25
25
|
withdrawLlamathenaProportionally(_: LlamathenaProportionalWithdrawProps): Promise<CreditAccountOperationResult>;
|
|
26
26
|
}
|
|
@@ -3,7 +3,7 @@ import type { creditAccountCompressorAbi } from "../../abi/compressors/creditAcc
|
|
|
3
3
|
import type { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
|
|
4
4
|
import type { ConnectedBotData, Construct, CreditAccountData } from "../base/index.js";
|
|
5
5
|
import type { GearboxSDK } from "../GearboxSDK.js";
|
|
6
|
-
import type { CreditSuite, OnDemandPriceUpdates,
|
|
6
|
+
import type { CreditSuite, OnDemandPriceUpdates, UpdatePriceFeedsResult } from "../market/index.js";
|
|
7
7
|
import type { Asset, CreditAccountTokensSlice, RouterCASlice, RouterCloseResult } from "../router/index.js";
|
|
8
8
|
import type { MultiCall, RawTx } from "../types/index.js";
|
|
9
9
|
export type GetCreditAccountsArgs = ContractFunctionArgs<typeof creditAccountCompressorAbi, "pure" | "view", "getCreditAccounts">;
|
|
@@ -235,15 +235,17 @@ export interface ClaimFarmRewardsProps extends PrepareUpdateQuotasProps {
|
|
|
235
235
|
*/
|
|
236
236
|
tokensToDisable: Array<Asset>;
|
|
237
237
|
/**
|
|
238
|
-
*
|
|
238
|
+
* External calls to execute instead of finding claim path
|
|
239
239
|
*/
|
|
240
|
-
calls: Array<MultiCall
|
|
240
|
+
calls: Array<MultiCall> | undefined;
|
|
241
241
|
/**
|
|
242
242
|
* minimal credit account data on which operation is performed
|
|
243
243
|
*/
|
|
244
244
|
creditAccount: RouterCASlice;
|
|
245
|
+
/**
|
|
246
|
+
* List of token rewards of which we want to claim
|
|
247
|
+
*/
|
|
245
248
|
tokensToClaim: Asset[];
|
|
246
|
-
forceCalls?: boolean;
|
|
247
249
|
}
|
|
248
250
|
export interface OpenCAProps extends PrepareUpdateQuotasProps {
|
|
249
251
|
/**
|
|
@@ -315,10 +317,6 @@ export interface FullyLiquidateProps {
|
|
|
315
317
|
* Slippage in PERCENTAGE_FORMAT (100% = 10_000) per operation
|
|
316
318
|
*/
|
|
317
319
|
slippage?: bigint;
|
|
318
|
-
/**
|
|
319
|
-
* TODO: legacy v3 option to remove
|
|
320
|
-
*/
|
|
321
|
-
force?: boolean;
|
|
322
320
|
/**
|
|
323
321
|
* List of assets to keep on account after liquidation
|
|
324
322
|
*/
|
|
@@ -459,7 +457,7 @@ export interface ICreditAccountsService extends Construct {
|
|
|
459
457
|
additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
|
|
460
458
|
}>;
|
|
461
459
|
/**
|
|
462
|
-
*
|
|
460
|
+
* Connects/disables a bot and updates prices
|
|
463
461
|
* @param props - {@link SetBotProps}
|
|
464
462
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
465
463
|
*/
|
|
@@ -569,7 +567,7 @@ export interface ICreditAccountsService extends Construct {
|
|
|
569
567
|
* @param options
|
|
570
568
|
* @returns
|
|
571
569
|
*/
|
|
572
|
-
getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates
|
|
570
|
+
getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates>;
|
|
573
571
|
/**
|
|
574
572
|
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
|
|
575
573
|
* @param options
|
|
@@ -588,8 +586,6 @@ export interface ICreditAccountsService extends Construct {
|
|
|
588
586
|
* Fully repays credit account or repays credit account and keeps it open with zero debt
|
|
589
587
|
* - Repays in the following order: price update -> add collateral to cover the debt ->
|
|
590
588
|
* -> disable quotas for all tokens -> decrease debt -> disable tokens all tokens -> withdraw all tokens
|
|
591
|
-
* - V3.0 claims rewards for tokens which are specified in legacy SDK
|
|
592
|
-
* - V3.1 claims rewards for all tokens IF router is also V3.1
|
|
593
589
|
* @param props - {@link RepayCreditAccountProps}
|
|
594
590
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
595
591
|
*/
|
|
@@ -598,18 +594,14 @@ export interface ICreditAccountsService extends Construct {
|
|
|
598
594
|
* Fully repays liquidatable account
|
|
599
595
|
* - Repay and liquidate is executed in the following order: price update -> add collateral to cover the debt ->
|
|
600
596
|
* withdraw all tokens from credit account
|
|
601
|
-
* - V3.0 claims rewards for tokens which are specified in legacy SDK
|
|
602
|
-
* - V3.1 claims rewards for all tokens IF router is also V3.1
|
|
603
597
|
* @param props - {@link RepayAndLiquidateCreditAccountProps}
|
|
604
598
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
605
599
|
*/
|
|
606
600
|
repayAndLiquidateCreditAccount(props: RepayAndLiquidateCreditAccountProps): Promise<CreditAccountOperationResult>;
|
|
607
601
|
/**
|
|
608
|
-
*
|
|
602
|
+
* Claims farm rewards and optionally updates quotas
|
|
609
603
|
* - Claim rewards is executed in the following order: price update -> execute claim calls ->
|
|
610
|
-
* -> (optionally:
|
|
611
|
-
* - V3.0 claims rewards for tokens which are specified in legacy SDK
|
|
612
|
-
* - V3.1 claims rewards for all tokens IF router is also V3.1 and falls back to legacy calls if router is not v3.0
|
|
604
|
+
* -> (optionally: update quotas)
|
|
613
605
|
* @param props - {@link ClaimFarmRewardsProps}
|
|
614
606
|
* @return All necessary data to execute the transaction (call, credit facade)
|
|
615
607
|
*/
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Version range, inclusive of both ends
|
|
3
3
|
*/
|
|
4
4
|
export type VersionRange = [number, number];
|
|
5
|
-
export declare const VERSION_RANGE_300: VersionRange;
|
|
6
5
|
export declare const VERSION_RANGE_310: VersionRange;
|
|
7
6
|
export declare function isV310(version: number | bigint | string): boolean;
|
|
8
7
|
export declare function isVersionRange(version: number | bigint | string, range: VersionRange): boolean;
|
|
@@ -5,7 +5,7 @@ import { BaseContract } from "../../base/index.js";
|
|
|
5
5
|
import type { GearboxSDK } from "../../GearboxSDK.js";
|
|
6
6
|
import type { PriceOracleStateHuman } from "../../types/index.js";
|
|
7
7
|
import { AddressMap } from "../../utils/index.js";
|
|
8
|
-
import type { IPriceFeedContract,
|
|
8
|
+
import type { IPriceFeedContract, UpdatePriceFeedsResult } from "../pricefeeds/index.js";
|
|
9
9
|
import { PriceFeedRef } from "../pricefeeds/index.js";
|
|
10
10
|
import PriceFeedAnswerMap from "./PriceFeedAnswerMap.js";
|
|
11
11
|
import type { DelegatedOracleMulticall, IPriceOracleContract, OnDemandPriceUpdates, PriceFeedsForTokensOptions } from "./types.js";
|
|
@@ -36,7 +36,7 @@ export declare abstract class PriceOracleBaseContract<abi extends Abi | readonly
|
|
|
36
36
|
* @returns
|
|
37
37
|
*/
|
|
38
38
|
priceFeedsForTokens(tokens: Address[], opts?: PriceFeedsForTokensOptions): IPriceFeedContract[];
|
|
39
|
-
abstract onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates
|
|
39
|
+
abstract onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates;
|
|
40
40
|
/**
|
|
41
41
|
* Gets main price for given token
|
|
42
42
|
* Throws if token price feed is not found or answer is not successful
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Address, type ContractEventName, type Log } from "viem";
|
|
2
2
|
import type { PriceOracleData } from "../../base/index.js";
|
|
3
3
|
import type { GearboxSDK } from "../../GearboxSDK.js";
|
|
4
|
-
import { type
|
|
4
|
+
import { type UpdatePriceFeedsResult } from "../pricefeeds/index.js";
|
|
5
5
|
import { PriceOracleBaseContract } from "./PriceOracleBaseContract.js";
|
|
6
6
|
import type { OnDemandPriceUpdates } from "./types.js";
|
|
7
7
|
declare const abi: readonly [{
|
|
@@ -348,7 +348,7 @@ export declare class PriceOracleV310Contract extends PriceOracleBaseContract<abi
|
|
|
348
348
|
* @param updates
|
|
349
349
|
* @returns
|
|
350
350
|
*/
|
|
351
|
-
onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates
|
|
351
|
+
onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates;
|
|
352
352
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
353
353
|
}
|
|
354
354
|
export {};
|
|
@@ -10,13 +10,11 @@ export interface PriceFeedsForTokensOptions {
|
|
|
10
10
|
reserve?: boolean;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* as raw PriceUpdate in liquidator calls
|
|
15
|
-
* T is (priceFeed, data)
|
|
16
|
-
* TODO: should be removed after v310 migration
|
|
13
|
+
* On demand price updates acceptable by both credit facade multicall and
|
|
14
|
+
* as raw PriceUpdate in liquidator calls.
|
|
17
15
|
*/
|
|
18
|
-
export interface OnDemandPriceUpdates
|
|
19
|
-
raw:
|
|
16
|
+
export interface OnDemandPriceUpdates {
|
|
17
|
+
raw: PriceUpdateV310[];
|
|
20
18
|
multicall: MultiCall[];
|
|
21
19
|
}
|
|
22
20
|
export interface IPriceOracleContract extends IBaseContract {
|
|
@@ -78,7 +76,7 @@ export interface IPriceOracleContract extends IBaseContract {
|
|
|
78
76
|
* @param updates
|
|
79
77
|
* @returns
|
|
80
78
|
*/
|
|
81
|
-
onDemandPriceUpdates: (creditFacade: Address, updates?: UpdatePriceFeedsResult) => OnDemandPriceUpdates
|
|
79
|
+
onDemandPriceUpdates: (creditFacade: Address, updates?: UpdatePriceFeedsResult) => OnDemandPriceUpdates;
|
|
82
80
|
/**
|
|
83
81
|
* Tries to convert amount of from one token to another, using latest known prices
|
|
84
82
|
* @param from
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "13.0.0-beta.
|
|
3
|
+
"version": "13.0.0-beta.9",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -80,22 +80,22 @@
|
|
|
80
80
|
"zod": "^4.3.6"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@biomejs/biome": "^2.4.
|
|
84
|
-
"@commitlint/cli": "^20.
|
|
85
|
-
"@commitlint/config-conventional": "^20.
|
|
86
|
-
"@gearbox-protocol/biome-config": "^1.0.
|
|
83
|
+
"@biomejs/biome": "^2.4.9",
|
|
84
|
+
"@commitlint/cli": "^20.5.0",
|
|
85
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
86
|
+
"@gearbox-protocol/biome-config": "^1.0.24",
|
|
87
87
|
"@types/cross-spawn": "^6.0.6",
|
|
88
88
|
"axios": "^1.13.6",
|
|
89
89
|
"cross-spawn": "^7.0.6",
|
|
90
90
|
"husky": "^9.1.7",
|
|
91
|
-
"lint-staged": "^16.
|
|
91
|
+
"lint-staged": "^16.4.0",
|
|
92
92
|
"pino": "^10.3.1",
|
|
93
93
|
"pino-pretty": "^13.1.3",
|
|
94
94
|
"tsup": "^8.5.1",
|
|
95
95
|
"tsx": "^4.21.0",
|
|
96
96
|
"typescript": "^5.9.3",
|
|
97
97
|
"viem-deal": "^2.0.4",
|
|
98
|
-
"vitest": "^4.
|
|
98
|
+
"vitest": "^4.1.1"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
101
|
"axios": "^1.0.0",
|