@general-liquidity/gordon-cli 0.75.12 → 0.75.13
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/index.js +3216 -46
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -2783910,6 +2783910,3136 @@ var init_defillama_yields = __esm(() => {
|
|
|
2783910
2783910
|
};
|
|
2783911
2783911
|
});
|
|
2783912
2783912
|
|
|
2783913
|
+
// src/infra/chainlink/types.ts
|
|
2783914
|
+
function getRpcUrl(chainName) {
|
|
2783915
|
+
const envKey = `CHAINLINK_RPC_${chainName.toUpperCase()}`;
|
|
2783916
|
+
const envUrl = process.env[envKey];
|
|
2783917
|
+
if (envUrl)
|
|
2783918
|
+
return envUrl;
|
|
2783919
|
+
const defaultUrl = CHAIN_RPCS[chainName];
|
|
2783920
|
+
if (!defaultUrl) {
|
|
2783921
|
+
throw new Error(`Unknown chain "${chainName}". Supported: ${Object.keys(CHAIN_RPCS).join(", ")}`);
|
|
2783922
|
+
}
|
|
2783923
|
+
return defaultUrl;
|
|
2783924
|
+
}
|
|
2783925
|
+
var CHAINLINK_ENV_KEYS, STREAMS_BASE_URL = "https://api.dataengine.chain.link", STREAMS_FEED_IDS, FEED_SELECTORS, CHAIN_RPCS, FEED_DIRECTORY, CCIP_CHAINS, ERC20_APPROVE_ABI, CCIP_ROUTER_ABI;
|
|
2783926
|
+
var init_types53 = __esm(() => {
|
|
2783927
|
+
CHAINLINK_ENV_KEYS = {
|
|
2783928
|
+
API_KEY: "CHAINLINK_API_KEY",
|
|
2783929
|
+
API_SECRET: "CHAINLINK_API_SECRET",
|
|
2783930
|
+
EVM_PRIVATE_KEY: "EVM_PRIVATE_KEY"
|
|
2783931
|
+
};
|
|
2783932
|
+
STREAMS_FEED_IDS = {
|
|
2783933
|
+
"BTC/USD": "0x00027bbaff688c906a3e20a34fe951715d1018d262a5b66e38eda027a674cd1b",
|
|
2783934
|
+
"ETH/USD": "0x000359843a543ee2fe414dc14c7e7920ef10f4372990b79d6361cdc0dd1ba782",
|
|
2783935
|
+
"SOL/USD": "0x000346b313b6252ed2b79e0ba23bbfa04bace3de5dec995baab3c0a8756e1e47",
|
|
2783936
|
+
"LINK/USD": "0x000322e3155c32334a8af4ec4f3ad6f2e0ee3b8fc9b5bba459f2c2f9e2ace1a3",
|
|
2783937
|
+
"AVAX/USD": "0x0003ee5a13ec8c58f795e4c71e0c63c62b0c71b946c58d9afda4d5c0fbc34a07",
|
|
2783938
|
+
"DOGE/USD": "0x00036bbf92e81b12a1f3fb2e70b79aebc413adb9590e80cd75ada6a8b476a8c5",
|
|
2783939
|
+
"MATIC/USD": "0x0003ec8e24da58f00c3a14f36a76e556b3a4c2b6f7a2461b64c0e73f8a2a5c0e",
|
|
2783940
|
+
"ARB/USD": "0x00034cb3de9cebd64f06eb6ae978a5fb78bfe2e90d8a4d20a5c6fe34be3e4c89",
|
|
2783941
|
+
"OP/USD": "0x0003ccb8cf41e5749e2e3f1b6ea1f0e76e0f2079f9ce7cc3b3e3d2e3e4f08b6a",
|
|
2783942
|
+
"DOT/USD": "0x0003b413f4a7c94e7ecb1c6c6fcfc94e36a17ef5a3f1e1e6e5b8b0d5c8e1a2b3"
|
|
2783943
|
+
};
|
|
2783944
|
+
FEED_SELECTORS = {
|
|
2783945
|
+
latestRoundData: "0xfeaf968c",
|
|
2783946
|
+
decimals: "0x313ce567"
|
|
2783947
|
+
};
|
|
2783948
|
+
CHAIN_RPCS = {
|
|
2783949
|
+
ethereum: "https://eth.llamarpc.com",
|
|
2783950
|
+
arbitrum: "https://arb1.arbitrum.io/rpc",
|
|
2783951
|
+
optimism: "https://mainnet.optimism.io",
|
|
2783952
|
+
polygon: "https://polygon-rpc.com",
|
|
2783953
|
+
base: "https://mainnet.base.org",
|
|
2783954
|
+
avalanche: "https://api.avax.network/ext/bc/C/rpc",
|
|
2783955
|
+
bnb: "https://bsc-dataseed.binance.org"
|
|
2783956
|
+
};
|
|
2783957
|
+
FEED_DIRECTORY = {
|
|
2783958
|
+
"ethereum:BTC/USD": "0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c",
|
|
2783959
|
+
"ethereum:ETH/USD": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419",
|
|
2783960
|
+
"ethereum:LINK/USD": "0x2c1d072e956AFFC0D435Cb7AC38EF18d24d9127c",
|
|
2783961
|
+
"ethereum:SOL/USD": "0x4ffC43a60e009B551865A93d232E33Fce9f01507",
|
|
2783962
|
+
"ethereum:AVAX/USD": "0xFF3EEb22B5E3dE6e705b44749C2559d704923FD7",
|
|
2783963
|
+
"ethereum:DOGE/USD": "0x2465CefD3b488BE410b941b1d4b2767088e2A028",
|
|
2783964
|
+
"ethereum:DOT/USD": "0x1C07AFb8E2B827c5A4739C6d59Ae3A5035f28734",
|
|
2783965
|
+
"ethereum:USDC/USD": "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6",
|
|
2783966
|
+
"ethereum:USDT/USD": "0x3E7d1eAB13ad0104d2750B8863b489D65364e32D",
|
|
2783967
|
+
"arbitrum:BTC/USD": "0x6ce185860a4963106506C203335A2910413708e9",
|
|
2783968
|
+
"arbitrum:ETH/USD": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612",
|
|
2783969
|
+
"arbitrum:LINK/USD": "0x86E53CF1B870786351Da77A57575e79CB55812CB",
|
|
2783970
|
+
"arbitrum:ARB/USD": "0xb2A824043730FE05F3DA2efaFa1CBbe83fa548D6",
|
|
2783971
|
+
"arbitrum:SOL/USD": "0x24ceA4b8ce57cdA5058b924B9B9987992450590c",
|
|
2783972
|
+
"base:ETH/USD": "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
|
|
2783973
|
+
"base:USDC/USD": "0x7e860098F58bBFC8648a4311b374B1D669a2bc6B",
|
|
2783974
|
+
"polygon:BTC/USD": "0xc907E116054Ad103354f2D350FD2514433D57F6f",
|
|
2783975
|
+
"polygon:ETH/USD": "0xF9680D99D6C9589e2a93a78A04A279e509205945",
|
|
2783976
|
+
"polygon:LINK/USD": "0xd9FFdb71EbE7496cC440152d43986Aae0AB76665",
|
|
2783977
|
+
"polygon:MATIC/USD": "0xAB594600376Ec9fD91F8e8dC9E0950EfEf8a3c20"
|
|
2783978
|
+
};
|
|
2783979
|
+
CCIP_CHAINS = {
|
|
2783980
|
+
ethereum: {
|
|
2783981
|
+
selector: "5009297550715157269",
|
|
2783982
|
+
router: "0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D",
|
|
2783983
|
+
linkToken: "0x514910771AF9Ca656af840dff83E8264EcF986CA",
|
|
2783984
|
+
supportedTokens: {
|
|
2783985
|
+
WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
2783986
|
+
USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
2783987
|
+
USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
2783988
|
+
LINK: "0x514910771AF9Ca656af840dff83E8264EcF986CA"
|
|
2783989
|
+
},
|
|
2783990
|
+
rpcKey: "ethereum"
|
|
2783991
|
+
},
|
|
2783992
|
+
arbitrum: {
|
|
2783993
|
+
selector: "4949039107694359620",
|
|
2783994
|
+
router: "0x141fa059441E0ca23ce184B6A78bafD2A517DdE8",
|
|
2783995
|
+
linkToken: "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4",
|
|
2783996
|
+
supportedTokens: {
|
|
2783997
|
+
WETH: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
|
|
2783998
|
+
USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
2783999
|
+
USDT: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
2784000
|
+
LINK: "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4"
|
|
2784001
|
+
},
|
|
2784002
|
+
rpcKey: "arbitrum"
|
|
2784003
|
+
},
|
|
2784004
|
+
optimism: {
|
|
2784005
|
+
selector: "3734403246176062136",
|
|
2784006
|
+
router: "0x3206695CaE725f44B28e86ede0805bAD662Ce783",
|
|
2784007
|
+
linkToken: "0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
|
|
2784008
|
+
supportedTokens: {
|
|
2784009
|
+
WETH: "0x4200000000000000000000000000000000000006",
|
|
2784010
|
+
USDC: "0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
|
|
2784011
|
+
LINK: "0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6"
|
|
2784012
|
+
},
|
|
2784013
|
+
rpcKey: "optimism"
|
|
2784014
|
+
},
|
|
2784015
|
+
base: {
|
|
2784016
|
+
selector: "15971525489660198786",
|
|
2784017
|
+
router: "0x881e3A65B4d4a04dD529061dd0071cf975F58bCD",
|
|
2784018
|
+
linkToken: "0x88Fb150BDc53A65fe94Dea0c9BA0a6dAf8C6e196",
|
|
2784019
|
+
supportedTokens: {
|
|
2784020
|
+
WETH: "0x4200000000000000000000000000000000000006",
|
|
2784021
|
+
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
2784022
|
+
LINK: "0x88Fb150BDc53A65fe94Dea0c9BA0a6dAf8C6e196"
|
|
2784023
|
+
},
|
|
2784024
|
+
rpcKey: "base"
|
|
2784025
|
+
},
|
|
2784026
|
+
polygon: {
|
|
2784027
|
+
selector: "4051577828743386545",
|
|
2784028
|
+
router: "0x849c5ED5a80F5B408Dd4969b78c2C8fdf0565Bfe",
|
|
2784029
|
+
linkToken: "0xb0897686c545045aFc77CF20eC7A532E3120E0F1",
|
|
2784030
|
+
supportedTokens: {
|
|
2784031
|
+
WMATIC: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
2784032
|
+
USDC: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
|
|
2784033
|
+
USDT: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
|
|
2784034
|
+
LINK: "0xb0897686c545045aFc77CF20eC7A532E3120E0F1"
|
|
2784035
|
+
},
|
|
2784036
|
+
rpcKey: "polygon"
|
|
2784037
|
+
},
|
|
2784038
|
+
avalanche: {
|
|
2784039
|
+
selector: "6433500567565415381",
|
|
2784040
|
+
router: "0xF4c7E640EdA248ef95972845a62bdC74237805dB",
|
|
2784041
|
+
linkToken: "0x5947BB275c521040051D82396192181b413227A3",
|
|
2784042
|
+
supportedTokens: {
|
|
2784043
|
+
WAVAX: "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
|
|
2784044
|
+
USDC: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
2784045
|
+
LINK: "0x5947BB275c521040051D82396192181b413227A3"
|
|
2784046
|
+
},
|
|
2784047
|
+
rpcKey: "avalanche"
|
|
2784048
|
+
},
|
|
2784049
|
+
bnb: {
|
|
2784050
|
+
selector: "11344663589394136015",
|
|
2784051
|
+
router: "0x34B03Cb9086d7D758AC55af71584F81A598759FE",
|
|
2784052
|
+
linkToken: "0x404460C6A5EdE2D891e8297795264fDe62ADBB75",
|
|
2784053
|
+
supportedTokens: {
|
|
2784054
|
+
WBNB: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
|
|
2784055
|
+
USDC: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
|
|
2784056
|
+
USDT: "0x55d398326f99059fF775485246999027B3197955",
|
|
2784057
|
+
LINK: "0x404460C6A5EdE2D891e8297795264fDe62ADBB75"
|
|
2784058
|
+
},
|
|
2784059
|
+
rpcKey: "bnb"
|
|
2784060
|
+
}
|
|
2784061
|
+
};
|
|
2784062
|
+
ERC20_APPROVE_ABI = [
|
|
2784063
|
+
"function approve(address spender, uint256 amount) returns (bool)",
|
|
2784064
|
+
"function allowance(address owner, address spender) view returns (uint256)"
|
|
2784065
|
+
];
|
|
2784066
|
+
CCIP_ROUTER_ABI = [
|
|
2784067
|
+
"function getFee(uint64 destinationChainSelector, tuple(bytes receiver, bytes data, tuple(address token, uint256 amount)[] tokenAmounts, address feeToken, bytes extraArgs) message) view returns (uint256)",
|
|
2784068
|
+
"function ccipSend(uint64 destinationChainSelector, tuple(bytes receiver, bytes data, tuple(address token, uint256 amount)[] tokenAmounts, address feeToken, bytes extraArgs) message) payable returns (bytes32)"
|
|
2784069
|
+
];
|
|
2784070
|
+
});
|
|
2784071
|
+
|
|
2784072
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/utils/constants.js
|
|
2784073
|
+
var require_constants79 = __commonJS((exports6) => {
|
|
2784074
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784075
|
+
exports6.X_CLL_ORIGIN_HEADER = exports6.X_CLL_AVAILABLE_ORIGINS_HEADER = exports6.DEFAULT_RETRY_ATTEMPTS = exports6.DEFAULT_RETRY_DELAY = exports6.DEFAULT_TIMEOUT = exports6.VALIDATION_REGEX = exports6.WS_CONSTANTS = undefined;
|
|
2784076
|
+
exports6.WS_CONSTANTS = {
|
|
2784077
|
+
CONNECT_TIMEOUT: 5000,
|
|
2784078
|
+
PING_INTERVAL: 30000,
|
|
2784079
|
+
PONG_TIMEOUT: 5000,
|
|
2784080
|
+
MAX_RECONNECTS: 5,
|
|
2784081
|
+
RECONNECT_DELAY: 1000,
|
|
2784082
|
+
MAX_RECONNECT_INTERVAL: 1e4
|
|
2784083
|
+
};
|
|
2784084
|
+
exports6.VALIDATION_REGEX = {
|
|
2784085
|
+
FEED_ID: /^0x[0-9a-fA-F]{64}$/,
|
|
2784086
|
+
SCHEMA_VERSION: /^0x000([2-9]|a|b|c|d)$/
|
|
2784087
|
+
};
|
|
2784088
|
+
exports6.DEFAULT_TIMEOUT = 30000;
|
|
2784089
|
+
exports6.DEFAULT_RETRY_DELAY = 1000;
|
|
2784090
|
+
exports6.DEFAULT_RETRY_ATTEMPTS = 1;
|
|
2784091
|
+
exports6.X_CLL_AVAILABLE_ORIGINS_HEADER = "X-Cll-Available-Origins";
|
|
2784092
|
+
exports6.X_CLL_ORIGIN_HEADER = "X-Cll-Origin";
|
|
2784093
|
+
});
|
|
2784094
|
+
|
|
2784095
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/types/errors.js
|
|
2784096
|
+
var require_errors56 = __commonJS((exports6) => {
|
|
2784097
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784098
|
+
exports6.InsufficientConnectionsError = exports6.PartialConnectionFailureError = exports6.MultiConnectionError = exports6.OriginDiscoveryError = exports6.APIError = exports6.WebSocketError = exports6.ReportDecodingError = exports6.AuthenticationError = exports6.ValidationError = exports6.DataStreamsError = undefined;
|
|
2784099
|
+
|
|
2784100
|
+
class DataStreamsError extends Error {
|
|
2784101
|
+
constructor(message5) {
|
|
2784102
|
+
super(message5);
|
|
2784103
|
+
this.name = "DataStreamsError";
|
|
2784104
|
+
Object.setPrototypeOf(this, DataStreamsError.prototype);
|
|
2784105
|
+
}
|
|
2784106
|
+
}
|
|
2784107
|
+
exports6.DataStreamsError = DataStreamsError;
|
|
2784108
|
+
|
|
2784109
|
+
class ValidationError3 extends DataStreamsError {
|
|
2784110
|
+
constructor(message5) {
|
|
2784111
|
+
super(message5);
|
|
2784112
|
+
this.name = "ValidationError";
|
|
2784113
|
+
Object.setPrototypeOf(this, ValidationError3.prototype);
|
|
2784114
|
+
}
|
|
2784115
|
+
}
|
|
2784116
|
+
exports6.ValidationError = ValidationError3;
|
|
2784117
|
+
|
|
2784118
|
+
class AuthenticationError3 extends DataStreamsError {
|
|
2784119
|
+
constructor(message5) {
|
|
2784120
|
+
super(message5);
|
|
2784121
|
+
this.name = "AuthenticationError";
|
|
2784122
|
+
Object.setPrototypeOf(this, AuthenticationError3.prototype);
|
|
2784123
|
+
}
|
|
2784124
|
+
}
|
|
2784125
|
+
exports6.AuthenticationError = AuthenticationError3;
|
|
2784126
|
+
|
|
2784127
|
+
class ReportDecodingError extends DataStreamsError {
|
|
2784128
|
+
constructor(message5) {
|
|
2784129
|
+
super(message5);
|
|
2784130
|
+
this.name = "ReportDecodingError";
|
|
2784131
|
+
Object.setPrototypeOf(this, ReportDecodingError.prototype);
|
|
2784132
|
+
}
|
|
2784133
|
+
}
|
|
2784134
|
+
exports6.ReportDecodingError = ReportDecodingError;
|
|
2784135
|
+
|
|
2784136
|
+
class WebSocketError2 extends DataStreamsError {
|
|
2784137
|
+
constructor(message5) {
|
|
2784138
|
+
super(message5);
|
|
2784139
|
+
this.name = "WebSocketError";
|
|
2784140
|
+
Object.setPrototypeOf(this, WebSocketError2.prototype);
|
|
2784141
|
+
}
|
|
2784142
|
+
}
|
|
2784143
|
+
exports6.WebSocketError = WebSocketError2;
|
|
2784144
|
+
|
|
2784145
|
+
class APIError2 extends DataStreamsError {
|
|
2784146
|
+
constructor(message5, statusCode) {
|
|
2784147
|
+
super(message5);
|
|
2784148
|
+
this.statusCode = statusCode;
|
|
2784149
|
+
this.name = "APIError";
|
|
2784150
|
+
Object.setPrototypeOf(this, APIError2.prototype);
|
|
2784151
|
+
}
|
|
2784152
|
+
}
|
|
2784153
|
+
exports6.APIError = APIError2;
|
|
2784154
|
+
|
|
2784155
|
+
class OriginDiscoveryError extends DataStreamsError {
|
|
2784156
|
+
constructor(message5, cause) {
|
|
2784157
|
+
super(message5);
|
|
2784158
|
+
this.cause = cause;
|
|
2784159
|
+
this.name = "OriginDiscoveryError";
|
|
2784160
|
+
Object.setPrototypeOf(this, OriginDiscoveryError.prototype);
|
|
2784161
|
+
}
|
|
2784162
|
+
}
|
|
2784163
|
+
exports6.OriginDiscoveryError = OriginDiscoveryError;
|
|
2784164
|
+
|
|
2784165
|
+
class MultiConnectionError extends DataStreamsError {
|
|
2784166
|
+
constructor(message5) {
|
|
2784167
|
+
super(message5);
|
|
2784168
|
+
this.name = "MultiConnectionError";
|
|
2784169
|
+
Object.setPrototypeOf(this, MultiConnectionError.prototype);
|
|
2784170
|
+
}
|
|
2784171
|
+
}
|
|
2784172
|
+
exports6.MultiConnectionError = MultiConnectionError;
|
|
2784173
|
+
|
|
2784174
|
+
class PartialConnectionFailureError extends DataStreamsError {
|
|
2784175
|
+
constructor(message5, failedConnections, totalConnections) {
|
|
2784176
|
+
super(message5);
|
|
2784177
|
+
this.failedConnections = failedConnections;
|
|
2784178
|
+
this.totalConnections = totalConnections;
|
|
2784179
|
+
this.name = "PartialConnectionFailureError";
|
|
2784180
|
+
Object.setPrototypeOf(this, PartialConnectionFailureError.prototype);
|
|
2784181
|
+
}
|
|
2784182
|
+
}
|
|
2784183
|
+
exports6.PartialConnectionFailureError = PartialConnectionFailureError;
|
|
2784184
|
+
|
|
2784185
|
+
class InsufficientConnectionsError extends DataStreamsError {
|
|
2784186
|
+
constructor(message5, availableConnections, requiredConnections) {
|
|
2784187
|
+
super(message5);
|
|
2784188
|
+
this.availableConnections = availableConnections;
|
|
2784189
|
+
this.requiredConnections = requiredConnections;
|
|
2784190
|
+
this.name = "InsufficientConnectionsError";
|
|
2784191
|
+
Object.setPrototypeOf(this, InsufficientConnectionsError.prototype);
|
|
2784192
|
+
}
|
|
2784193
|
+
}
|
|
2784194
|
+
exports6.InsufficientConnectionsError = InsufficientConnectionsError;
|
|
2784195
|
+
});
|
|
2784196
|
+
|
|
2784197
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/types/logger.js
|
|
2784198
|
+
var require_logger16 = __commonJS((exports6) => {
|
|
2784199
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784200
|
+
exports6.LogLevel = undefined;
|
|
2784201
|
+
var LogLevel3;
|
|
2784202
|
+
(function(LogLevel4) {
|
|
2784203
|
+
LogLevel4[LogLevel4["DEBUG"] = 0] = "DEBUG";
|
|
2784204
|
+
LogLevel4[LogLevel4["INFO"] = 1] = "INFO";
|
|
2784205
|
+
LogLevel4[LogLevel4["WARN"] = 2] = "WARN";
|
|
2784206
|
+
LogLevel4[LogLevel4["ERROR"] = 3] = "ERROR";
|
|
2784207
|
+
})(LogLevel3 || (exports6.LogLevel = LogLevel3 = {}));
|
|
2784208
|
+
});
|
|
2784209
|
+
|
|
2784210
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/utils/auth.js
|
|
2784211
|
+
var require_auth2 = __commonJS((exports6) => {
|
|
2784212
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784213
|
+
exports6.generateAuthHeaders = generateAuthHeaders;
|
|
2784214
|
+
var crypto_1 = __require("crypto");
|
|
2784215
|
+
function generateAuthHeaders(apiKey, userSecret, method2, url3, body, timestamp2) {
|
|
2784216
|
+
const ts2 = timestamp2 || Date.now();
|
|
2784217
|
+
const pathWithQuery = new URL(url3).pathname + new URL(url3).search;
|
|
2784218
|
+
const bodyHash = (0, crypto_1.createHash)("sha256").update(body || "").digest("hex");
|
|
2784219
|
+
const hmacBaseString = `${method2} ${pathWithQuery} ${bodyHash} ${apiKey} ${ts2}`;
|
|
2784220
|
+
const hmac14 = (0, crypto_1.createHmac)("sha256", userSecret);
|
|
2784221
|
+
const signature5 = hmac14.update(hmacBaseString).digest("hex");
|
|
2784222
|
+
return {
|
|
2784223
|
+
Authorization: apiKey,
|
|
2784224
|
+
"X-Authorization-Timestamp": ts2.toString(),
|
|
2784225
|
+
"X-Authorization-Signature-SHA256": signature5
|
|
2784226
|
+
};
|
|
2784227
|
+
}
|
|
2784228
|
+
});
|
|
2784229
|
+
|
|
2784230
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/utils/logger.js
|
|
2784231
|
+
var require_logger17 = __commonJS((exports6) => {
|
|
2784232
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784233
|
+
exports6.SDKLogger = undefined;
|
|
2784234
|
+
var logger_1 = require_logger16();
|
|
2784235
|
+
|
|
2784236
|
+
class SDKLogger {
|
|
2784237
|
+
constructor(config9 = {}) {
|
|
2784238
|
+
this.config = config9;
|
|
2784239
|
+
}
|
|
2784240
|
+
debug(message5, ...args2) {
|
|
2784241
|
+
this.log(logger_1.LogLevel.DEBUG, message5, ...args2);
|
|
2784242
|
+
}
|
|
2784243
|
+
info(message5, ...args2) {
|
|
2784244
|
+
this.log(logger_1.LogLevel.INFO, message5, ...args2);
|
|
2784245
|
+
}
|
|
2784246
|
+
warn(message5, ...args2) {
|
|
2784247
|
+
this.log(logger_1.LogLevel.WARN, message5, ...args2);
|
|
2784248
|
+
}
|
|
2784249
|
+
error(message5, ...args2) {
|
|
2784250
|
+
this.log(logger_1.LogLevel.ERROR, message5, ...args2);
|
|
2784251
|
+
}
|
|
2784252
|
+
connectionDebug(message5, ...args2) {
|
|
2784253
|
+
if (this.config.enableConnectionDebug) {
|
|
2784254
|
+
this.debug(`[Connection] ${message5}`, ...args2);
|
|
2784255
|
+
}
|
|
2784256
|
+
}
|
|
2784257
|
+
log(level, message5, ...args2) {
|
|
2784258
|
+
if (!this.config.logger) {
|
|
2784259
|
+
return;
|
|
2784260
|
+
}
|
|
2784261
|
+
const minLevel = this.config.logLevel ?? logger_1.LogLevel.INFO;
|
|
2784262
|
+
if (level < minLevel) {
|
|
2784263
|
+
return;
|
|
2784264
|
+
}
|
|
2784265
|
+
const timestamp2 = new Date().toISOString();
|
|
2784266
|
+
const formattedMessage = `[${timestamp2}] [DataStreams] ${message5}`;
|
|
2784267
|
+
try {
|
|
2784268
|
+
switch (level) {
|
|
2784269
|
+
case logger_1.LogLevel.DEBUG:
|
|
2784270
|
+
this.config.logger.debug?.(formattedMessage, ...args2);
|
|
2784271
|
+
break;
|
|
2784272
|
+
case logger_1.LogLevel.INFO:
|
|
2784273
|
+
this.config.logger.info?.(formattedMessage, ...args2);
|
|
2784274
|
+
break;
|
|
2784275
|
+
case logger_1.LogLevel.WARN:
|
|
2784276
|
+
this.config.logger.warn?.(formattedMessage, ...args2);
|
|
2784277
|
+
break;
|
|
2784278
|
+
case logger_1.LogLevel.ERROR:
|
|
2784279
|
+
this.config.logger.error?.(formattedMessage, ...args2);
|
|
2784280
|
+
break;
|
|
2784281
|
+
}
|
|
2784282
|
+
} catch {}
|
|
2784283
|
+
}
|
|
2784284
|
+
}
|
|
2784285
|
+
exports6.SDKLogger = SDKLogger;
|
|
2784286
|
+
});
|
|
2784287
|
+
|
|
2784288
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/client/base.js
|
|
2784289
|
+
var require_base26 = __commonJS((exports6) => {
|
|
2784290
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784291
|
+
exports6.BaseClient = undefined;
|
|
2784292
|
+
var constants_1 = require_constants79();
|
|
2784293
|
+
var errors_1 = require_errors56();
|
|
2784294
|
+
var logger_1 = require_logger16();
|
|
2784295
|
+
var auth_1 = require_auth2();
|
|
2784296
|
+
var logger_2 = require_logger17();
|
|
2784297
|
+
|
|
2784298
|
+
class BaseClient {
|
|
2784299
|
+
constructor(config9) {
|
|
2784300
|
+
this.config = config9;
|
|
2784301
|
+
this.logger = new logger_2.SDKLogger(config9.logging);
|
|
2784302
|
+
this.validateConfig(config9);
|
|
2784303
|
+
}
|
|
2784304
|
+
validateConfig(config9) {
|
|
2784305
|
+
this.logger.debug("Starting configuration validation");
|
|
2784306
|
+
if (!config9 || typeof config9 !== "object") {
|
|
2784307
|
+
throw new errors_1.ValidationError("Configuration object is required");
|
|
2784308
|
+
}
|
|
2784309
|
+
this.validateRequiredString(config9.apiKey, "apiKey");
|
|
2784310
|
+
this.validateRequiredString(config9.userSecret, "userSecret");
|
|
2784311
|
+
this.validateRequiredString(config9.endpoint, "endpoint");
|
|
2784312
|
+
this.validateRequiredString(config9.wsEndpoint, "wsEndpoint");
|
|
2784313
|
+
this.validateUrl(config9.endpoint, "endpoint", ["http:", "https:"]);
|
|
2784314
|
+
this.validateWebSocketUrls(config9.wsEndpoint);
|
|
2784315
|
+
if (config9.timeout !== undefined) {
|
|
2784316
|
+
this.validatePositiveNumber(config9.timeout, "timeout");
|
|
2784317
|
+
}
|
|
2784318
|
+
if (config9.retryAttempts !== undefined) {
|
|
2784319
|
+
this.validateNonNegativeNumber(config9.retryAttempts, "retryAttempts");
|
|
2784320
|
+
}
|
|
2784321
|
+
if (config9.retryDelay !== undefined) {
|
|
2784322
|
+
this.validateNonNegativeNumber(config9.retryDelay, "retryDelay");
|
|
2784323
|
+
}
|
|
2784324
|
+
if (config9.haConnectionTimeout !== undefined) {
|
|
2784325
|
+
this.validatePositiveNumber(config9.haConnectionTimeout, "haConnectionTimeout");
|
|
2784326
|
+
}
|
|
2784327
|
+
if (config9.haMode !== undefined && typeof config9.haMode !== "boolean") {
|
|
2784328
|
+
throw new errors_1.ValidationError("haMode must be a boolean");
|
|
2784329
|
+
}
|
|
2784330
|
+
if (config9.connectionStatusCallback !== undefined && typeof config9.connectionStatusCallback !== "function") {
|
|
2784331
|
+
throw new errors_1.ValidationError("connectionStatusCallback must be a function");
|
|
2784332
|
+
}
|
|
2784333
|
+
this.validateLoggingConfig(config9.logging);
|
|
2784334
|
+
this.logger.debug("Configuration validation completed successfully");
|
|
2784335
|
+
}
|
|
2784336
|
+
validateRequiredString(value2, fieldName) {
|
|
2784337
|
+
if (value2 === undefined || value2 === null) {
|
|
2784338
|
+
throw new errors_1.ValidationError(`${fieldName} is required`);
|
|
2784339
|
+
}
|
|
2784340
|
+
if (typeof value2 !== "string") {
|
|
2784341
|
+
throw new errors_1.ValidationError(`${fieldName} must be a string`);
|
|
2784342
|
+
}
|
|
2784343
|
+
if (value2.trim() === "") {
|
|
2784344
|
+
throw new errors_1.ValidationError(`${fieldName} cannot be empty`);
|
|
2784345
|
+
}
|
|
2784346
|
+
}
|
|
2784347
|
+
validateUrl(value2, fieldName, allowedProtocols) {
|
|
2784348
|
+
try {
|
|
2784349
|
+
const url3 = new URL(value2);
|
|
2784350
|
+
if (!allowedProtocols.includes(url3.protocol)) {
|
|
2784351
|
+
throw new errors_1.ValidationError(`${fieldName} must use one of these protocols: ${allowedProtocols.join(", ")}`);
|
|
2784352
|
+
}
|
|
2784353
|
+
} catch (error56) {
|
|
2784354
|
+
if (error56 instanceof errors_1.ValidationError) {
|
|
2784355
|
+
throw error56;
|
|
2784356
|
+
}
|
|
2784357
|
+
throw new errors_1.ValidationError(`${fieldName} must be a valid URL`);
|
|
2784358
|
+
}
|
|
2784359
|
+
}
|
|
2784360
|
+
validateWebSocketUrls(wsEndpoint) {
|
|
2784361
|
+
const urls = wsEndpoint.split(",").map((url3) => url3.trim()).filter((url3) => url3.length > 0);
|
|
2784362
|
+
if (urls.length === 0) {
|
|
2784363
|
+
throw new errors_1.ValidationError("wsEndpoint cannot be empty");
|
|
2784364
|
+
}
|
|
2784365
|
+
for (const url3 of urls) {
|
|
2784366
|
+
this.validateUrl(url3, "wsEndpoint", ["ws:", "wss:"]);
|
|
2784367
|
+
}
|
|
2784368
|
+
}
|
|
2784369
|
+
validatePositiveNumber(value2, fieldName) {
|
|
2784370
|
+
if (typeof value2 !== "number" || isNaN(value2)) {
|
|
2784371
|
+
throw new errors_1.ValidationError(`${fieldName} must be a number`);
|
|
2784372
|
+
}
|
|
2784373
|
+
if (value2 <= 0) {
|
|
2784374
|
+
throw new errors_1.ValidationError(`${fieldName} must be positive`);
|
|
2784375
|
+
}
|
|
2784376
|
+
}
|
|
2784377
|
+
validateNonNegativeNumber(value2, fieldName) {
|
|
2784378
|
+
if (typeof value2 !== "number" || isNaN(value2)) {
|
|
2784379
|
+
throw new errors_1.ValidationError(`${fieldName} must be a number`);
|
|
2784380
|
+
}
|
|
2784381
|
+
if (value2 < 0) {
|
|
2784382
|
+
throw new errors_1.ValidationError(`${fieldName} cannot be negative`);
|
|
2784383
|
+
}
|
|
2784384
|
+
}
|
|
2784385
|
+
validateLoggingConfig(logging2) {
|
|
2784386
|
+
if (!logging2) {
|
|
2784387
|
+
return;
|
|
2784388
|
+
}
|
|
2784389
|
+
if (logging2.logLevel !== undefined) {
|
|
2784390
|
+
if (!Object.values(logger_1.LogLevel).includes(logging2.logLevel)) {
|
|
2784391
|
+
throw new errors_1.ValidationError(`Invalid logLevel: ${logging2.logLevel}. Must be one of: ${Object.values(logger_1.LogLevel).join(", ")}`);
|
|
2784392
|
+
}
|
|
2784393
|
+
}
|
|
2784394
|
+
if (logging2.logger) {
|
|
2784395
|
+
const logger106 = logging2.logger;
|
|
2784396
|
+
const validLevels = ["debug", "info", "warn", "error"];
|
|
2784397
|
+
validLevels.forEach((level) => {
|
|
2784398
|
+
if (logger106[level] && typeof logger106[level] !== "function") {
|
|
2784399
|
+
throw new errors_1.ValidationError(`Logger.${level} must be a function, got ${typeof logger106[level]}`);
|
|
2784400
|
+
}
|
|
2784401
|
+
});
|
|
2784402
|
+
}
|
|
2784403
|
+
if (logging2.enableConnectionDebug !== undefined && typeof logging2.enableConnectionDebug !== "boolean") {
|
|
2784404
|
+
throw new errors_1.ValidationError("enableConnectionDebug must be a boolean");
|
|
2784405
|
+
}
|
|
2784406
|
+
}
|
|
2784407
|
+
async makeRequest(path7, options4 = {}) {
|
|
2784408
|
+
const url3 = new URL(path7, this.config.endpoint);
|
|
2784409
|
+
const method2 = options4.method || "GET";
|
|
2784410
|
+
const body = typeof options4.body === "string" ? options4.body : undefined;
|
|
2784411
|
+
this.logger.debug(`Making ${method2} request to ${url3}`);
|
|
2784412
|
+
const authHeaders = (0, auth_1.generateAuthHeaders)(this.config.apiKey, this.config.userSecret, method2, url3.toString(), body);
|
|
2784413
|
+
const headers = new Headers(options4.headers);
|
|
2784414
|
+
headers.set("Content-Type", "application/json");
|
|
2784415
|
+
Object.entries(authHeaders).forEach(([key5, value2]) => {
|
|
2784416
|
+
headers.set(key5, value2);
|
|
2784417
|
+
});
|
|
2784418
|
+
const response = await fetch(url3.toString(), {
|
|
2784419
|
+
...options4,
|
|
2784420
|
+
headers,
|
|
2784421
|
+
signal: AbortSignal.timeout(this.config.timeout ?? constants_1.DEFAULT_TIMEOUT)
|
|
2784422
|
+
});
|
|
2784423
|
+
if (!response.ok) {
|
|
2784424
|
+
let errorMessage;
|
|
2784425
|
+
try {
|
|
2784426
|
+
const errorData = await response.json();
|
|
2784427
|
+
errorMessage = errorData.message || response.statusText;
|
|
2784428
|
+
} catch {
|
|
2784429
|
+
errorMessage = response.statusText;
|
|
2784430
|
+
}
|
|
2784431
|
+
this.logger.error(`Request failed: ${method2} ${url3} - ${response.status} ${errorMessage}`);
|
|
2784432
|
+
throw new errors_1.APIError(errorMessage, response.status);
|
|
2784433
|
+
}
|
|
2784434
|
+
this.logger.info(`Request successful: ${method2} ${url3} - ${response.status}`);
|
|
2784435
|
+
return response.json();
|
|
2784436
|
+
}
|
|
2784437
|
+
async withRetry(fn3) {
|
|
2784438
|
+
const maxAttempts = this.config.retryAttempts ?? constants_1.DEFAULT_RETRY_ATTEMPTS;
|
|
2784439
|
+
const baseDelay = this.config.retryDelay ?? constants_1.DEFAULT_RETRY_DELAY;
|
|
2784440
|
+
this.logger.debug(`Starting retry logic: max ${maxAttempts} attempts`);
|
|
2784441
|
+
let lastError;
|
|
2784442
|
+
for (let attempt = 0;attempt <= maxAttempts; attempt++) {
|
|
2784443
|
+
try {
|
|
2784444
|
+
return await fn3();
|
|
2784445
|
+
} catch (error56) {
|
|
2784446
|
+
lastError = error56;
|
|
2784447
|
+
if (attempt === maxAttempts) {
|
|
2784448
|
+
this.logger.error(`All retry attempts failed (${maxAttempts}/${maxAttempts}):`, lastError);
|
|
2784449
|
+
break;
|
|
2784450
|
+
}
|
|
2784451
|
+
if (error56 instanceof errors_1.APIError && (error56.statusCode === 400 || error56.statusCode === 401)) {
|
|
2784452
|
+
this.logger.warn(`Not retrying client error ${error56.statusCode}: ${error56.message}`);
|
|
2784453
|
+
throw error56;
|
|
2784454
|
+
}
|
|
2784455
|
+
const delay8 = baseDelay * Math.pow(2, attempt) * (0.5 + Math.random() * 0.5);
|
|
2784456
|
+
this.logger.warn(`Retry attempt ${attempt}/${maxAttempts} failed, retrying in ${Math.round(delay8)}ms:`, error56);
|
|
2784457
|
+
await new Promise((resolve7) => setTimeout(resolve7, delay8));
|
|
2784458
|
+
}
|
|
2784459
|
+
}
|
|
2784460
|
+
throw lastError;
|
|
2784461
|
+
}
|
|
2784462
|
+
}
|
|
2784463
|
+
exports6.BaseClient = BaseClient;
|
|
2784464
|
+
});
|
|
2784465
|
+
|
|
2784466
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/utils/validation.js
|
|
2784467
|
+
var require_validation3 = __commonJS((exports6) => {
|
|
2784468
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784469
|
+
exports6.validateFeedId = validateFeedId;
|
|
2784470
|
+
exports6.validateTimestamp = validateTimestamp;
|
|
2784471
|
+
exports6.validateFeedIds = validateFeedIds;
|
|
2784472
|
+
exports6.validateHexString = validateHexString;
|
|
2784473
|
+
exports6.validateEnvironment = validateEnvironment;
|
|
2784474
|
+
var errors_1 = require_errors56();
|
|
2784475
|
+
var constants_1 = require_constants79();
|
|
2784476
|
+
function validateFeedId(feedId) {
|
|
2784477
|
+
if (!feedId) {
|
|
2784478
|
+
throw new errors_1.ValidationError("Feed ID is required");
|
|
2784479
|
+
}
|
|
2784480
|
+
if (!constants_1.VALIDATION_REGEX.FEED_ID.test(feedId)) {
|
|
2784481
|
+
throw new errors_1.ValidationError("Invalid feed ID format. Must be 0x followed by 64 hex characters");
|
|
2784482
|
+
}
|
|
2784483
|
+
const version18 = feedId.slice(2, 6);
|
|
2784484
|
+
if (!constants_1.VALIDATION_REGEX.SCHEMA_VERSION.test(`0x${version18}`)) {
|
|
2784485
|
+
throw new errors_1.ValidationError("Invalid feed ID version. Must start with 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c or 0x000d");
|
|
2784486
|
+
}
|
|
2784487
|
+
}
|
|
2784488
|
+
function validateTimestamp(timestamp2) {
|
|
2784489
|
+
if (!Number.isInteger(timestamp2)) {
|
|
2784490
|
+
throw new errors_1.ValidationError("Timestamp must be an integer");
|
|
2784491
|
+
}
|
|
2784492
|
+
if (timestamp2 < 0) {
|
|
2784493
|
+
throw new errors_1.ValidationError("Timestamp cannot be negative");
|
|
2784494
|
+
}
|
|
2784495
|
+
}
|
|
2784496
|
+
function validateFeedIds(feedIds) {
|
|
2784497
|
+
if (!Array.isArray(feedIds)) {
|
|
2784498
|
+
throw new errors_1.ValidationError("Feed IDs must be an array");
|
|
2784499
|
+
}
|
|
2784500
|
+
if (feedIds.length === 0) {
|
|
2784501
|
+
throw new errors_1.ValidationError("At least one feed ID is required");
|
|
2784502
|
+
}
|
|
2784503
|
+
feedIds.forEach(validateFeedId);
|
|
2784504
|
+
}
|
|
2784505
|
+
function validateHexString(hexString, fieldName = "hex string") {
|
|
2784506
|
+
if (!hexString) {
|
|
2784507
|
+
throw new errors_1.ValidationError(`${fieldName} is required`);
|
|
2784508
|
+
}
|
|
2784509
|
+
if (typeof hexString !== "string") {
|
|
2784510
|
+
throw new errors_1.ValidationError(`${fieldName} must be a string`);
|
|
2784511
|
+
}
|
|
2784512
|
+
if (!hexString.startsWith("0x")) {
|
|
2784513
|
+
throw new errors_1.ValidationError(`${fieldName} must start with 0x`);
|
|
2784514
|
+
}
|
|
2784515
|
+
if (!/^0x[0-9a-fA-F]+$/.test(hexString)) {
|
|
2784516
|
+
throw new errors_1.ValidationError(`${fieldName} contains invalid hex characters`);
|
|
2784517
|
+
}
|
|
2784518
|
+
if (hexString.length < 3) {
|
|
2784519
|
+
throw new errors_1.ValidationError(`${fieldName} must contain at least one hex character after 0x`);
|
|
2784520
|
+
}
|
|
2784521
|
+
}
|
|
2784522
|
+
function validateEnvironment() {
|
|
2784523
|
+
if (!process.env.API_KEY) {
|
|
2784524
|
+
throw new errors_1.ValidationError("API_KEY environment variable is required");
|
|
2784525
|
+
}
|
|
2784526
|
+
if (!process.env.USER_SECRET) {
|
|
2784527
|
+
throw new errors_1.ValidationError("USER_SECRET environment variable is required");
|
|
2784528
|
+
}
|
|
2784529
|
+
}
|
|
2784530
|
+
});
|
|
2784531
|
+
|
|
2784532
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/types/metrics.js
|
|
2784533
|
+
var require_metrics4 = __commonJS((exports6) => {
|
|
2784534
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784535
|
+
exports6.ConnectionStatus = undefined;
|
|
2784536
|
+
var ConnectionStatus;
|
|
2784537
|
+
(function(ConnectionStatus2) {
|
|
2784538
|
+
ConnectionStatus2["DISCONNECTED"] = "disconnected";
|
|
2784539
|
+
ConnectionStatus2["CONNECTING"] = "connecting";
|
|
2784540
|
+
ConnectionStatus2["CONNECTED"] = "connected";
|
|
2784541
|
+
ConnectionStatus2["RECONNECTING"] = "reconnecting";
|
|
2784542
|
+
ConnectionStatus2["FAILED"] = "failed";
|
|
2784543
|
+
})(ConnectionStatus || (exports6.ConnectionStatus = ConnectionStatus = {}));
|
|
2784544
|
+
});
|
|
2784545
|
+
|
|
2784546
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/stream/stats.js
|
|
2784547
|
+
var require_stats = __commonJS((exports6) => {
|
|
2784548
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784549
|
+
exports6.StreamStats = undefined;
|
|
2784550
|
+
var metrics_1 = require_metrics4();
|
|
2784551
|
+
|
|
2784552
|
+
class StreamStats {
|
|
2784553
|
+
constructor(configuredConnections = 1) {
|
|
2784554
|
+
this._accepted = 0;
|
|
2784555
|
+
this._deduplicated = 0;
|
|
2784556
|
+
this._partialReconnects = 0;
|
|
2784557
|
+
this._fullReconnects = 0;
|
|
2784558
|
+
this._configuredConnections = 0;
|
|
2784559
|
+
this._activeConnections = 0;
|
|
2784560
|
+
this._originStatus = {};
|
|
2784561
|
+
this._totalReceived = 0;
|
|
2784562
|
+
this._configuredConnections = configuredConnections;
|
|
2784563
|
+
}
|
|
2784564
|
+
incrementAccepted() {
|
|
2784565
|
+
this._accepted++;
|
|
2784566
|
+
this._totalReceived++;
|
|
2784567
|
+
}
|
|
2784568
|
+
incrementDeduplicated() {
|
|
2784569
|
+
this._deduplicated++;
|
|
2784570
|
+
this._totalReceived++;
|
|
2784571
|
+
}
|
|
2784572
|
+
incrementPartialReconnects() {
|
|
2784573
|
+
this._partialReconnects++;
|
|
2784574
|
+
}
|
|
2784575
|
+
incrementFullReconnects() {
|
|
2784576
|
+
this._fullReconnects++;
|
|
2784577
|
+
}
|
|
2784578
|
+
setActiveConnections(count3) {
|
|
2784579
|
+
this._activeConnections = count3;
|
|
2784580
|
+
}
|
|
2784581
|
+
setConfiguredConnections(count3) {
|
|
2784582
|
+
this._configuredConnections = count3;
|
|
2784583
|
+
}
|
|
2784584
|
+
setOriginStatus(origin2, status) {
|
|
2784585
|
+
this._originStatus[origin2] = status;
|
|
2784586
|
+
}
|
|
2784587
|
+
removeOriginStatus(origin2) {
|
|
2784588
|
+
delete this._originStatus[origin2];
|
|
2784589
|
+
}
|
|
2784590
|
+
getOriginStatus(origin2) {
|
|
2784591
|
+
return this._originStatus[origin2] || metrics_1.ConnectionStatus.DISCONNECTED;
|
|
2784592
|
+
}
|
|
2784593
|
+
getAllOriginStatuses() {
|
|
2784594
|
+
return { ...this._originStatus };
|
|
2784595
|
+
}
|
|
2784596
|
+
updateOriginStatuses(originStatus) {
|
|
2784597
|
+
this._originStatus = { ...originStatus };
|
|
2784598
|
+
}
|
|
2784599
|
+
reset() {
|
|
2784600
|
+
this._accepted = 0;
|
|
2784601
|
+
this._deduplicated = 0;
|
|
2784602
|
+
this._partialReconnects = 0;
|
|
2784603
|
+
this._fullReconnects = 0;
|
|
2784604
|
+
this._totalReceived = 0;
|
|
2784605
|
+
this._activeConnections = 0;
|
|
2784606
|
+
this._originStatus = {};
|
|
2784607
|
+
}
|
|
2784608
|
+
getStats() {
|
|
2784609
|
+
return {
|
|
2784610
|
+
accepted: this._accepted,
|
|
2784611
|
+
deduplicated: this._deduplicated,
|
|
2784612
|
+
partialReconnects: this._partialReconnects,
|
|
2784613
|
+
fullReconnects: this._fullReconnects,
|
|
2784614
|
+
configuredConnections: this._configuredConnections,
|
|
2784615
|
+
activeConnections: this._activeConnections,
|
|
2784616
|
+
totalReceived: this._totalReceived,
|
|
2784617
|
+
originStatus: Object.freeze({ ...this._originStatus })
|
|
2784618
|
+
};
|
|
2784619
|
+
}
|
|
2784620
|
+
}
|
|
2784621
|
+
exports6.StreamStats = StreamStats;
|
|
2784622
|
+
});
|
|
2784623
|
+
|
|
2784624
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/utils/origin-discovery.js
|
|
2784625
|
+
var require_origin_discovery = __commonJS((exports6) => {
|
|
2784626
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784627
|
+
exports6.parseCommaSeparatedUrls = parseCommaSeparatedUrls;
|
|
2784628
|
+
exports6.convertWebSocketToHttpScheme = convertWebSocketToHttpScheme;
|
|
2784629
|
+
exports6.parseOriginsHeader = parseOriginsHeader;
|
|
2784630
|
+
exports6.discoverOrigins = discoverOrigins;
|
|
2784631
|
+
exports6.getAvailableOrigins = getAvailableOrigins;
|
|
2784632
|
+
var constants_1 = require_constants79();
|
|
2784633
|
+
var auth_1 = require_auth2();
|
|
2784634
|
+
var errors_1 = require_errors56();
|
|
2784635
|
+
function parseCommaSeparatedUrls(wsUrl) {
|
|
2784636
|
+
return wsUrl.split(",").map((url3) => url3.trim()).filter((url3) => url3.length > 0);
|
|
2784637
|
+
}
|
|
2784638
|
+
function convertWebSocketToHttpScheme(wsUrl) {
|
|
2784639
|
+
if (wsUrl.startsWith("wss://")) {
|
|
2784640
|
+
return wsUrl.replace("wss://", "https://");
|
|
2784641
|
+
} else if (wsUrl.startsWith("ws://")) {
|
|
2784642
|
+
return wsUrl.replace("ws://", "http://");
|
|
2784643
|
+
}
|
|
2784644
|
+
return wsUrl;
|
|
2784645
|
+
}
|
|
2784646
|
+
function parseOriginsHeader(headerValue) {
|
|
2784647
|
+
if (!headerValue) {
|
|
2784648
|
+
return [];
|
|
2784649
|
+
}
|
|
2784650
|
+
let cleaned = headerValue.trim();
|
|
2784651
|
+
if (cleaned.startsWith("{")) {
|
|
2784652
|
+
cleaned = cleaned.slice(1);
|
|
2784653
|
+
}
|
|
2784654
|
+
if (cleaned.endsWith("}")) {
|
|
2784655
|
+
cleaned = cleaned.slice(0, -1);
|
|
2784656
|
+
}
|
|
2784657
|
+
return cleaned.split(",").map((origin2) => origin2.trim()).filter((origin2) => origin2.length > 0);
|
|
2784658
|
+
}
|
|
2784659
|
+
async function discoverOrigins(baseUrl, apiKey, userSecret, timeout = constants_1.WS_CONSTANTS.CONNECT_TIMEOUT, logger106) {
|
|
2784660
|
+
logger106?.debug(`Starting origin discovery for ${baseUrl}`);
|
|
2784661
|
+
try {
|
|
2784662
|
+
const httpUrl2 = convertWebSocketToHttpScheme(baseUrl);
|
|
2784663
|
+
logger106?.debug(`Converted WebSocket URL to HTTP: ${httpUrl2}`);
|
|
2784664
|
+
const url3 = new URL("/", httpUrl2);
|
|
2784665
|
+
const headers = (0, auth_1.generateAuthHeaders)(apiKey, userSecret, "HEAD", url3.toString());
|
|
2784666
|
+
const controller = new AbortController;
|
|
2784667
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
2784668
|
+
try {
|
|
2784669
|
+
const response = await fetch(url3.toString(), {
|
|
2784670
|
+
method: "HEAD",
|
|
2784671
|
+
headers,
|
|
2784672
|
+
signal: controller.signal
|
|
2784673
|
+
});
|
|
2784674
|
+
if (!response.ok) {
|
|
2784675
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
2784676
|
+
}
|
|
2784677
|
+
const originsHeader = response.headers.get(constants_1.X_CLL_AVAILABLE_ORIGINS_HEADER);
|
|
2784678
|
+
if (!originsHeader) {
|
|
2784679
|
+
logger106?.info("No origins header found in response");
|
|
2784680
|
+
return [];
|
|
2784681
|
+
}
|
|
2784682
|
+
const origins = parseOriginsHeader(originsHeader);
|
|
2784683
|
+
logger106?.info(`Origin discovery successful: found ${origins.length} origins`);
|
|
2784684
|
+
return origins;
|
|
2784685
|
+
} finally {
|
|
2784686
|
+
clearTimeout(timeoutId);
|
|
2784687
|
+
}
|
|
2784688
|
+
} catch (error56) {
|
|
2784689
|
+
logger106?.error(`Origin discovery failed for ${baseUrl}:`, error56);
|
|
2784690
|
+
if (error56 instanceof Error) {
|
|
2784691
|
+
if (error56.name === "AbortError") {
|
|
2784692
|
+
throw new errors_1.OriginDiscoveryError(`Origin discovery timed out after ${timeout}ms`, error56);
|
|
2784693
|
+
}
|
|
2784694
|
+
throw new errors_1.OriginDiscoveryError(`Failed to discover origins: ${error56.message}`, error56);
|
|
2784695
|
+
}
|
|
2784696
|
+
throw new errors_1.OriginDiscoveryError("Unknown error during origin discovery");
|
|
2784697
|
+
}
|
|
2784698
|
+
}
|
|
2784699
|
+
async function getAvailableOrigins(wsUrl, apiKey, userSecret, haEnabled = true, timeout = constants_1.WS_CONSTANTS.CONNECT_TIMEOUT, logger106) {
|
|
2784700
|
+
logger106?.debug(`Getting available origins for ${wsUrl}, dynamic discovery: ${haEnabled}`);
|
|
2784701
|
+
const staticOrigins = parseCommaSeparatedUrls(wsUrl);
|
|
2784702
|
+
logger106?.debug(`Found ${staticOrigins.length} static origins`);
|
|
2784703
|
+
if (!haEnabled || staticOrigins.length > 1) {
|
|
2784704
|
+
logger106?.info(`Using static origins: ${staticOrigins.join(", ")}`);
|
|
2784705
|
+
return staticOrigins;
|
|
2784706
|
+
}
|
|
2784707
|
+
try {
|
|
2784708
|
+
const dynamicOrigins = await discoverOrigins(staticOrigins[0], apiKey, userSecret, timeout, logger106);
|
|
2784709
|
+
let finalOrigins = dynamicOrigins.length > 0 ? dynamicOrigins : staticOrigins;
|
|
2784710
|
+
if (dynamicOrigins.length > 0 && !dynamicOrigins[0].startsWith("ws")) {
|
|
2784711
|
+
const baseUrl = staticOrigins[0];
|
|
2784712
|
+
finalOrigins = dynamicOrigins.map((originId) => `${baseUrl}#${originId}`);
|
|
2784713
|
+
}
|
|
2784714
|
+
if (finalOrigins.length === 0) {
|
|
2784715
|
+
throw new errors_1.InsufficientConnectionsError("No origins available for connection", 0, 1);
|
|
2784716
|
+
}
|
|
2784717
|
+
logger106?.info(`Dynamic discovery completed: ${finalOrigins.length} origins available`);
|
|
2784718
|
+
return finalOrigins;
|
|
2784719
|
+
} catch (error56) {
|
|
2784720
|
+
logger106?.warn(`Dynamic discovery failed, falling back to static origins:`, error56);
|
|
2784721
|
+
if (staticOrigins.length === 0) {
|
|
2784722
|
+
throw new errors_1.InsufficientConnectionsError("No origins available for connection after discovery failure", 0, 1);
|
|
2784723
|
+
}
|
|
2784724
|
+
return staticOrigins;
|
|
2784725
|
+
}
|
|
2784726
|
+
}
|
|
2784727
|
+
});
|
|
2784728
|
+
|
|
2784729
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/stream/connection-manager.js
|
|
2784730
|
+
var require_connection_manager = __commonJS((exports6) => {
|
|
2784731
|
+
var __importDefault = exports6 && exports6.__importDefault || function(mod11) {
|
|
2784732
|
+
return mod11 && mod11.__esModule ? mod11 : { default: mod11 };
|
|
2784733
|
+
};
|
|
2784734
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2784735
|
+
exports6.ConnectionManager = exports6.ConnectionState = undefined;
|
|
2784736
|
+
var ws_1 = __importDefault(__require("ws"));
|
|
2784737
|
+
var events_1 = __require("events");
|
|
2784738
|
+
var auth_1 = require_auth2();
|
|
2784739
|
+
var origin_discovery_1 = require_origin_discovery();
|
|
2784740
|
+
var constants_1 = require_constants79();
|
|
2784741
|
+
var errors_1 = require_errors56();
|
|
2784742
|
+
var logger_1 = require_logger17();
|
|
2784743
|
+
var metrics_1 = require_metrics4();
|
|
2784744
|
+
var ConnectionState;
|
|
2784745
|
+
(function(ConnectionState2) {
|
|
2784746
|
+
ConnectionState2["DISCONNECTED"] = "disconnected";
|
|
2784747
|
+
ConnectionState2["CONNECTING"] = "connecting";
|
|
2784748
|
+
ConnectionState2["CONNECTED"] = "connected";
|
|
2784749
|
+
ConnectionState2["RECONNECTING"] = "reconnecting";
|
|
2784750
|
+
ConnectionState2["FAILED"] = "failed";
|
|
2784751
|
+
})(ConnectionState || (exports6.ConnectionState = ConnectionState = {}));
|
|
2784752
|
+
|
|
2784753
|
+
class ConnectionManager extends events_1.EventEmitter {
|
|
2784754
|
+
constructor(config9, managerConfig) {
|
|
2784755
|
+
super();
|
|
2784756
|
+
this.connections = new Map;
|
|
2784757
|
+
this.isShuttingDown = false;
|
|
2784758
|
+
this.reconnectTimeouts = new Map;
|
|
2784759
|
+
this.streamStats = null;
|
|
2784760
|
+
this.config = config9;
|
|
2784761
|
+
this.managerConfig = managerConfig;
|
|
2784762
|
+
this.logger = new logger_1.SDKLogger(config9.logging);
|
|
2784763
|
+
}
|
|
2784764
|
+
setStreamStats(streamStats) {
|
|
2784765
|
+
this.streamStats = streamStats;
|
|
2784766
|
+
}
|
|
2784767
|
+
async initialize() {
|
|
2784768
|
+
try {
|
|
2784769
|
+
const origins = await (0, origin_discovery_1.getAvailableOrigins)(this.config.wsEndpoint, this.config.apiKey, this.config.userSecret, this.managerConfig.haMode, this.managerConfig.haConnectionTimeout);
|
|
2784770
|
+
const useHAMode = this.managerConfig.haMode && origins.length > 1;
|
|
2784771
|
+
const originsToUse = useHAMode ? origins : [origins[0]];
|
|
2784772
|
+
if (useHAMode) {
|
|
2784773
|
+
this.logger.info(`Initializing in HA mode with ${origins.length} origins`, {
|
|
2784774
|
+
origins: origins.map((o4) => new URL(o4).host)
|
|
2784775
|
+
});
|
|
2784776
|
+
} else {
|
|
2784777
|
+
if (this.managerConfig.haMode) {
|
|
2784778
|
+
this.logger.warn(`HA mode requested but only ${origins.length} origin available, falling back to single connection`, {
|
|
2784779
|
+
origin: new URL(origins[0]).host
|
|
2784780
|
+
});
|
|
2784781
|
+
} else {
|
|
2784782
|
+
this.logger.info(`Initializing in single connection mode`, { origin: new URL(origins[0]).host });
|
|
2784783
|
+
}
|
|
2784784
|
+
}
|
|
2784785
|
+
if (!useHAMode && this.managerConfig.haMode) {
|
|
2784786
|
+
this.emit("ha-fallback-warning", {
|
|
2784787
|
+
message: "HA mode requested but only one origin available, falling back to single connection",
|
|
2784788
|
+
requestedOrigins: origins.length,
|
|
2784789
|
+
actualMode: "single"
|
|
2784790
|
+
});
|
|
2784791
|
+
}
|
|
2784792
|
+
const connectionPromises = originsToUse.map((origin2, index4) => this.createConnection(origin2, index4));
|
|
2784793
|
+
const results = await Promise.allSettled(connectionPromises);
|
|
2784794
|
+
const successfulConnections = results.filter((r2) => r2.status === "fulfilled").length;
|
|
2784795
|
+
const failedConnections = results.length - successfulConnections;
|
|
2784796
|
+
if (successfulConnections === 0) {
|
|
2784797
|
+
throw new errors_1.InsufficientConnectionsError("Failed to establish any WebSocket connections", 0, 1);
|
|
2784798
|
+
} else if (failedConnections > 0 && useHAMode) {
|
|
2784799
|
+
this.emit("partial-failure", failedConnections, results.length);
|
|
2784800
|
+
}
|
|
2784801
|
+
} catch (error56) {
|
|
2784802
|
+
throw new errors_1.MultiConnectionError(`Failed to initialize connections: ${error56 instanceof Error ? error56.message : error56}`);
|
|
2784803
|
+
}
|
|
2784804
|
+
}
|
|
2784805
|
+
updateConnectionState(connection, newState, reason) {
|
|
2784806
|
+
const oldState = connection.state;
|
|
2784807
|
+
connection.state = newState;
|
|
2784808
|
+
if (oldState !== newState) {
|
|
2784809
|
+
const logData = {
|
|
2784810
|
+
connectionId: connection.id,
|
|
2784811
|
+
host: connection.host,
|
|
2784812
|
+
oldState,
|
|
2784813
|
+
newState,
|
|
2784814
|
+
reason
|
|
2784815
|
+
};
|
|
2784816
|
+
switch (newState) {
|
|
2784817
|
+
case ConnectionState.CONNECTING:
|
|
2784818
|
+
this.logger.connectionDebug(`Connection ${connection.id} transitioning to CONNECTING`, logData);
|
|
2784819
|
+
break;
|
|
2784820
|
+
case ConnectionState.CONNECTED:
|
|
2784821
|
+
this.logger.info(`Connection ${connection.id} established to ${connection.host}`, logData);
|
|
2784822
|
+
break;
|
|
2784823
|
+
case ConnectionState.RECONNECTING:
|
|
2784824
|
+
this.logger.warn(`Connection ${connection.id} reconnecting to ${connection.host}: ${reason || "Unknown reason"}`, logData);
|
|
2784825
|
+
break;
|
|
2784826
|
+
case ConnectionState.FAILED:
|
|
2784827
|
+
this.logger.error(`Connection ${connection.id} failed to ${connection.host}: ${reason || "Unknown reason"}`, logData);
|
|
2784828
|
+
break;
|
|
2784829
|
+
case ConnectionState.DISCONNECTED:
|
|
2784830
|
+
if (oldState === ConnectionState.CONNECTED) {
|
|
2784831
|
+
this.logger.warn(`Connection ${connection.id} lost to ${connection.host}: ${reason || "Unknown reason"}`, logData);
|
|
2784832
|
+
} else {
|
|
2784833
|
+
this.logger.connectionDebug(`Connection ${connection.id} disconnected from ${connection.host}`, logData);
|
|
2784834
|
+
}
|
|
2784835
|
+
break;
|
|
2784836
|
+
}
|
|
2784837
|
+
}
|
|
2784838
|
+
}
|
|
2784839
|
+
cleanupWebSocket(connection) {
|
|
2784840
|
+
if (!connection.ws) {
|
|
2784841
|
+
return;
|
|
2784842
|
+
}
|
|
2784843
|
+
this.logger.connectionDebug(`Cleaning up WebSocket for ${connection.id} (readyState: ${connection.ws.readyState})`);
|
|
2784844
|
+
const ws4 = connection.ws;
|
|
2784845
|
+
ws4.once("error", (error56) => {
|
|
2784846
|
+
this.logger.connectionDebug(`Error during WebSocket cleanup for ${connection.id}:`, error56);
|
|
2784847
|
+
});
|
|
2784848
|
+
ws4.removeAllListeners("open");
|
|
2784849
|
+
ws4.removeAllListeners("close");
|
|
2784850
|
+
ws4.removeAllListeners("message");
|
|
2784851
|
+
ws4.removeAllListeners("ping");
|
|
2784852
|
+
ws4.removeAllListeners("pong");
|
|
2784853
|
+
ws4.removeAllListeners("unexpected-response");
|
|
2784854
|
+
if (ws4.readyState === ws_1.default.OPEN || ws4.readyState === ws_1.default.CONNECTING) {
|
|
2784855
|
+
try {
|
|
2784856
|
+
ws4.terminate();
|
|
2784857
|
+
} catch (error56) {
|
|
2784858
|
+
this.logger.connectionDebug(`Synchronous error terminating WebSocket for ${connection.id}:`, error56);
|
|
2784859
|
+
}
|
|
2784860
|
+
}
|
|
2784861
|
+
connection.ws = null;
|
|
2784862
|
+
this.stopHealthMonitoring(connection);
|
|
2784863
|
+
}
|
|
2784864
|
+
async createConnection(origin2, index4) {
|
|
2784865
|
+
const connectionId = `conn-${index4}`;
|
|
2784866
|
+
const url3 = new URL(origin2);
|
|
2784867
|
+
const connection = {
|
|
2784868
|
+
id: connectionId,
|
|
2784869
|
+
origin: origin2,
|
|
2784870
|
+
host: url3.host,
|
|
2784871
|
+
ws: null,
|
|
2784872
|
+
state: ConnectionState.DISCONNECTED,
|
|
2784873
|
+
reconnectAttempts: 0
|
|
2784874
|
+
};
|
|
2784875
|
+
this.connections.set(connectionId, connection);
|
|
2784876
|
+
try {
|
|
2784877
|
+
await this.establishConnection(connection);
|
|
2784878
|
+
return connection;
|
|
2784879
|
+
} catch (error56) {
|
|
2784880
|
+
this.updateConnectionState(connection, ConnectionState.FAILED, `Connection setup failed: ${error56 instanceof Error ? error56.message : error56}`);
|
|
2784881
|
+
connection.lastError = error56 instanceof Error ? error56 : new Error(String(error56));
|
|
2784882
|
+
throw error56;
|
|
2784883
|
+
}
|
|
2784884
|
+
}
|
|
2784885
|
+
async establishConnection(connection) {
|
|
2784886
|
+
return new Promise((resolve7, reject) => {
|
|
2784887
|
+
try {
|
|
2784888
|
+
const hadExistingConnection = !!connection.ws;
|
|
2784889
|
+
if (hadExistingConnection) {
|
|
2784890
|
+
this.logger.connectionDebug(`Cleaning up existing WebSocket for ${connection.id} before reconnection`);
|
|
2784891
|
+
this.cleanupWebSocket(connection);
|
|
2784892
|
+
}
|
|
2784893
|
+
this.updateConnectionState(connection, ConnectionState.CONNECTING, "WebSocket connection initiated");
|
|
2784894
|
+
this.logger.connectionDebug(`Creating new WebSocket for ${connection.id} to ${connection.origin} (cleaned up old: ${hadExistingConnection})`);
|
|
2784895
|
+
const feedIdsParam = this.managerConfig.feedIds.join(",");
|
|
2784896
|
+
let baseUrl = connection.origin;
|
|
2784897
|
+
let originId = "";
|
|
2784898
|
+
if (connection.origin.includes("#")) {
|
|
2784899
|
+
[baseUrl, originId] = connection.origin.split("#");
|
|
2784900
|
+
} else if (!connection.origin.startsWith("ws")) {
|
|
2784901
|
+
baseUrl = this.config.wsEndpoint.split(",")[0];
|
|
2784902
|
+
originId = connection.origin;
|
|
2784903
|
+
}
|
|
2784904
|
+
const wsUrl = `${baseUrl}/api/v1/ws?feedIDs=${feedIdsParam}`;
|
|
2784905
|
+
const headers = (0, auth_1.generateAuthHeaders)(this.config.apiKey, this.config.userSecret, "GET", wsUrl);
|
|
2784906
|
+
if (originId) {
|
|
2784907
|
+
headers[constants_1.X_CLL_ORIGIN_HEADER] = originId;
|
|
2784908
|
+
}
|
|
2784909
|
+
const connectTimeout = setTimeout(() => {
|
|
2784910
|
+
if (connection.ws) {
|
|
2784911
|
+
connection.ws.terminate();
|
|
2784912
|
+
}
|
|
2784913
|
+
reject(new errors_1.WebSocketError(`Connection timeout after ${this.managerConfig.connectTimeout}ms`));
|
|
2784914
|
+
}, this.managerConfig.connectTimeout);
|
|
2784915
|
+
connection.ws = new ws_1.default(wsUrl, { headers });
|
|
2784916
|
+
connection.ws.once("unexpected-response", (_req, res) => {
|
|
2784917
|
+
clearTimeout(connectTimeout);
|
|
2784918
|
+
const status = res?.statusCode;
|
|
2784919
|
+
if (status === 401 || status === 403) {
|
|
2784920
|
+
reject(new errors_1.WebSocketError(`Authentication failed during WebSocket handshake (${status}). Check API key/secret.`));
|
|
2784921
|
+
} else {
|
|
2784922
|
+
reject(new errors_1.WebSocketError(`Unexpected WebSocket handshake response: ${String(status)}`));
|
|
2784923
|
+
}
|
|
2784924
|
+
});
|
|
2784925
|
+
connection.ws.on("open", () => {
|
|
2784926
|
+
clearTimeout(connectTimeout);
|
|
2784927
|
+
this.updateConnectionState(connection, ConnectionState.CONNECTED, "WebSocket connection established");
|
|
2784928
|
+
connection.connectedAt = Date.now();
|
|
2784929
|
+
connection.reconnectAttempts = 0;
|
|
2784930
|
+
this.startHealthMonitoring(connection);
|
|
2784931
|
+
if (this.managerConfig.statusCallback) {
|
|
2784932
|
+
this.managerConfig.statusCallback(true, connection.host, connection.origin);
|
|
2784933
|
+
}
|
|
2784934
|
+
this.emit("connection-established", connection);
|
|
2784935
|
+
resolve7();
|
|
2784936
|
+
});
|
|
2784937
|
+
connection.ws.on("message", (data7) => {
|
|
2784938
|
+
this.emit("message", data7, connection);
|
|
2784939
|
+
});
|
|
2784940
|
+
connection.ws.on("close", () => {
|
|
2784941
|
+
clearTimeout(connectTimeout);
|
|
2784942
|
+
this.handleConnectionLoss(connection);
|
|
2784943
|
+
});
|
|
2784944
|
+
connection.ws.on("error", (error56) => {
|
|
2784945
|
+
clearTimeout(connectTimeout);
|
|
2784946
|
+
connection.lastError = error56;
|
|
2784947
|
+
if (connection.state === ConnectionState.CONNECTING) {
|
|
2784948
|
+
const message5 = /401|403/.test(error56.message) ? `Authentication failed during WebSocket handshake. Check API key/secret. (${error56.message})` : `Failed to connect to ${connection.origin}: ${error56.message}`;
|
|
2784949
|
+
reject(new errors_1.WebSocketError(message5));
|
|
2784950
|
+
} else {
|
|
2784951
|
+
this.handleConnectionLoss(connection, error56);
|
|
2784952
|
+
}
|
|
2784953
|
+
});
|
|
2784954
|
+
connection.ws.on("ping", (data7) => {
|
|
2784955
|
+
this.logger.connectionDebug(`Received ping from ${connection.origin}`);
|
|
2784956
|
+
if (connection.ws && connection.ws.readyState === ws_1.default.OPEN) {
|
|
2784957
|
+
try {
|
|
2784958
|
+
this.logger.connectionDebug(`Responding with pong to ${connection.origin}`);
|
|
2784959
|
+
connection.ws.pong(data7);
|
|
2784960
|
+
} catch {}
|
|
2784961
|
+
}
|
|
2784962
|
+
});
|
|
2784963
|
+
connection.ws.on("pong", () => {
|
|
2784964
|
+
this.handlePongReceived(connection);
|
|
2784965
|
+
});
|
|
2784966
|
+
} catch (error56) {
|
|
2784967
|
+
reject(error56);
|
|
2784968
|
+
}
|
|
2784969
|
+
});
|
|
2784970
|
+
}
|
|
2784971
|
+
handleConnectionLoss(connection, error56) {
|
|
2784972
|
+
if (this.isShuttingDown) {
|
|
2784973
|
+
return;
|
|
2784974
|
+
}
|
|
2784975
|
+
const wasConnected = connection.state === ConnectionState.CONNECTED;
|
|
2784976
|
+
this.updateConnectionState(connection, ConnectionState.DISCONNECTED, error56 ? `Connection lost: ${error56.message}` : "Connection closed");
|
|
2784977
|
+
connection.lastError = error56;
|
|
2784978
|
+
this.stopHealthMonitoring(connection);
|
|
2784979
|
+
if (this.managerConfig.statusCallback && wasConnected) {
|
|
2784980
|
+
this.managerConfig.statusCallback(false, connection.host, connection.origin);
|
|
2784981
|
+
}
|
|
2784982
|
+
this.emit("connection-lost", connection, error56);
|
|
2784983
|
+
const activeConnections = this.getActiveConnectionCount();
|
|
2784984
|
+
if (activeConnections === 0) {
|
|
2784985
|
+
this.emit("all-connections-lost");
|
|
2784986
|
+
}
|
|
2784987
|
+
this.scheduleReconnection(connection);
|
|
2784988
|
+
}
|
|
2784989
|
+
scheduleReconnection(connection) {
|
|
2784990
|
+
if (this.isShuttingDown) {
|
|
2784991
|
+
return;
|
|
2784992
|
+
}
|
|
2784993
|
+
connection.reconnectAttempts++;
|
|
2784994
|
+
this.updateConnectionState(connection, ConnectionState.RECONNECTING, `Reconnect attempt ${connection.reconnectAttempts}/${this.managerConfig.maxReconnectAttempts}`);
|
|
2784995
|
+
connection.lastReconnectAt = Date.now();
|
|
2784996
|
+
const activeConnections = this.getActiveConnectionCount();
|
|
2784997
|
+
if (activeConnections === 0) {
|
|
2784998
|
+
if (this.streamStats) {
|
|
2784999
|
+
this.streamStats.incrementFullReconnects();
|
|
2785000
|
+
}
|
|
2785001
|
+
this.logger.debug(`Full reconnection attempt (no active connections)`);
|
|
2785002
|
+
} else {
|
|
2785003
|
+
if (this.streamStats) {
|
|
2785004
|
+
this.streamStats.incrementPartialReconnects();
|
|
2785005
|
+
}
|
|
2785006
|
+
this.logger.debug(`Partial reconnection attempt (${activeConnections} active connections remaining)`);
|
|
2785007
|
+
}
|
|
2785008
|
+
const baseDelay = this.managerConfig.reconnectInterval || constants_1.WS_CONSTANTS.RECONNECT_DELAY;
|
|
2785009
|
+
const delay8 = Math.min(baseDelay * Math.pow(2, connection.reconnectAttempts - 1), constants_1.WS_CONSTANTS.MAX_RECONNECT_INTERVAL);
|
|
2785010
|
+
this.logger.debug(`Scheduling reconnection for ${connection.id} in ${delay8}ms (attempt ${connection.reconnectAttempts})`);
|
|
2785011
|
+
this.emit("reconnecting", {
|
|
2785012
|
+
attempt: connection.reconnectAttempts,
|
|
2785013
|
+
delayMs: delay8,
|
|
2785014
|
+
origin: connection.origin,
|
|
2785015
|
+
host: connection.host
|
|
2785016
|
+
}, connection);
|
|
2785017
|
+
const timeout = setTimeout(async () => {
|
|
2785018
|
+
this.reconnectTimeouts.delete(connection.id);
|
|
2785019
|
+
if (this.isShuttingDown) {
|
|
2785020
|
+
return;
|
|
2785021
|
+
}
|
|
2785022
|
+
const activeConnections2 = this.getActiveConnectionCount();
|
|
2785023
|
+
if (connection.reconnectAttempts >= this.managerConfig.maxReconnectAttempts && activeConnections2 === 0) {
|
|
2785024
|
+
this.updateConnectionState(connection, ConnectionState.FAILED, `Max reconnection attempts (${this.managerConfig.maxReconnectAttempts}) reached with no active connections`);
|
|
2785025
|
+
this.emit("max-reconnect-attempts-reached", {
|
|
2785026
|
+
origin: connection.origin,
|
|
2785027
|
+
attempts: connection.reconnectAttempts,
|
|
2785028
|
+
activeConnections: activeConnections2,
|
|
2785029
|
+
message: `Max reconnection attempts reached for ${connection.origin} with no active connections`
|
|
2785030
|
+
});
|
|
2785031
|
+
this.emit("all-connections-lost");
|
|
2785032
|
+
return;
|
|
2785033
|
+
}
|
|
2785034
|
+
try {
|
|
2785035
|
+
await this.establishConnection(connection);
|
|
2785036
|
+
this.emit("connection-restored", connection);
|
|
2785037
|
+
} catch {
|
|
2785038
|
+
this.scheduleReconnection(connection);
|
|
2785039
|
+
}
|
|
2785040
|
+
}, delay8);
|
|
2785041
|
+
timeout.unref();
|
|
2785042
|
+
this.reconnectTimeouts.set(connection.id, timeout);
|
|
2785043
|
+
}
|
|
2785044
|
+
getActiveConnectionCount() {
|
|
2785045
|
+
return Array.from(this.connections.values()).filter((conn) => conn.state === ConnectionState.CONNECTED).length;
|
|
2785046
|
+
}
|
|
2785047
|
+
getConfiguredConnectionCount() {
|
|
2785048
|
+
return this.connections.size;
|
|
2785049
|
+
}
|
|
2785050
|
+
getConnectionStates() {
|
|
2785051
|
+
const states = {};
|
|
2785052
|
+
for (const [id4, conn] of this.connections) {
|
|
2785053
|
+
states[id4] = conn.state;
|
|
2785054
|
+
}
|
|
2785055
|
+
return states;
|
|
2785056
|
+
}
|
|
2785057
|
+
getConnectionDetails() {
|
|
2785058
|
+
return Array.from(this.connections.values()).map((conn) => ({
|
|
2785059
|
+
...conn,
|
|
2785060
|
+
ws: null
|
|
2785061
|
+
}));
|
|
2785062
|
+
}
|
|
2785063
|
+
startHealthMonitoring(connection) {
|
|
2785064
|
+
connection.pingInterval = setInterval(() => {
|
|
2785065
|
+
this.sendPing(connection);
|
|
2785066
|
+
}, constants_1.WS_CONSTANTS.PING_INTERVAL);
|
|
2785067
|
+
connection.pingInterval.unref();
|
|
2785068
|
+
}
|
|
2785069
|
+
sendPing(connection) {
|
|
2785070
|
+
if (!connection.ws || connection.ws.readyState !== ws_1.default.OPEN) {
|
|
2785071
|
+
return;
|
|
2785072
|
+
}
|
|
2785073
|
+
try {
|
|
2785074
|
+
this.logger.connectionDebug(`Sending ping to ${connection.origin}`);
|
|
2785075
|
+
connection.ws.ping();
|
|
2785076
|
+
connection.pongTimeout = setTimeout(() => {
|
|
2785077
|
+
this.logger.warn(`Pong timeout for ${connection.origin} - terminating connection`);
|
|
2785078
|
+
if (connection.ws) {
|
|
2785079
|
+
connection.ws.terminate();
|
|
2785080
|
+
}
|
|
2785081
|
+
}, constants_1.WS_CONSTANTS.PONG_TIMEOUT);
|
|
2785082
|
+
connection.pongTimeout.unref();
|
|
2785083
|
+
} catch (error56) {
|
|
2785084
|
+
this.logger.error(`Ping failed for ${connection.origin}:`, error56);
|
|
2785085
|
+
if (connection.ws) {
|
|
2785086
|
+
connection.ws.terminate();
|
|
2785087
|
+
}
|
|
2785088
|
+
}
|
|
2785089
|
+
}
|
|
2785090
|
+
handlePongReceived(connection) {
|
|
2785091
|
+
this.logger.connectionDebug(`Received pong from ${connection.origin}`);
|
|
2785092
|
+
if (connection.pongTimeout) {
|
|
2785093
|
+
clearTimeout(connection.pongTimeout);
|
|
2785094
|
+
connection.pongTimeout = undefined;
|
|
2785095
|
+
}
|
|
2785096
|
+
}
|
|
2785097
|
+
stopHealthMonitoring(connection) {
|
|
2785098
|
+
if (connection.pingInterval) {
|
|
2785099
|
+
clearInterval(connection.pingInterval);
|
|
2785100
|
+
connection.pingInterval = undefined;
|
|
2785101
|
+
}
|
|
2785102
|
+
if (connection.pongTimeout) {
|
|
2785103
|
+
clearTimeout(connection.pongTimeout);
|
|
2785104
|
+
connection.pongTimeout = undefined;
|
|
2785105
|
+
}
|
|
2785106
|
+
}
|
|
2785107
|
+
async shutdown() {
|
|
2785108
|
+
this.isShuttingDown = true;
|
|
2785109
|
+
for (const timeout of this.reconnectTimeouts.values()) {
|
|
2785110
|
+
clearTimeout(timeout);
|
|
2785111
|
+
}
|
|
2785112
|
+
this.reconnectTimeouts.clear();
|
|
2785113
|
+
const closePromises = Array.from(this.connections.values()).map((connection) => this.closeConnection(connection));
|
|
2785114
|
+
await Promise.allSettled(closePromises);
|
|
2785115
|
+
this.connections.clear();
|
|
2785116
|
+
}
|
|
2785117
|
+
async closeConnection(connection) {
|
|
2785118
|
+
return new Promise((resolve7) => {
|
|
2785119
|
+
if (!connection.ws) {
|
|
2785120
|
+
resolve7();
|
|
2785121
|
+
return;
|
|
2785122
|
+
}
|
|
2785123
|
+
const ws4 = connection.ws;
|
|
2785124
|
+
this.updateConnectionState(connection, ConnectionState.DISCONNECTED, "Graceful shutdown initiated");
|
|
2785125
|
+
this.stopHealthMonitoring(connection);
|
|
2785126
|
+
if (ws4.readyState === ws_1.default.OPEN || ws4.readyState === ws_1.default.CONNECTING) {
|
|
2785127
|
+
const timeout = setTimeout(() => {
|
|
2785128
|
+
this.cleanupWebSocket(connection);
|
|
2785129
|
+
resolve7();
|
|
2785130
|
+
}, 1000);
|
|
2785131
|
+
ws4.once("close", () => {
|
|
2785132
|
+
clearTimeout(timeout);
|
|
2785133
|
+
this.cleanupWebSocket(connection);
|
|
2785134
|
+
resolve7();
|
|
2785135
|
+
});
|
|
2785136
|
+
try {
|
|
2785137
|
+
ws4.close();
|
|
2785138
|
+
} catch (error56) {
|
|
2785139
|
+
this.logger.connectionDebug(`Error closing WebSocket for ${connection.id}:`, error56);
|
|
2785140
|
+
this.cleanupWebSocket(connection);
|
|
2785141
|
+
clearTimeout(timeout);
|
|
2785142
|
+
resolve7();
|
|
2785143
|
+
}
|
|
2785144
|
+
} else {
|
|
2785145
|
+
this.cleanupWebSocket(connection);
|
|
2785146
|
+
resolve7();
|
|
2785147
|
+
}
|
|
2785148
|
+
});
|
|
2785149
|
+
}
|
|
2785150
|
+
getOriginStatusMap() {
|
|
2785151
|
+
const originStatus = {};
|
|
2785152
|
+
for (const connection of this.connections.values()) {
|
|
2785153
|
+
let status;
|
|
2785154
|
+
switch (connection.state) {
|
|
2785155
|
+
case ConnectionState.CONNECTED:
|
|
2785156
|
+
status = metrics_1.ConnectionStatus.CONNECTED;
|
|
2785157
|
+
break;
|
|
2785158
|
+
case ConnectionState.CONNECTING:
|
|
2785159
|
+
status = metrics_1.ConnectionStatus.CONNECTING;
|
|
2785160
|
+
break;
|
|
2785161
|
+
case ConnectionState.RECONNECTING:
|
|
2785162
|
+
status = metrics_1.ConnectionStatus.RECONNECTING;
|
|
2785163
|
+
break;
|
|
2785164
|
+
case ConnectionState.FAILED:
|
|
2785165
|
+
status = metrics_1.ConnectionStatus.FAILED;
|
|
2785166
|
+
break;
|
|
2785167
|
+
case ConnectionState.DISCONNECTED:
|
|
2785168
|
+
default:
|
|
2785169
|
+
status = metrics_1.ConnectionStatus.DISCONNECTED;
|
|
2785170
|
+
break;
|
|
2785171
|
+
}
|
|
2785172
|
+
originStatus[connection.origin] = status;
|
|
2785173
|
+
}
|
|
2785174
|
+
return Object.freeze(originStatus);
|
|
2785175
|
+
}
|
|
2785176
|
+
}
|
|
2785177
|
+
exports6.ConnectionManager = ConnectionManager;
|
|
2785178
|
+
});
|
|
2785179
|
+
|
|
2785180
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/stream/deduplication.js
|
|
2785181
|
+
var require_deduplication = __commonJS((exports6) => {
|
|
2785182
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2785183
|
+
exports6.ReportDeduplicator = undefined;
|
|
2785184
|
+
|
|
2785185
|
+
class ReportDeduplicator {
|
|
2785186
|
+
constructor(options4 = {}) {
|
|
2785187
|
+
this.waterMark = new Map;
|
|
2785188
|
+
this.acceptedCount = 0;
|
|
2785189
|
+
this.deduplicatedCount = 0;
|
|
2785190
|
+
this.cleanupInterval = null;
|
|
2785191
|
+
this.maxWatermarkAge = options4.maxWatermarkAge ?? 60 * 60 * 1000;
|
|
2785192
|
+
this.cleanupIntervalMs = options4.cleanupIntervalMs ?? 5 * 60 * 1000;
|
|
2785193
|
+
this.startCleanup();
|
|
2785194
|
+
}
|
|
2785195
|
+
processReport(report) {
|
|
2785196
|
+
const feedId = report.feedID;
|
|
2785197
|
+
const observationsTimestamp = report.observationsTimestamp;
|
|
2785198
|
+
const currentWatermark = this.waterMark.get(feedId);
|
|
2785199
|
+
if (currentWatermark !== undefined && currentWatermark >= observationsTimestamp) {
|
|
2785200
|
+
this.deduplicatedCount++;
|
|
2785201
|
+
return {
|
|
2785202
|
+
isAccepted: false,
|
|
2785203
|
+
isDuplicate: true,
|
|
2785204
|
+
reason: `Report timestamp ${observationsTimestamp} <= watermark ${currentWatermark} for feed ${feedId}`
|
|
2785205
|
+
};
|
|
2785206
|
+
}
|
|
2785207
|
+
this.waterMark.set(feedId, observationsTimestamp);
|
|
2785208
|
+
this.acceptedCount++;
|
|
2785209
|
+
return {
|
|
2785210
|
+
isAccepted: true,
|
|
2785211
|
+
isDuplicate: false
|
|
2785212
|
+
};
|
|
2785213
|
+
}
|
|
2785214
|
+
getStats() {
|
|
2785215
|
+
return {
|
|
2785216
|
+
accepted: this.acceptedCount,
|
|
2785217
|
+
deduplicated: this.deduplicatedCount,
|
|
2785218
|
+
totalReceived: this.acceptedCount + this.deduplicatedCount,
|
|
2785219
|
+
watermarkCount: this.waterMark.size
|
|
2785220
|
+
};
|
|
2785221
|
+
}
|
|
2785222
|
+
getWatermark(feedId) {
|
|
2785223
|
+
return this.waterMark.get(feedId);
|
|
2785224
|
+
}
|
|
2785225
|
+
getAllWatermarks() {
|
|
2785226
|
+
const watermarks = {};
|
|
2785227
|
+
for (const [feedId, timestamp2] of this.waterMark) {
|
|
2785228
|
+
watermarks[feedId] = timestamp2;
|
|
2785229
|
+
}
|
|
2785230
|
+
return watermarks;
|
|
2785231
|
+
}
|
|
2785232
|
+
setWatermark(feedId, timestamp2) {
|
|
2785233
|
+
this.waterMark.set(feedId, timestamp2);
|
|
2785234
|
+
}
|
|
2785235
|
+
clearWatermark(feedId) {
|
|
2785236
|
+
return this.waterMark.delete(feedId);
|
|
2785237
|
+
}
|
|
2785238
|
+
clearAllWatermarks() {
|
|
2785239
|
+
this.waterMark.clear();
|
|
2785240
|
+
}
|
|
2785241
|
+
reset() {
|
|
2785242
|
+
this.acceptedCount = 0;
|
|
2785243
|
+
this.deduplicatedCount = 0;
|
|
2785244
|
+
this.waterMark.clear();
|
|
2785245
|
+
}
|
|
2785246
|
+
startCleanup() {
|
|
2785247
|
+
this.cleanupInterval = setInterval(() => {
|
|
2785248
|
+
this.cleanupOldWatermarks();
|
|
2785249
|
+
}, this.cleanupIntervalMs);
|
|
2785250
|
+
}
|
|
2785251
|
+
cleanupOldWatermarks() {
|
|
2785252
|
+
const now4 = Date.now();
|
|
2785253
|
+
const cutoffTime = now4 - this.maxWatermarkAge;
|
|
2785254
|
+
const cutoffTimestamp = Math.floor(cutoffTime / 1000);
|
|
2785255
|
+
let _removedCount = 0;
|
|
2785256
|
+
for (const [feedId, timestamp2] of this.waterMark) {
|
|
2785257
|
+
if (timestamp2 < cutoffTimestamp) {
|
|
2785258
|
+
this.waterMark.delete(feedId);
|
|
2785259
|
+
_removedCount++;
|
|
2785260
|
+
}
|
|
2785261
|
+
}
|
|
2785262
|
+
}
|
|
2785263
|
+
stop() {
|
|
2785264
|
+
if (this.cleanupInterval) {
|
|
2785265
|
+
clearInterval(this.cleanupInterval);
|
|
2785266
|
+
this.cleanupInterval = null;
|
|
2785267
|
+
}
|
|
2785268
|
+
}
|
|
2785269
|
+
getMemoryInfo() {
|
|
2785270
|
+
const watermarkCount = this.waterMark.size;
|
|
2785271
|
+
const estimatedMemoryBytes = watermarkCount * (64 + 8 + 32);
|
|
2785272
|
+
return {
|
|
2785273
|
+
watermarkCount,
|
|
2785274
|
+
estimatedMemoryBytes
|
|
2785275
|
+
};
|
|
2785276
|
+
}
|
|
2785277
|
+
exportWatermarks() {
|
|
2785278
|
+
return Array.from(this.waterMark.entries()).map(([feedId, timestamp2]) => ({
|
|
2785279
|
+
feedId,
|
|
2785280
|
+
timestamp: timestamp2
|
|
2785281
|
+
}));
|
|
2785282
|
+
}
|
|
2785283
|
+
importWatermarks(watermarks) {
|
|
2785284
|
+
for (const { feedId, timestamp: timestamp2 } of watermarks) {
|
|
2785285
|
+
this.waterMark.set(feedId, timestamp2);
|
|
2785286
|
+
}
|
|
2785287
|
+
}
|
|
2785288
|
+
}
|
|
2785289
|
+
exports6.ReportDeduplicator = ReportDeduplicator;
|
|
2785290
|
+
});
|
|
2785291
|
+
|
|
2785292
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/stream/index.js
|
|
2785293
|
+
var require_stream = __commonJS((exports6) => {
|
|
2785294
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2785295
|
+
exports6.Stream = exports6.ConnectionType = undefined;
|
|
2785296
|
+
var events_1 = __require("events");
|
|
2785297
|
+
var stats_1 = require_stats();
|
|
2785298
|
+
var metrics_1 = require_metrics4();
|
|
2785299
|
+
var constants_1 = require_constants79();
|
|
2785300
|
+
var connection_manager_1 = require_connection_manager();
|
|
2785301
|
+
var deduplication_1 = require_deduplication();
|
|
2785302
|
+
var errors_1 = require_errors56();
|
|
2785303
|
+
var logger_1 = require_logger17();
|
|
2785304
|
+
var ConnectionType;
|
|
2785305
|
+
(function(ConnectionType2) {
|
|
2785306
|
+
ConnectionType2["Single"] = "single";
|
|
2785307
|
+
ConnectionType2["Multiple"] = "multiple";
|
|
2785308
|
+
})(ConnectionType || (exports6.ConnectionType = ConnectionType = {}));
|
|
2785309
|
+
|
|
2785310
|
+
class Stream4 extends events_1.EventEmitter {
|
|
2785311
|
+
constructor(config9, feedIds, options4 = {}) {
|
|
2785312
|
+
super();
|
|
2785313
|
+
this.isClosing = false;
|
|
2785314
|
+
this.origins = [];
|
|
2785315
|
+
this.config = config9;
|
|
2785316
|
+
this.feedIds = feedIds;
|
|
2785317
|
+
this.logger = new logger_1.SDKLogger(config9.logging);
|
|
2785318
|
+
this.options = {
|
|
2785319
|
+
reconnectInterval: options4.reconnectInterval || constants_1.WS_CONSTANTS.RECONNECT_DELAY,
|
|
2785320
|
+
maxReconnectAttempts: options4.maxReconnectAttempts || constants_1.WS_CONSTANTS.MAX_RECONNECTS
|
|
2785321
|
+
};
|
|
2785322
|
+
this.logger.debug(`Creating stream for feeds: ${feedIds.join(", ")}`);
|
|
2785323
|
+
this.logger.debug(`Stream options: reconnectInterval=${this.options.reconnectInterval}ms, maxReconnectAttempts=${this.options.maxReconnectAttempts}`);
|
|
2785324
|
+
const useHAMode = config9.haMode && this.parseOrigins().length > 1;
|
|
2785325
|
+
this.connectionType = useHAMode ? ConnectionType.Multiple : ConnectionType.Single;
|
|
2785326
|
+
this.logger.info(`Initializing stream in ${this.connectionType} mode`);
|
|
2785327
|
+
const expectedConnections = useHAMode ? this.parseOrigins().length : 1;
|
|
2785328
|
+
this.stats = new stats_1.StreamStats(expectedConnections);
|
|
2785329
|
+
this.logger.debug(`Expected connections: ${expectedConnections}`);
|
|
2785330
|
+
const managerConfig = {
|
|
2785331
|
+
feedIds: this.feedIds,
|
|
2785332
|
+
maxReconnectAttempts: this.options.maxReconnectAttempts,
|
|
2785333
|
+
reconnectInterval: this.options.reconnectInterval,
|
|
2785334
|
+
connectTimeout: config9.haConnectionTimeout || constants_1.WS_CONSTANTS.CONNECT_TIMEOUT,
|
|
2785335
|
+
haMode: config9.haMode || false,
|
|
2785336
|
+
haConnectionTimeout: config9.haConnectionTimeout || constants_1.WS_CONSTANTS.CONNECT_TIMEOUT,
|
|
2785337
|
+
statusCallback: config9.connectionStatusCallback
|
|
2785338
|
+
};
|
|
2785339
|
+
this.connectionManager = new connection_manager_1.ConnectionManager(config9, managerConfig);
|
|
2785340
|
+
this.deduplicator = new deduplication_1.ReportDeduplicator;
|
|
2785341
|
+
this.connectionManager.setStreamStats(this.stats);
|
|
2785342
|
+
this.setupConnectionManagerEvents();
|
|
2785343
|
+
}
|
|
2785344
|
+
parseOrigins() {
|
|
2785345
|
+
if (!this.config.wsEndpoint) {
|
|
2785346
|
+
return [];
|
|
2785347
|
+
}
|
|
2785348
|
+
return this.config.wsEndpoint.split(",").map((url3) => url3.trim()).filter((url3) => url3.length > 0);
|
|
2785349
|
+
}
|
|
2785350
|
+
setupConnectionManagerEvents() {
|
|
2785351
|
+
this.connectionManager.on("connection-established", (connection) => {
|
|
2785352
|
+
this.stats.setOriginStatus(connection.origin, metrics_1.ConnectionStatus.CONNECTED);
|
|
2785353
|
+
});
|
|
2785354
|
+
this.connectionManager.on("connection-lost", (connection, error56) => {
|
|
2785355
|
+
this.stats.setOriginStatus(connection.origin, metrics_1.ConnectionStatus.DISCONNECTED);
|
|
2785356
|
+
this.emit("connection-lost", connection, error56);
|
|
2785357
|
+
});
|
|
2785358
|
+
this.connectionManager.on("message", (data7, connection) => {
|
|
2785359
|
+
try {
|
|
2785360
|
+
const message5 = JSON.parse(data7.toString());
|
|
2785361
|
+
if (message5 && message5.report) {
|
|
2785362
|
+
const report = {
|
|
2785363
|
+
feedID: message5.report.feedID,
|
|
2785364
|
+
fullReport: message5.report.fullReport,
|
|
2785365
|
+
validFromTimestamp: message5.report.validFromTimestamp,
|
|
2785366
|
+
observationsTimestamp: message5.report.observationsTimestamp
|
|
2785367
|
+
};
|
|
2785368
|
+
this.logger.debug(`Received report for feed ${report.feedID} from ${connection.origin}`);
|
|
2785369
|
+
this.handleReport(report, connection.origin);
|
|
2785370
|
+
} else {
|
|
2785371
|
+
this.logger.warn(`Invalid message format received from ${connection.origin}`);
|
|
2785372
|
+
this.emit("error", new Error("Invalid message format"));
|
|
2785373
|
+
}
|
|
2785374
|
+
} catch (error56) {
|
|
2785375
|
+
this.logger.error(`Failed to parse WebSocket message from ${connection.origin}:`, error56);
|
|
2785376
|
+
this.emit("error", new Error("Failed to parse WebSocket message"));
|
|
2785377
|
+
}
|
|
2785378
|
+
});
|
|
2785379
|
+
this.connectionManager.on("reconnecting", (info11) => {
|
|
2785380
|
+
this.emit("reconnecting", info11);
|
|
2785381
|
+
});
|
|
2785382
|
+
this.connectionManager.on("all-connections-lost", () => {
|
|
2785383
|
+
this.logger.error("All connections lost - stream disconnected");
|
|
2785384
|
+
this.emit("disconnected");
|
|
2785385
|
+
this.emit("all-connections-lost");
|
|
2785386
|
+
});
|
|
2785387
|
+
this.connectionManager.on("partial-failure", (failedCount, totalCount) => {
|
|
2785388
|
+
this.logger.warn(`Partial connection failure: ${failedCount}/${totalCount} connections failed`);
|
|
2785389
|
+
});
|
|
2785390
|
+
this.connectionManager.on("connection-restored", (connection) => {
|
|
2785391
|
+
this.stats.setOriginStatus(connection.origin, metrics_1.ConnectionStatus.CONNECTED);
|
|
2785392
|
+
this.emit("connection-restored", connection);
|
|
2785393
|
+
});
|
|
2785394
|
+
}
|
|
2785395
|
+
handleReport(report, origin2) {
|
|
2785396
|
+
const result = this.deduplicator.processReport({
|
|
2785397
|
+
feedID: report.feedID,
|
|
2785398
|
+
observationsTimestamp: report.observationsTimestamp,
|
|
2785399
|
+
validFromTimestamp: report.validFromTimestamp,
|
|
2785400
|
+
fullReport: report.fullReport
|
|
2785401
|
+
});
|
|
2785402
|
+
const originInfo = origin2 ? ` from ${new URL(origin2).host}` : "";
|
|
2785403
|
+
if (result.isAccepted) {
|
|
2785404
|
+
this.stats.incrementAccepted();
|
|
2785405
|
+
this.logger.debug(`Report accepted for feed ${report.feedID}${originInfo} (timestamp: ${report.observationsTimestamp})`);
|
|
2785406
|
+
this.emit("report", report);
|
|
2785407
|
+
} else {
|
|
2785408
|
+
this.stats.incrementDeduplicated();
|
|
2785409
|
+
this.logger.debug(`Report deduplicated for feed ${report.feedID}${originInfo} (timestamp: ${report.observationsTimestamp})`);
|
|
2785410
|
+
}
|
|
2785411
|
+
}
|
|
2785412
|
+
async connect() {
|
|
2785413
|
+
this.logger.info(`Connecting stream in ${this.connectionType} mode`);
|
|
2785414
|
+
try {
|
|
2785415
|
+
await this.connectionManager.initialize();
|
|
2785416
|
+
const connectionDetails = this.connectionManager.getConnectionDetails();
|
|
2785417
|
+
this.origins = connectionDetails.map((conn) => conn.origin);
|
|
2785418
|
+
if (this.origins.length === 0) {
|
|
2785419
|
+
this.logger.error("No origins available for connection");
|
|
2785420
|
+
throw new errors_1.InsufficientConnectionsError("No origins available for connection", 0, 1);
|
|
2785421
|
+
}
|
|
2785422
|
+
this.connectionType = this.origins.length > 1 && this.config.haMode ? ConnectionType.Multiple : ConnectionType.Single;
|
|
2785423
|
+
this.stats.setConfiguredConnections(this.origins.length);
|
|
2785424
|
+
this.stats.setActiveConnections(this.connectionManager.getActiveConnectionCount());
|
|
2785425
|
+
this.logger.info(`Stream connected successfully with ${this.origins.length} origins: ${this.origins.join(", ")}`);
|
|
2785426
|
+
} catch (error56) {
|
|
2785427
|
+
if (error56 instanceof errors_1.OriginDiscoveryError) {
|
|
2785428
|
+
this.logger.warn("Origin discovery failed, falling back to single connection mode");
|
|
2785429
|
+
this.connectionType = ConnectionType.Single;
|
|
2785430
|
+
this.origins = this.parseOrigins().slice(0, 1);
|
|
2785431
|
+
this.stats.setConfiguredConnections(1);
|
|
2785432
|
+
this.stats.setActiveConnections(this.connectionManager.getActiveConnectionCount());
|
|
2785433
|
+
this.logger.info(`Fallback connection established to: ${this.origins[0]}`);
|
|
2785434
|
+
} else {
|
|
2785435
|
+
this.logger.error("Failed to connect stream:", error56);
|
|
2785436
|
+
throw error56;
|
|
2785437
|
+
}
|
|
2785438
|
+
}
|
|
2785439
|
+
}
|
|
2785440
|
+
async close() {
|
|
2785441
|
+
this.logger.info("Closing stream and shutting down connections");
|
|
2785442
|
+
this.isClosing = true;
|
|
2785443
|
+
await this.connectionManager.shutdown();
|
|
2785444
|
+
this.deduplicator.stop();
|
|
2785445
|
+
this.stats.setActiveConnections(0);
|
|
2785446
|
+
this.logger.info("Stream closed successfully");
|
|
2785447
|
+
}
|
|
2785448
|
+
async read() {
|
|
2785449
|
+
return new Promise((resolve7, reject) => {
|
|
2785450
|
+
const onReport = (report) => {
|
|
2785451
|
+
cleanup();
|
|
2785452
|
+
resolve7(report);
|
|
2785453
|
+
};
|
|
2785454
|
+
const onError = (error56) => {
|
|
2785455
|
+
cleanup();
|
|
2785456
|
+
reject(error56);
|
|
2785457
|
+
};
|
|
2785458
|
+
const cleanup = () => {
|
|
2785459
|
+
this.removeListener("report", onReport);
|
|
2785460
|
+
this.removeListener("error", onError);
|
|
2785461
|
+
};
|
|
2785462
|
+
this.once("report", onReport);
|
|
2785463
|
+
this.once("error", onError);
|
|
2785464
|
+
});
|
|
2785465
|
+
}
|
|
2785466
|
+
getMetrics() {
|
|
2785467
|
+
this.stats.setActiveConnections(this.connectionManager.getActiveConnectionCount());
|
|
2785468
|
+
this.stats.updateOriginStatuses(this.connectionManager.getOriginStatusMap());
|
|
2785469
|
+
return this.stats.getStats();
|
|
2785470
|
+
}
|
|
2785471
|
+
getConnectionType() {
|
|
2785472
|
+
return this.connectionType;
|
|
2785473
|
+
}
|
|
2785474
|
+
getOrigins() {
|
|
2785475
|
+
return [...this.origins];
|
|
2785476
|
+
}
|
|
2785477
|
+
getConnectionDetails() {
|
|
2785478
|
+
return this.connectionManager.getConnectionDetails();
|
|
2785479
|
+
}
|
|
2785480
|
+
getConnectionStates() {
|
|
2785481
|
+
return this.connectionManager.getConnectionStates();
|
|
2785482
|
+
}
|
|
2785483
|
+
}
|
|
2785484
|
+
exports6.Stream = Stream4;
|
|
2785485
|
+
});
|
|
2785486
|
+
|
|
2785487
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/client/implementation.js
|
|
2785488
|
+
var require_implementation2 = __commonJS((exports6) => {
|
|
2785489
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2785490
|
+
exports6.DataStreamsClientImpl = undefined;
|
|
2785491
|
+
var base_1 = require_base26();
|
|
2785492
|
+
var validation_1 = require_validation3();
|
|
2785493
|
+
var stream_1 = require_stream();
|
|
2785494
|
+
|
|
2785495
|
+
class DataStreamsClientImpl extends base_1.BaseClient {
|
|
2785496
|
+
constructor(config9) {
|
|
2785497
|
+
super(config9);
|
|
2785498
|
+
this.validateHAConfiguration(config9);
|
|
2785499
|
+
this.logger.info("Data Streams client initialized");
|
|
2785500
|
+
}
|
|
2785501
|
+
validateHAConfiguration(config9) {
|
|
2785502
|
+
if (config9.haMode) {
|
|
2785503
|
+
const origins = this.parseOrigins(config9.wsEndpoint);
|
|
2785504
|
+
if (origins.length === 0) {
|
|
2785505
|
+
throw new Error("HA mode enabled but no WebSocket endpoints provided");
|
|
2785506
|
+
}
|
|
2785507
|
+
}
|
|
2785508
|
+
if (config9.wsEndpoint) {
|
|
2785509
|
+
const origins = this.parseOrigins(config9.wsEndpoint);
|
|
2785510
|
+
for (const origin2 of origins) {
|
|
2785511
|
+
if (!origin2.startsWith("ws://") && !origin2.startsWith("wss://")) {
|
|
2785512
|
+
throw new Error(`Invalid WebSocket URL format: ${origin2}. Must start with ws:// or wss://`);
|
|
2785513
|
+
}
|
|
2785514
|
+
}
|
|
2785515
|
+
}
|
|
2785516
|
+
}
|
|
2785517
|
+
parseOrigins(wsEndpoint) {
|
|
2785518
|
+
if (!wsEndpoint) {
|
|
2785519
|
+
return [];
|
|
2785520
|
+
}
|
|
2785521
|
+
return wsEndpoint.split(",").map((url3) => url3.trim()).filter((url3) => url3.length > 0);
|
|
2785522
|
+
}
|
|
2785523
|
+
async listFeeds() {
|
|
2785524
|
+
this.logger.debug("Fetching available feeds");
|
|
2785525
|
+
const response = await this.withRetry(() => this.makeRequest("/api/v1/feeds"));
|
|
2785526
|
+
this.logger.debug(`Retrieved ${response.feeds.length} feeds`);
|
|
2785527
|
+
return response.feeds;
|
|
2785528
|
+
}
|
|
2785529
|
+
async getLatestReport(feedId) {
|
|
2785530
|
+
(0, validation_1.validateFeedId)(feedId);
|
|
2785531
|
+
this.logger.debug(`Fetching latest report for feed ${feedId}`);
|
|
2785532
|
+
const response = await this.withRetry(() => this.makeRequest(`/api/v1/reports/latest?feedID=${feedId}`));
|
|
2785533
|
+
this.logger.debug(`Retrieved latest report for feed ${feedId} (timestamp: ${response.report.observationsTimestamp})`);
|
|
2785534
|
+
return response.report;
|
|
2785535
|
+
}
|
|
2785536
|
+
async getReportByTimestamp(feedId, timestamp2) {
|
|
2785537
|
+
(0, validation_1.validateFeedId)(feedId);
|
|
2785538
|
+
(0, validation_1.validateTimestamp)(timestamp2);
|
|
2785539
|
+
this.logger.debug(`Fetching report for feed ${feedId} at timestamp ${timestamp2}`);
|
|
2785540
|
+
const response = await this.withRetry(() => this.makeRequest(`/api/v1/reports?feedID=${feedId}×tamp=${timestamp2}`));
|
|
2785541
|
+
this.logger.debug(`Retrieved report for feed ${feedId} at timestamp ${timestamp2}`);
|
|
2785542
|
+
return response.report;
|
|
2785543
|
+
}
|
|
2785544
|
+
async getReportsPage(feedId, startTime, limit2 = 10) {
|
|
2785545
|
+
(0, validation_1.validateFeedId)(feedId);
|
|
2785546
|
+
(0, validation_1.validateTimestamp)(startTime);
|
|
2785547
|
+
this.logger.debug(`Fetching ${limit2} reports for feed ${feedId} starting from timestamp ${startTime}`);
|
|
2785548
|
+
const response = await this.withRetry(() => this.makeRequest(`/api/v1/reports/page?feedID=${feedId}&startTimestamp=${startTime}&limit=${limit2}`));
|
|
2785549
|
+
this.logger.info(`Retrieved ${response.reports.length} reports for feed ${feedId} (requested: ${limit2})`);
|
|
2785550
|
+
return response.reports;
|
|
2785551
|
+
}
|
|
2785552
|
+
async getReportsBulk(feedIds, timestamp2) {
|
|
2785553
|
+
(0, validation_1.validateFeedIds)(feedIds);
|
|
2785554
|
+
(0, validation_1.validateTimestamp)(timestamp2);
|
|
2785555
|
+
this.logger.debug(`Fetching bulk reports for ${feedIds.length} feeds at timestamp ${timestamp2}`);
|
|
2785556
|
+
const response = await this.withRetry(() => this.makeRequest(`/api/v1/reports/bulk?feedIDs=${feedIds.join(",")}×tamp=${timestamp2}`));
|
|
2785557
|
+
this.logger.info(`Retrieved ${response.reports.length} bulk reports for timestamp ${timestamp2}`);
|
|
2785558
|
+
return response.reports;
|
|
2785559
|
+
}
|
|
2785560
|
+
createStream(feedIds, options4) {
|
|
2785561
|
+
const feedIdArray = Array.isArray(feedIds) ? feedIds : [feedIds];
|
|
2785562
|
+
feedIdArray.forEach(validation_1.validateFeedId);
|
|
2785563
|
+
this.logger.debug(`Creating stream for ${feedIdArray.length} feeds: ${feedIdArray.join(", ")}`);
|
|
2785564
|
+
const streamOptions = options4 ? {
|
|
2785565
|
+
reconnectInterval: options4.reconnectInterval,
|
|
2785566
|
+
maxReconnectAttempts: options4.maxReconnectAttempts
|
|
2785567
|
+
} : {};
|
|
2785568
|
+
const stream4 = new stream_1.Stream(this.config, feedIdArray, streamOptions);
|
|
2785569
|
+
this.logger.info(`Stream created successfully for ${feedIdArray.length} feed(s)`);
|
|
2785570
|
+
return stream4;
|
|
2785571
|
+
}
|
|
2785572
|
+
}
|
|
2785573
|
+
exports6.DataStreamsClientImpl = DataStreamsClientImpl;
|
|
2785574
|
+
});
|
|
2785575
|
+
|
|
2785576
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/client/index.js
|
|
2785577
|
+
var require_client18 = __commonJS((exports6) => {
|
|
2785578
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2785579
|
+
exports6.DataStreamsClientImpl = undefined;
|
|
2785580
|
+
exports6.createClient = createClient8;
|
|
2785581
|
+
var implementation_1 = require_implementation2();
|
|
2785582
|
+
Object.defineProperty(exports6, "DataStreamsClientImpl", { enumerable: true, get: function() {
|
|
2785583
|
+
return implementation_1.DataStreamsClientImpl;
|
|
2785584
|
+
} });
|
|
2785585
|
+
function createClient8(config9) {
|
|
2785586
|
+
return new implementation_1.DataStreamsClientImpl(config9);
|
|
2785587
|
+
}
|
|
2785588
|
+
});
|
|
2785589
|
+
|
|
2785590
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/types/report.js
|
|
2785591
|
+
var require_report = __commonJS((exports6) => {
|
|
2785592
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2785593
|
+
exports6.Ripcord = exports6.MarketStatus = undefined;
|
|
2785594
|
+
var MarketStatus;
|
|
2785595
|
+
(function(MarketStatus2) {
|
|
2785596
|
+
MarketStatus2[MarketStatus2["UNKNOWN"] = 0] = "UNKNOWN";
|
|
2785597
|
+
MarketStatus2[MarketStatus2["INACTIVE"] = 1] = "INACTIVE";
|
|
2785598
|
+
MarketStatus2[MarketStatus2["ACTIVE"] = 2] = "ACTIVE";
|
|
2785599
|
+
})(MarketStatus || (exports6.MarketStatus = MarketStatus = {}));
|
|
2785600
|
+
var Ripcord;
|
|
2785601
|
+
(function(Ripcord2) {
|
|
2785602
|
+
Ripcord2[Ripcord2["NORMAL"] = 0] = "NORMAL";
|
|
2785603
|
+
Ripcord2[Ripcord2["PAUSED"] = 1] = "PAUSED";
|
|
2785604
|
+
})(Ripcord || (exports6.Ripcord = Ripcord = {}));
|
|
2785605
|
+
});
|
|
2785606
|
+
|
|
2785607
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/types/client.js
|
|
2785608
|
+
var require_client19 = __commonJS((exports6) => {
|
|
2785609
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2785610
|
+
});
|
|
2785611
|
+
|
|
2785612
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/types/index.js
|
|
2785613
|
+
var require_types102 = __commonJS((exports6) => {
|
|
2785614
|
+
var __createBinding = exports6 && exports6.__createBinding || (Object.create ? function(o4, m2, k2, k22) {
|
|
2785615
|
+
if (k22 === undefined)
|
|
2785616
|
+
k22 = k2;
|
|
2785617
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k2);
|
|
2785618
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
2785619
|
+
desc = { enumerable: true, get: function() {
|
|
2785620
|
+
return m2[k2];
|
|
2785621
|
+
} };
|
|
2785622
|
+
}
|
|
2785623
|
+
Object.defineProperty(o4, k22, desc);
|
|
2785624
|
+
} : function(o4, m2, k2, k22) {
|
|
2785625
|
+
if (k22 === undefined)
|
|
2785626
|
+
k22 = k2;
|
|
2785627
|
+
o4[k22] = m2[k2];
|
|
2785628
|
+
});
|
|
2785629
|
+
var __exportStar = exports6 && exports6.__exportStar || function(m2, exports7) {
|
|
2785630
|
+
for (var p in m2)
|
|
2785631
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports7, p))
|
|
2785632
|
+
__createBinding(exports7, m2, p);
|
|
2785633
|
+
};
|
|
2785634
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2785635
|
+
__exportStar(require_report(), exports6);
|
|
2785636
|
+
__exportStar(require_errors56(), exports6);
|
|
2785637
|
+
__exportStar(require_client19(), exports6);
|
|
2785638
|
+
});
|
|
2785639
|
+
|
|
2785640
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/decoder/implementation.js
|
|
2785641
|
+
var require_implementation3 = __commonJS((exports6) => {
|
|
2785642
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2785643
|
+
exports6.decodeReport = decodeReport;
|
|
2785644
|
+
var ethers_1 = require_lib6();
|
|
2785645
|
+
var errors_1 = require_errors56();
|
|
2785646
|
+
var types_1 = require_types102();
|
|
2785647
|
+
var globalAbiCoder = new ethers_1.AbiCoder;
|
|
2785648
|
+
var outerReportAbiCoder = new ethers_1.AbiCoder;
|
|
2785649
|
+
var reportSchemaV2 = [
|
|
2785650
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785651
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785652
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785653
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785654
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785655
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785656
|
+
{ type: "int192", name: "price" }
|
|
2785657
|
+
];
|
|
2785658
|
+
var reportSchemaV3 = [
|
|
2785659
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785660
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785661
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785662
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785663
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785664
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785665
|
+
{ type: "int192", name: "price" },
|
|
2785666
|
+
{ type: "int192", name: "bid" },
|
|
2785667
|
+
{ type: "int192", name: "ask" }
|
|
2785668
|
+
];
|
|
2785669
|
+
var reportSchemaV4 = [
|
|
2785670
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785671
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785672
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785673
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785674
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785675
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785676
|
+
{ type: "int192", name: "price" },
|
|
2785677
|
+
{ type: "uint8", name: "marketStatus" }
|
|
2785678
|
+
];
|
|
2785679
|
+
var reportSchemaV5 = [
|
|
2785680
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785681
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785682
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785683
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785684
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785685
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785686
|
+
{ type: "int192", name: "rate" },
|
|
2785687
|
+
{ type: "uint32", name: "timestamp" },
|
|
2785688
|
+
{ type: "uint32", name: "duration" }
|
|
2785689
|
+
];
|
|
2785690
|
+
var reportSchemaV6 = [
|
|
2785691
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785692
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785693
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785694
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785695
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785696
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785697
|
+
{ type: "int192", name: "price" },
|
|
2785698
|
+
{ type: "int192", name: "price2" },
|
|
2785699
|
+
{ type: "int192", name: "price3" },
|
|
2785700
|
+
{ type: "int192", name: "price4" },
|
|
2785701
|
+
{ type: "int192", name: "price5" }
|
|
2785702
|
+
];
|
|
2785703
|
+
var reportSchemaV7 = [
|
|
2785704
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785705
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785706
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785707
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785708
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785709
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785710
|
+
{ type: "int192", name: "exchangeRate" }
|
|
2785711
|
+
];
|
|
2785712
|
+
var reportSchemaV8 = [
|
|
2785713
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785714
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785715
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785716
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785717
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785718
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785719
|
+
{ type: "uint64", name: "lastUpdateTimestamp" },
|
|
2785720
|
+
{ type: "int192", name: "midPrice" },
|
|
2785721
|
+
{ type: "uint32", name: "marketStatus" }
|
|
2785722
|
+
];
|
|
2785723
|
+
var reportSchemaV9 = [
|
|
2785724
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785725
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785726
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785727
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785728
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785729
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785730
|
+
{ type: "int192", name: "navPerShare" },
|
|
2785731
|
+
{ type: "uint64", name: "navDate" },
|
|
2785732
|
+
{ type: "int192", name: "aum" },
|
|
2785733
|
+
{ type: "uint32", name: "ripcord" }
|
|
2785734
|
+
];
|
|
2785735
|
+
var reportSchemaV10 = [
|
|
2785736
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785737
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785738
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785739
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785740
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785741
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785742
|
+
{ type: "uint64", name: "lastUpdateTimestamp" },
|
|
2785743
|
+
{ type: "int192", name: "price" },
|
|
2785744
|
+
{ type: "uint32", name: "marketStatus" },
|
|
2785745
|
+
{ type: "int192", name: "currentMultiplier" },
|
|
2785746
|
+
{ type: "int192", name: "newMultiplier" },
|
|
2785747
|
+
{ type: "uint32", name: "activationDateTime" },
|
|
2785748
|
+
{ type: "int192", name: "tokenizedPrice" }
|
|
2785749
|
+
];
|
|
2785750
|
+
var reportSchemaV11 = [
|
|
2785751
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785752
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785753
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785754
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785755
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785756
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785757
|
+
{ type: "int192", name: "mid" },
|
|
2785758
|
+
{ type: "uint64", name: "lastSeenTimestampNs" },
|
|
2785759
|
+
{ type: "int192", name: "bid" },
|
|
2785760
|
+
{ type: "int192", name: "bidVolume" },
|
|
2785761
|
+
{ type: "int192", name: "ask" },
|
|
2785762
|
+
{ type: "int192", name: "askVolume" },
|
|
2785763
|
+
{ type: "int192", name: "lastTradedPrice" },
|
|
2785764
|
+
{ type: "uint32", name: "marketStatus" }
|
|
2785765
|
+
];
|
|
2785766
|
+
var reportSchemaV12 = [
|
|
2785767
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785768
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785769
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785770
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785771
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785772
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785773
|
+
{ type: "int192", name: "navPerShare" },
|
|
2785774
|
+
{ type: "int192", name: "nextNavPerShare" },
|
|
2785775
|
+
{ type: "uint64", name: "navDate" },
|
|
2785776
|
+
{ type: "uint32", name: "ripcord" }
|
|
2785777
|
+
];
|
|
2785778
|
+
var reportSchemaV13 = [
|
|
2785779
|
+
{ type: "bytes32", name: "feedId" },
|
|
2785780
|
+
{ type: "uint32", name: "validFromTimestamp" },
|
|
2785781
|
+
{ type: "uint32", name: "observationsTimestamp" },
|
|
2785782
|
+
{ type: "uint192", name: "nativeFee" },
|
|
2785783
|
+
{ type: "uint192", name: "linkFee" },
|
|
2785784
|
+
{ type: "uint32", name: "expiresAt" },
|
|
2785785
|
+
{ type: "int192", name: "bestAsk" },
|
|
2785786
|
+
{ type: "int192", name: "bestBid" },
|
|
2785787
|
+
{ type: "uint64", name: "askVolume" },
|
|
2785788
|
+
{ type: "uint64", name: "bidVolume" },
|
|
2785789
|
+
{ type: "int192", name: "lastTradedPrice" }
|
|
2785790
|
+
];
|
|
2785791
|
+
function decodeReport(reportHex, feedId, logger106) {
|
|
2785792
|
+
logger106?.debug(`Decoding report for feed ${feedId}`);
|
|
2785793
|
+
try {
|
|
2785794
|
+
if (!(0, ethers_1.isHexString)(reportHex)) {
|
|
2785795
|
+
throw new errors_1.ReportDecodingError("Report hex string must start with 0x");
|
|
2785796
|
+
}
|
|
2785797
|
+
const version18 = feedId.slice(2, 6);
|
|
2785798
|
+
logger106?.debug(`Detected report version: V${version18.slice(2)}`);
|
|
2785799
|
+
const fullReportAbi = [
|
|
2785800
|
+
{ type: "bytes32[3]", name: "reportContext" },
|
|
2785801
|
+
{ type: "bytes", name: "reportBlob" },
|
|
2785802
|
+
{ type: "bytes32[]", name: "rawRs" },
|
|
2785803
|
+
{ type: "bytes32[]", name: "rawSs" },
|
|
2785804
|
+
{ type: "bytes32", name: "rawVs" }
|
|
2785805
|
+
];
|
|
2785806
|
+
const decodedFullReport = outerReportAbiCoder.decode(fullReportAbi.map((item) => item.type), reportHex);
|
|
2785807
|
+
const reportBlob = decodedFullReport[1];
|
|
2785808
|
+
switch (version18) {
|
|
2785809
|
+
case "0002":
|
|
2785810
|
+
return decodeV2Report(reportBlob);
|
|
2785811
|
+
case "0003":
|
|
2785812
|
+
return decodeV3Report(reportBlob);
|
|
2785813
|
+
case "0004":
|
|
2785814
|
+
return decodeV4Report(reportBlob);
|
|
2785815
|
+
case "0005":
|
|
2785816
|
+
return decodeV5Report(reportBlob);
|
|
2785817
|
+
case "0006":
|
|
2785818
|
+
return decodeV6Report(reportBlob);
|
|
2785819
|
+
case "0007":
|
|
2785820
|
+
return decodeV7Report(reportBlob);
|
|
2785821
|
+
case "0008":
|
|
2785822
|
+
return decodeV8Report(reportBlob);
|
|
2785823
|
+
case "0009":
|
|
2785824
|
+
return decodeV9Report(reportBlob);
|
|
2785825
|
+
case "000a":
|
|
2785826
|
+
return decodeV10Report(reportBlob);
|
|
2785827
|
+
case "000b":
|
|
2785828
|
+
return decodeV11Report(reportBlob);
|
|
2785829
|
+
case "000c":
|
|
2785830
|
+
return decodeV12Report(reportBlob);
|
|
2785831
|
+
case "000d":
|
|
2785832
|
+
return decodeV13Report(reportBlob);
|
|
2785833
|
+
default:
|
|
2785834
|
+
throw new errors_1.ReportDecodingError(`Unknown report version: 0x${version18}`);
|
|
2785835
|
+
}
|
|
2785836
|
+
} catch (error56) {
|
|
2785837
|
+
if (error56 instanceof errors_1.ReportDecodingError) {
|
|
2785838
|
+
throw error56;
|
|
2785839
|
+
}
|
|
2785840
|
+
throw new errors_1.ReportDecodingError(`Failed to decode report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785841
|
+
}
|
|
2785842
|
+
}
|
|
2785843
|
+
function decodeV2Report(reportBlob) {
|
|
2785844
|
+
try {
|
|
2785845
|
+
const decoded = globalAbiCoder.decode(reportSchemaV2.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785846
|
+
return {
|
|
2785847
|
+
version: "V2",
|
|
2785848
|
+
nativeFee: decoded[3],
|
|
2785849
|
+
linkFee: decoded[4],
|
|
2785850
|
+
expiresAt: Number(decoded[5]),
|
|
2785851
|
+
price: decoded[6]
|
|
2785852
|
+
};
|
|
2785853
|
+
} catch (error56) {
|
|
2785854
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V2 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785855
|
+
}
|
|
2785856
|
+
}
|
|
2785857
|
+
function decodeV3Report(reportBlob) {
|
|
2785858
|
+
try {
|
|
2785859
|
+
const decoded = globalAbiCoder.decode(reportSchemaV3.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785860
|
+
return {
|
|
2785861
|
+
version: "V3",
|
|
2785862
|
+
nativeFee: decoded[3],
|
|
2785863
|
+
linkFee: decoded[4],
|
|
2785864
|
+
expiresAt: Number(decoded[5]),
|
|
2785865
|
+
price: decoded[6],
|
|
2785866
|
+
bid: decoded[7],
|
|
2785867
|
+
ask: decoded[8]
|
|
2785868
|
+
};
|
|
2785869
|
+
} catch (error56) {
|
|
2785870
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V3 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785871
|
+
}
|
|
2785872
|
+
}
|
|
2785873
|
+
function decodeV4Report(reportBlob) {
|
|
2785874
|
+
try {
|
|
2785875
|
+
const decoded = globalAbiCoder.decode(reportSchemaV4.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785876
|
+
const marketStatus = Number(decoded[7]);
|
|
2785877
|
+
if (marketStatus !== types_1.MarketStatus.UNKNOWN && marketStatus !== types_1.MarketStatus.INACTIVE && marketStatus !== types_1.MarketStatus.ACTIVE) {
|
|
2785878
|
+
throw new errors_1.ReportDecodingError(`Invalid market status: ${marketStatus}`);
|
|
2785879
|
+
}
|
|
2785880
|
+
return {
|
|
2785881
|
+
version: "V4",
|
|
2785882
|
+
nativeFee: decoded[3],
|
|
2785883
|
+
linkFee: decoded[4],
|
|
2785884
|
+
expiresAt: Number(decoded[5]),
|
|
2785885
|
+
price: decoded[6],
|
|
2785886
|
+
marketStatus
|
|
2785887
|
+
};
|
|
2785888
|
+
} catch (error56) {
|
|
2785889
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V4 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785890
|
+
}
|
|
2785891
|
+
}
|
|
2785892
|
+
function decodeV5Report(reportBlob) {
|
|
2785893
|
+
try {
|
|
2785894
|
+
const decoded = globalAbiCoder.decode(reportSchemaV5.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785895
|
+
return {
|
|
2785896
|
+
version: "V5",
|
|
2785897
|
+
nativeFee: decoded[3],
|
|
2785898
|
+
linkFee: decoded[4],
|
|
2785899
|
+
expiresAt: Number(decoded[5]),
|
|
2785900
|
+
rate: decoded[6],
|
|
2785901
|
+
timestamp: Number(decoded[7]),
|
|
2785902
|
+
duration: Number(decoded[8])
|
|
2785903
|
+
};
|
|
2785904
|
+
} catch (error56) {
|
|
2785905
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V5 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785906
|
+
}
|
|
2785907
|
+
}
|
|
2785908
|
+
function decodeV6Report(reportBlob) {
|
|
2785909
|
+
try {
|
|
2785910
|
+
const decoded = globalAbiCoder.decode(reportSchemaV6.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785911
|
+
return {
|
|
2785912
|
+
version: "V6",
|
|
2785913
|
+
nativeFee: decoded[3],
|
|
2785914
|
+
linkFee: decoded[4],
|
|
2785915
|
+
expiresAt: Number(decoded[5]),
|
|
2785916
|
+
price: decoded[6],
|
|
2785917
|
+
price2: decoded[7],
|
|
2785918
|
+
price3: decoded[8],
|
|
2785919
|
+
price4: decoded[9],
|
|
2785920
|
+
price5: decoded[10]
|
|
2785921
|
+
};
|
|
2785922
|
+
} catch (error56) {
|
|
2785923
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V6 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785924
|
+
}
|
|
2785925
|
+
}
|
|
2785926
|
+
function decodeV7Report(reportBlob) {
|
|
2785927
|
+
try {
|
|
2785928
|
+
const decoded = globalAbiCoder.decode(reportSchemaV7.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785929
|
+
return {
|
|
2785930
|
+
version: "V7",
|
|
2785931
|
+
nativeFee: decoded[3],
|
|
2785932
|
+
linkFee: decoded[4],
|
|
2785933
|
+
expiresAt: Number(decoded[5]),
|
|
2785934
|
+
exchangeRate: decoded[6]
|
|
2785935
|
+
};
|
|
2785936
|
+
} catch (error56) {
|
|
2785937
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V7 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785938
|
+
}
|
|
2785939
|
+
}
|
|
2785940
|
+
function decodeV8Report(reportBlob) {
|
|
2785941
|
+
try {
|
|
2785942
|
+
const decoded = globalAbiCoder.decode(reportSchemaV8.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785943
|
+
const marketStatus = Number(decoded[8]);
|
|
2785944
|
+
if (marketStatus !== types_1.MarketStatus.UNKNOWN && marketStatus !== types_1.MarketStatus.INACTIVE && marketStatus !== types_1.MarketStatus.ACTIVE) {
|
|
2785945
|
+
throw new errors_1.ReportDecodingError(`Invalid market status: ${marketStatus}`);
|
|
2785946
|
+
}
|
|
2785947
|
+
return {
|
|
2785948
|
+
version: "V8",
|
|
2785949
|
+
nativeFee: decoded[3],
|
|
2785950
|
+
linkFee: decoded[4],
|
|
2785951
|
+
expiresAt: Number(decoded[5]),
|
|
2785952
|
+
lastUpdateTimestamp: Number(decoded[6]),
|
|
2785953
|
+
midPrice: decoded[7],
|
|
2785954
|
+
marketStatus
|
|
2785955
|
+
};
|
|
2785956
|
+
} catch (error56) {
|
|
2785957
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V8 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785958
|
+
}
|
|
2785959
|
+
}
|
|
2785960
|
+
function decodeV9Report(reportBlob) {
|
|
2785961
|
+
try {
|
|
2785962
|
+
const decoded = globalAbiCoder.decode(reportSchemaV9.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785963
|
+
const ripcord = Number(decoded[9]);
|
|
2785964
|
+
if (ripcord !== types_1.Ripcord.NORMAL && ripcord !== types_1.Ripcord.PAUSED) {
|
|
2785965
|
+
throw new errors_1.ReportDecodingError(`Invalid ripcord value: ${ripcord}. Must be 0 (normal) or 1 (paused)`);
|
|
2785966
|
+
}
|
|
2785967
|
+
return {
|
|
2785968
|
+
version: "V9",
|
|
2785969
|
+
nativeFee: decoded[3],
|
|
2785970
|
+
linkFee: decoded[4],
|
|
2785971
|
+
expiresAt: Number(decoded[5]),
|
|
2785972
|
+
navPerShare: decoded[6],
|
|
2785973
|
+
navDate: Number(decoded[7]),
|
|
2785974
|
+
aum: decoded[8],
|
|
2785975
|
+
ripcord
|
|
2785976
|
+
};
|
|
2785977
|
+
} catch (error56) {
|
|
2785978
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V9 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2785979
|
+
}
|
|
2785980
|
+
}
|
|
2785981
|
+
function decodeV10Report(reportBlob) {
|
|
2785982
|
+
try {
|
|
2785983
|
+
const decoded = globalAbiCoder.decode(reportSchemaV10.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2785984
|
+
const marketStatus = Number(decoded[8]);
|
|
2785985
|
+
if (marketStatus !== types_1.MarketStatus.UNKNOWN && marketStatus !== types_1.MarketStatus.INACTIVE && marketStatus !== types_1.MarketStatus.ACTIVE) {
|
|
2785986
|
+
throw new errors_1.ReportDecodingError(`Invalid market status: ${marketStatus}`);
|
|
2785987
|
+
}
|
|
2785988
|
+
return {
|
|
2785989
|
+
version: "V10",
|
|
2785990
|
+
nativeFee: decoded[3],
|
|
2785991
|
+
linkFee: decoded[4],
|
|
2785992
|
+
expiresAt: Number(decoded[5]),
|
|
2785993
|
+
lastUpdateTimestamp: Number(decoded[6]),
|
|
2785994
|
+
price: decoded[7],
|
|
2785995
|
+
marketStatus,
|
|
2785996
|
+
currentMultiplier: decoded[9],
|
|
2785997
|
+
newMultiplier: decoded[10],
|
|
2785998
|
+
activationDateTime: Number(decoded[11]),
|
|
2785999
|
+
tokenizedPrice: decoded[12]
|
|
2786000
|
+
};
|
|
2786001
|
+
} catch (error56) {
|
|
2786002
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V10 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2786003
|
+
}
|
|
2786004
|
+
}
|
|
2786005
|
+
function decodeV11Report(reportBlob) {
|
|
2786006
|
+
try {
|
|
2786007
|
+
const decoded = globalAbiCoder.decode(reportSchemaV11.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2786008
|
+
return {
|
|
2786009
|
+
version: "V11",
|
|
2786010
|
+
nativeFee: decoded[3],
|
|
2786011
|
+
linkFee: decoded[4],
|
|
2786012
|
+
expiresAt: Number(decoded[5]),
|
|
2786013
|
+
mid: decoded[6],
|
|
2786014
|
+
lastSeenTimestampNs: decoded[7],
|
|
2786015
|
+
bid: decoded[8],
|
|
2786016
|
+
bidVolume: decoded[9],
|
|
2786017
|
+
ask: decoded[10],
|
|
2786018
|
+
askVolume: decoded[11],
|
|
2786019
|
+
lastTradedPrice: decoded[12],
|
|
2786020
|
+
marketStatus: Number(decoded[13])
|
|
2786021
|
+
};
|
|
2786022
|
+
} catch (error56) {
|
|
2786023
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V11 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2786024
|
+
}
|
|
2786025
|
+
}
|
|
2786026
|
+
function decodeV12Report(reportBlob) {
|
|
2786027
|
+
try {
|
|
2786028
|
+
const decoded = globalAbiCoder.decode(reportSchemaV12.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2786029
|
+
const ripcord = Number(decoded[9]);
|
|
2786030
|
+
if (ripcord !== types_1.Ripcord.NORMAL && ripcord !== types_1.Ripcord.PAUSED) {
|
|
2786031
|
+
throw new errors_1.ReportDecodingError(`Invalid ripcord value: ${ripcord}. Must be 0 (normal) or 1 (paused)`);
|
|
2786032
|
+
}
|
|
2786033
|
+
return {
|
|
2786034
|
+
version: "V12",
|
|
2786035
|
+
nativeFee: decoded[3],
|
|
2786036
|
+
linkFee: decoded[4],
|
|
2786037
|
+
expiresAt: Number(decoded[5]),
|
|
2786038
|
+
navPerShare: decoded[6],
|
|
2786039
|
+
nextNavPerShare: decoded[7],
|
|
2786040
|
+
navDate: Number(decoded[8]),
|
|
2786041
|
+
ripcord
|
|
2786042
|
+
};
|
|
2786043
|
+
} catch (error56) {
|
|
2786044
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V12 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2786045
|
+
}
|
|
2786046
|
+
}
|
|
2786047
|
+
function decodeV13Report(reportBlob) {
|
|
2786048
|
+
try {
|
|
2786049
|
+
const decoded = globalAbiCoder.decode(reportSchemaV13.map((item) => item.type), (0, ethers_1.getBytes)(reportBlob));
|
|
2786050
|
+
return {
|
|
2786051
|
+
version: "V13",
|
|
2786052
|
+
nativeFee: decoded[3],
|
|
2786053
|
+
linkFee: decoded[4],
|
|
2786054
|
+
expiresAt: Number(decoded[5]),
|
|
2786055
|
+
bestAsk: decoded[6],
|
|
2786056
|
+
bestBid: decoded[7],
|
|
2786057
|
+
askVolume: Number(decoded[8]),
|
|
2786058
|
+
bidVolume: Number(decoded[9]),
|
|
2786059
|
+
lastTradedPrice: decoded[10]
|
|
2786060
|
+
};
|
|
2786061
|
+
} catch (error56) {
|
|
2786062
|
+
throw new errors_1.ReportDecodingError(`Failed to decode V13 report: ${error56 instanceof Error ? error56.message : String(error56)}`);
|
|
2786063
|
+
}
|
|
2786064
|
+
}
|
|
2786065
|
+
});
|
|
2786066
|
+
|
|
2786067
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/decoder/index.js
|
|
2786068
|
+
var require_decoder12 = __commonJS((exports6) => {
|
|
2786069
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2786070
|
+
exports6.decodeReport = undefined;
|
|
2786071
|
+
var implementation_1 = require_implementation3();
|
|
2786072
|
+
Object.defineProperty(exports6, "decodeReport", { enumerable: true, get: function() {
|
|
2786073
|
+
return implementation_1.decodeReport;
|
|
2786074
|
+
} });
|
|
2786075
|
+
});
|
|
2786076
|
+
|
|
2786077
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/utils/time.js
|
|
2786078
|
+
var require_time5 = __commonJS((exports6) => {
|
|
2786079
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2786080
|
+
exports6.getCurrentTimestamp = getCurrentTimestamp;
|
|
2786081
|
+
exports6.getThirtyDaysAgoTimestamp = getThirtyDaysAgoTimestamp;
|
|
2786082
|
+
exports6.isTimestampWithinLast30Days = isTimestampWithinLast30Days;
|
|
2786083
|
+
exports6.validateTimestampWithin30Days = validateTimestampWithin30Days;
|
|
2786084
|
+
var errors_1 = require_errors56();
|
|
2786085
|
+
function getCurrentTimestamp() {
|
|
2786086
|
+
return Math.floor(Date.now() / 1000);
|
|
2786087
|
+
}
|
|
2786088
|
+
function getThirtyDaysAgoTimestamp() {
|
|
2786089
|
+
return getCurrentTimestamp() - 30 * 24 * 60 * 60;
|
|
2786090
|
+
}
|
|
2786091
|
+
function isTimestampWithinLast30Days(timestamp2) {
|
|
2786092
|
+
return timestamp2 >= getThirtyDaysAgoTimestamp();
|
|
2786093
|
+
}
|
|
2786094
|
+
function validateTimestampWithin30Days(timestamp2) {
|
|
2786095
|
+
if (!isTimestampWithinLast30Days(timestamp2)) {
|
|
2786096
|
+
throw new errors_1.ValidationError(`Timestamp ${timestamp2} is not within the last 30 days. ` + `Earliest allowed timestamp is ${getThirtyDaysAgoTimestamp()}`);
|
|
2786097
|
+
}
|
|
2786098
|
+
}
|
|
2786099
|
+
});
|
|
2786100
|
+
|
|
2786101
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/utils/report.js
|
|
2786102
|
+
var require_report2 = __commonJS((exports6) => {
|
|
2786103
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2786104
|
+
exports6.getReportVersion = getReportVersion;
|
|
2786105
|
+
exports6.formatReport = formatReport;
|
|
2786106
|
+
var types_1 = require_types102();
|
|
2786107
|
+
function getReportVersion(feedId) {
|
|
2786108
|
+
const schemaVersion = feedId.slice(2, 6);
|
|
2786109
|
+
switch (schemaVersion) {
|
|
2786110
|
+
case "0002":
|
|
2786111
|
+
return "V2";
|
|
2786112
|
+
case "0003":
|
|
2786113
|
+
return "V3";
|
|
2786114
|
+
case "0004":
|
|
2786115
|
+
return "V4";
|
|
2786116
|
+
case "0005":
|
|
2786117
|
+
return "V5";
|
|
2786118
|
+
case "0006":
|
|
2786119
|
+
return "V6";
|
|
2786120
|
+
case "0007":
|
|
2786121
|
+
return "V7";
|
|
2786122
|
+
case "0008":
|
|
2786123
|
+
return "V8";
|
|
2786124
|
+
case "0009":
|
|
2786125
|
+
return "V9";
|
|
2786126
|
+
case "000a":
|
|
2786127
|
+
return "V10";
|
|
2786128
|
+
case "000b":
|
|
2786129
|
+
return "V11";
|
|
2786130
|
+
case "000c":
|
|
2786131
|
+
return "V12";
|
|
2786132
|
+
case "000d":
|
|
2786133
|
+
return "V13";
|
|
2786134
|
+
default:
|
|
2786135
|
+
throw new Error(`Unknown schema version: 0x${schemaVersion}`);
|
|
2786136
|
+
}
|
|
2786137
|
+
}
|
|
2786138
|
+
function formatReport(report, version18) {
|
|
2786139
|
+
let output4 = "";
|
|
2786140
|
+
output4 += `
|
|
2786141
|
+
Report Metadata:
|
|
2786142
|
+
`;
|
|
2786143
|
+
output4 += `Feed ID: ${report.feedID}
|
|
2786144
|
+
`;
|
|
2786145
|
+
output4 += `Valid From: ${report.validFromTimestamp}
|
|
2786146
|
+
`;
|
|
2786147
|
+
output4 += `Observations: ${report.observationsTimestamp}
|
|
2786148
|
+
`;
|
|
2786149
|
+
output4 += `
|
|
2786150
|
+
Decoded Data:
|
|
2786151
|
+
`;
|
|
2786152
|
+
output4 += `Native Fee: ${report.nativeFee.toString()}
|
|
2786153
|
+
`;
|
|
2786154
|
+
output4 += `LINK Fee: ${report.linkFee.toString()}
|
|
2786155
|
+
`;
|
|
2786156
|
+
output4 += `Expires At: ${report.expiresAt}
|
|
2786157
|
+
`;
|
|
2786158
|
+
switch (version18) {
|
|
2786159
|
+
case "V2": {
|
|
2786160
|
+
const r2 = report;
|
|
2786161
|
+
output4 += `Price: ${r2.price.toString()}
|
|
2786162
|
+
`;
|
|
2786163
|
+
break;
|
|
2786164
|
+
}
|
|
2786165
|
+
case "V3": {
|
|
2786166
|
+
const r2 = report;
|
|
2786167
|
+
output4 += `Price: ${r2.price.toString()}
|
|
2786168
|
+
`;
|
|
2786169
|
+
output4 += `Bid Price: ${r2.bid.toString()}
|
|
2786170
|
+
`;
|
|
2786171
|
+
output4 += `Ask Price: ${r2.ask.toString()}
|
|
2786172
|
+
`;
|
|
2786173
|
+
break;
|
|
2786174
|
+
}
|
|
2786175
|
+
case "V4": {
|
|
2786176
|
+
const r2 = report;
|
|
2786177
|
+
output4 += `Price: ${r2.price.toString()}
|
|
2786178
|
+
`;
|
|
2786179
|
+
output4 += `Market Status: ${types_1.MarketStatus[r2.marketStatus]} (${r2.marketStatus})
|
|
2786180
|
+
`;
|
|
2786181
|
+
break;
|
|
2786182
|
+
}
|
|
2786183
|
+
case "V5": {
|
|
2786184
|
+
const r2 = report;
|
|
2786185
|
+
output4 += `Rate: ${r2.rate.toString()}
|
|
2786186
|
+
`;
|
|
2786187
|
+
output4 += `Rate Timestamp: ${r2.timestamp}
|
|
2786188
|
+
`;
|
|
2786189
|
+
output4 += `Duration: ${r2.duration}
|
|
2786190
|
+
`;
|
|
2786191
|
+
break;
|
|
2786192
|
+
}
|
|
2786193
|
+
case "V6": {
|
|
2786194
|
+
const r2 = report;
|
|
2786195
|
+
output4 += `Price: ${r2.price.toString()}
|
|
2786196
|
+
`;
|
|
2786197
|
+
output4 += `Price2: ${r2.price2.toString()}
|
|
2786198
|
+
`;
|
|
2786199
|
+
output4 += `Price3: ${r2.price3.toString()}
|
|
2786200
|
+
`;
|
|
2786201
|
+
output4 += `Price4: ${r2.price4.toString()}
|
|
2786202
|
+
`;
|
|
2786203
|
+
output4 += `Price5: ${r2.price5.toString()}
|
|
2786204
|
+
`;
|
|
2786205
|
+
break;
|
|
2786206
|
+
}
|
|
2786207
|
+
case "V7": {
|
|
2786208
|
+
const r2 = report;
|
|
2786209
|
+
output4 += `Exchange Rate: ${r2.exchangeRate.toString()}
|
|
2786210
|
+
`;
|
|
2786211
|
+
break;
|
|
2786212
|
+
}
|
|
2786213
|
+
case "V8": {
|
|
2786214
|
+
const r2 = report;
|
|
2786215
|
+
output4 += `Mid Price: ${r2.midPrice.toString()}
|
|
2786216
|
+
`;
|
|
2786217
|
+
output4 += `Last Update: ${r2.lastUpdateTimestamp}
|
|
2786218
|
+
`;
|
|
2786219
|
+
output4 += `Market Status: ${types_1.MarketStatus[r2.marketStatus]} (${r2.marketStatus})
|
|
2786220
|
+
`;
|
|
2786221
|
+
break;
|
|
2786222
|
+
}
|
|
2786223
|
+
case "V9": {
|
|
2786224
|
+
const r2 = report;
|
|
2786225
|
+
output4 += `NAV per Share: ${r2.navPerShare.toString()}
|
|
2786226
|
+
`;
|
|
2786227
|
+
output4 += `NAV Date: ${r2.navDate}
|
|
2786228
|
+
`;
|
|
2786229
|
+
output4 += `AUM: ${r2.aum.toString()}
|
|
2786230
|
+
`;
|
|
2786231
|
+
output4 += `Ripcord: ${r2.ripcord === 0 ? `Normal (${r2.ripcord})` : `PAUSED - DO NOT CONSUME (${r2.ripcord})`}
|
|
2786232
|
+
`;
|
|
2786233
|
+
break;
|
|
2786234
|
+
}
|
|
2786235
|
+
case "V10": {
|
|
2786236
|
+
const r2 = report;
|
|
2786237
|
+
output4 += `Price: ${r2.price.toString()}
|
|
2786238
|
+
`;
|
|
2786239
|
+
output4 += `Last Update: ${r2.lastUpdateTimestamp}
|
|
2786240
|
+
`;
|
|
2786241
|
+
output4 += `Market Status: ${types_1.MarketStatus[r2.marketStatus]} (${r2.marketStatus})
|
|
2786242
|
+
`;
|
|
2786243
|
+
output4 += `Current Multiplier: ${r2.currentMultiplier.toString()}
|
|
2786244
|
+
`;
|
|
2786245
|
+
output4 += `New Multiplier: ${r2.newMultiplier.toString()}
|
|
2786246
|
+
`;
|
|
2786247
|
+
output4 += `Activation Date: ${r2.activationDateTime}
|
|
2786248
|
+
`;
|
|
2786249
|
+
output4 += `Tokenized Price: ${r2.tokenizedPrice.toString()}
|
|
2786250
|
+
`;
|
|
2786251
|
+
break;
|
|
2786252
|
+
}
|
|
2786253
|
+
case "V11": {
|
|
2786254
|
+
const r2 = report;
|
|
2786255
|
+
output4 += `Mid: ${r2.mid.toString()}
|
|
2786256
|
+
`;
|
|
2786257
|
+
output4 += `Last Seen Timestamp Nanos: ${r2.lastSeenTimestampNs.toString()}
|
|
2786258
|
+
`;
|
|
2786259
|
+
output4 += `Bid: ${r2.bid.toString()}
|
|
2786260
|
+
`;
|
|
2786261
|
+
output4 += `Bid Volume: ${r2.bidVolume.toString()}
|
|
2786262
|
+
`;
|
|
2786263
|
+
output4 += `Ask: ${r2.ask.toString()}
|
|
2786264
|
+
`;
|
|
2786265
|
+
output4 += `Ask Volume: ${r2.askVolume.toString()}
|
|
2786266
|
+
`;
|
|
2786267
|
+
output4 += `Last Traded Price: ${r2.lastTradedPrice.toString()}
|
|
2786268
|
+
`;
|
|
2786269
|
+
output4 += `Market Status: ${r2.marketStatus.toString()}
|
|
2786270
|
+
`;
|
|
2786271
|
+
break;
|
|
2786272
|
+
}
|
|
2786273
|
+
case "V12": {
|
|
2786274
|
+
const r2 = report;
|
|
2786275
|
+
output4 += `NAV per Share: ${r2.navPerShare.toString()}
|
|
2786276
|
+
`;
|
|
2786277
|
+
output4 += `Next NAV per Share: ${r2.nextNavPerShare.toString()}
|
|
2786278
|
+
`;
|
|
2786279
|
+
output4 += `NAV Date: ${r2.navDate}
|
|
2786280
|
+
`;
|
|
2786281
|
+
output4 += `Ripcord: ${r2.ripcord === 0 ? `Normal (${r2.ripcord})` : `PAUSED - DO NOT CONSUME (${r2.ripcord})`}
|
|
2786282
|
+
`;
|
|
2786283
|
+
break;
|
|
2786284
|
+
}
|
|
2786285
|
+
case "V13": {
|
|
2786286
|
+
const r2 = report;
|
|
2786287
|
+
output4 += `Best Ask: ${r2.bestAsk.toString()}
|
|
2786288
|
+
`;
|
|
2786289
|
+
output4 += `Best Bid: ${r2.bestBid.toString()}
|
|
2786290
|
+
`;
|
|
2786291
|
+
output4 += `Ask Volume: ${r2.askVolume.toString()}
|
|
2786292
|
+
`;
|
|
2786293
|
+
output4 += `Bid Volume: ${r2.bidVolume.toString()}
|
|
2786294
|
+
`;
|
|
2786295
|
+
output4 += `Last Traded Price: ${r2.lastTradedPrice.toString()}
|
|
2786296
|
+
`;
|
|
2786297
|
+
break;
|
|
2786298
|
+
}
|
|
2786299
|
+
}
|
|
2786300
|
+
output4 += "-".repeat(50);
|
|
2786301
|
+
return output4;
|
|
2786302
|
+
}
|
|
2786303
|
+
});
|
|
2786304
|
+
|
|
2786305
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/utils/index.js
|
|
2786306
|
+
var require_utils193 = __commonJS((exports6) => {
|
|
2786307
|
+
var __createBinding = exports6 && exports6.__createBinding || (Object.create ? function(o4, m2, k2, k22) {
|
|
2786308
|
+
if (k22 === undefined)
|
|
2786309
|
+
k22 = k2;
|
|
2786310
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k2);
|
|
2786311
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
2786312
|
+
desc = { enumerable: true, get: function() {
|
|
2786313
|
+
return m2[k2];
|
|
2786314
|
+
} };
|
|
2786315
|
+
}
|
|
2786316
|
+
Object.defineProperty(o4, k22, desc);
|
|
2786317
|
+
} : function(o4, m2, k2, k22) {
|
|
2786318
|
+
if (k22 === undefined)
|
|
2786319
|
+
k22 = k2;
|
|
2786320
|
+
o4[k22] = m2[k2];
|
|
2786321
|
+
});
|
|
2786322
|
+
var __exportStar = exports6 && exports6.__exportStar || function(m2, exports7) {
|
|
2786323
|
+
for (var p in m2)
|
|
2786324
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports7, p))
|
|
2786325
|
+
__createBinding(exports7, m2, p);
|
|
2786326
|
+
};
|
|
2786327
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2786328
|
+
__exportStar(require_constants79(), exports6);
|
|
2786329
|
+
__exportStar(require_time5(), exports6);
|
|
2786330
|
+
__exportStar(require_auth2(), exports6);
|
|
2786331
|
+
__exportStar(require_logger17(), exports6);
|
|
2786332
|
+
__exportStar(require_report2(), exports6);
|
|
2786333
|
+
__exportStar(require_origin_discovery(), exports6);
|
|
2786334
|
+
__exportStar(require_validation3(), exports6);
|
|
2786335
|
+
});
|
|
2786336
|
+
|
|
2786337
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/defaultConfig.js
|
|
2786338
|
+
var require_defaultConfig = __commonJS((exports6) => {
|
|
2786339
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2786340
|
+
exports6.DEFAULT_CONFIG = undefined;
|
|
2786341
|
+
var constants_1 = require_constants79();
|
|
2786342
|
+
exports6.DEFAULT_CONFIG = {
|
|
2786343
|
+
endpoint: "https://api.testnet-dataengine.chain.link",
|
|
2786344
|
+
wsEndpoint: "wss://ws.testnet-dataengine.chain.link",
|
|
2786345
|
+
retryAttempts: constants_1.DEFAULT_RETRY_ATTEMPTS,
|
|
2786346
|
+
retryDelay: constants_1.DEFAULT_RETRY_DELAY,
|
|
2786347
|
+
timeout: constants_1.DEFAULT_TIMEOUT,
|
|
2786348
|
+
haMode: false,
|
|
2786349
|
+
haConnectionTimeout: constants_1.WS_CONSTANTS.CONNECT_TIMEOUT,
|
|
2786350
|
+
logging: undefined
|
|
2786351
|
+
};
|
|
2786352
|
+
});
|
|
2786353
|
+
|
|
2786354
|
+
// node_modules/@chainlink/data-streams-sdk/dist/src/index.js
|
|
2786355
|
+
var require_src41 = __commonJS((exports6) => {
|
|
2786356
|
+
var __createBinding = exports6 && exports6.__createBinding || (Object.create ? function(o4, m2, k2, k22) {
|
|
2786357
|
+
if (k22 === undefined)
|
|
2786358
|
+
k22 = k2;
|
|
2786359
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k2);
|
|
2786360
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
2786361
|
+
desc = { enumerable: true, get: function() {
|
|
2786362
|
+
return m2[k2];
|
|
2786363
|
+
} };
|
|
2786364
|
+
}
|
|
2786365
|
+
Object.defineProperty(o4, k22, desc);
|
|
2786366
|
+
} : function(o4, m2, k2, k22) {
|
|
2786367
|
+
if (k22 === undefined)
|
|
2786368
|
+
k22 = k2;
|
|
2786369
|
+
o4[k22] = m2[k2];
|
|
2786370
|
+
});
|
|
2786371
|
+
var __exportStar = exports6 && exports6.__exportStar || function(m2, exports7) {
|
|
2786372
|
+
for (var p in m2)
|
|
2786373
|
+
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports7, p))
|
|
2786374
|
+
__createBinding(exports7, m2, p);
|
|
2786375
|
+
};
|
|
2786376
|
+
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2786377
|
+
exports6.DEFAULT_RETRY_DELAY = exports6.DEFAULT_RETRY_ATTEMPTS = exports6.DEFAULT_TIMEOUT = exports6.DEFAULT_CONFIG = exports6.generateAuthHeaders = exports6.getCurrentTimestamp = exports6.formatReport = exports6.getReportVersion = exports6.ConnectionStatus = exports6.LogLevel = exports6.Stream = exports6.decodeReport = exports6.createClient = undefined;
|
|
2786378
|
+
var client_1 = require_client18();
|
|
2786379
|
+
Object.defineProperty(exports6, "createClient", { enumerable: true, get: function() {
|
|
2786380
|
+
return client_1.createClient;
|
|
2786381
|
+
} });
|
|
2786382
|
+
var decoder_1 = require_decoder12();
|
|
2786383
|
+
Object.defineProperty(exports6, "decodeReport", { enumerable: true, get: function() {
|
|
2786384
|
+
return decoder_1.decodeReport;
|
|
2786385
|
+
} });
|
|
2786386
|
+
var stream_1 = require_stream();
|
|
2786387
|
+
Object.defineProperty(exports6, "Stream", { enumerable: true, get: function() {
|
|
2786388
|
+
return stream_1.Stream;
|
|
2786389
|
+
} });
|
|
2786390
|
+
var logger_1 = require_logger16();
|
|
2786391
|
+
Object.defineProperty(exports6, "LogLevel", { enumerable: true, get: function() {
|
|
2786392
|
+
return logger_1.LogLevel;
|
|
2786393
|
+
} });
|
|
2786394
|
+
var metrics_1 = require_metrics4();
|
|
2786395
|
+
Object.defineProperty(exports6, "ConnectionStatus", { enumerable: true, get: function() {
|
|
2786396
|
+
return metrics_1.ConnectionStatus;
|
|
2786397
|
+
} });
|
|
2786398
|
+
__exportStar(require_errors56(), exports6);
|
|
2786399
|
+
var utils_1 = require_utils193();
|
|
2786400
|
+
Object.defineProperty(exports6, "getReportVersion", { enumerable: true, get: function() {
|
|
2786401
|
+
return utils_1.getReportVersion;
|
|
2786402
|
+
} });
|
|
2786403
|
+
Object.defineProperty(exports6, "formatReport", { enumerable: true, get: function() {
|
|
2786404
|
+
return utils_1.formatReport;
|
|
2786405
|
+
} });
|
|
2786406
|
+
Object.defineProperty(exports6, "getCurrentTimestamp", { enumerable: true, get: function() {
|
|
2786407
|
+
return utils_1.getCurrentTimestamp;
|
|
2786408
|
+
} });
|
|
2786409
|
+
Object.defineProperty(exports6, "generateAuthHeaders", { enumerable: true, get: function() {
|
|
2786410
|
+
return utils_1.generateAuthHeaders;
|
|
2786411
|
+
} });
|
|
2786412
|
+
var defaultConfig_1 = require_defaultConfig();
|
|
2786413
|
+
Object.defineProperty(exports6, "DEFAULT_CONFIG", { enumerable: true, get: function() {
|
|
2786414
|
+
return defaultConfig_1.DEFAULT_CONFIG;
|
|
2786415
|
+
} });
|
|
2786416
|
+
var constants_1 = require_constants79();
|
|
2786417
|
+
Object.defineProperty(exports6, "DEFAULT_TIMEOUT", { enumerable: true, get: function() {
|
|
2786418
|
+
return constants_1.DEFAULT_TIMEOUT;
|
|
2786419
|
+
} });
|
|
2786420
|
+
Object.defineProperty(exports6, "DEFAULT_RETRY_ATTEMPTS", { enumerable: true, get: function() {
|
|
2786421
|
+
return constants_1.DEFAULT_RETRY_ATTEMPTS;
|
|
2786422
|
+
} });
|
|
2786423
|
+
Object.defineProperty(exports6, "DEFAULT_RETRY_DELAY", { enumerable: true, get: function() {
|
|
2786424
|
+
return constants_1.DEFAULT_RETRY_DELAY;
|
|
2786425
|
+
} });
|
|
2786426
|
+
});
|
|
2786427
|
+
|
|
2786428
|
+
// src/infra/chainlink/streams.ts
|
|
2786429
|
+
function isStreamsConfigured() {
|
|
2786430
|
+
return Boolean(process.env[CHAINLINK_ENV_KEYS.API_KEY] && process.env[CHAINLINK_ENV_KEYS.API_SECRET]);
|
|
2786431
|
+
}
|
|
2786432
|
+
function getClient4() {
|
|
2786433
|
+
if (_client)
|
|
2786434
|
+
return _client;
|
|
2786435
|
+
if (!isStreamsConfigured()) {
|
|
2786436
|
+
throw new Error("Chainlink Data Streams not configured. Set CHAINLINK_API_KEY and CHAINLINK_API_SECRET environment variables.");
|
|
2786437
|
+
}
|
|
2786438
|
+
_client = import_data_streams_sdk.createClient({
|
|
2786439
|
+
apiKey: process.env[CHAINLINK_ENV_KEYS.API_KEY],
|
|
2786440
|
+
userSecret: process.env[CHAINLINK_ENV_KEYS.API_SECRET],
|
|
2786441
|
+
endpoint: STREAMS_BASE_URL,
|
|
2786442
|
+
wsEndpoint: STREAMS_BASE_URL.replace("https://", "wss://").replace("api.", "ws.")
|
|
2786443
|
+
});
|
|
2786444
|
+
return _client;
|
|
2786445
|
+
}
|
|
2786446
|
+
function resolveFeedId(pairOrFeedId) {
|
|
2786447
|
+
if (pairOrFeedId.startsWith("0x"))
|
|
2786448
|
+
return pairOrFeedId;
|
|
2786449
|
+
const normalized = pairOrFeedId.toUpperCase().replace("-", "/");
|
|
2786450
|
+
const pair = normalized.includes("/") ? normalized : `${normalized}/USD`;
|
|
2786451
|
+
const feedId = STREAMS_FEED_IDS[pair];
|
|
2786452
|
+
if (!feedId) {
|
|
2786453
|
+
throw new Error(`Unknown feed pair "${pair}". Available: ${Object.keys(STREAMS_FEED_IDS).join(", ")}. ` + `You can also provide a raw feed ID (0x...).`);
|
|
2786454
|
+
}
|
|
2786455
|
+
return feedId;
|
|
2786456
|
+
}
|
|
2786457
|
+
function feedIdToPair(feedId) {
|
|
2786458
|
+
for (const [pair, id4] of Object.entries(STREAMS_FEED_IDS)) {
|
|
2786459
|
+
if (id4.toLowerCase() === feedId.toLowerCase())
|
|
2786460
|
+
return pair;
|
|
2786461
|
+
}
|
|
2786462
|
+
return feedId;
|
|
2786463
|
+
}
|
|
2786464
|
+
function toStreamsReport(rawReport, feedId) {
|
|
2786465
|
+
const decoded = import_data_streams_sdk.decodeReport(rawReport.fullReport, rawReport.feedID);
|
|
2786466
|
+
const price = toNumber9(decoded.price ?? decoded.benchmarkPrice ?? 0n, decoded.decimals);
|
|
2786467
|
+
const bid = toNumber9(decoded.bid ?? price, decoded.decimals);
|
|
2786468
|
+
const ask = toNumber9(decoded.ask ?? price, decoded.decimals);
|
|
2786469
|
+
const timestamp2 = Number(decoded.observationsTimestamp ?? rawReport.observationsTimestamp ?? 0);
|
|
2786470
|
+
const validFrom = Number(decoded.validFromTimestamp ?? rawReport.validFromTimestamp ?? timestamp2);
|
|
2786471
|
+
const expiresAt = Number(decoded.expiresAt ?? 0);
|
|
2786472
|
+
return {
|
|
2786473
|
+
feedId,
|
|
2786474
|
+
pair: feedIdToPair(feedId),
|
|
2786475
|
+
price: typeof price === "number" ? price : Number(price),
|
|
2786476
|
+
bid: typeof bid === "number" ? bid : Number(bid),
|
|
2786477
|
+
ask: typeof ask === "number" ? ask : Number(ask),
|
|
2786478
|
+
timestamp: timestamp2,
|
|
2786479
|
+
validFromTimestamp: validFrom,
|
|
2786480
|
+
expiresAt
|
|
2786481
|
+
};
|
|
2786482
|
+
}
|
|
2786483
|
+
function toNumber9(value2, decimals) {
|
|
2786484
|
+
if (typeof value2 === "number")
|
|
2786485
|
+
return value2;
|
|
2786486
|
+
if (typeof value2 === "bigint") {
|
|
2786487
|
+
const dec2 = typeof decimals === "number" ? decimals : typeof decimals === "bigint" ? Number(decimals) : 18;
|
|
2786488
|
+
return Number(value2) / Math.pow(10, dec2);
|
|
2786489
|
+
}
|
|
2786490
|
+
return parseFloat(String(value2)) || 0;
|
|
2786491
|
+
}
|
|
2786492
|
+
async function getLatestReport(pairOrFeedId) {
|
|
2786493
|
+
const feedId = resolveFeedId(pairOrFeedId);
|
|
2786494
|
+
const client4 = getClient4();
|
|
2786495
|
+
const report = await client4.getLatestReport(feedId);
|
|
2786496
|
+
return toStreamsReport(report, feedId);
|
|
2786497
|
+
}
|
|
2786498
|
+
async function getReportAtTimestamp(pairOrFeedId, timestamp2) {
|
|
2786499
|
+
const feedId = resolveFeedId(pairOrFeedId);
|
|
2786500
|
+
const client4 = getClient4();
|
|
2786501
|
+
const report = await client4.getReportByTimestamp(feedId, timestamp2);
|
|
2786502
|
+
return toStreamsReport(report, feedId);
|
|
2786503
|
+
}
|
|
2786504
|
+
async function getBulkReports(pairsOrFeedIds) {
|
|
2786505
|
+
const feedIds = pairsOrFeedIds.map(resolveFeedId);
|
|
2786506
|
+
const client4 = getClient4();
|
|
2786507
|
+
const now4 = Math.floor(Date.now() / 1000);
|
|
2786508
|
+
const reports = await client4.getReportsBulk(feedIds, now4);
|
|
2786509
|
+
const results = Array.isArray(reports) ? reports : [reports];
|
|
2786510
|
+
return results.map((raw, i2) => toStreamsReport(raw, feedIds[i2] ?? "unknown"));
|
|
2786511
|
+
}
|
|
2786512
|
+
function listAvailableFeeds() {
|
|
2786513
|
+
return Object.entries(STREAMS_FEED_IDS).map(([pair, feedId]) => ({
|
|
2786514
|
+
pair,
|
|
2786515
|
+
feedId
|
|
2786516
|
+
}));
|
|
2786517
|
+
}
|
|
2786518
|
+
var import_data_streams_sdk, _client = null;
|
|
2786519
|
+
var init_streams = __esm(() => {
|
|
2786520
|
+
init_types53();
|
|
2786521
|
+
import_data_streams_sdk = __toESM(require_src41(), 1);
|
|
2786522
|
+
});
|
|
2786523
|
+
|
|
2786524
|
+
// src/infra/chainlink/feeds.ts
|
|
2786525
|
+
async function ethCall(rpcUrl, to3, data7) {
|
|
2786526
|
+
const response = await fetch(rpcUrl, {
|
|
2786527
|
+
method: "POST",
|
|
2786528
|
+
headers: { "Content-Type": "application/json" },
|
|
2786529
|
+
body: JSON.stringify({
|
|
2786530
|
+
jsonrpc: "2.0",
|
|
2786531
|
+
id: 1,
|
|
2786532
|
+
method: "eth_call",
|
|
2786533
|
+
params: [{ to: to3, data: data7 }, "latest"]
|
|
2786534
|
+
})
|
|
2786535
|
+
});
|
|
2786536
|
+
if (!response.ok) {
|
|
2786537
|
+
throw new Error(`RPC request failed: ${response.status} ${response.statusText}`);
|
|
2786538
|
+
}
|
|
2786539
|
+
const json8 = await response.json();
|
|
2786540
|
+
if (json8.error) {
|
|
2786541
|
+
throw new Error(`eth_call error: ${json8.error.message}`);
|
|
2786542
|
+
}
|
|
2786543
|
+
if (!json8.result || json8.result === "0x") {
|
|
2786544
|
+
throw new Error("eth_call returned empty result \u2014 contract may not exist at this address");
|
|
2786545
|
+
}
|
|
2786546
|
+
return json8.result;
|
|
2786547
|
+
}
|
|
2786548
|
+
function decodeLatestRoundData(hex29) {
|
|
2786549
|
+
const data7 = hex29.startsWith("0x") ? hex29.slice(2) : hex29;
|
|
2786550
|
+
const roundId = BigInt("0x" + data7.slice(0, 64)).toString();
|
|
2786551
|
+
const answer = BigInt("0x" + data7.slice(64, 128));
|
|
2786552
|
+
const updatedAt = Number(BigInt("0x" + data7.slice(192, 256)));
|
|
2786553
|
+
return { roundId, answer, updatedAt };
|
|
2786554
|
+
}
|
|
2786555
|
+
function decodeDecimals(hex29) {
|
|
2786556
|
+
const data7 = hex29.startsWith("0x") ? hex29.slice(2) : hex29;
|
|
2786557
|
+
return Number(BigInt("0x" + data7));
|
|
2786558
|
+
}
|
|
2786559
|
+
async function readFeed(chainName, aggregatorAddress, pair) {
|
|
2786560
|
+
const rpcUrl = getRpcUrl(chainName);
|
|
2786561
|
+
const [roundDataHex, decimalsHex] = await Promise.all([
|
|
2786562
|
+
ethCall(rpcUrl, aggregatorAddress, FEED_SELECTORS.latestRoundData),
|
|
2786563
|
+
ethCall(rpcUrl, aggregatorAddress, FEED_SELECTORS.decimals)
|
|
2786564
|
+
]);
|
|
2786565
|
+
const { roundId, answer, updatedAt } = decodeLatestRoundData(roundDataHex);
|
|
2786566
|
+
const decimals = decodeDecimals(decimalsHex);
|
|
2786567
|
+
const price = Number(answer) / Math.pow(10, decimals);
|
|
2786568
|
+
return {
|
|
2786569
|
+
chain: chainName,
|
|
2786570
|
+
pair: pair || "UNKNOWN",
|
|
2786571
|
+
price,
|
|
2786572
|
+
decimals,
|
|
2786573
|
+
roundId,
|
|
2786574
|
+
updatedAt,
|
|
2786575
|
+
aggregatorAddress
|
|
2786576
|
+
};
|
|
2786577
|
+
}
|
|
2786578
|
+
async function readFeedByPair(chainName, pair) {
|
|
2786579
|
+
const normalized = pair.toUpperCase().replace("-", "/");
|
|
2786580
|
+
const key5 = `${chainName}:${normalized}`;
|
|
2786581
|
+
const aggregatorAddress = FEED_DIRECTORY[key5];
|
|
2786582
|
+
if (!aggregatorAddress) {
|
|
2786583
|
+
const available = Object.keys(FEED_DIRECTORY).filter((k2) => k2.startsWith(`${chainName}:`)).map((k2) => k2.split(":")[1]);
|
|
2786584
|
+
if (available.length === 0) {
|
|
2786585
|
+
throw new Error(`No Data Feeds available for chain "${chainName}". ` + `Supported chains: ${[...new Set(Object.keys(FEED_DIRECTORY).map((k2) => k2.split(":")[0]))].join(", ")}`);
|
|
2786586
|
+
}
|
|
2786587
|
+
throw new Error(`Data Feed "${normalized}" not found on ${chainName}. ` + `Available: ${available.join(", ")}. ` + `Or provide a custom aggregator address.`);
|
|
2786588
|
+
}
|
|
2786589
|
+
return readFeed(chainName, aggregatorAddress, normalized);
|
|
2786590
|
+
}
|
|
2786591
|
+
async function comparePrices(pair, chainName = "ethereum", streamPrice) {
|
|
2786592
|
+
const feedResult = await readFeedByPair(chainName, pair);
|
|
2786593
|
+
let streamsPrice = streamPrice ?? null;
|
|
2786594
|
+
if (streamsPrice === null && isStreamsConfigured()) {
|
|
2786595
|
+
try {
|
|
2786596
|
+
const report = await getLatestReport(pair);
|
|
2786597
|
+
streamsPrice = report.price;
|
|
2786598
|
+
} catch {
|
|
2786599
|
+
streamsPrice = null;
|
|
2786600
|
+
}
|
|
2786601
|
+
}
|
|
2786602
|
+
const deltaPercent = streamsPrice !== null ? (feedResult.price - streamsPrice) / streamsPrice * 100 : null;
|
|
2786603
|
+
return {
|
|
2786604
|
+
pair: feedResult.pair,
|
|
2786605
|
+
onChainPrice: feedResult.price,
|
|
2786606
|
+
streamsPrice,
|
|
2786607
|
+
deltaPercent,
|
|
2786608
|
+
onChainUpdatedAt: feedResult.updatedAt,
|
|
2786609
|
+
chain: chainName
|
|
2786610
|
+
};
|
|
2786611
|
+
}
|
|
2786612
|
+
var init_feeds = __esm(() => {
|
|
2786613
|
+
init_types53();
|
|
2786614
|
+
init_streams();
|
|
2786615
|
+
});
|
|
2786616
|
+
|
|
2786617
|
+
// src/infra/chainlink/ccip.ts
|
|
2786618
|
+
function isCCIPConfigured() {
|
|
2786619
|
+
return Boolean(process.env[CHAINLINK_ENV_KEYS.EVM_PRIVATE_KEY]);
|
|
2786620
|
+
}
|
|
2786621
|
+
function getWallet(chainName) {
|
|
2786622
|
+
const privateKey = process.env[CHAINLINK_ENV_KEYS.EVM_PRIVATE_KEY];
|
|
2786623
|
+
if (!privateKey) {
|
|
2786624
|
+
throw new Error("CCIP not configured. Set EVM_PRIVATE_KEY environment variable.");
|
|
2786625
|
+
}
|
|
2786626
|
+
const rpcUrl = getRpcUrl(chainName);
|
|
2786627
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
2786628
|
+
const key5 = privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`;
|
|
2786629
|
+
return new Wallet(key5, provider);
|
|
2786630
|
+
}
|
|
2786631
|
+
function getChainConfig3(chainName) {
|
|
2786632
|
+
const config9 = CCIP_CHAINS[chainName.toLowerCase()];
|
|
2786633
|
+
if (!config9) {
|
|
2786634
|
+
throw new Error(`Chain "${chainName}" not supported for CCIP. ` + `Supported: ${Object.keys(CCIP_CHAINS).join(", ")}`);
|
|
2786635
|
+
}
|
|
2786636
|
+
return config9;
|
|
2786637
|
+
}
|
|
2786638
|
+
function buildCCIPMessage(recipient, tokenAddress, amount, feeToken) {
|
|
2786639
|
+
const abiCoder = AbiCoder.defaultAbiCoder();
|
|
2786640
|
+
const receiver = abiCoder.encode(["address"], [recipient]);
|
|
2786641
|
+
const extraArgs = "0x97a657c9" + abiCoder.encode(["uint256"], [200000n]).slice(2);
|
|
2786642
|
+
return {
|
|
2786643
|
+
receiver,
|
|
2786644
|
+
data: "0x",
|
|
2786645
|
+
tokenAmounts: [{ token: tokenAddress, amount }],
|
|
2786646
|
+
feeToken,
|
|
2786647
|
+
extraArgs
|
|
2786648
|
+
};
|
|
2786649
|
+
}
|
|
2786650
|
+
function getSupportedChains3() {
|
|
2786651
|
+
return Object.entries(CCIP_CHAINS).map(([chain5, config9]) => ({
|
|
2786652
|
+
chain: chain5,
|
|
2786653
|
+
selector: config9.selector,
|
|
2786654
|
+
tokens: Object.keys(config9.supportedTokens)
|
|
2786655
|
+
}));
|
|
2786656
|
+
}
|
|
2786657
|
+
async function getCCIPFee(sourceChain, destChain, tokenSymbol, amount, recipient, decimals = 18) {
|
|
2786658
|
+
const sourceConfig = getChainConfig3(sourceChain);
|
|
2786659
|
+
const destConfig = getChainConfig3(destChain);
|
|
2786660
|
+
const tokenAddress = sourceConfig.supportedTokens[tokenSymbol.toUpperCase()];
|
|
2786661
|
+
if (!tokenAddress) {
|
|
2786662
|
+
throw new Error(`Token "${tokenSymbol}" not supported on ${sourceChain} for CCIP. ` + `Available: ${Object.keys(sourceConfig.supportedTokens).join(", ")}`);
|
|
2786663
|
+
}
|
|
2786664
|
+
const wallet3 = getWallet(sourceChain);
|
|
2786665
|
+
const router = new Contract(sourceConfig.router, CCIP_ROUTER_ABI, wallet3);
|
|
2786666
|
+
const amountWei = parseUnits(amount, decimals);
|
|
2786667
|
+
const linkFeeMessage = buildCCIPMessage(recipient, tokenAddress, amountWei, sourceConfig.linkToken);
|
|
2786668
|
+
const nativeFeeMessage = buildCCIPMessage(recipient, tokenAddress, amountWei, "0x0000000000000000000000000000000000000000");
|
|
2786669
|
+
const getFee2 = router.getFunction("getFee");
|
|
2786670
|
+
const [feeInLink, feeInNative] = await Promise.all([
|
|
2786671
|
+
getFee2(destConfig.selector, linkFeeMessage),
|
|
2786672
|
+
getFee2(destConfig.selector, nativeFeeMessage)
|
|
2786673
|
+
]);
|
|
2786674
|
+
return {
|
|
2786675
|
+
sourceChain,
|
|
2786676
|
+
destChain,
|
|
2786677
|
+
token: tokenSymbol,
|
|
2786678
|
+
amount,
|
|
2786679
|
+
feeInLink: formatUnits(feeInLink, 18),
|
|
2786680
|
+
feeInNative: formatUnits(feeInNative, 18)
|
|
2786681
|
+
};
|
|
2786682
|
+
}
|
|
2786683
|
+
async function executeCCIPTransfer(sourceChain, destChain, tokenSymbol, amount, recipient, payFeesInLink = false, decimals = 18) {
|
|
2786684
|
+
if (!isCCIPConfigured()) {
|
|
2786685
|
+
throw new Error("CCIP not configured. Set EVM_PRIVATE_KEY environment variable.");
|
|
2786686
|
+
}
|
|
2786687
|
+
const sourceConfig = getChainConfig3(sourceChain);
|
|
2786688
|
+
const destConfig = getChainConfig3(destChain);
|
|
2786689
|
+
const tokenAddress = sourceConfig.supportedTokens[tokenSymbol.toUpperCase()];
|
|
2786690
|
+
if (!tokenAddress) {
|
|
2786691
|
+
throw new Error(`Token "${tokenSymbol}" not supported on ${sourceChain} for CCIP. ` + `Available: ${Object.keys(sourceConfig.supportedTokens).join(", ")}`);
|
|
2786692
|
+
}
|
|
2786693
|
+
const wallet3 = getWallet(sourceChain);
|
|
2786694
|
+
const amountWei = parseUnits(amount, decimals);
|
|
2786695
|
+
const tokenContract = new Contract(tokenAddress, ERC20_APPROVE_ABI, wallet3);
|
|
2786696
|
+
const tokenApprove = tokenContract.getFunction("approve");
|
|
2786697
|
+
const approveTx = await tokenApprove(sourceConfig.router, amountWei);
|
|
2786698
|
+
await approveTx.wait();
|
|
2786699
|
+
const feeToken = payFeesInLink ? sourceConfig.linkToken : "0x0000000000000000000000000000000000000000";
|
|
2786700
|
+
const message5 = buildCCIPMessage(recipient, tokenAddress, amountWei, feeToken);
|
|
2786701
|
+
const router = new Contract(sourceConfig.router, CCIP_ROUTER_ABI, wallet3);
|
|
2786702
|
+
const routerGetFee = router.getFunction("getFee");
|
|
2786703
|
+
const fee3 = await routerGetFee(destConfig.selector, message5);
|
|
2786704
|
+
if (payFeesInLink) {
|
|
2786705
|
+
const linkContract = new Contract(sourceConfig.linkToken, ERC20_APPROVE_ABI, wallet3);
|
|
2786706
|
+
const linkApprove = linkContract.getFunction("approve");
|
|
2786707
|
+
const linkApproveTx = await linkApprove(sourceConfig.router, fee3);
|
|
2786708
|
+
await linkApproveTx.wait();
|
|
2786709
|
+
}
|
|
2786710
|
+
const ccipSend = router.getFunction("ccipSend");
|
|
2786711
|
+
const tx = await ccipSend(destConfig.selector, message5, {
|
|
2786712
|
+
value: payFeesInLink ? 0n : fee3
|
|
2786713
|
+
});
|
|
2786714
|
+
const receipt = await tx.wait();
|
|
2786715
|
+
const messageId = receipt?.logs?.[receipt.logs.length - 1]?.topics?.[1] ?? "unknown";
|
|
2786716
|
+
return {
|
|
2786717
|
+
txHash: receipt?.hash ?? tx.hash,
|
|
2786718
|
+
messageId,
|
|
2786719
|
+
sourceChain,
|
|
2786720
|
+
destChain,
|
|
2786721
|
+
token: tokenSymbol,
|
|
2786722
|
+
amount,
|
|
2786723
|
+
recipient
|
|
2786724
|
+
};
|
|
2786725
|
+
}
|
|
2786726
|
+
async function getCCIPStatus(messageId) {
|
|
2786727
|
+
const url3 = `https://ccip.chain.link/api/h/atlas/message/${messageId}`;
|
|
2786728
|
+
const response = await fetch(url3, {
|
|
2786729
|
+
headers: { Accept: "application/json" }
|
|
2786730
|
+
});
|
|
2786731
|
+
if (!response.ok) {
|
|
2786732
|
+
if (response.status === 404) {
|
|
2786733
|
+
return {
|
|
2786734
|
+
messageId,
|
|
2786735
|
+
status: "pending",
|
|
2786736
|
+
sourceChain: "unknown",
|
|
2786737
|
+
destChain: "unknown",
|
|
2786738
|
+
timestamp: null
|
|
2786739
|
+
};
|
|
2786740
|
+
}
|
|
2786741
|
+
throw new Error(`CCIP Explorer error ${response.status}: ${await response.text()}`);
|
|
2786742
|
+
}
|
|
2786743
|
+
const data7 = await response.json();
|
|
2786744
|
+
return {
|
|
2786745
|
+
messageId,
|
|
2786746
|
+
status: String(data7.state || data7.status || "unknown"),
|
|
2786747
|
+
sourceChain: String(data7.sourceChainName || data7.sourceNetwork || "unknown"),
|
|
2786748
|
+
destChain: String(data7.destChainName || data7.destNetwork || "unknown"),
|
|
2786749
|
+
timestamp: data7.timestamp ? Number(data7.timestamp) : null
|
|
2786750
|
+
};
|
|
2786751
|
+
}
|
|
2786752
|
+
var init_ccip7 = __esm(() => {
|
|
2786753
|
+
init_lib2();
|
|
2786754
|
+
init_types53();
|
|
2786755
|
+
});
|
|
2786756
|
+
|
|
2786757
|
+
// src/infra/chainlink/index.ts
|
|
2786758
|
+
var init_chainlink = __esm(() => {
|
|
2786759
|
+
init_types53();
|
|
2786760
|
+
init_streams();
|
|
2786761
|
+
init_feeds();
|
|
2786762
|
+
init_ccip7();
|
|
2786763
|
+
});
|
|
2786764
|
+
|
|
2786765
|
+
// src/infra/agents/tools/chainlink-streams.ts
|
|
2786766
|
+
var chainlinkGetPriceTool, chainlinkGetPriceAtTool, chainlinkBulkPricesTool, chainlinkListFeedsTool, chainlinkStreamsTools;
|
|
2786767
|
+
var init_chainlink_streams = __esm(() => {
|
|
2786768
|
+
init_tools();
|
|
2786769
|
+
init_zod();
|
|
2786770
|
+
init_chainlink();
|
|
2786771
|
+
chainlinkGetPriceTool = createTool({
|
|
2786772
|
+
id: "chainlink_get_price",
|
|
2786773
|
+
description: "Get the latest institutional-grade price for a crypto pair from Chainlink Data Streams. " + "Returns price, bid, ask, and timestamp. Supports BTC/USD, ETH/USD, SOL/USD, LINK/USD, and more. " + "Requires CHAINLINK_API_KEY and CHAINLINK_API_SECRET.",
|
|
2786774
|
+
inputSchema: exports_external.object({
|
|
2786775
|
+
pair: exports_external.string().describe('Price pair (e.g., "BTC/USD", "ETH/USD") or raw Chainlink feed ID (0x...)')
|
|
2786776
|
+
}),
|
|
2786777
|
+
outputSchema: exports_external.object({
|
|
2786778
|
+
success: exports_external.boolean(),
|
|
2786779
|
+
data: exports_external.unknown().optional(),
|
|
2786780
|
+
error: exports_external.string().optional()
|
|
2786781
|
+
}),
|
|
2786782
|
+
execute: async ({ pair }) => {
|
|
2786783
|
+
if (!isStreamsConfigured()) {
|
|
2786784
|
+
return {
|
|
2786785
|
+
success: false,
|
|
2786786
|
+
error: "Chainlink Data Streams not configured. Set CHAINLINK_API_KEY and CHAINLINK_API_SECRET."
|
|
2786787
|
+
};
|
|
2786788
|
+
}
|
|
2786789
|
+
try {
|
|
2786790
|
+
const report = await getLatestReport(pair);
|
|
2786791
|
+
return { success: true, data: report };
|
|
2786792
|
+
} catch (error56) {
|
|
2786793
|
+
return { success: false, error: error56.message };
|
|
2786794
|
+
}
|
|
2786795
|
+
}
|
|
2786796
|
+
});
|
|
2786797
|
+
chainlinkGetPriceAtTool = createTool({
|
|
2786798
|
+
id: "chainlink_get_price_at",
|
|
2786799
|
+
description: "Get a historical Chainlink Data Streams price at a specific timestamp. " + "Useful for checking what the price was at a particular moment in time.",
|
|
2786800
|
+
inputSchema: exports_external.object({
|
|
2786801
|
+
pair: exports_external.string().describe('Price pair (e.g., "BTC/USD") or raw feed ID (0x...)'),
|
|
2786802
|
+
timestamp: exports_external.number().describe("Unix timestamp in seconds to query the price at")
|
|
2786803
|
+
}),
|
|
2786804
|
+
outputSchema: exports_external.object({
|
|
2786805
|
+
success: exports_external.boolean(),
|
|
2786806
|
+
data: exports_external.unknown().optional(),
|
|
2786807
|
+
error: exports_external.string().optional()
|
|
2786808
|
+
}),
|
|
2786809
|
+
execute: async ({ pair, timestamp: timestamp2 }) => {
|
|
2786810
|
+
if (!isStreamsConfigured()) {
|
|
2786811
|
+
return {
|
|
2786812
|
+
success: false,
|
|
2786813
|
+
error: "Chainlink Data Streams not configured. Set CHAINLINK_API_KEY and CHAINLINK_API_SECRET."
|
|
2786814
|
+
};
|
|
2786815
|
+
}
|
|
2786816
|
+
try {
|
|
2786817
|
+
const report = await getReportAtTimestamp(pair, timestamp2);
|
|
2786818
|
+
return { success: true, data: report };
|
|
2786819
|
+
} catch (error56) {
|
|
2786820
|
+
return { success: false, error: error56.message };
|
|
2786821
|
+
}
|
|
2786822
|
+
}
|
|
2786823
|
+
});
|
|
2786824
|
+
chainlinkBulkPricesTool = createTool({
|
|
2786825
|
+
id: "chainlink_bulk_prices",
|
|
2786826
|
+
description: "Get latest prices for multiple crypto pairs in a single Chainlink Data Streams API call. " + "More efficient than calling chainlink_get_price multiple times.",
|
|
2786827
|
+
inputSchema: exports_external.object({
|
|
2786828
|
+
pairs: exports_external.array(exports_external.string()).min(1).max(20).describe('Array of price pairs (e.g., ["BTC/USD", "ETH/USD", "SOL/USD"])')
|
|
2786829
|
+
}),
|
|
2786830
|
+
outputSchema: exports_external.object({
|
|
2786831
|
+
success: exports_external.boolean(),
|
|
2786832
|
+
data: exports_external.unknown().optional(),
|
|
2786833
|
+
error: exports_external.string().optional()
|
|
2786834
|
+
}),
|
|
2786835
|
+
execute: async ({ pairs: pairs2 }) => {
|
|
2786836
|
+
if (!isStreamsConfigured()) {
|
|
2786837
|
+
return {
|
|
2786838
|
+
success: false,
|
|
2786839
|
+
error: "Chainlink Data Streams not configured. Set CHAINLINK_API_KEY and CHAINLINK_API_SECRET."
|
|
2786840
|
+
};
|
|
2786841
|
+
}
|
|
2786842
|
+
try {
|
|
2786843
|
+
const reports = await getBulkReports(pairs2);
|
|
2786844
|
+
return { success: true, data: reports };
|
|
2786845
|
+
} catch (error56) {
|
|
2786846
|
+
return { success: false, error: error56.message };
|
|
2786847
|
+
}
|
|
2786848
|
+
}
|
|
2786849
|
+
});
|
|
2786850
|
+
chainlinkListFeedsTool = createTool({
|
|
2786851
|
+
id: "chainlink_list_feeds",
|
|
2786852
|
+
description: "List all available Chainlink Data Streams feed IDs and their corresponding pairs. " + "Use this to discover which crypto pairs are available for price queries.",
|
|
2786853
|
+
inputSchema: exports_external.object({}),
|
|
2786854
|
+
outputSchema: exports_external.object({
|
|
2786855
|
+
success: exports_external.boolean(),
|
|
2786856
|
+
data: exports_external.unknown().optional()
|
|
2786857
|
+
}),
|
|
2786858
|
+
execute: async () => {
|
|
2786859
|
+
const feeds = listAvailableFeeds();
|
|
2786860
|
+
return { success: true, data: feeds };
|
|
2786861
|
+
}
|
|
2786862
|
+
});
|
|
2786863
|
+
chainlinkStreamsTools = {
|
|
2786864
|
+
chainlink_get_price: chainlinkGetPriceTool,
|
|
2786865
|
+
chainlink_get_price_at: chainlinkGetPriceAtTool,
|
|
2786866
|
+
chainlink_bulk_prices: chainlinkBulkPricesTool,
|
|
2786867
|
+
chainlink_list_feeds: chainlinkListFeedsTool
|
|
2786868
|
+
};
|
|
2786869
|
+
});
|
|
2786870
|
+
|
|
2786871
|
+
// src/infra/agents/tools/chainlink-feeds.ts
|
|
2786872
|
+
var chainlinkReadFeedTool, chainlinkComparePricesTool, chainlinkFeedsTools;
|
|
2786873
|
+
var init_chainlink_feeds = __esm(() => {
|
|
2786874
|
+
init_tools();
|
|
2786875
|
+
init_zod();
|
|
2786876
|
+
init_chainlink();
|
|
2786877
|
+
chainlinkReadFeedTool = createTool({
|
|
2786878
|
+
id: "chainlink_read_feed",
|
|
2786879
|
+
description: "Read the latest price from a Chainlink on-chain Data Feed (aggregator contract). " + "Free \u2014 no API key needed. Reads directly from the blockchain via eth_call. " + "Supports multiple EVM chains: ethereum, arbitrum, base, polygon, optimism, avalanche, bnb. " + "You can specify a pair (e.g., ETH/USD) or a custom aggregator address.",
|
|
2786880
|
+
inputSchema: exports_external.object({
|
|
2786881
|
+
chain: exports_external.string().default("ethereum").describe('EVM chain name (e.g., "ethereum", "arbitrum", "base", "polygon")'),
|
|
2786882
|
+
pair: exports_external.string().optional().describe('Price pair (e.g., "ETH/USD", "BTC/USD"). Use this OR aggregatorAddress.'),
|
|
2786883
|
+
aggregatorAddress: exports_external.string().optional().describe("Custom aggregator proxy contract address (0x...). Use this OR pair.")
|
|
2786884
|
+
}),
|
|
2786885
|
+
outputSchema: exports_external.object({
|
|
2786886
|
+
success: exports_external.boolean(),
|
|
2786887
|
+
data: exports_external.unknown().optional(),
|
|
2786888
|
+
error: exports_external.string().optional()
|
|
2786889
|
+
}),
|
|
2786890
|
+
execute: async ({ chain: chain5, pair, aggregatorAddress }) => {
|
|
2786891
|
+
try {
|
|
2786892
|
+
if (aggregatorAddress) {
|
|
2786893
|
+
const result = await readFeed(chain5, aggregatorAddress, pair);
|
|
2786894
|
+
return { success: true, data: result };
|
|
2786895
|
+
}
|
|
2786896
|
+
if (pair) {
|
|
2786897
|
+
const result = await readFeedByPair(chain5, pair);
|
|
2786898
|
+
return { success: true, data: result };
|
|
2786899
|
+
}
|
|
2786900
|
+
return { success: false, error: "Provide either 'pair' or 'aggregatorAddress'." };
|
|
2786901
|
+
} catch (error56) {
|
|
2786902
|
+
return { success: false, error: error56.message };
|
|
2786903
|
+
}
|
|
2786904
|
+
}
|
|
2786905
|
+
});
|
|
2786906
|
+
chainlinkComparePricesTool = createTool({
|
|
2786907
|
+
id: "chainlink_compare_prices",
|
|
2786908
|
+
description: "Compare a Chainlink on-chain Data Feed price with the Chainlink Data Streams price for the same pair. " + "Shows the delta percentage between the two sources. Useful for detecting price manipulation or confirming fair value. " + "Data Streams requires API keys; on-chain feed is free.",
|
|
2786909
|
+
inputSchema: exports_external.object({
|
|
2786910
|
+
pair: exports_external.string().describe('Price pair to compare (e.g., "ETH/USD", "BTC/USD")'),
|
|
2786911
|
+
chain: exports_external.string().default("ethereum").describe('Chain to read on-chain feed from (default: "ethereum")')
|
|
2786912
|
+
}),
|
|
2786913
|
+
outputSchema: exports_external.object({
|
|
2786914
|
+
success: exports_external.boolean(),
|
|
2786915
|
+
data: exports_external.unknown().optional(),
|
|
2786916
|
+
error: exports_external.string().optional()
|
|
2786917
|
+
}),
|
|
2786918
|
+
execute: async ({ pair, chain: chain5 }) => {
|
|
2786919
|
+
try {
|
|
2786920
|
+
const result = await comparePrices(pair, chain5);
|
|
2786921
|
+
return { success: true, data: result };
|
|
2786922
|
+
} catch (error56) {
|
|
2786923
|
+
return { success: false, error: error56.message };
|
|
2786924
|
+
}
|
|
2786925
|
+
}
|
|
2786926
|
+
});
|
|
2786927
|
+
chainlinkFeedsTools = {
|
|
2786928
|
+
chainlink_read_feed: chainlinkReadFeedTool,
|
|
2786929
|
+
chainlink_compare_prices: chainlinkComparePricesTool
|
|
2786930
|
+
};
|
|
2786931
|
+
});
|
|
2786932
|
+
|
|
2786933
|
+
// src/infra/agents/tools/chainlink-ccip.ts
|
|
2786934
|
+
var chainlinkCCIPSupportedChainsTool, chainlinkCCIPGetFeeTool, chainlinkCCIPTransferTool, chainlinkCCIPStatusTool, chainlinkCCIPTools;
|
|
2786935
|
+
var init_chainlink_ccip = __esm(() => {
|
|
2786936
|
+
init_tools();
|
|
2786937
|
+
init_zod();
|
|
2786938
|
+
init_chainlink();
|
|
2786939
|
+
chainlinkCCIPSupportedChainsTool = createTool({
|
|
2786940
|
+
id: "chainlink_ccip_supported_chains",
|
|
2786941
|
+
description: "List all chains and tokens supported by Chainlink CCIP for cross-chain transfers. " + "Shows which EVM chains can send/receive tokens and what tokens are available on each.",
|
|
2786942
|
+
inputSchema: exports_external.object({}),
|
|
2786943
|
+
outputSchema: exports_external.object({
|
|
2786944
|
+
success: exports_external.boolean(),
|
|
2786945
|
+
data: exports_external.unknown().optional()
|
|
2786946
|
+
}),
|
|
2786947
|
+
execute: async () => {
|
|
2786948
|
+
const chains5 = getSupportedChains3();
|
|
2786949
|
+
return { success: true, data: chains5 };
|
|
2786950
|
+
}
|
|
2786951
|
+
});
|
|
2786952
|
+
chainlinkCCIPGetFeeTool = createTool({
|
|
2786953
|
+
id: "chainlink_ccip_get_fee",
|
|
2786954
|
+
description: "Estimate the fee for a Chainlink CCIP cross-chain token transfer. " + "Returns fee in both LINK and native token. Does NOT execute the transfer. " + "Requires EVM_PRIVATE_KEY to query the router contract.",
|
|
2786955
|
+
inputSchema: exports_external.object({
|
|
2786956
|
+
sourceChain: exports_external.string().describe('Source chain (e.g., "ethereum", "arbitrum", "base")'),
|
|
2786957
|
+
destChain: exports_external.string().describe('Destination chain (e.g., "arbitrum", "optimism", "polygon")'),
|
|
2786958
|
+
token: exports_external.string().describe('Token symbol to transfer (e.g., "USDC", "LINK", "WETH")'),
|
|
2786959
|
+
amount: exports_external.string().describe('Amount to transfer in human-readable format (e.g., "100.5")'),
|
|
2786960
|
+
recipient: exports_external.string().describe("Recipient address on the destination chain (0x...)"),
|
|
2786961
|
+
decimals: exports_external.number().default(18).describe("Token decimals (default 18, USDC=6)")
|
|
2786962
|
+
}),
|
|
2786963
|
+
outputSchema: exports_external.object({
|
|
2786964
|
+
success: exports_external.boolean(),
|
|
2786965
|
+
data: exports_external.unknown().optional(),
|
|
2786966
|
+
error: exports_external.string().optional()
|
|
2786967
|
+
}),
|
|
2786968
|
+
execute: async ({ sourceChain, destChain, token: token2, amount, recipient, decimals }) => {
|
|
2786969
|
+
if (!isCCIPConfigured()) {
|
|
2786970
|
+
return {
|
|
2786971
|
+
success: false,
|
|
2786972
|
+
error: "CCIP not configured. Set EVM_PRIVATE_KEY environment variable."
|
|
2786973
|
+
};
|
|
2786974
|
+
}
|
|
2786975
|
+
try {
|
|
2786976
|
+
const fee3 = await getCCIPFee(sourceChain, destChain, token2, amount, recipient, decimals);
|
|
2786977
|
+
return { success: true, data: fee3 };
|
|
2786978
|
+
} catch (error56) {
|
|
2786979
|
+
return { success: false, error: error56.message };
|
|
2786980
|
+
}
|
|
2786981
|
+
}
|
|
2786982
|
+
});
|
|
2786983
|
+
chainlinkCCIPTransferTool = createTool({
|
|
2786984
|
+
id: "chainlink_ccip_transfer",
|
|
2786985
|
+
description: "Execute a cross-chain token transfer using Chainlink CCIP. " + "Transfers tokens between EVM chains (e.g., Ethereum -> Arbitrum). " + "REQUIRES ARMED MODE. Confirm transfer details with user before executing. " + "Flow: approve -> estimate fee -> ccipSend. Requires EVM_PRIVATE_KEY.",
|
|
2786986
|
+
inputSchema: exports_external.object({
|
|
2786987
|
+
sourceChain: exports_external.string().describe('Source chain (e.g., "ethereum", "arbitrum")'),
|
|
2786988
|
+
destChain: exports_external.string().describe('Destination chain (e.g., "arbitrum", "base")'),
|
|
2786989
|
+
token: exports_external.string().describe('Token symbol (e.g., "USDC", "LINK", "WETH")'),
|
|
2786990
|
+
amount: exports_external.string().describe('Amount to transfer (e.g., "100.5")'),
|
|
2786991
|
+
recipient: exports_external.string().describe("Recipient address on destination chain (0x...)"),
|
|
2786992
|
+
payFeesInLink: exports_external.boolean().default(false).describe("Pay fees in LINK (true) or native token (false, default)"),
|
|
2786993
|
+
decimals: exports_external.number().default(18).describe("Token decimals (default 18, USDC=6)")
|
|
2786994
|
+
}),
|
|
2786995
|
+
outputSchema: exports_external.object({
|
|
2786996
|
+
success: exports_external.boolean(),
|
|
2786997
|
+
data: exports_external.unknown().optional(),
|
|
2786998
|
+
error: exports_external.string().optional()
|
|
2786999
|
+
}),
|
|
2787000
|
+
execute: async ({ sourceChain, destChain, token: token2, amount, recipient, payFeesInLink, decimals }) => {
|
|
2787001
|
+
if (!isCCIPConfigured()) {
|
|
2787002
|
+
return {
|
|
2787003
|
+
success: false,
|
|
2787004
|
+
error: "CCIP not configured. Set EVM_PRIVATE_KEY environment variable."
|
|
2787005
|
+
};
|
|
2787006
|
+
}
|
|
2787007
|
+
try {
|
|
2787008
|
+
const result = await executeCCIPTransfer(sourceChain, destChain, token2, amount, recipient, payFeesInLink, decimals);
|
|
2787009
|
+
return { success: true, data: result };
|
|
2787010
|
+
} catch (error56) {
|
|
2787011
|
+
return { success: false, error: error56.message };
|
|
2787012
|
+
}
|
|
2787013
|
+
}
|
|
2787014
|
+
});
|
|
2787015
|
+
chainlinkCCIPStatusTool = createTool({
|
|
2787016
|
+
id: "chainlink_ccip_status",
|
|
2787017
|
+
description: "Check the status of a Chainlink CCIP cross-chain transfer by its message ID. " + "Returns the transfer state (pending, in-flight, success, failed).",
|
|
2787018
|
+
inputSchema: exports_external.object({
|
|
2787019
|
+
messageId: exports_external.string().describe("The CCIP message ID returned from chainlink_ccip_transfer")
|
|
2787020
|
+
}),
|
|
2787021
|
+
outputSchema: exports_external.object({
|
|
2787022
|
+
success: exports_external.boolean(),
|
|
2787023
|
+
data: exports_external.unknown().optional(),
|
|
2787024
|
+
error: exports_external.string().optional()
|
|
2787025
|
+
}),
|
|
2787026
|
+
execute: async ({ messageId }) => {
|
|
2787027
|
+
try {
|
|
2787028
|
+
const status = await getCCIPStatus(messageId);
|
|
2787029
|
+
return { success: true, data: status };
|
|
2787030
|
+
} catch (error56) {
|
|
2787031
|
+
return { success: false, error: error56.message };
|
|
2787032
|
+
}
|
|
2787033
|
+
}
|
|
2787034
|
+
});
|
|
2787035
|
+
chainlinkCCIPTools = {
|
|
2787036
|
+
chainlink_ccip_supported_chains: chainlinkCCIPSupportedChainsTool,
|
|
2787037
|
+
chainlink_ccip_get_fee: chainlinkCCIPGetFeeTool,
|
|
2787038
|
+
chainlink_ccip_transfer: chainlinkCCIPTransferTool,
|
|
2787039
|
+
chainlink_ccip_status: chainlinkCCIPStatusTool
|
|
2787040
|
+
};
|
|
2787041
|
+
});
|
|
2787042
|
+
|
|
2783913
2787043
|
// src/infra/agents/tools/position-tracking.ts
|
|
2783914
2787044
|
async function getManager() {
|
|
2783915
2787045
|
return getPositionManager(getEventBus());
|
|
@@ -2785318,7 +2788448,7 @@ var init_runtime_tools = __esm(() => {
|
|
|
2785318
2788448
|
|
|
2785319
2788449
|
// src/core/regime/types.ts
|
|
2785320
2788450
|
var MarketRegimeSchema, RegimeMetricsSchema, RegimeSignalSchema, RegimeSpanSchema, RegimeHistorySchema, MultiTimeframeRegimeSchema;
|
|
2785321
|
-
var
|
|
2788451
|
+
var init_types54 = __esm(() => {
|
|
2785322
2788452
|
init_zod();
|
|
2785323
2788453
|
MarketRegimeSchema = exports_external.enum([
|
|
2785324
2788454
|
"trending_up",
|
|
@@ -2785546,7 +2788676,7 @@ var init_watcher = __esm(() => {
|
|
|
2785546
2788676
|
|
|
2785547
2788677
|
// src/core/regime/index.ts
|
|
2785548
2788678
|
var init_regime = __esm(() => {
|
|
2785549
|
-
|
|
2788679
|
+
init_types54();
|
|
2785550
2788680
|
init_classifier();
|
|
2785551
2788681
|
init_detector();
|
|
2785552
2788682
|
init_watcher();
|
|
@@ -2785558,7 +2788688,7 @@ var init_regime_tools = __esm(() => {
|
|
|
2785558
2788688
|
init_tools();
|
|
2785559
2788689
|
init_zod();
|
|
2785560
2788690
|
init_regime();
|
|
2785561
|
-
|
|
2788691
|
+
init_types54();
|
|
2785562
2788692
|
init_types9();
|
|
2785563
2788693
|
init_logger2();
|
|
2785564
2788694
|
logger112 = createModuleLogger("regime-tools");
|
|
@@ -2786235,7 +2789365,7 @@ var init_advanced_tools = __esm(() => {
|
|
|
2786235
2789365
|
|
|
2786236
2789366
|
// src/core/genome/types.ts
|
|
2786237
2789367
|
var MutationSchema2, GenomeSchema, ExperimentSchema, MutationSuggestionSchema;
|
|
2786238
|
-
var
|
|
2789368
|
+
var init_types55 = __esm(() => {
|
|
2786239
2789369
|
init_zod();
|
|
2786240
2789370
|
MutationSchema2 = exports_external.object({
|
|
2786241
2789371
|
mutation_id: exports_external.string().uuid(),
|
|
@@ -2786762,7 +2789892,7 @@ __export(exports_genome, {
|
|
|
2786762
2789892
|
EvolutionLoop: () => EvolutionLoop
|
|
2786763
2789893
|
});
|
|
2786764
2789894
|
var init_genome = __esm(() => {
|
|
2786765
|
-
|
|
2789895
|
+
init_types55();
|
|
2786766
2789896
|
init_manager3();
|
|
2786767
2789897
|
init_mutator();
|
|
2786768
2789898
|
init_fitness();
|
|
@@ -2790281,6 +2793411,9 @@ var init_tools7 = __esm(async () => {
|
|
|
2790281
2793411
|
init_uniswap_data();
|
|
2790282
2793412
|
init_dex_search();
|
|
2790283
2793413
|
init_defillama_yields();
|
|
2793414
|
+
init_chainlink_streams();
|
|
2793415
|
+
init_chainlink_feeds();
|
|
2793416
|
+
init_chainlink_ccip();
|
|
2790284
2793417
|
init_position_tracking();
|
|
2790285
2793418
|
init_risk_gate();
|
|
2790286
2793419
|
init_memory_tools();
|
|
@@ -2790344,6 +2793477,9 @@ var init_tools7 = __esm(async () => {
|
|
|
2790344
2793477
|
init_uniswap_data();
|
|
2790345
2793478
|
init_dex_search();
|
|
2790346
2793479
|
init_defillama_yields();
|
|
2793480
|
+
init_chainlink_streams();
|
|
2793481
|
+
init_chainlink_feeds();
|
|
2793482
|
+
init_chainlink_ccip();
|
|
2790347
2793483
|
init_position_tracking();
|
|
2790348
2793484
|
init_risk_gate();
|
|
2790349
2793485
|
init_memory_tools();
|
|
@@ -2790411,6 +2793547,9 @@ var init_tools7 = __esm(async () => {
|
|
|
2790411
2793547
|
...uniswapDataTools,
|
|
2790412
2793548
|
...dexSearchTools,
|
|
2790413
2793549
|
...defillamaYieldTools,
|
|
2793550
|
+
...chainlinkStreamsTools,
|
|
2793551
|
+
...chainlinkFeedsTools,
|
|
2793552
|
+
...chainlinkCCIPTools,
|
|
2790414
2793553
|
...multiModalChartTools,
|
|
2790415
2793554
|
...evalTools,
|
|
2790416
2793555
|
...positionTrackingTools,
|
|
@@ -2790469,6 +2793608,9 @@ var init_tools7 = __esm(async () => {
|
|
|
2790469
2793608
|
uniswapData: Object.keys(uniswapDataTools).length,
|
|
2790470
2793609
|
dexSearch: Object.keys(dexSearchTools).length,
|
|
2790471
2793610
|
defillamaYields: Object.keys(defillamaYieldTools).length,
|
|
2793611
|
+
chainlinkStreams: Object.keys(chainlinkStreamsTools).length,
|
|
2793612
|
+
chainlinkFeeds: Object.keys(chainlinkFeedsTools).length,
|
|
2793613
|
+
chainlinkCCIP: Object.keys(chainlinkCCIPTools).length,
|
|
2790472
2793614
|
multiModalCharts: Object.keys(multiModalChartTools).length,
|
|
2790473
2793615
|
evals: Object.keys(evalTools).length,
|
|
2790474
2793616
|
positionTracking: Object.keys(positionTrackingTools).length,
|
|
@@ -2790869,7 +2794011,7 @@ var require_url5 = __commonJS((exports6) => {
|
|
|
2790869
2794011
|
});
|
|
2790870
2794012
|
|
|
2790871
2794013
|
// node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/errors.js
|
|
2790872
|
-
var
|
|
2794014
|
+
var require_errors57 = __commonJS((exports6) => {
|
|
2790873
2794015
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2790874
2794016
|
exports6.InvalidPointerError = exports6.TimeoutError = exports6.MissingPointerError = exports6.UnmatchedResolverError = exports6.ResolverError = exports6.UnmatchedParserError = exports6.ParserError = exports6.JSONParserErrorGroup = exports6.JSONParserError = undefined;
|
|
2790875
2794017
|
exports6.toJSON = toJSON;
|
|
@@ -2791090,7 +2794232,7 @@ var require_pointer = __commonJS((exports6) => {
|
|
|
2791090
2794232
|
exports6.nullSymbol = undefined;
|
|
2791091
2794233
|
var ref_js_1 = __importDefault(require_ref3());
|
|
2791092
2794234
|
var url3 = __importStar(require_url5());
|
|
2791093
|
-
var errors_js_1 =
|
|
2794235
|
+
var errors_js_1 = require_errors57();
|
|
2791094
2794236
|
exports6.nullSymbol = Symbol("null");
|
|
2791095
2794237
|
var slashes = /\//g;
|
|
2791096
2794238
|
var tildes = /~/g;
|
|
@@ -2791307,7 +2794449,7 @@ var require_ref3 = __commonJS((exports6) => {
|
|
|
2791307
2794449
|
}();
|
|
2791308
2794450
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2791309
2794451
|
var pointer_js_1 = __importStar(require_pointer());
|
|
2791310
|
-
var errors_js_1 =
|
|
2794452
|
+
var errors_js_1 = require_errors57();
|
|
2791311
2794453
|
var url_js_1 = require_url5();
|
|
2791312
2794454
|
|
|
2791313
2794455
|
class $Ref {
|
|
@@ -2791693,7 +2794835,7 @@ var require_parse21 = __commonJS((exports6) => {
|
|
|
2791693
2794835
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2791694
2794836
|
var url3 = __importStar(require_url5());
|
|
2791695
2794837
|
var plugins = __importStar(require_plugins2());
|
|
2791696
|
-
var errors_js_1 =
|
|
2794838
|
+
var errors_js_1 = require_errors57();
|
|
2791697
2794839
|
async function parse26(path8, $refs, options4) {
|
|
2791698
2794840
|
const hashIndex = path8.indexOf("#");
|
|
2791699
2794841
|
let hash12 = "";
|
|
@@ -2791776,7 +2794918,7 @@ Parsed value is empty`);
|
|
|
2791776
2794918
|
// node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/json.js
|
|
2791777
2794919
|
var require_json12 = __commonJS((exports6) => {
|
|
2791778
2794920
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2791779
|
-
var errors_js_1 =
|
|
2794921
|
+
var errors_js_1 = require_errors57();
|
|
2791780
2794922
|
exports6.default = {
|
|
2791781
2794923
|
order: 100,
|
|
2791782
2794924
|
allowEmpty: true,
|
|
@@ -2791819,7 +2794961,7 @@ var require_yaml = __commonJS((exports6) => {
|
|
|
2791819
2794961
|
return mod11 && mod11.__esModule ? mod11 : { default: mod11 };
|
|
2791820
2794962
|
};
|
|
2791821
2794963
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2791822
|
-
var errors_js_1 =
|
|
2794964
|
+
var errors_js_1 = require_errors57();
|
|
2791823
2794965
|
var js_yaml_1 = __importDefault(require_js_yaml3());
|
|
2791824
2794966
|
var js_yaml_2 = require_js_yaml3();
|
|
2791825
2794967
|
exports6.default = {
|
|
@@ -2791851,7 +2794993,7 @@ var require_yaml = __commonJS((exports6) => {
|
|
|
2791851
2794993
|
// node_modules/@apidevtools/json-schema-ref-parser/dist/lib/parsers/text.js
|
|
2791852
2794994
|
var require_text = __commonJS((exports6) => {
|
|
2791853
2794995
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2791854
|
-
var errors_js_1 =
|
|
2794996
|
+
var errors_js_1 = require_errors57();
|
|
2791855
2794997
|
var TEXT_REGEXP = /\.(txt|htm|html|md|xml|js|min|map|css|scss|less|svg)$/i;
|
|
2791856
2794998
|
exports6.default = {
|
|
2791857
2794999
|
order: 300,
|
|
@@ -2791944,7 +2795086,7 @@ var require_file = __commonJS((exports6) => {
|
|
|
2791944
2795086
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2791945
2795087
|
var fs_1 = __importDefault(__require("fs"));
|
|
2791946
2795088
|
var url3 = __importStar(require_url5());
|
|
2791947
|
-
var errors_js_1 =
|
|
2795089
|
+
var errors_js_1 = require_errors57();
|
|
2791948
2795090
|
exports6.default = {
|
|
2791949
2795091
|
order: 100,
|
|
2791950
2795092
|
canRead(file2) {
|
|
@@ -2792021,7 +2795163,7 @@ var require_http17 = __commonJS((exports6) => {
|
|
|
2792021
2795163
|
}();
|
|
2792022
2795164
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2792023
2795165
|
var url3 = __importStar(require_url5());
|
|
2792024
|
-
var errors_js_1 =
|
|
2795166
|
+
var errors_js_1 = require_errors57();
|
|
2792025
2795167
|
exports6.default = {
|
|
2792026
2795168
|
order: 200,
|
|
2792027
2795169
|
headers: null,
|
|
@@ -2792268,7 +2795410,7 @@ var require_resolve_external = __commonJS((exports6) => {
|
|
|
2792268
2795410
|
var pointer_js_1 = __importDefault(require_pointer());
|
|
2792269
2795411
|
var parse_js_1 = __importDefault(require_parse21());
|
|
2792270
2795412
|
var url3 = __importStar(require_url5());
|
|
2792271
|
-
var errors_js_1 =
|
|
2795413
|
+
var errors_js_1 = require_errors57();
|
|
2792272
2795414
|
function resolveExternal(parser, options4) {
|
|
2792273
2795415
|
if (!options4.resolve?.external) {
|
|
2792274
2795416
|
return Promise.resolve();
|
|
@@ -2792567,7 +2795709,7 @@ var require_dereference = __commonJS((exports6) => {
|
|
|
2792567
2795709
|
var ref_js_1 = __importDefault(require_ref3());
|
|
2792568
2795710
|
var pointer_js_1 = __importDefault(require_pointer());
|
|
2792569
2795711
|
var url3 = __importStar(require_url5());
|
|
2792570
|
-
var errors_1 =
|
|
2795712
|
+
var errors_1 = require_errors57();
|
|
2792571
2795713
|
exports6.default = dereference3;
|
|
2792572
2795714
|
function dereference3(parser, options4) {
|
|
2792573
2795715
|
const start3 = Date.now();
|
|
@@ -2792830,7 +2795972,7 @@ var require_lib321 = __commonJS((exports6) => {
|
|
|
2792830
2795972
|
var dereference_js_1 = __importDefault(require_dereference());
|
|
2792831
2795973
|
exports6.dereferenceInternal = dereference_js_1.default;
|
|
2792832
2795974
|
var url3 = __importStar(require_url5());
|
|
2792833
|
-
var errors_js_1 =
|
|
2795975
|
+
var errors_js_1 = require_errors57();
|
|
2792834
2795976
|
Object.defineProperty(exports6, "JSONParserError", { enumerable: true, get: function() {
|
|
2792835
2795977
|
return errors_js_1.JSONParserError;
|
|
2792836
2795978
|
} });
|
|
@@ -2793084,7 +2796226,7 @@ var init_zod_compat = __esm(() => {
|
|
|
2793084
2796226
|
|
|
2793085
2796227
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
2793086
2796228
|
var LATEST_PROTOCOL_VERSION = "2025-11-25", SUPPORTED_PROTOCOL_VERSIONS, RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task", JSONRPC_VERSION4 = "2.0", AssertObjectSchema, ProgressTokenSchema, CursorSchema, TaskCreationParamsSchema, TaskMetadataSchema, RelatedTaskMetadataSchema, RequestMetaSchema, BaseRequestParamsSchema, TaskAugmentedRequestParamsSchema, isTaskAugmentedRequestParams = (value2) => TaskAugmentedRequestParamsSchema.safeParse(value2).success, RequestSchema4, NotificationsParamsSchema, NotificationSchema, ResultSchema4, RequestIdSchema, JSONRPCRequestSchema4, isJSONRPCRequest = (value2) => JSONRPCRequestSchema4.safeParse(value2).success, JSONRPCNotificationSchema4, isJSONRPCNotification = (value2) => JSONRPCNotificationSchema4.safeParse(value2).success, JSONRPCResultResponseSchema, isJSONRPCResultResponse = (value2) => JSONRPCResultResponseSchema.safeParse(value2).success, ErrorCode, JSONRPCErrorResponseSchema, isJSONRPCErrorResponse = (value2) => JSONRPCErrorResponseSchema.safeParse(value2).success, JSONRPCMessageSchema, JSONRPCResponseSchema4, EmptyResultSchema, CancelledNotificationParamsSchema, CancelledNotificationSchema, IconSchema, IconsSchema, BaseMetadataSchema, ImplementationSchema, FormElicitationCapabilitySchema, ElicitationCapabilitySchema, ClientTasksCapabilitySchema, ServerTasksCapabilitySchema, ClientCapabilitiesSchema, InitializeRequestParamsSchema, InitializeRequestSchema, ServerCapabilitiesSchema4, InitializeResultSchema, InitializedNotificationSchema, isInitializedNotification = (value2) => InitializedNotificationSchema.safeParse(value2).success, PingRequestSchema, ProgressSchema, ProgressNotificationParamsSchema, ProgressNotificationSchema, PaginatedRequestParamsSchema, PaginatedRequestSchema, PaginatedResultSchema4, TaskStatusSchema, TaskSchema, CreateTaskResultSchema, TaskStatusNotificationParamsSchema, TaskStatusNotificationSchema, GetTaskRequestSchema, GetTaskResultSchema, GetTaskPayloadRequestSchema, GetTaskPayloadResultSchema, ListTasksRequestSchema, ListTasksResultSchema, CancelTaskRequestSchema, CancelTaskResultSchema, ResourceContentsSchema4, TextResourceContentsSchema4, Base64Schema, BlobResourceContentsSchema4, RoleSchema, AnnotationsSchema, ResourceSchema, ResourceTemplateSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListResourceTemplatesRequestSchema, ListResourceTemplatesResultSchema, ResourceRequestParamsSchema, ReadResourceRequestParamsSchema, ReadResourceRequestSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, SubscribeRequestParamsSchema, SubscribeRequestSchema, UnsubscribeRequestParamsSchema, UnsubscribeRequestSchema, ResourceUpdatedNotificationParamsSchema, ResourceUpdatedNotificationSchema, PromptArgumentSchema, PromptSchema, ListPromptsRequestSchema, ListPromptsResultSchema, GetPromptRequestParamsSchema, GetPromptRequestSchema, TextContentSchema4, ImageContentSchema4, AudioContentSchema, ToolUseContentSchema, EmbeddedResourceSchema4, ResourceLinkSchema, ContentBlockSchema, PromptMessageSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ToolAnnotationsSchema, ToolExecutionSchema, ToolSchema4, ListToolsRequestSchema, ListToolsResultSchema, CallToolResultSchema, CompatibilityCallToolResultSchema, CallToolRequestParamsSchema, CallToolRequestSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, LoggingLevelSchema, SetLevelRequestParamsSchema, SetLevelRequestSchema, LoggingMessageNotificationParamsSchema, LoggingMessageNotificationSchema, ModelHintSchema, ModelPreferencesSchema, ToolChoiceSchema, ToolResultContentSchema, SamplingContentSchema, SamplingMessageContentBlockSchema, SamplingMessageSchema, CreateMessageRequestParamsSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema, LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema, EnumSchemaSchema, PrimitiveSchemaDefinitionSchema, ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema, ElicitRequestParamsSchema, ElicitRequestSchema, ElicitationCompleteNotificationParamsSchema, ElicitationCompleteNotificationSchema, ElicitResultSchema, ResourceTemplateReferenceSchema, PromptReferenceSchema, CompleteRequestParamsSchema, CompleteRequestSchema, CompleteResultSchema, RootSchema, ListRootsRequestSchema, ListRootsResultSchema, RootsListChangedNotificationSchema, ClientRequestSchema, ClientNotificationSchema, ClientResultSchema, ServerRequestSchema, ServerNotificationSchema, ServerResultSchema, McpError, UrlElicitationRequiredError;
|
|
2793087
|
-
var
|
|
2796229
|
+
var init_types56 = __esm(() => {
|
|
2793088
2796230
|
init_v42();
|
|
2793089
2796231
|
SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
2793090
2796232
|
AssertObjectSchema = custom((v18) => v18 !== null && (typeof v18 === "object" || typeof v18 === "function"));
|
|
@@ -2794760,7 +2797902,7 @@ function mergeCapabilities(base10, additional) {
|
|
|
2794760
2797902
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 60000;
|
|
2794761
2797903
|
var init_protocol4 = __esm(() => {
|
|
2794762
2797904
|
init_zod_compat();
|
|
2794763
|
-
|
|
2797905
|
+
init_types56();
|
|
2794764
2797906
|
init_zod_json_schema_compat();
|
|
2794765
2797907
|
});
|
|
2794766
2797908
|
|
|
@@ -2795964,7 +2799106,7 @@ var require_names2 = __commonJS((exports6) => {
|
|
|
2795964
2799106
|
});
|
|
2795965
2799107
|
|
|
2795966
2799108
|
// node_modules/ajv/dist/compile/errors.js
|
|
2795967
|
-
var
|
|
2799109
|
+
var require_errors58 = __commonJS((exports6) => {
|
|
2795968
2799110
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2795969
2799111
|
exports6.extendErrors = exports6.resetErrorsCount = exports6.reportExtraError = exports6.reportError = exports6.keyword$DataError = exports6.keywordError = undefined;
|
|
2795970
2799112
|
var codegen_1 = require_codegen3();
|
|
@@ -2796085,7 +2799227,7 @@ var require_errors57 = __commonJS((exports6) => {
|
|
|
2796085
2799227
|
var require_boolSchema2 = __commonJS((exports6) => {
|
|
2796086
2799228
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2796087
2799229
|
exports6.boolOrEmptySchema = exports6.topBoolOrEmptySchema = undefined;
|
|
2796088
|
-
var errors_1 =
|
|
2799230
|
+
var errors_1 = require_errors58();
|
|
2796089
2799231
|
var codegen_1 = require_codegen3();
|
|
2796090
2799232
|
var names_1 = require_names2();
|
|
2796091
2799233
|
var boolError = {
|
|
@@ -2796183,7 +2799325,7 @@ var require_dataType2 = __commonJS((exports6) => {
|
|
|
2796183
2799325
|
exports6.reportTypeError = exports6.checkDataTypes = exports6.checkDataType = exports6.coerceAndCheckDataType = exports6.getJSONTypes = exports6.getSchemaTypes = exports6.DataType = undefined;
|
|
2796184
2799326
|
var rules_1 = require_rules2();
|
|
2796185
2799327
|
var applicability_1 = require_applicability2();
|
|
2796186
|
-
var errors_1 =
|
|
2799328
|
+
var errors_1 = require_errors58();
|
|
2796187
2799329
|
var codegen_1 = require_codegen3();
|
|
2796188
2799330
|
var util_1 = require_util76();
|
|
2796189
2799331
|
var DataType;
|
|
@@ -2796528,7 +2799670,7 @@ var require_keyword2 = __commonJS((exports6) => {
|
|
|
2796528
2799670
|
var codegen_1 = require_codegen3();
|
|
2796529
2799671
|
var names_1 = require_names2();
|
|
2796530
2799672
|
var code_1 = require_code5();
|
|
2796531
|
-
var errors_1 =
|
|
2799673
|
+
var errors_1 = require_errors58();
|
|
2796532
2799674
|
function macroKeywordCode(cxt, def2) {
|
|
2796533
2799675
|
const { gen: gen10, keyword, schema, parentSchema, it: it2 } = cxt;
|
|
2796534
2799676
|
const macroSchema = def2.macro.call(it2.self, schema, parentSchema, it2);
|
|
@@ -2797009,7 +2800151,7 @@ var require_validate28 = __commonJS((exports6) => {
|
|
|
2797009
2800151
|
var names_1 = require_names2();
|
|
2797010
2800152
|
var resolve_1 = require_resolve3();
|
|
2797011
2800153
|
var util_1 = require_util76();
|
|
2797012
|
-
var errors_1 =
|
|
2800154
|
+
var errors_1 = require_errors58();
|
|
2797013
2800155
|
function validateFunctionCode(it2) {
|
|
2797014
2800156
|
if (isSchemaObj(it2)) {
|
|
2797015
2800157
|
checkKeywords(it2);
|
|
@@ -2797767,7 +2800909,7 @@ var require_data11 = __commonJS((exports6, module) => {
|
|
|
2797767
2800909
|
});
|
|
2797768
2800910
|
|
|
2797769
2800911
|
// node_modules/fast-uri/lib/utils.js
|
|
2797770
|
-
var
|
|
2800912
|
+
var require_utils194 = __commonJS((exports6, module) => {
|
|
2797771
2800913
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
2797772
2800914
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
2797773
2800915
|
function stringArrayToHexStripped(input) {
|
|
@@ -2798023,7 +2801165,7 @@ var require_utils193 = __commonJS((exports6, module) => {
|
|
|
2798023
2801165
|
|
|
2798024
2801166
|
// node_modules/fast-uri/lib/schemes.js
|
|
2798025
2801167
|
var require_schemes2 = __commonJS((exports6, module) => {
|
|
2798026
|
-
var { isUUID } =
|
|
2801168
|
+
var { isUUID } = require_utils194();
|
|
2798027
2801169
|
var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
|
|
2798028
2801170
|
var supportedSchemeNames = [
|
|
2798029
2801171
|
"http",
|
|
@@ -2798197,7 +2801339,7 @@ var require_schemes2 = __commonJS((exports6, module) => {
|
|
|
2798197
2801339
|
|
|
2798198
2801340
|
// node_modules/fast-uri/index.js
|
|
2798199
2801341
|
var require_fast_uri2 = __commonJS((exports6, module) => {
|
|
2798200
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } =
|
|
2801342
|
+
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils194();
|
|
2798201
2801343
|
var { SCHEMES, getSchemeHandler } = require_schemes2();
|
|
2798202
2801344
|
function normalize6(uri2, options4) {
|
|
2798203
2801345
|
if (typeof uri2 === "string") {
|
|
@@ -2799603,7 +2802745,7 @@ var require_enum4 = __commonJS((exports6) => {
|
|
|
2799603
2802745
|
});
|
|
2799604
2802746
|
|
|
2799605
2802747
|
// node_modules/ajv/dist/vocabularies/validation/index.js
|
|
2799606
|
-
var
|
|
2802748
|
+
var require_validation4 = __commonJS((exports6) => {
|
|
2799607
2802749
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2799608
2802750
|
var limitNumber_1 = require_limitNumber2();
|
|
2799609
2802751
|
var multipleOf_1 = require_multipleOf2();
|
|
@@ -2800591,7 +2803733,7 @@ var require_metadata6 = __commonJS((exports6) => {
|
|
|
2800591
2803733
|
var require_draft72 = __commonJS((exports6) => {
|
|
2800592
2803734
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2800593
2803735
|
var core_1 = require_core9();
|
|
2800594
|
-
var validation_1 =
|
|
2803736
|
+
var validation_1 = require_validation4();
|
|
2800595
2803737
|
var applicator_1 = require_applicator2();
|
|
2800596
2803738
|
var format_1 = require_format26();
|
|
2800597
2803739
|
var metadata_1 = require_metadata6();
|
|
@@ -2800607,7 +2803749,7 @@ var require_draft72 = __commonJS((exports6) => {
|
|
|
2800607
2803749
|
});
|
|
2800608
2803750
|
|
|
2800609
2803751
|
// node_modules/ajv/dist/vocabularies/discriminator/types.js
|
|
2800610
|
-
var
|
|
2803752
|
+
var require_types103 = __commonJS((exports6) => {
|
|
2800611
2803753
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2800612
2803754
|
exports6.DiscrError = undefined;
|
|
2800613
2803755
|
var DiscrError;
|
|
@@ -2800621,7 +2803763,7 @@ var require_types102 = __commonJS((exports6) => {
|
|
|
2800621
2803763
|
var require_discriminator6 = __commonJS((exports6) => {
|
|
2800622
2803764
|
Object.defineProperty(exports6, "__esModule", { value: true });
|
|
2800623
2803765
|
var codegen_1 = require_codegen3();
|
|
2800624
|
-
var types_1 =
|
|
2803766
|
+
var types_1 = require_types103();
|
|
2800625
2803767
|
var compile_1 = require_compile2();
|
|
2800626
2803768
|
var ref_error_1 = require_ref_error2();
|
|
2800627
2803769
|
var util_1 = require_util76();
|
|
@@ -2801272,8 +2804414,8 @@ var init_ajv_provider = __esm(() => {
|
|
|
2801272
2804414
|
|
|
2801273
2804415
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
|
|
2801274
2804416
|
class ExperimentalClientTasks {
|
|
2801275
|
-
constructor(
|
|
2801276
|
-
this._client =
|
|
2804417
|
+
constructor(_client2) {
|
|
2804418
|
+
this._client = _client2;
|
|
2801277
2804419
|
}
|
|
2801278
2804420
|
async* callToolStream(params2, resultSchema = CallToolResultSchema, options4) {
|
|
2801279
2804421
|
const clientInternal = this._client;
|
|
@@ -2801336,7 +2804478,7 @@ class ExperimentalClientTasks {
|
|
|
2801336
2804478
|
}
|
|
2801337
2804479
|
}
|
|
2801338
2804480
|
var init_client17 = __esm(() => {
|
|
2801339
|
-
|
|
2804481
|
+
init_types56();
|
|
2801340
2804482
|
});
|
|
2801341
2804483
|
|
|
2801342
2804484
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
@@ -2801419,7 +2804561,7 @@ function getSupportedElicitationModes(capabilities) {
|
|
|
2801419
2804561
|
var Client3;
|
|
2801420
2804562
|
var init_client18 = __esm(() => {
|
|
2801421
2804563
|
init_protocol4();
|
|
2801422
|
-
|
|
2804564
|
+
init_types56();
|
|
2801423
2804565
|
init_ajv_provider();
|
|
2801424
2804566
|
init_zod_compat();
|
|
2801425
2804567
|
init_client17();
|
|
@@ -2802666,7 +2805808,7 @@ async function registerClient(authorizationServerUrl, { metadata: metadata4, cli
|
|
|
2802666
2805808
|
var UnauthorizedError2, AUTHORIZATION_CODE_RESPONSE_TYPE = "code", AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
|
|
2802667
2805809
|
var init_auth2 = __esm(() => {
|
|
2802668
2805810
|
init_index_node10();
|
|
2802669
|
-
|
|
2805811
|
+
init_types56();
|
|
2802670
2805812
|
init_auth();
|
|
2802671
2805813
|
init_auth();
|
|
2802672
2805814
|
init_errors43();
|
|
@@ -2802859,7 +2806001,7 @@ class SSEClientTransport {
|
|
|
2802859
2806001
|
var SseError;
|
|
2802860
2806002
|
var init_sse = __esm(() => {
|
|
2802861
2806003
|
init_dist43();
|
|
2802862
|
-
|
|
2806004
|
+
init_types56();
|
|
2802863
2806005
|
init_auth2();
|
|
2802864
2806006
|
SseError = class SseError extends Error {
|
|
2802865
2806007
|
constructor(code, message5, event9) {
|
|
@@ -2803356,7 +2806498,7 @@ function serializeMessage2(message5) {
|
|
|
2803356
2806498
|
`;
|
|
2803357
2806499
|
}
|
|
2803358
2806500
|
var init_stdio = __esm(() => {
|
|
2803359
|
-
|
|
2806501
|
+
init_types56();
|
|
2803360
2806502
|
});
|
|
2803361
2806503
|
|
|
2803362
2806504
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
|
|
@@ -2803865,7 +2807007,7 @@ class StreamableHTTPClientTransport {
|
|
|
2803865
2807007
|
}
|
|
2803866
2807008
|
var DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS, StreamableHTTPError;
|
|
2803867
2807009
|
var init_streamableHttp = __esm(() => {
|
|
2803868
|
-
|
|
2807010
|
+
init_types56();
|
|
2803869
2807011
|
init_auth2();
|
|
2803870
2807012
|
init_stream();
|
|
2803871
2807013
|
DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
|
|
@@ -2804014,7 +2807156,7 @@ var init_exit_hook = __esm(() => {
|
|
|
2804014
2807156
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
2804015
2807157
|
var init_server = __esm(() => {
|
|
2804016
2807158
|
init_protocol4();
|
|
2804017
|
-
|
|
2807159
|
+
init_types56();
|
|
2804018
2807160
|
init_ajv_provider();
|
|
2804019
2807161
|
init_zod_compat();
|
|
2804020
2807162
|
});
|
|
@@ -2808767,7 +2811909,7 @@ var require_content_type = __commonJS((exports6) => {
|
|
|
2808767
2811909
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js
|
|
2808768
2811910
|
var import_raw_body, import_content_type;
|
|
2808769
2811911
|
var init_sse2 = __esm(() => {
|
|
2808770
|
-
|
|
2811912
|
+
init_types56();
|
|
2808771
2811913
|
import_raw_body = __toESM(require_raw_body(), 1);
|
|
2808772
2811914
|
import_content_type = __toESM(require_content_type(), 1);
|
|
2808773
2811915
|
});
|
|
@@ -2808979,7 +2812121,7 @@ var init_dist47 = __esm(() => {
|
|
|
2808979
2812121
|
|
|
2808980
2812122
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js
|
|
2808981
2812123
|
var init_webStandardStreamableHttp = __esm(() => {
|
|
2808982
|
-
|
|
2812124
|
+
init_types56();
|
|
2808983
2812125
|
});
|
|
2808984
2812126
|
|
|
2808985
2812127
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/streamableHttp.js
|
|
@@ -2809138,7 +2812280,7 @@ var init_dist48 = __esm(() => {
|
|
|
2809138
2812280
|
init_stdio2();
|
|
2809139
2812281
|
init_streamableHttp();
|
|
2809140
2812282
|
init_protocol4();
|
|
2809141
|
-
|
|
2812283
|
+
init_types56();
|
|
2809142
2812284
|
init_exit_hook();
|
|
2809143
2812285
|
init_zod();
|
|
2809144
2812286
|
init_dist6();
|
|
@@ -2810977,6 +2814119,8 @@ function getScannerAgent() {
|
|
|
2810977
2814119
|
...instrumentedRegimeTools,
|
|
2810978
2814120
|
solana_get_token_data: instrumentedSolanaKitWalletTools.solana_get_token_data,
|
|
2810979
2814121
|
solana_rugcheck: instrumentedSolanaKitWalletTools.solana_rugcheck,
|
|
2814122
|
+
chainlink_bulk_prices: instrumentedChainlinkStreamsTools.chainlink_bulk_prices,
|
|
2814123
|
+
chainlink_list_feeds: instrumentedChainlinkStreamsTools.chainlink_list_feeds,
|
|
2810980
2814124
|
...getRoutingToolsForAgent("Scanner")
|
|
2810981
2814125
|
},
|
|
2810982
2814126
|
memory: createSubAgentMemory(),
|
|
@@ -2811063,6 +2814207,12 @@ function getAnalystAgent() {
|
|
|
2811063
2814207
|
solana_debridge_status: instrumentedSolanaKitDefiBridgeTools.solana_debridge_status,
|
|
2811064
2814208
|
solana_okx_quote: instrumentedSolanaKitDefiBridgeTools.solana_okx_quote,
|
|
2811065
2814209
|
solana_okx_tokens: instrumentedSolanaKitDefiBridgeTools.solana_okx_tokens,
|
|
2814210
|
+
chainlink_get_price: instrumentedChainlinkStreamsTools.chainlink_get_price,
|
|
2814211
|
+
chainlink_get_price_at: instrumentedChainlinkStreamsTools.chainlink_get_price_at,
|
|
2814212
|
+
chainlink_read_feed: instrumentedChainlinkFeedsTools.chainlink_read_feed,
|
|
2814213
|
+
chainlink_compare_prices: instrumentedChainlinkFeedsTools.chainlink_compare_prices,
|
|
2814214
|
+
chainlink_ccip_supported_chains: instrumentedChainlinkCCIPTools.chainlink_ccip_supported_chains,
|
|
2814215
|
+
chainlink_ccip_get_fee: instrumentedChainlinkCCIPTools.chainlink_ccip_get_fee,
|
|
2811066
2814216
|
...getRoutingToolsForAgent("Analyst")
|
|
2811067
2814217
|
},
|
|
2811068
2814218
|
memory: createSubAgentMemory(),
|
|
@@ -2811222,6 +2814372,7 @@ function getExecutorAgent() {
|
|
|
2811222
2814372
|
solana_debridge_create_order: instrumentedSolanaKitDefiBridgeTools.solana_debridge_create_order,
|
|
2811223
2814373
|
solana_debridge_execute: instrumentedSolanaKitDefiBridgeTools.solana_debridge_execute,
|
|
2811224
2814374
|
solana_okx_swap: instrumentedSolanaKitDefiBridgeTools.solana_okx_swap,
|
|
2814375
|
+
chainlink_ccip_transfer: instrumentedChainlinkCCIPTools.chainlink_ccip_transfer,
|
|
2811225
2814376
|
...getRoutingToolsForAgent("Executor")
|
|
2811226
2814377
|
},
|
|
2811227
2814378
|
memory: createSubAgentMemory(),
|
|
@@ -2811285,6 +2814436,7 @@ function getMonitorAgent() {
|
|
|
2811285
2814436
|
solana_orca_fetch_positions: instrumentedSolanaKitDefiPoolsTools.solana_orca_fetch_positions,
|
|
2811286
2814437
|
solana_sanctum_owned_lst: instrumentedSolanaKitDefiLendingTools.solana_sanctum_owned_lst,
|
|
2811287
2814438
|
solana_voltr_positions: instrumentedSolanaKitDefiLendingTools.solana_voltr_positions,
|
|
2814439
|
+
chainlink_ccip_status: instrumentedChainlinkCCIPTools.chainlink_ccip_status,
|
|
2811288
2814440
|
...getRoutingToolsForAgent("Monitor")
|
|
2811289
2814441
|
},
|
|
2811290
2814442
|
memory: createSubAgentMemory(),
|
|
@@ -2811395,7 +2814547,7 @@ function resetAgents() {
|
|
|
2811395
2814547
|
_agents = {};
|
|
2811396
2814548
|
_subAgentMemory = null;
|
|
2811397
2814549
|
}
|
|
2811398
|
-
var gordonInputGuard, gordonOutputSanitizer, DEFAULT_MEMORY_CONFIG, _memoryConfig, instrumentedIndicatorTools, instrumentedExplainTools, instrumentedMarketTools, instrumentedPositionTools, instrumentedSchedulerTools, instrumentedSystemTools, instrumentedEarnTools, instrumentedChartTools, instrumentedOrderbookTools, instrumentedWalletTools, instrumentedDiscoveryTools, instrumentedHistoryTools, instrumentedAccountTools, instrumentedTradingTools, instrumentedMarketAnalysisTools, instrumentedLiquidationIntelligenceTools, instrumentedRiskManagementTools, instrumentedStrategyTools, instrumentedMetricsTools, instrumentedCompositionTools, instrumentedBacktestTools, instrumentedSharedContextTools, instrumentedParallelAnalysisTools, instrumentedStrategyGenerationTools, instrumentedMultiModalChartTools, instrumentedMarketDataTools, instrumentedPairAnalysisTools, instrumentedAutonomousTools, instrumentedBaseOnchainTools, instrumentedAgentKitOnchainTools, instrumentedAgentKitDefiTools, instrumentedPolkadotKitAssetTools, instrumentedPolkadotKitStakingTools, instrumentedPolkadotKitDefiTools, instrumentedSolanaKitWalletTools, instrumentedSolanaKitTradingTools, instrumentedSolanaKitDefiPerpsTools, instrumentedSolanaKitDefiLendingTools, instrumentedSolanaKitDefiPoolsTools, instrumentedSolanaKitDefiBridgeTools, instrumentedBaseSignalTools, instrumentedBaseIndexerTools, instrumentedUniswapDataTools, instrumentedDexSearchTools, instrumentedDefillamaYieldTools, instrumentedEvalTools, instrumentedPositionTrackingTools, instrumentedMemoryTools, instrumentedPlaybookTools, instrumentedPlaybookBacktestTools, instrumentedAuditTools, instrumentedProtocolTools, instrumentedRegimeTools, instrumentedRuntimeTools, instrumentedAdvancedTools, instrumentedCheckRiskTool, WORKING_MEMORY_TEMPLATE = `
|
|
2814550
|
+
var gordonInputGuard, gordonOutputSanitizer, DEFAULT_MEMORY_CONFIG, _memoryConfig, instrumentedIndicatorTools, instrumentedExplainTools, instrumentedMarketTools, instrumentedPositionTools, instrumentedSchedulerTools, instrumentedSystemTools, instrumentedEarnTools, instrumentedChartTools, instrumentedOrderbookTools, instrumentedWalletTools, instrumentedDiscoveryTools, instrumentedHistoryTools, instrumentedAccountTools, instrumentedTradingTools, instrumentedMarketAnalysisTools, instrumentedLiquidationIntelligenceTools, instrumentedRiskManagementTools, instrumentedStrategyTools, instrumentedMetricsTools, instrumentedCompositionTools, instrumentedBacktestTools, instrumentedSharedContextTools, instrumentedParallelAnalysisTools, instrumentedStrategyGenerationTools, instrumentedMultiModalChartTools, instrumentedMarketDataTools, instrumentedPairAnalysisTools, instrumentedAutonomousTools, instrumentedBaseOnchainTools, instrumentedAgentKitOnchainTools, instrumentedAgentKitDefiTools, instrumentedPolkadotKitAssetTools, instrumentedPolkadotKitStakingTools, instrumentedPolkadotKitDefiTools, instrumentedSolanaKitWalletTools, instrumentedSolanaKitTradingTools, instrumentedSolanaKitDefiPerpsTools, instrumentedSolanaKitDefiLendingTools, instrumentedSolanaKitDefiPoolsTools, instrumentedSolanaKitDefiBridgeTools, instrumentedChainlinkStreamsTools, instrumentedChainlinkFeedsTools, instrumentedChainlinkCCIPTools, instrumentedBaseSignalTools, instrumentedBaseIndexerTools, instrumentedUniswapDataTools, instrumentedDexSearchTools, instrumentedDefillamaYieldTools, instrumentedEvalTools, instrumentedPositionTrackingTools, instrumentedMemoryTools, instrumentedPlaybookTools, instrumentedPlaybookBacktestTools, instrumentedAuditTools, instrumentedProtocolTools, instrumentedRegimeTools, instrumentedRuntimeTools, instrumentedAdvancedTools, instrumentedCheckRiskTool, WORKING_MEMORY_TEMPLATE = `
|
|
2811399
2814551
|
# Trader Profile
|
|
2811400
2814552
|
|
|
2811401
2814553
|
## Personal Info
|
|
@@ -2811984,6 +2815136,10 @@ When the user asks for analysis, scanning, planning, backtesting, or execution \
|
|
|
2811984
2815136
|
- Polkadot: DOT/KSM balance checks across 12+ chains -> Monitor (when POLKADOT_PRIVATE_KEY is set)
|
|
2811985
2815137
|
- Polkadot: native transfers, XCM cross-chain transfers, nomination pool staking, Hydration DEX swaps, Bifrost vDOT liquid staking, identity registration -> Executor (when POLKADOT_PRIVATE_KEY is set)
|
|
2811986
2815138
|
- Polkadot: nomination pool info, chain initialization -> Analyst (when POLKADOT_PRIVATE_KEY is set)
|
|
2815139
|
+
- Chainlink Data Streams: real-time institutional prices (BTC, ETH, SOL, LINK, etc.), bulk price queries, historical prices -> Analyst and Scanner (when CHAINLINK_API_KEY is set)
|
|
2815140
|
+
- Chainlink Data Feeds: free on-chain price oracles on Ethereum, Arbitrum, Base, Polygon, price comparison/verification -> Analyst
|
|
2815141
|
+
- Chainlink CCIP: cross-chain EVM token transfers (USDC, LINK, WETH across Ethereum, Arbitrum, Base, Optimism, Polygon, Avalanche, BNB), fee estimation -> Executor for transfers, Analyst for fees/info (when EVM_PRIVATE_KEY is set)
|
|
2815142
|
+
- Chainlink CCIP transfer status tracking -> Monitor
|
|
2811987
2815143
|
- Educational explanations -> Teacher
|
|
2811988
2815144
|
- Position lifecycle tracking (setup \u2192 analysis \u2192 plan \u2192 execute \u2192 monitor \u2192 review) -> tracked automatically across agents
|
|
2811989
2815145
|
- Risk pre-checks on all orders -> Planner and Executor (automatic)
|
|
@@ -2812066,6 +2815222,9 @@ var init_agents = __esm(async () => {
|
|
|
2812066
2815222
|
instrumentedSolanaKitDefiLendingTools = withToolsMetrics(solanaKitDefiLendingTools);
|
|
2812067
2815223
|
instrumentedSolanaKitDefiPoolsTools = withToolsMetrics(solanaKitDefiPoolsTools);
|
|
2812068
2815224
|
instrumentedSolanaKitDefiBridgeTools = withToolsMetrics(solanaKitDefiBridgeTools);
|
|
2815225
|
+
instrumentedChainlinkStreamsTools = withToolsMetrics(chainlinkStreamsTools);
|
|
2815226
|
+
instrumentedChainlinkFeedsTools = withToolsMetrics(chainlinkFeedsTools);
|
|
2815227
|
+
instrumentedChainlinkCCIPTools = withToolsMetrics(chainlinkCCIPTools);
|
|
2812069
2815228
|
instrumentedBaseSignalTools = withToolsMetrics(baseSignalTools);
|
|
2812070
2815229
|
instrumentedBaseIndexerTools = withToolsMetrics(baseIndexerTools);
|
|
2812071
2815230
|
instrumentedUniswapDataTools = withToolsMetrics(uniswapDataTools);
|
|
@@ -2813949,7 +2817108,17 @@ var init_orchestrator = __esm(async () => {
|
|
|
2813949
2817108
|
get_portfolio_state: "Monitor",
|
|
2813950
2817109
|
rebalance_portfolio: "Planner",
|
|
2813951
2817110
|
check_portfolio_health: "Monitor",
|
|
2813952
|
-
approve_strategy_trade: "Executor"
|
|
2817111
|
+
approve_strategy_trade: "Executor",
|
|
2817112
|
+
chainlink_get_price: "Analyst",
|
|
2817113
|
+
chainlink_get_price_at: "Analyst",
|
|
2817114
|
+
chainlink_bulk_prices: "Scanner",
|
|
2817115
|
+
chainlink_list_feeds: "Scanner",
|
|
2817116
|
+
chainlink_read_feed: "Analyst",
|
|
2817117
|
+
chainlink_compare_prices: "Analyst",
|
|
2817118
|
+
chainlink_ccip_supported_chains: "Analyst",
|
|
2817119
|
+
chainlink_ccip_get_fee: "Analyst",
|
|
2817120
|
+
chainlink_ccip_transfer: "Executor",
|
|
2817121
|
+
chainlink_ccip_status: "Monitor"
|
|
2813953
2817122
|
};
|
|
2813954
2817123
|
handoffHistory = [];
|
|
2813955
2817124
|
VALID_HANDOFF_RULES = {
|
|
@@ -2823942,7 +2827111,7 @@ var import_react64 = __toESM(require_react(), 1);
|
|
|
2823942
2827111
|
// package.json
|
|
2823943
2827112
|
var package_default2 = {
|
|
2823944
2827113
|
name: "@general-liquidity/gordon-cli",
|
|
2823945
|
-
version: "0.75.
|
|
2827114
|
+
version: "0.75.13",
|
|
2823946
2827115
|
description: "The Frontier Trading Agent",
|
|
2823947
2827116
|
author: "General Liquidity, Inc.",
|
|
2823948
2827117
|
license: "MIT",
|
|
@@ -2824000,6 +2827169,7 @@ var package_default2 = {
|
|
|
2824000
2827169
|
"@ai-sdk/anthropic": "^1.0.0",
|
|
2824001
2827170
|
"@ai-sdk/google": "^1.0.0",
|
|
2824002
2827171
|
"@ai-sdk/openai": "^1.0.0",
|
|
2827172
|
+
"@chainlink/data-streams-sdk": "^1.2.1",
|
|
2824003
2827173
|
"@coinbase/agentkit": "^0.10.4",
|
|
2824004
2827174
|
"@galacticcouncil/api-augment": "^0.9.0",
|
|
2824005
2827175
|
"@inkjs/ui": "^2.0.0",
|