@gearbox-protocol/sdk 10.9.0 → 11.0.0-next.1
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/AbstractCreditAccountsService.js +1 -4
- package/dist/cjs/sdk/market/loss-policy/AliasLossPolicyV310Contract.js +1 -0
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +6 -18
- package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +1 -3
- package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +1 -3
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +1 -4
- package/dist/esm/sdk/market/loss-policy/AliasLossPolicyV310Contract.js +1 -0
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +6 -18
- package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +1 -3
- package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +1 -3
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +3 -6
- package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/updates/types.d.ts +1 -1
- package/package.json +4 -4
|
@@ -931,10 +931,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
931
931
|
{ account: creditAccount?.creditAccount, manager: cm.name },
|
|
932
932
|
`generating price feed updates for ${tStr} from ${priceFeeds.length}${remark} price feeds`
|
|
933
933
|
);
|
|
934
|
-
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
|
|
935
|
-
priceFeeds,
|
|
936
|
-
creditAccount ? { account: creditAccount.creditAccount } : void 0
|
|
937
|
-
);
|
|
934
|
+
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
938
935
|
}
|
|
939
936
|
/**
|
|
940
937
|
* Returns account price updates that can be used in credit facade multicall or liquidator calls
|
|
@@ -42,6 +42,7 @@ class AliasLossPolicyV310Contract extends import_base.BaseContract {
|
|
|
42
42
|
args: [creditAccount],
|
|
43
43
|
blockNumber
|
|
44
44
|
});
|
|
45
|
+
this.logger?.debug({ feeds: pfs }, "got required alias price feeds");
|
|
45
46
|
const updates = await this.sdk.priceFeeds.generateExternalPriceFeedsUpdates(
|
|
46
47
|
[...pfs],
|
|
47
48
|
blockNumber ? { blockNumber } : void 0
|
|
@@ -74,10 +74,9 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
74
74
|
* @param priceFeeds Array oftop-level price feeds, actual updatable price feeds will be derived.
|
|
75
75
|
* Or filter criteria, that will gather all main or reserve price feeds from all oracles
|
|
76
76
|
* If not provided will use all price feeds that are attached
|
|
77
|
-
* @param logContext extra information for logging
|
|
78
77
|
* @returns
|
|
79
78
|
*/
|
|
80
|
-
async generatePriceFeedsUpdateTxs(priceFeeds
|
|
79
|
+
async generatePriceFeedsUpdateTxs(priceFeeds) {
|
|
81
80
|
let updateables = this.#feeds.values();
|
|
82
81
|
let filterRemark = "";
|
|
83
82
|
if (priceFeeds) {
|
|
@@ -96,9 +95,7 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
96
95
|
updates: [],
|
|
97
96
|
timestamp: Math.floor(Date.now() / 1e3)
|
|
98
97
|
};
|
|
99
|
-
const updates = (await Promise.all(
|
|
100
|
-
this.updaters.map((u) => u.getUpdateTxs(updateables, logContext))
|
|
101
|
-
)).flat();
|
|
98
|
+
const updates = (await Promise.all(this.updaters.map((u) => u.getUpdateTxs(updateables)))).flat();
|
|
102
99
|
let maxTimestamp = 0;
|
|
103
100
|
for (const tx of updates) {
|
|
104
101
|
const { data } = tx;
|
|
@@ -115,7 +112,6 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
115
112
|
const result = { txs, timestamp: maxTimestamp };
|
|
116
113
|
const tsDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
117
114
|
this.logger?.debug(
|
|
118
|
-
logContext,
|
|
119
115
|
`generated ${txs.length}${filterRemark} price feed update transactions, timestamp: ${maxTimestamp} (delta ${tsDelta})`
|
|
120
116
|
);
|
|
121
117
|
if (txs.length) {
|
|
@@ -127,28 +123,20 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
127
123
|
/**
|
|
128
124
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
129
125
|
* @param priceFeeds
|
|
130
|
-
* @param logContext
|
|
131
126
|
* @returns
|
|
132
127
|
*/
|
|
133
|
-
async generatePriceFeedsUpdates(priceFeeds
|
|
134
|
-
const updates = await this.generatePriceFeedsUpdateTxs(
|
|
135
|
-
priceFeeds,
|
|
136
|
-
logContext
|
|
137
|
-
);
|
|
128
|
+
async generatePriceFeedsUpdates(priceFeeds) {
|
|
129
|
+
const updates = await this.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
138
130
|
return (0, import_getRawPriceUpdates.getRawPriceUpdates)(updates);
|
|
139
131
|
}
|
|
140
132
|
/**
|
|
141
133
|
* Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
|
|
142
134
|
* @param priceFeeds
|
|
143
|
-
* @param logContext
|
|
144
135
|
* @returns
|
|
145
136
|
*/
|
|
146
|
-
async getPriceFeedStoreUpdateTx(priceFeeds
|
|
137
|
+
async getPriceFeedStoreUpdateTx(priceFeeds) {
|
|
147
138
|
const pfs = this.sdk.addressProvider.getAddress(import_constants.AP_PRICE_FEED_STORE);
|
|
148
|
-
const updates = await this.generatePriceFeedsUpdates(
|
|
149
|
-
priceFeeds,
|
|
150
|
-
logContext
|
|
151
|
-
);
|
|
139
|
+
const updates = await this.generatePriceFeedsUpdates(priceFeeds);
|
|
152
140
|
return (0, import_utils.createRawTx)(pfs, {
|
|
153
141
|
abi: (0, import_viem.parseAbi)(["function updatePrices((address,bytes)[])"]),
|
|
154
142
|
functionName: "updatePrices",
|
|
@@ -82,9 +82,8 @@ class PythUpdater extends import_base.SDKConstruct {
|
|
|
82
82
|
historical: !!ts
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
-
async getUpdateTxs(feeds
|
|
85
|
+
async getUpdateTxs(feeds) {
|
|
86
86
|
this.#logger?.debug(
|
|
87
|
-
logContext,
|
|
88
87
|
`generating update transactions for ${feeds.length} pyth price feeds`
|
|
89
88
|
);
|
|
90
89
|
const pythFeeds = new Map(
|
|
@@ -120,7 +119,6 @@ class PythUpdater extends import_base.SDKConstruct {
|
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
this.#logger?.debug(
|
|
123
|
-
logContext,
|
|
124
122
|
`generated ${results.length} update transactions for pyth price feeds: ${Array.from(pythFeeds.keys()).join(", ")}${tsRange}`
|
|
125
123
|
);
|
|
126
124
|
return results;
|
|
@@ -89,9 +89,8 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
89
89
|
historical: !!ts
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
async getUpdateTxs(feeds
|
|
92
|
+
async getUpdateTxs(feeds) {
|
|
93
93
|
this.#logger?.debug(
|
|
94
|
-
logContext,
|
|
95
94
|
`generating update transactions for ${feeds.length} redstone price feeds`
|
|
96
95
|
);
|
|
97
96
|
const groupedFeeds = {};
|
|
@@ -149,7 +148,6 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
150
|
this.#logger?.debug(
|
|
152
|
-
logContext,
|
|
153
151
|
`generated ${results.length} update transactions for redstone price feeds: ${Array.from(priceFeeds.keys()).join(", ")}${tsRange}`
|
|
154
152
|
);
|
|
155
153
|
return results;
|
|
@@ -921,10 +921,7 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
921
921
|
{ account: creditAccount?.creditAccount, manager: cm.name },
|
|
922
922
|
`generating price feed updates for ${tStr} from ${priceFeeds.length}${remark} price feeds`
|
|
923
923
|
);
|
|
924
|
-
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(
|
|
925
|
-
priceFeeds,
|
|
926
|
-
creditAccount ? { account: creditAccount.creditAccount } : void 0
|
|
927
|
-
);
|
|
924
|
+
return this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
928
925
|
}
|
|
929
926
|
/**
|
|
930
927
|
* Returns account price updates that can be used in credit facade multicall or liquidator calls
|
|
@@ -19,6 +19,7 @@ class AliasLossPolicyV310Contract extends BaseContract {
|
|
|
19
19
|
args: [creditAccount],
|
|
20
20
|
blockNumber
|
|
21
21
|
});
|
|
22
|
+
this.logger?.debug({ feeds: pfs }, "got required alias price feeds");
|
|
22
23
|
const updates = await this.sdk.priceFeeds.generateExternalPriceFeedsUpdates(
|
|
23
24
|
[...pfs],
|
|
24
25
|
blockNumber ? { blockNumber } : void 0
|
|
@@ -63,10 +63,9 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
63
63
|
* @param priceFeeds Array oftop-level price feeds, actual updatable price feeds will be derived.
|
|
64
64
|
* Or filter criteria, that will gather all main or reserve price feeds from all oracles
|
|
65
65
|
* If not provided will use all price feeds that are attached
|
|
66
|
-
* @param logContext extra information for logging
|
|
67
66
|
* @returns
|
|
68
67
|
*/
|
|
69
|
-
async generatePriceFeedsUpdateTxs(priceFeeds
|
|
68
|
+
async generatePriceFeedsUpdateTxs(priceFeeds) {
|
|
70
69
|
let updateables = this.#feeds.values();
|
|
71
70
|
let filterRemark = "";
|
|
72
71
|
if (priceFeeds) {
|
|
@@ -85,9 +84,7 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
85
84
|
updates: [],
|
|
86
85
|
timestamp: Math.floor(Date.now() / 1e3)
|
|
87
86
|
};
|
|
88
|
-
const updates = (await Promise.all(
|
|
89
|
-
this.updaters.map((u) => u.getUpdateTxs(updateables, logContext))
|
|
90
|
-
)).flat();
|
|
87
|
+
const updates = (await Promise.all(this.updaters.map((u) => u.getUpdateTxs(updateables)))).flat();
|
|
91
88
|
let maxTimestamp = 0;
|
|
92
89
|
for (const tx of updates) {
|
|
93
90
|
const { data } = tx;
|
|
@@ -104,7 +101,6 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
104
101
|
const result = { txs, timestamp: maxTimestamp };
|
|
105
102
|
const tsDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
106
103
|
this.logger?.debug(
|
|
107
|
-
logContext,
|
|
108
104
|
`generated ${txs.length}${filterRemark} price feed update transactions, timestamp: ${maxTimestamp} (delta ${tsDelta})`
|
|
109
105
|
);
|
|
110
106
|
if (txs.length) {
|
|
@@ -116,28 +112,20 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
116
112
|
/**
|
|
117
113
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
118
114
|
* @param priceFeeds
|
|
119
|
-
* @param logContext
|
|
120
115
|
* @returns
|
|
121
116
|
*/
|
|
122
|
-
async generatePriceFeedsUpdates(priceFeeds
|
|
123
|
-
const updates = await this.generatePriceFeedsUpdateTxs(
|
|
124
|
-
priceFeeds,
|
|
125
|
-
logContext
|
|
126
|
-
);
|
|
117
|
+
async generatePriceFeedsUpdates(priceFeeds) {
|
|
118
|
+
const updates = await this.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
127
119
|
return getRawPriceUpdates(updates);
|
|
128
120
|
}
|
|
129
121
|
/**
|
|
130
122
|
* Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
|
|
131
123
|
* @param priceFeeds
|
|
132
|
-
* @param logContext
|
|
133
124
|
* @returns
|
|
134
125
|
*/
|
|
135
|
-
async getPriceFeedStoreUpdateTx(priceFeeds
|
|
126
|
+
async getPriceFeedStoreUpdateTx(priceFeeds) {
|
|
136
127
|
const pfs = this.sdk.addressProvider.getAddress(AP_PRICE_FEED_STORE);
|
|
137
|
-
const updates = await this.generatePriceFeedsUpdates(
|
|
138
|
-
priceFeeds,
|
|
139
|
-
logContext
|
|
140
|
-
);
|
|
128
|
+
const updates = await this.generatePriceFeedsUpdates(priceFeeds);
|
|
141
129
|
return createRawTx(pfs, {
|
|
142
130
|
abi: parseAbi(["function updatePrices((address,bytes)[])"]),
|
|
143
131
|
functionName: "updatePrices",
|
|
@@ -62,9 +62,8 @@ class PythUpdater extends SDKConstruct {
|
|
|
62
62
|
historical: !!ts
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
async getUpdateTxs(feeds
|
|
65
|
+
async getUpdateTxs(feeds) {
|
|
66
66
|
this.#logger?.debug(
|
|
67
|
-
logContext,
|
|
68
67
|
`generating update transactions for ${feeds.length} pyth price feeds`
|
|
69
68
|
);
|
|
70
69
|
const pythFeeds = new Map(
|
|
@@ -100,7 +99,6 @@ class PythUpdater extends SDKConstruct {
|
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
this.#logger?.debug(
|
|
103
|
-
logContext,
|
|
104
102
|
`generated ${results.length} update transactions for pyth price feeds: ${Array.from(pythFeeds.keys()).join(", ")}${tsRange}`
|
|
105
103
|
);
|
|
106
104
|
return results;
|
|
@@ -67,9 +67,8 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
67
67
|
historical: !!ts
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
async getUpdateTxs(feeds
|
|
70
|
+
async getUpdateTxs(feeds) {
|
|
71
71
|
this.#logger?.debug(
|
|
72
|
-
logContext,
|
|
73
72
|
`generating update transactions for ${feeds.length} redstone price feeds`
|
|
74
73
|
);
|
|
75
74
|
const groupedFeeds = {};
|
|
@@ -127,7 +126,6 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
this.#logger?.debug(
|
|
130
|
-
logContext,
|
|
131
129
|
`generated ${results.length} update transactions for redstone price feeds: ${Array.from(priceFeeds.keys()).join(", ")}${tsRange}`
|
|
132
130
|
);
|
|
133
131
|
return results;
|
|
@@ -42,36 +42,33 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
|
|
|
42
42
|
* @param priceFeeds Array oftop-level price feeds, actual updatable price feeds will be derived.
|
|
43
43
|
* Or filter criteria, that will gather all main or reserve price feeds from all oracles
|
|
44
44
|
* If not provided will use all price feeds that are attached
|
|
45
|
-
* @param logContext extra information for logging
|
|
46
45
|
* @returns
|
|
47
46
|
*/
|
|
48
47
|
generatePriceFeedsUpdateTxs(priceFeeds?: IPriceFeedContract[] | {
|
|
49
48
|
main: true;
|
|
50
49
|
} | {
|
|
51
50
|
reserve: true;
|
|
52
|
-
}
|
|
51
|
+
}): Promise<UpdatePriceFeedsResult>;
|
|
53
52
|
/**
|
|
54
53
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
55
54
|
* @param priceFeeds
|
|
56
|
-
* @param logContext
|
|
57
55
|
* @returns
|
|
58
56
|
*/
|
|
59
57
|
generatePriceFeedsUpdates(priceFeeds?: IPriceFeedContract[] | {
|
|
60
58
|
main: true;
|
|
61
59
|
} | {
|
|
62
60
|
reserve: true;
|
|
63
|
-
}
|
|
61
|
+
}): Promise<PriceUpdateV310[]>;
|
|
64
62
|
/**
|
|
65
63
|
* Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
|
|
66
64
|
* @param priceFeeds
|
|
67
|
-
* @param logContext
|
|
68
65
|
* @returns
|
|
69
66
|
*/
|
|
70
67
|
getPriceFeedStoreUpdateTx(priceFeeds?: IPriceFeedContract[] | {
|
|
71
68
|
main: true;
|
|
72
69
|
} | {
|
|
73
70
|
reserve: true;
|
|
74
|
-
}
|
|
71
|
+
}): Promise<RawTx>;
|
|
75
72
|
/**
|
|
76
73
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
|
|
77
74
|
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
@@ -21,6 +21,6 @@ export type PythOptions = z.infer<typeof PythOptions>;
|
|
|
21
21
|
export declare class PythUpdater extends SDKConstruct implements IPriceUpdater<PythUpdateTask> {
|
|
22
22
|
#private;
|
|
23
23
|
constructor(sdk: GearboxSDK, opts?: PythOptions);
|
|
24
|
-
getUpdateTxs(feeds: IPriceFeedContract[]
|
|
24
|
+
getUpdateTxs(feeds: IPriceFeedContract[]): Promise<PythUpdateTx[]>;
|
|
25
25
|
}
|
|
26
26
|
export {};
|
|
@@ -24,6 +24,6 @@ export type RedstoneOptions = z.infer<typeof RedstoneOptions>;
|
|
|
24
24
|
export declare class RedstoneUpdater extends SDKConstruct implements IPriceUpdater<RedstoneUpdateTask> {
|
|
25
25
|
#private;
|
|
26
26
|
constructor(sdk: GearboxSDK, opts?: RedstoneOptions);
|
|
27
|
-
getUpdateTxs(feeds: IPriceFeedContract[]
|
|
27
|
+
getUpdateTxs(feeds: IPriceFeedContract[]): Promise<RedstoneUpdateTx[]>;
|
|
28
28
|
}
|
|
29
29
|
export {};
|
|
@@ -8,7 +8,7 @@ export interface IPriceUpdateTask {
|
|
|
8
8
|
cached: boolean;
|
|
9
9
|
}
|
|
10
10
|
export interface IPriceUpdater<T extends IPriceUpdateTask = IPriceUpdateTask> {
|
|
11
|
-
getUpdateTxs: (feeds: IPriceFeedContract[]
|
|
11
|
+
getUpdateTxs: (feeds: IPriceFeedContract[]) => Promise<IPriceUpdateTx<T>[]>;
|
|
12
12
|
}
|
|
13
13
|
export interface TimestampedCalldata {
|
|
14
14
|
dataFeedId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-next.1",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"zod": "^4.1.12"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@biomejs/biome": "^2.3.
|
|
68
|
+
"@biomejs/biome": "^2.3.5",
|
|
69
69
|
"@commitlint/cli": "^20.1.0",
|
|
70
70
|
"@commitlint/config-conventional": "^20.0.0",
|
|
71
|
-
"@gearbox-protocol/biome-config": "^1.0.
|
|
71
|
+
"@gearbox-protocol/biome-config": "^1.0.11",
|
|
72
72
|
"@types/cross-spawn": "^6.0.6",
|
|
73
73
|
"axios": "^1.13.2",
|
|
74
74
|
"cross-spawn": "^7.0.6",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"tsx": "^4.20.6",
|
|
81
81
|
"typescript": "^5.9.3",
|
|
82
82
|
"viem-deal": "^2.0.4",
|
|
83
|
-
"vitest": "^4.0.
|
|
83
|
+
"vitest": "^4.0.8"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"axios": "^1.0.0",
|