@gearbox-protocol/sdk 8.25.1-next.1 → 8.25.1-next.3
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 +18 -5
- package/dist/cjs/sdk/market/oracle/PriceOracleV300Contract.js +7 -5
- package/dist/cjs/sdk/market/oracle/PriceOracleV310Contract.js +16 -29
- package/dist/cjs/sdk/market/pricefeeds/updates/PriceUpdateTx.js +3 -0
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +18 -5
- package/dist/esm/sdk/market/oracle/PriceOracleV300Contract.js +7 -5
- package/dist/esm/sdk/market/oracle/PriceOracleV310Contract.js +18 -30
- package/dist/esm/sdk/market/pricefeeds/updates/PriceUpdateTx.js +3 -0
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +7 -1
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +3 -2
- package/dist/types/sdk/market/oracle/PriceOracleV300Contract.d.ts +3 -3
- package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +3 -3
- package/dist/types/sdk/market/oracle/types.d.ts +11 -1
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +3 -3
- package/dist/types/sdk/market/pricefeeds/getRawPriceUpdates.d.ts +2 -2
- package/dist/types/sdk/market/pricefeeds/types.d.ts +9 -1
- package/dist/types/sdk/market/pricefeeds/updates/PriceUpdateTx.d.ts +3 -0
- package/dist/types/sdk/utils/viem/simulateWithPriceUpdates.d.ts +1 -4
- package/package.json +5 -5
|
@@ -836,14 +836,11 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
836
836
|
);
|
|
837
837
|
}
|
|
838
838
|
/**
|
|
839
|
-
* Returns price updates
|
|
840
|
-
* - If there are desiredQuotas and creditAccount update quotaBalance > 0 || (balance > 10n && isEnabled). Is used when account has both: balances and quota buys.
|
|
841
|
-
* - If there is creditAccount update balance > 10n && isEnabled. Is used in credit account actions when quota is not being bought.
|
|
842
|
-
* - If there is desiredQuotas update quotaBalance > 0. Is used on credit account opening, when quota is bought for the first time.
|
|
839
|
+
* Returns account price updates that can be used in credit facade multicall or liquidator calls
|
|
843
840
|
* @param acc
|
|
844
841
|
* @returns
|
|
845
842
|
*/
|
|
846
|
-
async
|
|
843
|
+
async getOnDemandPriceUpdates(creditManager, creditAccount, desiredQuotas) {
|
|
847
844
|
const market = this.sdk.marketRegister.findByCreditManager(creditManager);
|
|
848
845
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
849
846
|
const update = await this.getUpdateForAccount(
|
|
@@ -860,6 +857,22 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
860
857
|
update
|
|
861
858
|
);
|
|
862
859
|
}
|
|
860
|
+
/**
|
|
861
|
+
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
|
|
862
|
+
* - If there are desiredQuotas and creditAccount update quotaBalance > 0 || (balance > 10n && isEnabled). Is used when account has both: balances and quota buys.
|
|
863
|
+
* - If there is creditAccount update balance > 10n && isEnabled. Is used in credit account actions when quota is not being bought.
|
|
864
|
+
* - If there is desiredQuotas update quotaBalance > 0. Is used on credit account opening, when quota is bought for the first time.
|
|
865
|
+
* @param acc
|
|
866
|
+
* @returns
|
|
867
|
+
*/
|
|
868
|
+
async getPriceUpdatesForFacade(creditManager, creditAccount, desiredQuotas) {
|
|
869
|
+
const updates = await this.getOnDemandPriceUpdates(
|
|
870
|
+
creditManager,
|
|
871
|
+
creditAccount,
|
|
872
|
+
desiredQuotas
|
|
873
|
+
);
|
|
874
|
+
return updates.multicall;
|
|
875
|
+
}
|
|
863
876
|
prepareDisableQuotas(ca) {
|
|
864
877
|
const calls = [];
|
|
865
878
|
for (const { token, quota } of ca.tokens) {
|
|
@@ -59,10 +59,11 @@ class PriceOracleV300Contract extends import_PriceOracleBaseContract.PriceOracle
|
|
|
59
59
|
* @returns
|
|
60
60
|
*/
|
|
61
61
|
onDemandPriceUpdates(creditFacade, updates) {
|
|
62
|
-
const
|
|
62
|
+
const multicall = [];
|
|
63
|
+
const raw = [];
|
|
63
64
|
if (!updates) {
|
|
64
65
|
this.logger?.debug("empty updates list");
|
|
65
|
-
return
|
|
66
|
+
return { multicall, raw };
|
|
66
67
|
}
|
|
67
68
|
const { txs } = updates;
|
|
68
69
|
for (const tx of txs) {
|
|
@@ -87,7 +88,8 @@ class PriceOracleV300Contract extends import_PriceOracleBaseContract.PriceOracle
|
|
|
87
88
|
`failed to decode update price args for ${description}`
|
|
88
89
|
);
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
+
raw.push({ token, reserve, data });
|
|
92
|
+
multicall.push({
|
|
91
93
|
target: creditFacade,
|
|
92
94
|
callData: (0, import_viem.encodeFunctionData)({
|
|
93
95
|
abi: import_v300.iCreditFacadeV300MulticallAbi,
|
|
@@ -97,9 +99,9 @@ class PriceOracleV300Contract extends import_PriceOracleBaseContract.PriceOracle
|
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
this.logger?.debug(
|
|
100
|
-
`got ${
|
|
102
|
+
`got ${multicall.length} onDemandPriceUpdates from ${txs.length} txs`
|
|
101
103
|
);
|
|
102
|
-
return
|
|
104
|
+
return { multicall, raw };
|
|
103
105
|
}
|
|
104
106
|
findTokenForPriceFeed(priceFeed) {
|
|
105
107
|
const [token, reserve] = super.findTokenForPriceFeed(priceFeed);
|
|
@@ -22,8 +22,8 @@ __export(PriceOracleV310Contract_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(PriceOracleV310Contract_exports);
|
|
24
24
|
var import_viem = require("viem");
|
|
25
|
-
var import_iUpdatablePriceFeed = require("../../../abi/iUpdatablePriceFeed.js");
|
|
26
25
|
var import_v310 = require("../../../abi/v310.js");
|
|
26
|
+
var import_pricefeeds = require("../pricefeeds/index.js");
|
|
27
27
|
var import_PriceOracleBaseContract = require("./PriceOracleBaseContract.js");
|
|
28
28
|
const abi = import_v310.iPriceOracleV310Abi;
|
|
29
29
|
class PriceOracleV310Contract extends import_PriceOracleBaseContract.PriceOracleBaseContract {
|
|
@@ -47,35 +47,22 @@ class PriceOracleV310Contract extends import_PriceOracleBaseContract.PriceOracle
|
|
|
47
47
|
onDemandPriceUpdates(creditFacade, updates) {
|
|
48
48
|
if (!updates) {
|
|
49
49
|
this.logger?.debug("empty updates list");
|
|
50
|
-
return [];
|
|
50
|
+
return { multicall: [], raw: [] };
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
throw new Error(
|
|
67
|
-
`failed to decode update price args for ${u.raw.description}`
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
priceFeed: u.raw.to,
|
|
72
|
-
data
|
|
73
|
-
};
|
|
74
|
-
})
|
|
75
|
-
]
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
];
|
|
52
|
+
const raw = (0, import_pricefeeds.getRawPriceUpdates)(updates);
|
|
53
|
+
return {
|
|
54
|
+
raw,
|
|
55
|
+
multicall: [
|
|
56
|
+
{
|
|
57
|
+
target: creditFacade,
|
|
58
|
+
callData: (0, import_viem.encodeFunctionData)({
|
|
59
|
+
abi: import_v310.iCreditFacadeMulticallV310Abi,
|
|
60
|
+
functionName: "onDemandPriceUpdates",
|
|
61
|
+
args: [raw]
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
};
|
|
79
66
|
}
|
|
80
67
|
processLog(log) {
|
|
81
68
|
switch (log.eventName) {
|
|
@@ -24,6 +24,9 @@ module.exports = __toCommonJS(PriceUpdateTx_exports);
|
|
|
24
24
|
const MAX_DATA_TIMESTAMP_DELAY_SECONDS = 10n * 60n;
|
|
25
25
|
const MAX_DATA_TIMESTAMP_AHEAD_SECONDS = 60n;
|
|
26
26
|
class PriceUpdateTx {
|
|
27
|
+
/**
|
|
28
|
+
* raw tx with encoded `priceFeed.updatePrice` call
|
|
29
|
+
*/
|
|
27
30
|
raw;
|
|
28
31
|
data;
|
|
29
32
|
constructor(raw, data) {
|
|
@@ -827,14 +827,11 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
827
827
|
);
|
|
828
828
|
}
|
|
829
829
|
/**
|
|
830
|
-
* Returns price updates
|
|
831
|
-
* - If there are desiredQuotas and creditAccount update quotaBalance > 0 || (balance > 10n && isEnabled). Is used when account has both: balances and quota buys.
|
|
832
|
-
* - If there is creditAccount update balance > 10n && isEnabled. Is used in credit account actions when quota is not being bought.
|
|
833
|
-
* - If there is desiredQuotas update quotaBalance > 0. Is used on credit account opening, when quota is bought for the first time.
|
|
830
|
+
* Returns account price updates that can be used in credit facade multicall or liquidator calls
|
|
834
831
|
* @param acc
|
|
835
832
|
* @returns
|
|
836
833
|
*/
|
|
837
|
-
async
|
|
834
|
+
async getOnDemandPriceUpdates(creditManager, creditAccount, desiredQuotas) {
|
|
838
835
|
const market = this.sdk.marketRegister.findByCreditManager(creditManager);
|
|
839
836
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
840
837
|
const update = await this.getUpdateForAccount(
|
|
@@ -851,6 +848,22 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
851
848
|
update
|
|
852
849
|
);
|
|
853
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
|
|
853
|
+
* - If there are desiredQuotas and creditAccount update quotaBalance > 0 || (balance > 10n && isEnabled). Is used when account has both: balances and quota buys.
|
|
854
|
+
* - If there is creditAccount update balance > 10n && isEnabled. Is used in credit account actions when quota is not being bought.
|
|
855
|
+
* - If there is desiredQuotas update quotaBalance > 0. Is used on credit account opening, when quota is bought for the first time.
|
|
856
|
+
* @param acc
|
|
857
|
+
* @returns
|
|
858
|
+
*/
|
|
859
|
+
async getPriceUpdatesForFacade(creditManager, creditAccount, desiredQuotas) {
|
|
860
|
+
const updates = await this.getOnDemandPriceUpdates(
|
|
861
|
+
creditManager,
|
|
862
|
+
creditAccount,
|
|
863
|
+
desiredQuotas
|
|
864
|
+
);
|
|
865
|
+
return updates.multicall;
|
|
866
|
+
}
|
|
854
867
|
prepareDisableQuotas(ca) {
|
|
855
868
|
const calls = [];
|
|
856
869
|
for (const { token, quota } of ca.tokens) {
|
|
@@ -42,10 +42,11 @@ class PriceOracleV300Contract extends PriceOracleBaseContract {
|
|
|
42
42
|
* @returns
|
|
43
43
|
*/
|
|
44
44
|
onDemandPriceUpdates(creditFacade, updates) {
|
|
45
|
-
const
|
|
45
|
+
const multicall = [];
|
|
46
|
+
const raw = [];
|
|
46
47
|
if (!updates) {
|
|
47
48
|
this.logger?.debug("empty updates list");
|
|
48
|
-
return
|
|
49
|
+
return { multicall, raw };
|
|
49
50
|
}
|
|
50
51
|
const { txs } = updates;
|
|
51
52
|
for (const tx of txs) {
|
|
@@ -70,7 +71,8 @@ class PriceOracleV300Contract extends PriceOracleBaseContract {
|
|
|
70
71
|
`failed to decode update price args for ${description}`
|
|
71
72
|
);
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
+
raw.push({ token, reserve, data });
|
|
75
|
+
multicall.push({
|
|
74
76
|
target: creditFacade,
|
|
75
77
|
callData: encodeFunctionData({
|
|
76
78
|
abi: iCreditFacadeV300MulticallAbi,
|
|
@@ -80,9 +82,9 @@ class PriceOracleV300Contract extends PriceOracleBaseContract {
|
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
this.logger?.debug(
|
|
83
|
-
`got ${
|
|
85
|
+
`got ${multicall.length} onDemandPriceUpdates from ${txs.length} txs`
|
|
84
86
|
);
|
|
85
|
-
return
|
|
87
|
+
return { multicall, raw };
|
|
86
88
|
}
|
|
87
89
|
findTokenForPriceFeed(priceFeed) {
|
|
88
90
|
const [token, reserve] = super.findTokenForPriceFeed(priceFeed);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
decodeFunctionData,
|
|
3
2
|
encodeFunctionData
|
|
4
3
|
} from "viem";
|
|
5
|
-
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
6
4
|
import {
|
|
7
5
|
iCreditFacadeMulticallV310Abi,
|
|
8
6
|
iPriceOracleV310Abi
|
|
9
7
|
} from "../../../abi/v310.js";
|
|
8
|
+
import {
|
|
9
|
+
getRawPriceUpdates
|
|
10
|
+
} from "../pricefeeds/index.js";
|
|
10
11
|
import { PriceOracleBaseContract } from "./PriceOracleBaseContract.js";
|
|
11
12
|
const abi = iPriceOracleV310Abi;
|
|
12
13
|
class PriceOracleV310Contract extends PriceOracleBaseContract {
|
|
@@ -30,35 +31,22 @@ class PriceOracleV310Contract extends PriceOracleBaseContract {
|
|
|
30
31
|
onDemandPriceUpdates(creditFacade, updates) {
|
|
31
32
|
if (!updates) {
|
|
32
33
|
this.logger?.debug("empty updates list");
|
|
33
|
-
return [];
|
|
34
|
+
return { multicall: [], raw: [] };
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
throw new Error(
|
|
50
|
-
`failed to decode update price args for ${u.raw.description}`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
priceFeed: u.raw.to,
|
|
55
|
-
data
|
|
56
|
-
};
|
|
57
|
-
})
|
|
58
|
-
]
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
];
|
|
36
|
+
const raw = getRawPriceUpdates(updates);
|
|
37
|
+
return {
|
|
38
|
+
raw,
|
|
39
|
+
multicall: [
|
|
40
|
+
{
|
|
41
|
+
target: creditFacade,
|
|
42
|
+
callData: encodeFunctionData({
|
|
43
|
+
abi: iCreditFacadeMulticallV310Abi,
|
|
44
|
+
functionName: "onDemandPriceUpdates",
|
|
45
|
+
args: [raw]
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
};
|
|
62
50
|
}
|
|
63
51
|
processLog(log) {
|
|
64
52
|
switch (log.eventName) {
|
|
@@ -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 { UpdatePriceFeedsResult } from "../market/index.js";
|
|
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 { ClaimDelayedProps, FullyLiquidateProps, GetConnectedBotsResult, StartDelayedWithdrawalProps } from "./types";
|
|
@@ -179,6 +179,12 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
179
179
|
*/
|
|
180
180
|
getUpdateForAccounts(accounts: Array<RouterCASlice>): Promise<UpdatePriceFeedsResult>;
|
|
181
181
|
protected getUpdateForAccount(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<UpdatePriceFeedsResult>;
|
|
182
|
+
/**
|
|
183
|
+
* Returns account price updates that can be used in credit facade multicall or liquidator calls
|
|
184
|
+
* @param acc
|
|
185
|
+
* @returns
|
|
186
|
+
*/
|
|
187
|
+
getOnDemandPriceUpdates(creditManager: Address, creditAccount: RouterCASlice | undefined, desiredQuotas: Array<Asset> | undefined): Promise<OnDemandPriceUpdates>;
|
|
182
188
|
/**
|
|
183
189
|
* Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
|
|
184
190
|
* - If there are desiredQuotas and creditAccount update quotaBalance > 0 || (balance > 10n && isEnabled). Is used when account has both: balances and quota buys.
|
|
@@ -3,11 +3,12 @@ import type { BaseContractOptions } from "../../base/BaseContract.js";
|
|
|
3
3
|
import type { PriceOracleData } from "../../base/index.js";
|
|
4
4
|
import { BaseContract } from "../../base/index.js";
|
|
5
5
|
import type { GearboxSDK } from "../../GearboxSDK.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { PriceOracleStateHuman } from "../../types/index.js";
|
|
7
7
|
import { AddressMap } from "../../utils/index.js";
|
|
8
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
|
+
import type { OnDemandPriceUpdates } from "./types";
|
|
11
12
|
import type { DelegatedOracleMulticall, IPriceOracleContract, PriceFeedsForTokensOptions } from "./types.js";
|
|
12
13
|
export declare abstract class PriceOracleBaseContract<abi extends Abi | readonly unknown[]> extends BaseContract<abi> implements IPriceOracleContract {
|
|
13
14
|
#private;
|
|
@@ -40,7 +41,7 @@ export declare abstract class PriceOracleBaseContract<abi extends Abi | readonly
|
|
|
40
41
|
* @returns
|
|
41
42
|
*/
|
|
42
43
|
updatePriceFeeds(): Promise<UpdatePriceFeedsResult>;
|
|
43
|
-
abstract onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult):
|
|
44
|
+
abstract onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates;
|
|
44
45
|
/**
|
|
45
46
|
* Gets main price for given token
|
|
46
47
|
* Throws if token price feed is not found or answer is not successful
|
|
@@ -1,9 +1,9 @@
|
|
|
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 {
|
|
5
|
-
import type { UpdatePriceFeedsResult } from "../pricefeeds/index.js";
|
|
4
|
+
import type { PriceUpdateV300, UpdatePriceFeedsResult } from "../pricefeeds/index.js";
|
|
6
5
|
import { PriceOracleBaseContract } from "./PriceOracleBaseContract.js";
|
|
6
|
+
import type { OnDemandPriceUpdates } from "./types";
|
|
7
7
|
declare const abi: ({
|
|
8
8
|
readonly type: "function";
|
|
9
9
|
readonly name: "paused";
|
|
@@ -363,7 +363,7 @@ export declare class PriceOracleV300Contract extends PriceOracleBaseContract<abi
|
|
|
363
363
|
* @param updates
|
|
364
364
|
* @returns
|
|
365
365
|
*/
|
|
366
|
-
onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult):
|
|
366
|
+
onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates<PriceUpdateV300>;
|
|
367
367
|
findTokenForPriceFeed(priceFeed: Address): [token: Address | undefined, reserve: boolean];
|
|
368
368
|
}
|
|
369
369
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
|
5
|
-
import type { UpdatePriceFeedsResult } from "../pricefeeds/index.js";
|
|
4
|
+
import { type PriceUpdateV310, type UpdatePriceFeedsResult } from "../pricefeeds/index.js";
|
|
6
5
|
import { PriceOracleBaseContract } from "./PriceOracleBaseContract.js";
|
|
6
|
+
import type { OnDemandPriceUpdates } from "./types.js";
|
|
7
7
|
declare const abi: readonly [{
|
|
8
8
|
readonly type: "function";
|
|
9
9
|
readonly inputs: 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):
|
|
351
|
+
onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates<PriceUpdateV310>;
|
|
352
352
|
processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
|
|
353
353
|
}
|
|
354
354
|
export {};
|
|
@@ -9,6 +9,16 @@ export interface PriceFeedsForTokensOptions {
|
|
|
9
9
|
main?: boolean;
|
|
10
10
|
reserve?: boolean;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Abstraction that represents on demand price updates acceptable by both credit facade multicall and
|
|
14
|
+
* as raw PriceUpdate in liquidator calls
|
|
15
|
+
* T is (priceFeed, data) for v310 and (token, reserve, data) for v300
|
|
16
|
+
* TODO: should be removed after v310 migration
|
|
17
|
+
*/
|
|
18
|
+
export interface OnDemandPriceUpdates<T = unknown> {
|
|
19
|
+
raw: T[];
|
|
20
|
+
multicall: MultiCall[];
|
|
21
|
+
}
|
|
12
22
|
export interface IPriceOracleContract extends IBaseContract {
|
|
13
23
|
mainPriceFeeds: AddressMap<PriceFeedRef>;
|
|
14
24
|
mainPrices: PriceFeedAnswerMap;
|
|
@@ -72,7 +82,7 @@ export interface IPriceOracleContract extends IBaseContract {
|
|
|
72
82
|
* @param updates
|
|
73
83
|
* @returns
|
|
74
84
|
*/
|
|
75
|
-
onDemandPriceUpdates: (creditFacade: Address, updates?: UpdatePriceFeedsResult) =>
|
|
85
|
+
onDemandPriceUpdates: (creditFacade: Address, updates?: UpdatePriceFeedsResult) => OnDemandPriceUpdates;
|
|
76
86
|
/**
|
|
77
87
|
* Tries to convert amount of from one token to another, using latest known prices
|
|
78
88
|
* @param from
|
|
@@ -5,7 +5,7 @@ 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,
|
|
8
|
+
import type { IPriceFeedContract, PriceUpdateV310, UpdatePriceFeedsResult } from "./types.js";
|
|
9
9
|
import type { IPriceUpdater, IPriceUpdateTask, PythOptions, RedstoneOptions } from "./updates/index.js";
|
|
10
10
|
export type PriceFeedRegisterHooks = {
|
|
11
11
|
/**
|
|
@@ -46,7 +46,7 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
|
|
|
46
46
|
* @param logContext
|
|
47
47
|
* @returns
|
|
48
48
|
*/
|
|
49
|
-
generatePriceFeedsUpdates(priceFeeds?: IPriceFeedContract[], logContext?: Record<string, any>): Promise<
|
|
49
|
+
generatePriceFeedsUpdates(priceFeeds?: IPriceFeedContract[], logContext?: Record<string, any>): Promise<PriceUpdateV310[]>;
|
|
50
50
|
/**
|
|
51
51
|
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
|
|
52
52
|
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
@@ -69,7 +69,7 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
|
|
|
69
69
|
blockNumber: bigint;
|
|
70
70
|
} | {
|
|
71
71
|
blockTag: BlockTag;
|
|
72
|
-
}): Promise<
|
|
72
|
+
}): Promise<PriceUpdateV310[]>;
|
|
73
73
|
has(address: Address): boolean;
|
|
74
74
|
mustGet(address: Address): IPriceFeedContract;
|
|
75
75
|
getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function getRawPriceUpdates(updates: UpdatePriceFeedsResult):
|
|
1
|
+
import type { PriceUpdateV310, UpdatePriceFeedsResult } from "./types.js";
|
|
2
|
+
export declare function getRawPriceUpdates(updates: UpdatePriceFeedsResult): PriceUpdateV310[];
|
|
@@ -41,7 +41,7 @@ export interface UpdatePriceFeedsResult {
|
|
|
41
41
|
txs: IPriceUpdateTx[];
|
|
42
42
|
timestamp: number;
|
|
43
43
|
}
|
|
44
|
-
export interface
|
|
44
|
+
export interface PriceUpdateV310 {
|
|
45
45
|
/**
|
|
46
46
|
* IUpdatablePriceFeed contract address
|
|
47
47
|
*/
|
|
@@ -51,3 +51,11 @@ export interface PriceUpdateRaw {
|
|
|
51
51
|
*/
|
|
52
52
|
data: Hex;
|
|
53
53
|
}
|
|
54
|
+
export interface PriceUpdateV300 {
|
|
55
|
+
token: Address;
|
|
56
|
+
reserve: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Data that can be passed to IUpdatablePriceFeed.updatePrice
|
|
59
|
+
*/
|
|
60
|
+
data: Hex;
|
|
61
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { IPriceUpdateTx, RawTx } from "../../../types/index.js";
|
|
2
2
|
import type { IPriceUpdateTask } from "./types.js";
|
|
3
3
|
export declare abstract class PriceUpdateTx<T extends IPriceUpdateTask = IPriceUpdateTask> implements IPriceUpdateTx<T> {
|
|
4
|
+
/**
|
|
5
|
+
* raw tx with encoded `priceFeed.updatePrice` call
|
|
6
|
+
*/
|
|
4
7
|
readonly raw: RawTx;
|
|
5
8
|
readonly data: T;
|
|
6
9
|
abstract readonly name: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Narrow } from "abitype";
|
|
2
2
|
import type { CallParameters, Chain, Client, ContractFunctionParameters, MulticallContracts, MulticallReturnType, Transport } from "viem";
|
|
3
3
|
import { BaseError } from "viem";
|
|
4
4
|
import type { IPriceUpdateTx } from "../../types/index.js";
|
|
@@ -8,9 +8,6 @@ export type SimulateWithPriceUpdatesParameters<contracts extends readonly unknow
|
|
|
8
8
|
properties?: Record<string, any>;
|
|
9
9
|
} = {}> = SimulateMulticallParameters<contracts, false, options> & {
|
|
10
10
|
priceUpdates: IPriceUpdateTx[];
|
|
11
|
-
contracts: MulticallContracts<Narrow<contracts>, {
|
|
12
|
-
mutability: AbiStateMutability;
|
|
13
|
-
}>;
|
|
14
11
|
/**
|
|
15
12
|
* If true, price updates are not allowed to fail
|
|
16
13
|
* Defaults to false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "8.25.1-next.
|
|
3
|
+
"version": "8.25.1-next.3",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/cjs/sdk/index.js",
|
|
@@ -54,16 +54,16 @@
|
|
|
54
54
|
"@redstone-finance/evm-connector": "^0.7.5",
|
|
55
55
|
"@redstone-finance/protocol": "^0.7.5",
|
|
56
56
|
"@types/bn.js": "^5.2.0",
|
|
57
|
-
"abitype": "^1.0.
|
|
57
|
+
"abitype": "^1.0.9",
|
|
58
58
|
"bn.js": "^5.2.2",
|
|
59
59
|
"buffer": "^6.0.3",
|
|
60
60
|
"date-fns": "^4.1.0",
|
|
61
61
|
"decimal.js-light": "^2.5.1",
|
|
62
62
|
"viem": ">=2.23.15 <3.0.0",
|
|
63
|
-
"zod": "^4.
|
|
63
|
+
"zod": "^4.1.1"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@biomejs/biome": "^2.2.
|
|
66
|
+
"@biomejs/biome": "^2.2.2",
|
|
67
67
|
"@commitlint/cli": "^19.8.1",
|
|
68
68
|
"@commitlint/config-conventional": "^19.8.1",
|
|
69
69
|
"@gearbox-protocol/biome-config": "^1.0.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"pino": "^9.9.0",
|
|
76
76
|
"pino-pretty": "^13.1.1",
|
|
77
77
|
"tsup": "^8.5.0",
|
|
78
|
-
"tsx": "^4.20.
|
|
78
|
+
"tsx": "^4.20.5",
|
|
79
79
|
"typescript": "^5.9.2",
|
|
80
80
|
"vitest": "^3.2.4"
|
|
81
81
|
},
|