@gearbox-protocol/sdk 12.9.4 → 12.9.6
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/history/toLegacyOperation.js +6 -2
- package/dist/cjs/sdk/market/pricefeeds/PythPriceFeed.js +20 -0
- package/dist/esm/history/toLegacyOperation.js +6 -2
- package/dist/esm/sdk/market/pricefeeds/PythPriceFeed.js +21 -1
- package/dist/types/sdk/market/pricefeeds/PythPriceFeed.d.ts +21 -1
- package/package.json +1 -1
|
@@ -122,6 +122,7 @@ function createLegacyVisitor(params) {
|
|
|
122
122
|
txHash: op.txHash,
|
|
123
123
|
blockNum: op.blockNumber,
|
|
124
124
|
...commonFields(op, params),
|
|
125
|
+
multicall,
|
|
125
126
|
// TODO: missing legacy fields:
|
|
126
127
|
// userFunds: require prices to compute as
|
|
127
128
|
// sum of AddCollateral/WithdrawCollateral amounts denominated in underlying token.
|
|
@@ -129,7 +130,9 @@ function createLegacyVisitor(params) {
|
|
|
129
130
|
//
|
|
130
131
|
// leverage: (userFunds + borrowAmount) / userFunds
|
|
131
132
|
// where borrowAmount = sum of IncreaseDebt amounts in multicall (computable from data)
|
|
132
|
-
|
|
133
|
+
userFunds: "0",
|
|
134
|
+
initialFunds: "0",
|
|
135
|
+
leverage: "0"
|
|
133
136
|
};
|
|
134
137
|
},
|
|
135
138
|
CloseCreditAccount(op, multicall) {
|
|
@@ -138,9 +141,10 @@ function createLegacyVisitor(params) {
|
|
|
138
141
|
txHash: op.txHash,
|
|
139
142
|
blockNum: op.blockNumber,
|
|
140
143
|
...commonFields(op, params),
|
|
144
|
+
multicall,
|
|
141
145
|
// TODO: missing legacy fields:
|
|
142
146
|
// remainingFunds:
|
|
143
|
-
|
|
147
|
+
remainingFunds: "0"
|
|
144
148
|
};
|
|
145
149
|
},
|
|
146
150
|
LiquidateCreditAccount(op, multicall) {
|
|
@@ -25,6 +25,9 @@ var import_viem = require("viem");
|
|
|
25
25
|
var import_oracles = require("../../abi/oracles.js");
|
|
26
26
|
var import_AbstractPriceFeed = require("./AbstractPriceFeed.js");
|
|
27
27
|
const abi = import_oracles.pythPriceFeedAbi;
|
|
28
|
+
const iPythAbi = (0, import_viem.parseAbi)([
|
|
29
|
+
"function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount)"
|
|
30
|
+
]);
|
|
28
31
|
class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
29
32
|
token;
|
|
30
33
|
priceFeedId;
|
|
@@ -71,6 +74,23 @@ class PythPriceFeed extends import_AbstractPriceFeed.AbstractPriceFeedContract {
|
|
|
71
74
|
description: `updating pyth price for ${this.priceFeedId} [${this.labelAddress(this.address)}]`
|
|
72
75
|
});
|
|
73
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
79
|
+
* @param calldata
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
82
|
+
getUpdateFeeParams(calldata) {
|
|
83
|
+
const [, updateData] = (0, import_viem.decodeAbiParameters)(
|
|
84
|
+
[{ type: "uint256" }, { type: "bytes[]" }],
|
|
85
|
+
calldata
|
|
86
|
+
);
|
|
87
|
+
return {
|
|
88
|
+
address: this.pyth,
|
|
89
|
+
abi: iPythAbi,
|
|
90
|
+
functionName: "getUpdateFee",
|
|
91
|
+
args: [updateData]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
74
94
|
}
|
|
75
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
96
|
0 && (module.exports = {
|
|
@@ -98,6 +98,7 @@ function createLegacyVisitor(params) {
|
|
|
98
98
|
txHash: op.txHash,
|
|
99
99
|
blockNum: op.blockNumber,
|
|
100
100
|
...commonFields(op, params),
|
|
101
|
+
multicall,
|
|
101
102
|
// TODO: missing legacy fields:
|
|
102
103
|
// userFunds: require prices to compute as
|
|
103
104
|
// sum of AddCollateral/WithdrawCollateral amounts denominated in underlying token.
|
|
@@ -105,7 +106,9 @@ function createLegacyVisitor(params) {
|
|
|
105
106
|
//
|
|
106
107
|
// leverage: (userFunds + borrowAmount) / userFunds
|
|
107
108
|
// where borrowAmount = sum of IncreaseDebt amounts in multicall (computable from data)
|
|
108
|
-
|
|
109
|
+
userFunds: "0",
|
|
110
|
+
initialFunds: "0",
|
|
111
|
+
leverage: "0"
|
|
109
112
|
};
|
|
110
113
|
},
|
|
111
114
|
CloseCreditAccount(op, multicall) {
|
|
@@ -114,9 +117,10 @@ function createLegacyVisitor(params) {
|
|
|
114
117
|
txHash: op.txHash,
|
|
115
118
|
blockNum: op.blockNumber,
|
|
116
119
|
...commonFields(op, params),
|
|
120
|
+
multicall,
|
|
117
121
|
// TODO: missing legacy fields:
|
|
118
122
|
// remainingFunds:
|
|
119
|
-
|
|
123
|
+
remainingFunds: "0"
|
|
120
124
|
};
|
|
121
125
|
},
|
|
122
126
|
LiquidateCreditAccount(op, multicall) {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { decodeAbiParameters } from "viem";
|
|
1
|
+
import { decodeAbiParameters, parseAbi } from "viem";
|
|
2
2
|
import { pythPriceFeedAbi } from "../../abi/oracles.js";
|
|
3
3
|
import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
|
|
4
4
|
const abi = pythPriceFeedAbi;
|
|
5
|
+
const iPythAbi = parseAbi([
|
|
6
|
+
"function getUpdateFee(bytes[] calldata updateData) external view returns (uint256 feeAmount)"
|
|
7
|
+
]);
|
|
5
8
|
class PythPriceFeed extends AbstractPriceFeedContract {
|
|
6
9
|
token;
|
|
7
10
|
priceFeedId;
|
|
@@ -48,6 +51,23 @@ class PythPriceFeed extends AbstractPriceFeedContract {
|
|
|
48
51
|
description: `updating pyth price for ${this.priceFeedId} [${this.labelAddress(this.address)}]`
|
|
49
52
|
});
|
|
50
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
56
|
+
* @param calldata
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
getUpdateFeeParams(calldata) {
|
|
60
|
+
const [, updateData] = decodeAbiParameters(
|
|
61
|
+
[{ type: "uint256" }, { type: "bytes[]" }],
|
|
62
|
+
calldata
|
|
63
|
+
);
|
|
64
|
+
return {
|
|
65
|
+
address: this.pyth,
|
|
66
|
+
abi: iPythAbi,
|
|
67
|
+
functionName: "getUpdateFee",
|
|
68
|
+
args: [updateData]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
51
71
|
}
|
|
52
72
|
export {
|
|
53
73
|
PythPriceFeed
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
1
|
+
import type { Address, ContractFunctionParameters, Hex } from "viem";
|
|
2
2
|
import type { ConstructOptions } from "../../base/Construct.js";
|
|
3
3
|
import type { RawTx } from "../../types/index.js";
|
|
4
4
|
import type { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
|
|
@@ -217,6 +217,20 @@ declare const abi: readonly [{
|
|
|
217
217
|
readonly inputs: readonly [];
|
|
218
218
|
}];
|
|
219
219
|
type abi = typeof abi;
|
|
220
|
+
declare const iPythAbi: readonly [{
|
|
221
|
+
readonly name: "getUpdateFee";
|
|
222
|
+
readonly type: "function";
|
|
223
|
+
readonly stateMutability: "view";
|
|
224
|
+
readonly inputs: readonly [{
|
|
225
|
+
readonly type: "bytes[]";
|
|
226
|
+
readonly name: "updateData";
|
|
227
|
+
}];
|
|
228
|
+
readonly outputs: readonly [{
|
|
229
|
+
readonly type: "uint256";
|
|
230
|
+
readonly name: "feeAmount";
|
|
231
|
+
}];
|
|
232
|
+
}];
|
|
233
|
+
type iPythAbi = typeof iPythAbi;
|
|
220
234
|
export declare class PythPriceFeed extends AbstractPriceFeedContract<abi> implements IUpdatablePriceFeedContract {
|
|
221
235
|
readonly token: Address;
|
|
222
236
|
readonly priceFeedId: Hex;
|
|
@@ -224,5 +238,11 @@ export declare class PythPriceFeed extends AbstractPriceFeedContract<abi> implem
|
|
|
224
238
|
readonly maxConfToPriceRatio?: bigint;
|
|
225
239
|
constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
|
|
226
240
|
createPriceUpdateTx(data: `0x${string}`): RawTx;
|
|
241
|
+
/**
|
|
242
|
+
* Returns contract function parameters for the getUpdateFee function on original Pyth contract
|
|
243
|
+
* @param calldata
|
|
244
|
+
* @returns
|
|
245
|
+
*/
|
|
246
|
+
getUpdateFeeParams(calldata: Hex): ContractFunctionParameters<iPythAbi, "view", "getUpdateFee">;
|
|
227
247
|
}
|
|
228
248
|
export {};
|