@gearbox-protocol/sdk 13.7.0-kyc.3 → 14.0.0-next.10
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/dev/AccountOpener.js +5 -45
- package/dist/cjs/dev/RevolverTransport.js +10 -4
- package/dist/cjs/dev/index.js +0 -2
- package/dist/cjs/dev/logSplitterTransport.js +10 -1
- package/dist/cjs/permissionless/utils/create2.js +2 -2
- package/dist/cjs/permissionless/utils/price-update/get-price-feeds.js +11 -5
- package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +11 -5
- package/dist/cjs/permissionless/utils/price-update/get-prices.js +12 -6
- package/dist/cjs/sdk/MultichainSDK.js +232 -0
- package/dist/cjs/sdk/OnchainSDK.js +478 -0
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +16 -324
- package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +1 -7
- package/dist/cjs/sdk/base/TokensMeta.js +42 -22
- package/dist/cjs/sdk/base/token-types.js +0 -9
- package/dist/cjs/sdk/chain/chains.js +1 -2
- package/dist/cjs/sdk/constants/address-provider.js +0 -3
- package/dist/cjs/sdk/core/errors.js +77 -0
- package/dist/cjs/sdk/core/index.js +2 -0
- package/dist/cjs/sdk/index.js +4 -2
- package/dist/cjs/sdk/market/MarketRegister.js +116 -70
- package/dist/cjs/sdk/market/MarketSuite.js +0 -3
- package/dist/cjs/sdk/market/index.js +0 -2
- package/dist/cjs/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +2 -11
- package/dist/cjs/sdk/market/pool/index.js +0 -2
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +10 -3
- package/dist/cjs/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.js +20 -23
- package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +7 -4
- package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +4 -4
- package/dist/cjs/sdk/market/pricefeeds/updates/fetchPythPayloads.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/updates/index.js +3 -0
- package/dist/cjs/sdk/options.js +24 -52
- package/dist/cjs/sdk/plugins/BasePlugin.js +11 -4
- package/dist/cjs/sdk/pools/PoolService.js +12 -104
- package/dist/cjs/sdk/utils/formatter.js +99 -20
- package/dist/cjs/sdk/utils/viem/index.js +3 -3
- package/dist/cjs/sdk/utils/viem/watchBlocksAsync.js +76 -0
- package/dist/esm/dev/AccountOpener.js +6 -47
- package/dist/esm/dev/RevolverTransport.js +10 -4
- package/dist/esm/dev/index.js +0 -1
- package/dist/esm/dev/logSplitterTransport.js +10 -1
- package/dist/esm/permissionless/utils/create2.js +1 -1
- package/dist/esm/permissionless/utils/price-update/get-price-feeds.js +12 -6
- package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +13 -7
- package/dist/esm/permissionless/utils/price-update/get-prices.js +13 -7
- package/dist/esm/sdk/MultichainSDK.js +217 -0
- package/dist/esm/sdk/OnchainSDK.js +472 -0
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +17 -328
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +1 -7
- package/dist/esm/sdk/base/TokensMeta.js +44 -22
- package/dist/esm/sdk/base/token-types.js +0 -6
- package/dist/esm/sdk/chain/chains.js +1 -2
- package/dist/esm/sdk/constants/address-provider.js +0 -2
- package/dist/esm/sdk/core/errors.js +48 -0
- package/dist/esm/sdk/core/index.js +1 -0
- package/dist/esm/sdk/index.js +2 -1
- package/dist/esm/sdk/market/MarketRegister.js +118 -74
- package/dist/esm/sdk/market/MarketSuite.js +0 -3
- package/dist/esm/sdk/market/index.js +0 -1
- package/dist/esm/sdk/market/pool/PoolSuite.js +0 -3
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +2 -11
- package/dist/esm/sdk/market/pool/index.js +0 -1
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +10 -3
- package/dist/esm/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.js +20 -13
- package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +7 -4
- package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +4 -4
- package/dist/esm/sdk/market/pricefeeds/updates/fetchPythPayloads.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/updates/index.js +2 -0
- package/dist/esm/sdk/options.js +22 -51
- package/dist/esm/sdk/plugins/BasePlugin.js +11 -4
- package/dist/esm/sdk/pools/PoolService.js +13 -109
- package/dist/esm/sdk/utils/formatter.js +99 -10
- package/dist/esm/sdk/utils/viem/index.js +1 -1
- package/dist/esm/sdk/utils/viem/watchBlocksAsync.js +52 -0
- package/dist/types/dev/RevolverTransport.d.ts +2 -1
- package/dist/types/dev/calcLiquidatableLTs.d.ts +2 -2
- package/dist/types/dev/claimFromFaucet.d.ts +2 -2
- package/dist/types/dev/create2.d.ts +3 -4
- package/dist/types/dev/index.d.ts +0 -1
- package/dist/types/dev/logSplitterTransport.d.ts +3 -1
- package/dist/types/dev/migrateFaucet.d.ts +2 -2
- package/dist/types/dev/mint/AbstractMinter.d.ts +2 -2
- package/dist/types/dev/mint/FallbackMinter.d.ts +2 -2
- package/dist/types/dev/mint/factory.d.ts +2 -2
- package/dist/types/dev/replaceStorage.d.ts +1 -1
- package/dist/types/permissionless/utils/price-update/get-updatable-feeds.d.ts +2 -2
- package/dist/types/plugins/accounts/AccountsPlugin.d.ts +2 -2
- package/dist/types/plugins/accounts-counter/AccountsCounterPlugin.d.ts +2 -2
- package/dist/types/plugins/adapters/AdaptersPlugin.d.ts +2 -2
- package/dist/types/plugins/apy/ApyPlugin.d.ts +2 -2
- package/dist/types/plugins/bots/BotsPlugin.d.ts +2 -2
- package/dist/types/plugins/bots/PartialLiquidationBotV310Contract.d.ts +2 -2
- package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +2 -2
- package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +2 -2
- package/dist/types/sdk/MultichainSDK.d.ts +144 -0
- package/dist/types/sdk/OnchainSDK.d.ts +257 -0
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +4 -54
- package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
- package/dist/types/sdk/accounts/createCreditAccountService.d.ts +2 -2
- package/dist/types/sdk/accounts/types.d.ts +15 -95
- package/dist/types/sdk/base/SDKConstruct.d.ts +4 -4
- package/dist/types/sdk/base/TokensMeta.d.ts +3 -14
- package/dist/types/sdk/base/token-types.d.ts +4 -44
- package/dist/types/sdk/base/types.d.ts +2 -116
- package/dist/types/sdk/chain/chains.d.ts +1 -5
- package/dist/types/sdk/constants/address-provider.d.ts +0 -1
- package/dist/types/sdk/core/createAddressProvider.d.ts +3 -3
- package/dist/types/sdk/core/errors.d.ts +51 -0
- package/dist/types/sdk/core/index.d.ts +1 -0
- package/dist/types/sdk/index.d.ts +2 -1
- package/dist/types/sdk/market/MarketRegister.d.ts +11 -8
- package/dist/types/sdk/market/MarketSuite.d.ts +2 -4
- package/dist/types/sdk/market/adapters/createAdapter.d.ts +2 -2
- package/dist/types/sdk/market/credit/CreditConfiguratorV310Contract.d.ts +3 -3
- package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +2 -2
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +2 -2
- package/dist/types/sdk/market/credit/createCreditConfigurator.d.ts +2 -2
- package/dist/types/sdk/market/credit/createCreditFacade.d.ts +2 -2
- package/dist/types/sdk/market/credit/createCreditManager.d.ts +2 -2
- package/dist/types/sdk/market/credit/types.d.ts +1 -1
- package/dist/types/sdk/market/index.d.ts +0 -1
- package/dist/types/sdk/market/loss-policy/AliasLossPolicyV310Contract.d.ts +3 -3
- package/dist/types/sdk/market/loss-policy/createLossPolicy.d.ts +2 -2
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +5 -6
- package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +2 -2
- package/dist/types/sdk/market/oracle/createPriceOracle.d.ts +2 -2
- package/dist/types/sdk/market/oracle/types.d.ts +10 -3
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +2 -4
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +2 -6
- package/dist/types/sdk/market/pool/createInterestRateModel.d.ts +2 -2
- package/dist/types/sdk/market/pool/createPool.d.ts +2 -2
- package/dist/types/sdk/market/pool/createPoolQuotaKeeper.d.ts +2 -2
- package/dist/types/sdk/market/pool/createRateKeeper.d.ts +2 -2
- package/dist/types/sdk/market/pool/index.d.ts +0 -1
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +8 -3
- package/dist/types/sdk/market/pricefeeds/updates/PythAccumulatorUpdateData.d.ts +12 -13
- package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +8 -3
- package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.d.ts +8 -3
- package/dist/types/sdk/market/pricefeeds/updates/index.d.ts +1 -0
- package/dist/types/sdk/market/pricefeeds/updates/types.d.ts +4 -0
- package/dist/types/sdk/market/types.d.ts +1 -1
- package/dist/types/sdk/options.d.ts +15 -16
- package/dist/types/sdk/plugins/BasePlugin.d.ts +12 -6
- package/dist/types/sdk/plugins/errors.d.ts +2 -2
- package/dist/types/sdk/plugins/types.d.ts +16 -6
- package/dist/types/sdk/pools/PoolService.d.ts +8 -8
- package/dist/types/sdk/pools/types.d.ts +2 -3
- package/dist/types/sdk/router/AbstractRouterContract.d.ts +3 -3
- package/dist/types/sdk/router/RouterV310Contract.d.ts +2 -2
- package/dist/types/sdk/router/createRouter.d.ts +2 -2
- package/dist/types/sdk/router/helpers.d.ts +1 -1
- package/dist/types/sdk/types/state-human.d.ts +10 -2
- package/dist/types/sdk/types/state.d.ts +14 -8
- package/dist/types/sdk/utils/filterDust.d.ts +2 -2
- package/dist/types/sdk/utils/formatter.d.ts +1 -1
- package/dist/types/sdk/utils/isDust.d.ts +2 -2
- package/dist/types/sdk/utils/toAddress.d.ts +1 -1
- package/dist/types/sdk/utils/viem/getLogsPaginated.d.ts +1 -2
- package/dist/types/sdk/utils/viem/getLogsSafe.d.ts +1 -1
- package/dist/types/sdk/utils/viem/index.d.ts +1 -1
- package/dist/types/sdk/utils/viem/simulateWithPriceUpdates.d.ts +1 -2
- package/dist/types/sdk/utils/viem/watchBlocksAsync.d.ts +74 -0
- package/package.json +3 -6
- package/dist/cjs/abi/kyc/iDSRegistryService.js +0 -70
- package/dist/cjs/abi/kyc/iDSToken.js +0 -71
- package/dist/cjs/abi/kyc/iKYCCompressor.js +0 -196
- package/dist/cjs/abi/kyc/iKYCFactory.js +0 -122
- package/dist/cjs/abi/kyc/iKYCUnderlying.js +0 -401
- package/dist/cjs/abi/kyc/iSecuritizeDegenNFT.js +0 -326
- package/dist/cjs/abi/kyc/iSecuritizeKYCFactory.js +0 -319
- package/dist/cjs/dev/CachedStateSubscriber.js +0 -78
- package/dist/cjs/sdk/GearboxSDK.js +0 -696
- package/dist/cjs/sdk/market/kyc/KYCRegistry.js +0 -269
- package/dist/cjs/sdk/market/kyc/index.js +0 -26
- package/dist/cjs/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -244
- package/dist/cjs/sdk/market/kyc/securitize/constants.js +0 -28
- package/dist/cjs/sdk/market/kyc/securitize/index.js +0 -26
- package/dist/cjs/sdk/market/kyc/securitize/types.js +0 -16
- package/dist/cjs/sdk/market/kyc/types.js +0 -34
- package/dist/cjs/sdk/utils/viem/executeDelegatedMulticalls.js +0 -38
- package/dist/esm/abi/kyc/iDSRegistryService.js +0 -46
- package/dist/esm/abi/kyc/iDSToken.js +0 -47
- package/dist/esm/abi/kyc/iKYCCompressor.js +0 -172
- package/dist/esm/abi/kyc/iKYCFactory.js +0 -98
- package/dist/esm/abi/kyc/iKYCUnderlying.js +0 -377
- package/dist/esm/abi/kyc/iSecuritizeDegenNFT.js +0 -302
- package/dist/esm/abi/kyc/iSecuritizeKYCFactory.js +0 -295
- package/dist/esm/dev/CachedStateSubscriber.js +0 -54
- package/dist/esm/sdk/GearboxSDK.js +0 -689
- package/dist/esm/sdk/market/kyc/KYCRegistry.js +0 -253
- package/dist/esm/sdk/market/kyc/index.js +0 -3
- package/dist/esm/sdk/market/kyc/securitize/SecuritizeKYCFactory.js +0 -220
- package/dist/esm/sdk/market/kyc/securitize/constants.js +0 -4
- package/dist/esm/sdk/market/kyc/securitize/index.js +0 -3
- package/dist/esm/sdk/market/kyc/securitize/types.js +0 -0
- package/dist/esm/sdk/market/kyc/types.js +0 -9
- package/dist/esm/sdk/utils/viem/executeDelegatedMulticalls.js +0 -14
- package/dist/types/abi/kyc/iDSRegistryService.d.ts +0 -71
- package/dist/types/abi/kyc/iDSToken.d.ts +0 -67
- package/dist/types/abi/kyc/iKYCCompressor.d.ts +0 -228
- package/dist/types/abi/kyc/iKYCFactory.d.ts +0 -139
- package/dist/types/abi/kyc/iKYCUnderlying.d.ts +0 -548
- package/dist/types/abi/kyc/iSecuritizeDegenNFT.d.ts +0 -404
- package/dist/types/abi/kyc/iSecuritizeKYCFactory.d.ts +0 -376
- package/dist/types/dev/CachedStateSubscriber.d.ts +0 -21
- package/dist/types/sdk/GearboxSDK.d.ts +0 -324
- package/dist/types/sdk/market/kyc/KYCRegistry.d.ts +0 -52
- package/dist/types/sdk/market/kyc/index.d.ts +0 -3
- package/dist/types/sdk/market/kyc/securitize/SecuritizeKYCFactory.d.ts +0 -428
- package/dist/types/sdk/market/kyc/securitize/constants.d.ts +0 -1
- package/dist/types/sdk/market/kyc/securitize/index.d.ts +0 -3
- package/dist/types/sdk/market/kyc/securitize/types.d.ts +0 -127
- package/dist/types/sdk/market/kyc/types.d.ts +0 -170
- package/dist/types/sdk/utils/viem/executeDelegatedMulticalls.d.ts +0 -28
|
@@ -0,0 +1,77 @@
|
|
|
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 errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
SdkAlreadyAttachedError: () => SdkAlreadyAttachedError,
|
|
22
|
+
SdkChainMismatchError: () => SdkChainMismatchError,
|
|
23
|
+
SdkMissingChainStateError: () => SdkMissingChainStateError,
|
|
24
|
+
SdkNotAttachedError: () => SdkNotAttachedError,
|
|
25
|
+
SdkStateVersionMismatchError: () => SdkStateVersionMismatchError,
|
|
26
|
+
SdkSyncFailedError: () => SdkSyncFailedError
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(errors_exports);
|
|
29
|
+
var import_viem = require("viem");
|
|
30
|
+
class SdkNotAttachedError extends import_viem.BaseError {
|
|
31
|
+
name = "SdkNotAttachedError";
|
|
32
|
+
constructor() {
|
|
33
|
+
super("SDK is not attached \u2014 call attach() or hydrate() first");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class SdkAlreadyAttachedError extends import_viem.BaseError {
|
|
37
|
+
name = "SdkAlreadyAttachedError";
|
|
38
|
+
constructor() {
|
|
39
|
+
super("SDK is already attached");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class SdkStateVersionMismatchError extends import_viem.BaseError {
|
|
43
|
+
name = "SdkStateVersionMismatchError";
|
|
44
|
+
constructor(expected, actual) {
|
|
45
|
+
super(`State version mismatch: expected ${expected}, got ${actual}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class SdkChainMismatchError extends import_viem.BaseError {
|
|
49
|
+
name = "SdkChainMismatchError";
|
|
50
|
+
constructor(expected, actual) {
|
|
51
|
+
super(`Chain mismatch: expected ${expected}, got ${actual}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class SdkMissingChainStateError extends import_viem.BaseError {
|
|
55
|
+
name = "SdkMissingChainStateError";
|
|
56
|
+
constructor(network) {
|
|
57
|
+
super(`Hydration state missing for configured chain: ${network}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
class SdkSyncFailedError extends import_viem.BaseError {
|
|
61
|
+
name = "SdkSyncFailedError";
|
|
62
|
+
perChainErrors;
|
|
63
|
+
constructor(perChainErrors) {
|
|
64
|
+
const chains = Object.keys(perChainErrors).join(", ");
|
|
65
|
+
super(`syncState failed for chains: ${chains}`);
|
|
66
|
+
this.perChainErrors = perChainErrors;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
70
|
+
0 && (module.exports = {
|
|
71
|
+
SdkAlreadyAttachedError,
|
|
72
|
+
SdkChainMismatchError,
|
|
73
|
+
SdkMissingChainStateError,
|
|
74
|
+
SdkNotAttachedError,
|
|
75
|
+
SdkStateVersionMismatchError,
|
|
76
|
+
SdkSyncFailedError
|
|
77
|
+
});
|
|
@@ -17,10 +17,12 @@ var core_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(core_exports);
|
|
18
18
|
__reExport(core_exports, require("./AddressProviderV310Contract.js"), module.exports);
|
|
19
19
|
__reExport(core_exports, require("./createAddressProvider.js"), module.exports);
|
|
20
|
+
__reExport(core_exports, require("./errors.js"), module.exports);
|
|
20
21
|
__reExport(core_exports, require("./types.js"), module.exports);
|
|
21
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
23
|
0 && (module.exports = {
|
|
23
24
|
...require("./AddressProviderV310Contract.js"),
|
|
24
25
|
...require("./createAddressProvider.js"),
|
|
26
|
+
...require("./errors.js"),
|
|
25
27
|
...require("./types.js")
|
|
26
28
|
});
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -20,8 +20,9 @@ __reExport(sdk_exports, require("./base/index.js"), module.exports);
|
|
|
20
20
|
__reExport(sdk_exports, require("./chain/index.js"), module.exports);
|
|
21
21
|
__reExport(sdk_exports, require("./constants/index.js"), module.exports);
|
|
22
22
|
__reExport(sdk_exports, require("./core/index.js"), module.exports);
|
|
23
|
-
__reExport(sdk_exports, require("./
|
|
23
|
+
__reExport(sdk_exports, require("./MultichainSDK.js"), module.exports);
|
|
24
24
|
__reExport(sdk_exports, require("./market/index.js"), module.exports);
|
|
25
|
+
__reExport(sdk_exports, require("./OnchainSDK.js"), module.exports);
|
|
25
26
|
__reExport(sdk_exports, require("./options.js"), module.exports);
|
|
26
27
|
__reExport(sdk_exports, require("./plugins/index.js"), module.exports);
|
|
27
28
|
__reExport(sdk_exports, require("./pools/index.js"), module.exports);
|
|
@@ -36,8 +37,9 @@ __reExport(sdk_exports, require("./utils/viem/index.js"), module.exports);
|
|
|
36
37
|
...require("./chain/index.js"),
|
|
37
38
|
...require("./constants/index.js"),
|
|
38
39
|
...require("./core/index.js"),
|
|
39
|
-
...require("./
|
|
40
|
+
...require("./MultichainSDK.js"),
|
|
40
41
|
...require("./market/index.js"),
|
|
42
|
+
...require("./OnchainSDK.js"),
|
|
41
43
|
...require("./options.js"),
|
|
42
44
|
...require("./plugins/index.js"),
|
|
43
45
|
...require("./pools/index.js"),
|
|
@@ -29,9 +29,6 @@ var import_MarketConfiguratorContract = require("./MarketConfiguratorContract.js
|
|
|
29
29
|
var import_MarketSuite = require("./MarketSuite.js");
|
|
30
30
|
var import_ZapperRegister = require("./ZapperRegister.js");
|
|
31
31
|
class MarketRegister extends import_ZapperRegister.ZapperRegister {
|
|
32
|
-
/**
|
|
33
|
-
* Mapping pool.address -> MarketSuite
|
|
34
|
-
*/
|
|
35
32
|
#markets = new import_utils.AddressMap(void 0, "markets");
|
|
36
33
|
#marketFilter;
|
|
37
34
|
#marketConfigurators = new import_utils.AddressMap(
|
|
@@ -45,7 +42,9 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
|
|
|
45
42
|
**/
|
|
46
43
|
constructor(sdk, ignoreMarkets = []) {
|
|
47
44
|
super(sdk);
|
|
48
|
-
this.#ignoreMarkets = new
|
|
45
|
+
this.#ignoreMarkets = new Set(
|
|
46
|
+
ignoreMarkets.map((m) => m.toLowerCase())
|
|
47
|
+
);
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
51
50
|
* Restores market state from a previously serialized snapshot,
|
|
@@ -53,41 +52,40 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
|
|
|
53
52
|
* @param state - Array of market data snapshots.
|
|
54
53
|
**/
|
|
55
54
|
hydrate(state) {
|
|
55
|
+
this.#markets.clear();
|
|
56
56
|
const configurators = new Set(state.map((m) => m.configurator));
|
|
57
57
|
this.#setMarketFilter([...configurators]);
|
|
58
|
-
|
|
58
|
+
for (const data of state) {
|
|
59
|
+
const pool = data.pool.baseParams.addr;
|
|
60
|
+
if (this.#ignoreMarkets.has(pool.toLowerCase())) {
|
|
61
|
+
this.logger?.debug(
|
|
62
|
+
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
63
|
+
);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
this.#markets.upsert(
|
|
67
|
+
data.pool.baseParams.addr,
|
|
68
|
+
new import_MarketSuite.MarketSuite(this.sdk, data)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
59
71
|
}
|
|
60
72
|
/**
|
|
61
|
-
*
|
|
62
|
-
* Returns delegated multicalls for loading all markets from the on-chain
|
|
63
|
-
* market compressor. Used by the SDK to compose batched RPC calls.
|
|
73
|
+
* Fetches all markets from the on-chain for the given market configurators.
|
|
64
74
|
*
|
|
65
|
-
* @param
|
|
75
|
+
* @param marketConfigurators - Addresses of market configurator contracts to query.
|
|
76
|
+
* @param ignoreUpdateablePrices - When `true`, skips generating off-chain
|
|
77
|
+
* price updates before loading
|
|
66
78
|
**/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
call: {
|
|
76
|
-
abi: import_marketCompressor.marketCompressorAbi,
|
|
77
|
-
address: marketCompressorAddress,
|
|
78
|
-
functionName: "getMarkets",
|
|
79
|
-
args: [this.marketFilter]
|
|
80
|
-
},
|
|
81
|
-
onResult: (resp) => {
|
|
82
|
-
this.#setMarkets(resp);
|
|
83
|
-
this.logger?.info(
|
|
84
|
-
`loaded ${this.#markets.size} markets in block ${this.sdk.currentBlock}`
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
];
|
|
79
|
+
async loadMarkets(marketConfigurators, ignoreUpdateablePrices) {
|
|
80
|
+
if (!marketConfigurators.length) {
|
|
81
|
+
this.logger?.warn(
|
|
82
|
+
"no market configurators provided, skipping loadMarkets"
|
|
83
|
+
);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
await this.#loadMarkets(marketConfigurators, [], ignoreUpdateablePrices);
|
|
89
87
|
}
|
|
90
|
-
#setMarketFilter(configurators) {
|
|
88
|
+
#setMarketFilter(configurators, pools = []) {
|
|
91
89
|
for (const c of configurators) {
|
|
92
90
|
this.#marketConfigurators.upsert(
|
|
93
91
|
c,
|
|
@@ -96,7 +94,7 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
|
|
|
96
94
|
}
|
|
97
95
|
this.#marketFilter = {
|
|
98
96
|
configurators,
|
|
99
|
-
pools
|
|
97
|
+
pools,
|
|
100
98
|
underlying: import_constants.ADDRESS_0X0
|
|
101
99
|
};
|
|
102
100
|
}
|
|
@@ -123,45 +121,106 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
|
|
|
123
121
|
**/
|
|
124
122
|
async syncState(ignoreUpdateablePrices) {
|
|
125
123
|
const dirty = this.markets.some((m) => m.dirty) || this.marketConfigurators.some((c) => c.dirty);
|
|
126
|
-
let multicalls;
|
|
127
|
-
let txs = [];
|
|
128
124
|
if (dirty) {
|
|
129
125
|
this.logger?.debug(
|
|
130
126
|
"some markets or market configurators are dirty, reloading everything"
|
|
131
127
|
);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(updatables);
|
|
138
|
-
txs = updates.txs;
|
|
139
|
-
}
|
|
128
|
+
await this.#loadMarkets(
|
|
129
|
+
[...this.marketFilter.configurators],
|
|
130
|
+
[...this.marketFilter.pools],
|
|
131
|
+
ignoreUpdateablePrices
|
|
132
|
+
);
|
|
140
133
|
} else if (!ignoreUpdateablePrices) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
134
|
+
await this.updatePrices();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async #loadMarkets(configurators, pools, ignoreUpdateablePrices) {
|
|
138
|
+
this.#setMarketFilter(configurators, pools);
|
|
139
|
+
const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
140
|
+
import_constants.AP_MARKET_COMPRESSOR,
|
|
141
|
+
import_constants.VERSION_RANGE_310
|
|
142
|
+
);
|
|
143
|
+
let txs = [];
|
|
144
|
+
if (!ignoreUpdateablePrices) {
|
|
145
|
+
const updatables = await this.sdk.priceFeeds.getPartialUpdatablePriceFeeds(
|
|
146
|
+
configurators,
|
|
147
|
+
pools
|
|
148
|
+
);
|
|
149
|
+
const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(updatables);
|
|
147
150
|
txs = updates.txs;
|
|
151
|
+
}
|
|
152
|
+
this.logger?.debug(
|
|
153
|
+
{ configurators, pools },
|
|
154
|
+
`calling getMarkets with ${txs.length} price updates in block ${this.sdk.currentBlock}`
|
|
155
|
+
);
|
|
156
|
+
let markets = [];
|
|
157
|
+
if (txs.length) {
|
|
158
|
+
const [resp] = await (0, import_viem.simulateWithPriceUpdates)(this.client, {
|
|
159
|
+
priceUpdates: txs,
|
|
160
|
+
contracts: [
|
|
161
|
+
{
|
|
162
|
+
abi: import_marketCompressor.marketCompressorAbi,
|
|
163
|
+
address: marketCompressorAddress,
|
|
164
|
+
functionName: "getMarkets",
|
|
165
|
+
args: [this.marketFilter]
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
blockNumber: this.sdk.currentBlock,
|
|
169
|
+
gas: this.sdk.gasLimit
|
|
170
|
+
});
|
|
171
|
+
markets = resp;
|
|
148
172
|
} else {
|
|
149
|
-
|
|
173
|
+
markets = await this.client.readContract({
|
|
174
|
+
abi: import_marketCompressor.marketCompressorAbi,
|
|
175
|
+
address: marketCompressorAddress,
|
|
176
|
+
functionName: "getMarkets",
|
|
177
|
+
args: [this.marketFilter],
|
|
178
|
+
blockNumber: this.sdk.currentBlock,
|
|
179
|
+
// @ts-expect-error
|
|
180
|
+
gas: this.sdk.gasLimit
|
|
181
|
+
});
|
|
150
182
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
183
|
+
for (const data of markets) {
|
|
184
|
+
const pool = data.pool.baseParams.addr;
|
|
185
|
+
if (this.#ignoreMarkets.has(pool.toLowerCase())) {
|
|
186
|
+
this.logger?.debug(
|
|
187
|
+
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
188
|
+
);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
this.#markets.upsert(pool, new import_MarketSuite.MarketSuite(this.sdk, data));
|
|
192
|
+
}
|
|
193
|
+
this.logger?.info(
|
|
194
|
+
`loaded ${this.#markets.size} markets in block ${this.sdk.currentBlock}`
|
|
195
|
+
);
|
|
156
196
|
}
|
|
157
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
199
|
+
*/
|
|
200
|
+
async updatePrices(oracles) {
|
|
158
201
|
const uniqOracles = new import_utils.AddressMap();
|
|
159
202
|
for (const m of this.markets) {
|
|
160
203
|
if (!oracles || oracles.includes(m.priceOracle.address)) {
|
|
161
204
|
uniqOracles.upsert(m.priceOracle.address, m.priceOracle);
|
|
162
205
|
}
|
|
163
206
|
}
|
|
164
|
-
|
|
207
|
+
const multicalls = uniqOracles.values().map((o) => o.syncStateMulticall());
|
|
208
|
+
if (!multicalls.length) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
this.logger?.debug(`syncing prices on ${multicalls.length} oracles`);
|
|
212
|
+
const { txs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
|
|
213
|
+
const oraclesStates = await (0, import_viem.simulateWithPriceUpdates)(this.client, {
|
|
214
|
+
priceUpdates: txs,
|
|
215
|
+
contracts: multicalls.map((mc) => mc.call),
|
|
216
|
+
gas: this.sdk.gasLimit,
|
|
217
|
+
blockNumber: this.sdk.currentBlock
|
|
218
|
+
});
|
|
219
|
+
for (let i = 0; i < multicalls.length; i++) {
|
|
220
|
+
const handler = multicalls[i].onResult;
|
|
221
|
+
const result = oraclesStates[i];
|
|
222
|
+
handler(result);
|
|
223
|
+
}
|
|
165
224
|
}
|
|
166
225
|
get watchAddresses() {
|
|
167
226
|
return /* @__PURE__ */ new Set([
|
|
@@ -282,19 +341,6 @@ class MarketRegister extends import_ZapperRegister.ZapperRegister {
|
|
|
282
341
|
get markets() {
|
|
283
342
|
return this.#markets.values();
|
|
284
343
|
}
|
|
285
|
-
#setMarkets(markets) {
|
|
286
|
-
this.#markets.clear();
|
|
287
|
-
for (const data of markets) {
|
|
288
|
-
const pool = data.pool.baseParams.addr;
|
|
289
|
-
if (this.#ignoreMarkets.has(pool)) {
|
|
290
|
-
this.logger?.debug(
|
|
291
|
-
`ignoring market of pool ${pool} (${data.pool.name})`
|
|
292
|
-
);
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
this.#markets.upsert(pool, new import_MarketSuite.MarketSuite(this.sdk, data));
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
344
|
}
|
|
299
345
|
// Annotate the CommonJS export names for ESM import in node:
|
|
300
346
|
0 && (module.exports = {
|
|
@@ -65,9 +65,6 @@ class MarketSuite extends import_base.SDKConstruct {
|
|
|
65
65
|
get underlying() {
|
|
66
66
|
return this.pool.underlying;
|
|
67
67
|
}
|
|
68
|
-
get kycFactory() {
|
|
69
|
-
return this.pool.kycFactory;
|
|
70
|
-
}
|
|
71
68
|
get dirty() {
|
|
72
69
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
73
70
|
}
|
|
@@ -17,7 +17,6 @@ var market_exports = {};
|
|
|
17
17
|
module.exports = __toCommonJS(market_exports);
|
|
18
18
|
__reExport(market_exports, require("./adapters/index.js"), module.exports);
|
|
19
19
|
__reExport(market_exports, require("./credit/index.js"), module.exports);
|
|
20
|
-
__reExport(market_exports, require("./kyc/index.js"), module.exports);
|
|
21
20
|
__reExport(market_exports, require("./MarketRegister.js"), module.exports);
|
|
22
21
|
__reExport(market_exports, require("./MarketSuite.js"), module.exports);
|
|
23
22
|
__reExport(market_exports, require("./oracle/index.js"), module.exports);
|
|
@@ -28,7 +27,6 @@ __reExport(market_exports, require("./types.js"), module.exports);
|
|
|
28
27
|
0 && (module.exports = {
|
|
29
28
|
...require("./adapters/index.js"),
|
|
30
29
|
...require("./credit/index.js"),
|
|
31
|
-
...require("./kyc/index.js"),
|
|
32
30
|
...require("./MarketRegister.js"),
|
|
33
31
|
...require("./MarketSuite.js"),
|
|
34
32
|
...require("./oracle/index.js"),
|
|
@@ -88,9 +88,6 @@ class PoolSuite extends import_base.SDKConstruct {
|
|
|
88
88
|
get underlying() {
|
|
89
89
|
return this.pool.underlying;
|
|
90
90
|
}
|
|
91
|
-
get kycFactory() {
|
|
92
|
-
return this.pool.kycFactory;
|
|
93
|
-
}
|
|
94
91
|
get dirty() {
|
|
95
92
|
return this.pool.dirty || this.rateKeeper.dirty || this.pqk.dirty || this.interestRateModel.dirty;
|
|
96
93
|
}
|
|
@@ -28,15 +28,13 @@ var import_utils = require("../../utils/index.js");
|
|
|
28
28
|
const abi = [...import_generated.iPoolV310Abi, ...import_iPausable.iPausableAbi];
|
|
29
29
|
class PoolV310Contract extends import_base.BaseContract {
|
|
30
30
|
creditManagerDebtParams;
|
|
31
|
-
|
|
32
|
-
constructor(sdk, data) {
|
|
31
|
+
constructor(options, data) {
|
|
33
32
|
const { baseParams, creditManagerDebtParams, ...rest } = data;
|
|
34
|
-
super(
|
|
33
|
+
super(options, {
|
|
35
34
|
...data.baseParams,
|
|
36
35
|
name: `PoolV3(${data.name})`,
|
|
37
36
|
abi
|
|
38
37
|
});
|
|
39
|
-
this.#sdk = sdk;
|
|
40
38
|
Object.assign(this, rest);
|
|
41
39
|
this.creditManagerDebtParams = new import_utils.AddressMap(
|
|
42
40
|
creditManagerDebtParams.map((p) => [p.creditManager, p])
|
|
@@ -48,13 +46,6 @@ class PoolV310Contract extends import_base.BaseContract {
|
|
|
48
46
|
symbol: data.symbol
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
get kycFactory() {
|
|
52
|
-
const meta = this.#sdk.tokensMeta.mustGet(this.underlying);
|
|
53
|
-
if (this.#sdk.tokensMeta.isKYCUnderlying(meta)) {
|
|
54
|
-
return this.#sdk.mustGetContract(meta.kycFactory);
|
|
55
|
-
}
|
|
56
|
-
return void 0;
|
|
57
|
-
}
|
|
58
49
|
stateHuman(raw = true) {
|
|
59
50
|
return {
|
|
60
51
|
...super.stateHuman(raw),
|
|
@@ -18,13 +18,11 @@ module.exports = __toCommonJS(pool_exports);
|
|
|
18
18
|
__reExport(pool_exports, require("./GaugeContract.js"), module.exports);
|
|
19
19
|
__reExport(pool_exports, require("./LinearInterestRateModelContract.js"), module.exports);
|
|
20
20
|
__reExport(pool_exports, require("./PoolSuite.js"), module.exports);
|
|
21
|
-
__reExport(pool_exports, require("./PoolV310Contract.js"), module.exports);
|
|
22
21
|
__reExport(pool_exports, require("./types.js"), module.exports);
|
|
23
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24
23
|
0 && (module.exports = {
|
|
25
24
|
...require("./GaugeContract.js"),
|
|
26
25
|
...require("./LinearInterestRateModelContract.js"),
|
|
27
26
|
...require("./PoolSuite.js"),
|
|
28
|
-
...require("./PoolV310Contract.js"),
|
|
29
27
|
...require("./types.js")
|
|
30
28
|
});
|
|
@@ -237,13 +237,13 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
237
237
|
* Loads PARTIAL information about all updatable price feeds from MarketCompressor
|
|
238
238
|
* Discovered price feeds are not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
|
|
239
239
|
*/
|
|
240
|
-
async getPartialUpdatablePriceFeeds(configurators) {
|
|
240
|
+
async getPartialUpdatablePriceFeeds(configurators, pools) {
|
|
241
241
|
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
242
242
|
import_constants.AP_PRICE_FEED_COMPRESSOR,
|
|
243
243
|
import_constants.VERSION_RANGE_310
|
|
244
244
|
);
|
|
245
245
|
this.logger?.debug(
|
|
246
|
-
{ configurators },
|
|
246
|
+
{ configurators, pools },
|
|
247
247
|
`calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`
|
|
248
248
|
);
|
|
249
249
|
const result = await this.client.readContract({
|
|
@@ -253,7 +253,7 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
253
253
|
args: [
|
|
254
254
|
{
|
|
255
255
|
configurators,
|
|
256
|
-
pools: [],
|
|
256
|
+
pools: pools ?? [],
|
|
257
257
|
underlying: import_constants.ADDRESS_0X0
|
|
258
258
|
}
|
|
259
259
|
],
|
|
@@ -344,6 +344,13 @@ class PriceFeedRegister extends import_base.SDKConstruct {
|
|
|
344
344
|
get latestUpdate() {
|
|
345
345
|
return this.#latestUpdate;
|
|
346
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* @internal
|
|
349
|
+
* Returns true if any of the updaters are in historical mode
|
|
350
|
+
*/
|
|
351
|
+
get historical() {
|
|
352
|
+
return this.#updaters.some((u) => u.historical);
|
|
353
|
+
}
|
|
347
354
|
}
|
|
348
355
|
// Annotate the CommonJS export names for ESM import in node:
|
|
349
356
|
0 && (module.exports = {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var PythAccumulatorUpdateData_exports = {};
|
|
30
20
|
__export(PythAccumulatorUpdateData_exports, {
|
|
@@ -35,7 +25,6 @@ __export(PythAccumulatorUpdateData_exports, {
|
|
|
35
25
|
sliceAccumulatorUpdateData: () => sliceAccumulatorUpdateData
|
|
36
26
|
});
|
|
37
27
|
module.exports = __toCommonJS(PythAccumulatorUpdateData_exports);
|
|
38
|
-
var import_bn = __toESM(require("bn.js"));
|
|
39
28
|
var import_buffer = require("buffer");
|
|
40
29
|
const ACCUMULATOR_MAGIC = "504e4155";
|
|
41
30
|
const MAJOR_VERSION = 1;
|
|
@@ -43,6 +32,14 @@ const MINOR_VERSION = 0;
|
|
|
43
32
|
const KECCAK160_HASH_SIZE = 20;
|
|
44
33
|
const PRICE_FEED_MESSAGE_VARIANT = 0;
|
|
45
34
|
const TWAP_MESSAGE_VARIANT = 1;
|
|
35
|
+
function bufToBigInt(buf) {
|
|
36
|
+
if (buf.length === 0) return 0n;
|
|
37
|
+
let result = 0n;
|
|
38
|
+
for (let i = 0; i < buf.length; i++) {
|
|
39
|
+
result = result << 8n | BigInt(buf[i]);
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
46
43
|
function isAccumulatorUpdateData(updateBytes) {
|
|
47
44
|
return updateBytes.toString("hex").slice(0, 8) === ACCUMULATOR_MAGIC && updateBytes[4] === MAJOR_VERSION && updateBytes[5] === MINOR_VERSION;
|
|
48
45
|
}
|
|
@@ -55,19 +52,19 @@ function parsePriceFeedMessage(message) {
|
|
|
55
52
|
cursor += 1;
|
|
56
53
|
const feedId = message.subarray(cursor, cursor + 32);
|
|
57
54
|
cursor += 32;
|
|
58
|
-
const price =
|
|
55
|
+
const price = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
59
56
|
cursor += 8;
|
|
60
|
-
const confidence =
|
|
57
|
+
const confidence = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
61
58
|
cursor += 8;
|
|
62
59
|
const exponent = message.readInt32BE(cursor);
|
|
63
60
|
cursor += 4;
|
|
64
|
-
const publishTime =
|
|
61
|
+
const publishTime = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
65
62
|
cursor += 8;
|
|
66
|
-
const prevPublishTime =
|
|
63
|
+
const prevPublishTime = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
67
64
|
cursor += 8;
|
|
68
|
-
const emaPrice =
|
|
65
|
+
const emaPrice = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
69
66
|
cursor += 8;
|
|
70
|
-
const emaConf =
|
|
67
|
+
const emaConf = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
71
68
|
cursor += 8;
|
|
72
69
|
return {
|
|
73
70
|
feedId,
|
|
@@ -89,19 +86,19 @@ function parseTwapMessage(message) {
|
|
|
89
86
|
cursor += 1;
|
|
90
87
|
const feedId = message.subarray(cursor, cursor + 32);
|
|
91
88
|
cursor += 32;
|
|
92
|
-
const cumulativePrice =
|
|
89
|
+
const cumulativePrice = bufToBigInt(message.subarray(cursor, cursor + 16));
|
|
93
90
|
cursor += 16;
|
|
94
|
-
const cumulativeConf =
|
|
91
|
+
const cumulativeConf = bufToBigInt(message.subarray(cursor, cursor + 16));
|
|
95
92
|
cursor += 16;
|
|
96
|
-
const numDownSlots =
|
|
93
|
+
const numDownSlots = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
97
94
|
cursor += 8;
|
|
98
95
|
const exponent = message.readInt32BE(cursor);
|
|
99
96
|
cursor += 4;
|
|
100
|
-
const publishTime =
|
|
97
|
+
const publishTime = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
101
98
|
cursor += 8;
|
|
102
|
-
const prevPublishTime =
|
|
99
|
+
const prevPublishTime = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
103
100
|
cursor += 8;
|
|
104
|
-
const publishSlot =
|
|
101
|
+
const publishSlot = bufToBigInt(message.subarray(cursor, cursor + 8));
|
|
105
102
|
cursor += 8;
|
|
106
103
|
return {
|
|
107
104
|
feedId,
|
|
@@ -54,6 +54,9 @@ const PythOptions = import_v4.z.object({
|
|
|
54
54
|
});
|
|
55
55
|
class PythUpdater extends import_base.SDKConstruct {
|
|
56
56
|
#cache;
|
|
57
|
+
/**
|
|
58
|
+
* Fixed pyth historic timestamp in seconds
|
|
59
|
+
*/
|
|
57
60
|
#historicalTimestamp;
|
|
58
61
|
#apiProxy;
|
|
59
62
|
#failOnMissingFeeds;
|
|
@@ -68,10 +71,7 @@ class PythUpdater extends import_base.SDKConstruct {
|
|
|
68
71
|
`using historical timestamp ${this.#historicalTimestamp}`
|
|
69
72
|
);
|
|
70
73
|
}
|
|
71
|
-
this.#cache = new import_PriceUpdatesCache.PriceUpdatesCache({
|
|
72
|
-
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
73
|
-
// this period of 4 minutes is selected based on time that is required for user to sign transaction with wallet
|
|
74
|
-
// so it's unlikely to decrease
|
|
74
|
+
this.#cache = opts.cache ?? new import_PriceUpdatesCache.PriceUpdatesCache({
|
|
75
75
|
ttl: cacheTTL ?? 225 * 1e3,
|
|
76
76
|
historical: !!historicTimestamp
|
|
77
77
|
});
|
|
@@ -120,6 +120,9 @@ class PythUpdater extends import_base.SDKConstruct {
|
|
|
120
120
|
);
|
|
121
121
|
return results;
|
|
122
122
|
}
|
|
123
|
+
get historical() {
|
|
124
|
+
return !!this.#historicalTimestamp;
|
|
125
|
+
}
|
|
123
126
|
/**
|
|
124
127
|
* Gets pyth payloads
|
|
125
128
|
* @param dataFeedsIds
|
|
@@ -76,10 +76,7 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
76
76
|
`using historical timestamp ${this.#historicalTimestampMs}`
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
|
-
this.#cache = new import_PriceUpdatesCache.PriceUpdatesCache({
|
|
80
|
-
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
81
|
-
// this period of 4 minutes is selected based on time that is required for user to sign transaction with wallet
|
|
82
|
-
// so it's unlikely to decrease
|
|
79
|
+
this.#cache = opts.cache ?? new import_PriceUpdatesCache.PriceUpdatesCache({
|
|
83
80
|
ttl: opts.cacheTTL ?? 225 * 1e3,
|
|
84
81
|
historical: !!ts
|
|
85
82
|
});
|
|
@@ -150,6 +147,9 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
150
147
|
);
|
|
151
148
|
return results;
|
|
152
149
|
}
|
|
150
|
+
get historical() {
|
|
151
|
+
return !!this.#historicalTimestampMs;
|
|
152
|
+
}
|
|
153
153
|
/**
|
|
154
154
|
* Gets payloads, retries once if it has expired while inflight
|
|
155
155
|
* @param dataServiceId
|
|
@@ -123,7 +123,7 @@ function splitAccumulatorUpdates(binary) {
|
|
|
123
123
|
const msg = (0, import_PythAccumulatorUpdateData.parsePriceFeedMessage)(upd);
|
|
124
124
|
results.push({
|
|
125
125
|
dataFeedId: (0, import_viem.toHex)(msg.feedId),
|
|
126
|
-
timestamp: msg.publishTime
|
|
126
|
+
timestamp: Number(msg.publishTime),
|
|
127
127
|
data: (0, import_viem.toHex)((0, import_PythAccumulatorUpdateData.sliceAccumulatorUpdateData)(data, i, i + 1))
|
|
128
128
|
});
|
|
129
129
|
}
|
|
@@ -19,6 +19,7 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var updates_exports = {};
|
|
21
21
|
__export(updates_exports, {
|
|
22
|
+
PriceUpdatesCache: () => import_PriceUpdatesCache.PriceUpdatesCache,
|
|
22
23
|
PythOptions: () => import_PythUpdater.PythOptions,
|
|
23
24
|
PythUpdater: () => import_PythUpdater.PythUpdater,
|
|
24
25
|
RedstoneOptions: () => import_RedstoneUpdater.RedstoneOptions,
|
|
@@ -27,10 +28,12 @@ __export(updates_exports, {
|
|
|
27
28
|
module.exports = __toCommonJS(updates_exports);
|
|
28
29
|
__reExport(updates_exports, require("./fetchPythPayloads.js"), module.exports);
|
|
29
30
|
__reExport(updates_exports, require("./fetchRedstonePayloads.js"), module.exports);
|
|
31
|
+
var import_PriceUpdatesCache = require("./PriceUpdatesCache.js");
|
|
30
32
|
var import_PythUpdater = require("./PythUpdater.js");
|
|
31
33
|
var import_RedstoneUpdater = require("./RedstoneUpdater.js");
|
|
32
34
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
35
|
0 && (module.exports = {
|
|
36
|
+
PriceUpdatesCache,
|
|
34
37
|
PythOptions,
|
|
35
38
|
PythUpdater,
|
|
36
39
|
RedstoneOptions,
|