@gearbox-protocol/sdk 8.19.5 → 8.19.7
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/market/pricefeeds/PriceFeedsRegister.js +16 -13
- package/dist/cjs/sdk/market/pricefeeds/getRawPriceUpdates.js +41 -0
- package/dist/cjs/sdk/market/pricefeeds/index.js +2 -0
- package/dist/cjs/sdk/utils/viem/sendRawTx.js +2 -3
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +16 -15
- package/dist/esm/sdk/market/pricefeeds/getRawPriceUpdates.js +17 -0
- package/dist/esm/sdk/market/pricefeeds/index.js +1 -0
- package/dist/esm/sdk/utils/viem/sendRawTx.js +2 -3
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +10 -6
- package/dist/types/sdk/market/pricefeeds/getRawPriceUpdates.d.ts +2 -0
- package/dist/types/sdk/market/pricefeeds/index.d.ts +1 -0
- package/dist/types/sdk/market/pricefeeds/types.d.ts +11 -1
- package/dist/types/sdk/utils/viem/sendRawTx.d.ts +5 -5
- package/package.json +1 -1
|
@@ -21,9 +21,7 @@ __export(PriceFeedsRegister_exports, {
|
|
|
21
21
|
PriceFeedRegister: () => PriceFeedRegister
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(PriceFeedsRegister_exports);
|
|
24
|
-
var import_viem = require("viem");
|
|
25
24
|
var import_compressors = require("../../../abi/compressors.js");
|
|
26
|
-
var import_iUpdatablePriceFeed = require("../../../abi/iUpdatablePriceFeed.js");
|
|
27
25
|
var import_base = require("../../base/index.js");
|
|
28
26
|
var import_constants = require("../../constants/index.js");
|
|
29
27
|
var import_utils = require("../../utils/index.js");
|
|
@@ -39,6 +37,7 @@ var import_CurveStablePriceFeed = require("./CurveStablePriceFeed.js");
|
|
|
39
37
|
var import_CurveUSDPriceFeed = require("./CurveUSDPriceFeed.js");
|
|
40
38
|
var import_Erc4626PriceFeed = require("./Erc4626PriceFeed.js");
|
|
41
39
|
var import_ExternalPriceFeed = require("./ExternalPriceFeed.js");
|
|
40
|
+
var import_getRawPriceUpdates = require("./getRawPriceUpdates.js");
|
|
42
41
|
var import_MellowLRTPriceFeed = require("./MellowLRTPriceFeed.js");
|
|
43
42
|
var import_PendleTWAPPTPriceFeed = require("./PendleTWAPPTPriceFeed.js");
|
|
44
43
|
var import_PythPriceFeed = require("./PythPriceFeed.js");
|
|
@@ -101,6 +100,19 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
101
100
|
this.#latestUpdate = latestUpdate;
|
|
102
101
|
return result;
|
|
103
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
105
|
+
* @param priceFeeds
|
|
106
|
+
* @param logContext
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
async generatePriceFeedsUpdates(priceFeeds, logContext = {}) {
|
|
110
|
+
const updates = await this.generatePriceFeedsUpdateTxs(
|
|
111
|
+
priceFeeds,
|
|
112
|
+
logContext
|
|
113
|
+
);
|
|
114
|
+
return (0, import_getRawPriceUpdates.getRawPriceUpdates)(updates);
|
|
115
|
+
}
|
|
104
116
|
/**
|
|
105
117
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
|
|
106
118
|
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
@@ -133,20 +145,11 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
133
145
|
* @returns
|
|
134
146
|
*/
|
|
135
147
|
async generateExternalPriceFeedsUpdates(feeds, block) {
|
|
136
|
-
const
|
|
148
|
+
const updates = await this.generateExternalPriceFeedsUpdateTxs(
|
|
137
149
|
feeds,
|
|
138
150
|
block
|
|
139
151
|
);
|
|
140
|
-
return
|
|
141
|
-
const data = (0, import_viem.decodeFunctionData)({
|
|
142
|
-
abi: import_iUpdatablePriceFeed.iUpdatablePriceFeedAbi,
|
|
143
|
-
data: tx.raw.callData
|
|
144
|
-
});
|
|
145
|
-
return {
|
|
146
|
-
priceFeed: tx.raw.to,
|
|
147
|
-
data: data.args[0]
|
|
148
|
-
};
|
|
149
|
-
});
|
|
152
|
+
return (0, import_getRawPriceUpdates.getRawPriceUpdates)(updates);
|
|
150
153
|
}
|
|
151
154
|
has(address) {
|
|
152
155
|
return this.#feeds.has(address);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getRawPriceUpdates_exports = {};
|
|
20
|
+
__export(getRawPriceUpdates_exports, {
|
|
21
|
+
getRawPriceUpdates: () => getRawPriceUpdates
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getRawPriceUpdates_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_iUpdatablePriceFeed = require("../../../abi/iUpdatablePriceFeed.js");
|
|
26
|
+
function getRawPriceUpdates(updates) {
|
|
27
|
+
return updates.txs.map((tx) => {
|
|
28
|
+
const data = (0, import_viem.decodeFunctionData)({
|
|
29
|
+
abi: import_iUpdatablePriceFeed.iUpdatablePriceFeedAbi,
|
|
30
|
+
data: tx.raw.callData
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
priceFeed: tx.raw.to,
|
|
34
|
+
data: data.args[0]
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
getRawPriceUpdates
|
|
41
|
+
});
|
|
@@ -25,6 +25,7 @@ __reExport(pricefeeds_exports, require("./CurveStablePriceFeed.js"), module.expo
|
|
|
25
25
|
__reExport(pricefeeds_exports, require("./CurveUSDPriceFeed.js"), module.exports);
|
|
26
26
|
__reExport(pricefeeds_exports, require("./Erc4626PriceFeed.js"), module.exports);
|
|
27
27
|
__reExport(pricefeeds_exports, require("./ExternalPriceFeed.js"), module.exports);
|
|
28
|
+
__reExport(pricefeeds_exports, require("./getRawPriceUpdates.js"), module.exports);
|
|
28
29
|
__reExport(pricefeeds_exports, require("./isUpdatablePriceFeed.js"), module.exports);
|
|
29
30
|
__reExport(pricefeeds_exports, require("./MellowLRTPriceFeed.js"), module.exports);
|
|
30
31
|
__reExport(pricefeeds_exports, require("./PendleTWAPPTPriceFeed.js"), module.exports);
|
|
@@ -48,6 +49,7 @@ __reExport(pricefeeds_exports, require("./ZeroPriceFeed.js"), module.exports);
|
|
|
48
49
|
...require("./CurveUSDPriceFeed.js"),
|
|
49
50
|
...require("./Erc4626PriceFeed.js"),
|
|
50
51
|
...require("./ExternalPriceFeed.js"),
|
|
52
|
+
...require("./getRawPriceUpdates.js"),
|
|
51
53
|
...require("./isUpdatablePriceFeed.js"),
|
|
52
54
|
...require("./MellowLRTPriceFeed.js"),
|
|
53
55
|
...require("./PendleTWAPPTPriceFeed.js"),
|
|
@@ -24,14 +24,13 @@ module.exports = __toCommonJS(sendRawTx_exports);
|
|
|
24
24
|
var import_actions = require("viem/actions");
|
|
25
25
|
var import_utils = require("viem/utils");
|
|
26
26
|
async function sendRawTx(client, params) {
|
|
27
|
-
const {
|
|
27
|
+
const { tx, ...rest } = params;
|
|
28
28
|
return (0, import_utils.getAction)(
|
|
29
29
|
client,
|
|
30
30
|
import_actions.sendTransaction,
|
|
31
31
|
"sendTransaction"
|
|
32
32
|
)({
|
|
33
|
-
|
|
34
|
-
account,
|
|
33
|
+
...rest,
|
|
35
34
|
data: tx.callData,
|
|
36
35
|
to: tx.to,
|
|
37
36
|
value: BigInt(tx.value)
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
decodeFunctionData
|
|
3
|
-
} from "viem";
|
|
4
1
|
import { iPriceFeedCompressorAbi } from "../../../abi/compressors.js";
|
|
5
|
-
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
6
2
|
import { SDKConstruct } from "../../base/index.js";
|
|
7
3
|
import {
|
|
8
4
|
ADDRESS_0X0,
|
|
@@ -24,6 +20,7 @@ import { CurveStablePriceFeedContract } from "./CurveStablePriceFeed.js";
|
|
|
24
20
|
import { CurveUSDPriceFeedContract } from "./CurveUSDPriceFeed.js";
|
|
25
21
|
import { Erc4626PriceFeedContract } from "./Erc4626PriceFeed.js";
|
|
26
22
|
import { ExternalPriceFeedContract } from "./ExternalPriceFeed.js";
|
|
23
|
+
import { getRawPriceUpdates } from "./getRawPriceUpdates.js";
|
|
27
24
|
import { MellowLRTPriceFeedContract } from "./MellowLRTPriceFeed.js";
|
|
28
25
|
import { PendleTWAPPTPriceFeed } from "./PendleTWAPPTPriceFeed.js";
|
|
29
26
|
import { PythPriceFeed } from "./PythPriceFeed.js";
|
|
@@ -86,6 +83,19 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
86
83
|
this.#latestUpdate = latestUpdate;
|
|
87
84
|
return result;
|
|
88
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
88
|
+
* @param priceFeeds
|
|
89
|
+
* @param logContext
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
async generatePriceFeedsUpdates(priceFeeds, logContext = {}) {
|
|
93
|
+
const updates = await this.generatePriceFeedsUpdateTxs(
|
|
94
|
+
priceFeeds,
|
|
95
|
+
logContext
|
|
96
|
+
);
|
|
97
|
+
return getRawPriceUpdates(updates);
|
|
98
|
+
}
|
|
89
99
|
/**
|
|
90
100
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
|
|
91
101
|
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
@@ -118,20 +128,11 @@ class PriceFeedRegister extends SDKConstruct {
|
|
|
118
128
|
* @returns
|
|
119
129
|
*/
|
|
120
130
|
async generateExternalPriceFeedsUpdates(feeds, block) {
|
|
121
|
-
const
|
|
131
|
+
const updates = await this.generateExternalPriceFeedsUpdateTxs(
|
|
122
132
|
feeds,
|
|
123
133
|
block
|
|
124
134
|
);
|
|
125
|
-
return
|
|
126
|
-
const data = decodeFunctionData({
|
|
127
|
-
abi: iUpdatablePriceFeedAbi,
|
|
128
|
-
data: tx.raw.callData
|
|
129
|
-
});
|
|
130
|
-
return {
|
|
131
|
-
priceFeed: tx.raw.to,
|
|
132
|
-
data: data.args[0]
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
+
return getRawPriceUpdates(updates);
|
|
135
136
|
}
|
|
136
137
|
has(address) {
|
|
137
138
|
return this.#feeds.has(address);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { decodeFunctionData } from "viem";
|
|
2
|
+
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
|
+
function getRawPriceUpdates(updates) {
|
|
4
|
+
return updates.txs.map((tx) => {
|
|
5
|
+
const data = decodeFunctionData({
|
|
6
|
+
abi: iUpdatablePriceFeedAbi,
|
|
7
|
+
data: tx.raw.callData
|
|
8
|
+
});
|
|
9
|
+
return {
|
|
10
|
+
priceFeed: tx.raw.to,
|
|
11
|
+
data: data.args[0]
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
getRawPriceUpdates
|
|
17
|
+
};
|
|
@@ -8,6 +8,7 @@ export * from "./CurveStablePriceFeed.js";
|
|
|
8
8
|
export * from "./CurveUSDPriceFeed.js";
|
|
9
9
|
export * from "./Erc4626PriceFeed.js";
|
|
10
10
|
export * from "./ExternalPriceFeed.js";
|
|
11
|
+
export * from "./getRawPriceUpdates.js";
|
|
11
12
|
export * from "./isUpdatablePriceFeed.js";
|
|
12
13
|
export * from "./MellowLRTPriceFeed.js";
|
|
13
14
|
export * from "./PendleTWAPPTPriceFeed.js";
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { sendTransaction } from "viem/actions";
|
|
2
2
|
import { getAction } from "viem/utils";
|
|
3
3
|
async function sendRawTx(client, params) {
|
|
4
|
-
const {
|
|
4
|
+
const { tx, ...rest } = params;
|
|
5
5
|
return getAction(
|
|
6
6
|
client,
|
|
7
7
|
sendTransaction,
|
|
8
8
|
"sendTransaction"
|
|
9
9
|
)({
|
|
10
|
-
|
|
11
|
-
account,
|
|
10
|
+
...rest,
|
|
12
11
|
data: tx.callData,
|
|
13
12
|
to: tx.to,
|
|
14
13
|
value: BigInt(tx.value)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Address, BlockTag } from "viem";
|
|
2
2
|
import type { PriceFeedTreeNode } from "../../base/index.js";
|
|
3
3
|
import { SDKConstruct } from "../../base/index.js";
|
|
4
4
|
import type { GearboxSDK } from "../../GearboxSDK.js";
|
|
5
5
|
import type { ILogger } from "../../types/index.js";
|
|
6
6
|
import type { IHooks } from "../../utils/internal/index.js";
|
|
7
7
|
import { type PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
|
|
8
|
-
import type { IPriceFeedContract, UpdatePriceFeedsResult } from "./types.js";
|
|
8
|
+
import type { IPriceFeedContract, PriceUpdateRaw, UpdatePriceFeedsResult } from "./types.js";
|
|
9
9
|
import type { IPriceUpdater, IPriceUpdateTask, PythOptions, RedstoneOptions } from "./updates/index.js";
|
|
10
10
|
export type PriceFeedRegisterHooks = {
|
|
11
11
|
/**
|
|
@@ -40,6 +40,13 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
|
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
42
|
generatePriceFeedsUpdateTxs(priceFeeds?: IPriceFeedContract[], logContext?: Record<string, any>): Promise<UpdatePriceFeedsResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
45
|
+
* @param priceFeeds
|
|
46
|
+
* @param logContext
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
generatePriceFeedsUpdates(priceFeeds?: IPriceFeedContract[], logContext?: Record<string, any>): Promise<PriceUpdateRaw[]>;
|
|
43
50
|
/**
|
|
44
51
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
|
|
45
52
|
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
@@ -62,10 +69,7 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
|
|
|
62
69
|
blockNumber: bigint;
|
|
63
70
|
} | {
|
|
64
71
|
blockTag: BlockTag;
|
|
65
|
-
}): Promise<
|
|
66
|
-
priceFeed: Address;
|
|
67
|
-
data: Hex;
|
|
68
|
-
}>>;
|
|
72
|
+
}): Promise<PriceUpdateRaw[]>;
|
|
69
73
|
has(address: Address): boolean;
|
|
70
74
|
mustGet(address: Address): IPriceFeedContract;
|
|
71
75
|
getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
|
|
@@ -8,6 +8,7 @@ export * from "./CurveStablePriceFeed.js";
|
|
|
8
8
|
export * from "./CurveUSDPriceFeed.js";
|
|
9
9
|
export * from "./Erc4626PriceFeed.js";
|
|
10
10
|
export * from "./ExternalPriceFeed.js";
|
|
11
|
+
export * from "./getRawPriceUpdates.js";
|
|
11
12
|
export * from "./isUpdatablePriceFeed.js";
|
|
12
13
|
export * from "./MellowLRTPriceFeed.js";
|
|
13
14
|
export * from "./PendleTWAPPTPriceFeed.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UnionOmit } from "viem";
|
|
1
|
+
import type { Address, Hex, UnionOmit } from "viem";
|
|
2
2
|
import type { IBaseContract } from "../../base/index.js";
|
|
3
3
|
import type { IPriceUpdateTx, PriceFeedStateHuman, RawTx } from "../../types/index.js";
|
|
4
4
|
import type { PriceFeedRef } from "./PriceFeedRef.js";
|
|
@@ -41,3 +41,13 @@ export interface UpdatePriceFeedsResult {
|
|
|
41
41
|
txs: IPriceUpdateTx[];
|
|
42
42
|
timestamp: number;
|
|
43
43
|
}
|
|
44
|
+
export interface PriceUpdateRaw {
|
|
45
|
+
/**
|
|
46
|
+
* IUpdatablePriceFeed contract address
|
|
47
|
+
*/
|
|
48
|
+
priceFeed: Address;
|
|
49
|
+
/**
|
|
50
|
+
* Data that can be passed to IUpdatablePriceFeed.updatePrice
|
|
51
|
+
*/
|
|
52
|
+
data: Hex;
|
|
53
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Account, Chain, Client, SendTransactionReturnType, Transport } from "viem";
|
|
1
|
+
import type { Account, Chain, Client, SendTransactionRequest, SendTransactionReturnType, Transport } from "viem";
|
|
2
|
+
import { type SendTransactionParameters } from "viem/actions";
|
|
2
3
|
import type { RawTx } from "../../types/index.js";
|
|
3
|
-
export
|
|
4
|
-
account?: Account;
|
|
4
|
+
export type SendRawTxParameters<chain extends Chain, account extends Account | undefined, request extends SendTransactionRequest<chain, chainOverride>, chainOverride extends Chain | undefined = undefined> = Omit<SendTransactionParameters<chain, account, chainOverride, request>, "data" | "to" | "value"> & {
|
|
5
5
|
tx: Pick<RawTx, "to" | "callData" | "value">;
|
|
6
|
-
}
|
|
7
|
-
export declare function sendRawTx<chain extends Chain | undefined
|
|
6
|
+
};
|
|
7
|
+
export declare function sendRawTx<chain extends Chain, account extends Account | undefined, const request extends SendTransactionRequest<chain, chainOverride>, chainOverride extends Chain | undefined>(client: Client<Transport, chain, account>, params: SendRawTxParameters<chain, account, request, chainOverride>): Promise<SendTransactionReturnType>;
|