@win-trader/config 0.0.1

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/addresses.json ADDED
@@ -0,0 +1,131 @@
1
+ {
2
+ "local": {
3
+ "rpcUrl": "http://localhost:8000/soroban/rpc",
4
+ "networkPassphrase": "Standalone Network ; February 2017",
5
+ "tickers": [
6
+ "BTCUSD",
7
+ "ETHUSD",
8
+ "XLMUSD"
9
+ ],
10
+ "contracts": {
11
+ "vault": {
12
+ "address": "CDMVC36ICITKFR2CSHWAIFZTIFQPAOGY2R7QWRYW3OKQBUKNDKIEZQ3J",
13
+ "startLedger": 139
14
+ },
15
+ "positionManager": {
16
+ "address": "CBFYCQ4EP2VWMMEQIHVMLDFIFMYOZJ5ORJMAJ7VQWU4JKSIK3T25VD7Z",
17
+ "startLedger": 143
18
+ },
19
+ "configManager": {
20
+ "address": "CCHIDDRMXNFV6IOFBI6PA5Z7ZKZCSVWQSUHIOFKT2VT5QZ2LXFP7BHRR",
21
+ "startLedger": 125
22
+ },
23
+ "oracleRouter": {
24
+ "address": "CAGJKOPLVW4FVVUFFSJRKVLW6BDZYPJAUDCTG3WV3LUHW4AHHLSUTICC",
25
+ "startLedger": 129
26
+ },
27
+ "oracle": {
28
+ "address": "CA2EN6CC7IZYGNOZWKXBW5BDL55JUA6UYQYFN7NA5LV33JN5W6W4JC44",
29
+ "startLedger": 133
30
+ },
31
+ "binanceOracle": {
32
+ "address": "CASS2SIRQXCQO7QKRVADNU2HMYW4YLAIH7XRJQB562UNK2KMWYIOREUS",
33
+ "startLedger": 182
34
+ },
35
+ "kucoinOracle": {
36
+ "address": "CCYJVXCODK43YIJANGSHFESYD53SA3YHYDZNZEKPDSNGFG2LAV6EWQC2",
37
+ "startLedger": 183
38
+ },
39
+ "mockToken": {
40
+ "address": "CCWCCSQ2ANTABO3P2LNOBMDMS2UKRYHS5NAKURFGS6AGZBTBIXHX7APJ",
41
+ "startLedger": 137
42
+ }
43
+ }
44
+ },
45
+ "testnet": {
46
+ "rpcUrl": "https://soroban-testnet.stellar.org",
47
+ "networkPassphrase": "Test SDF Network ; September 2015",
48
+ "tickers": [
49
+ "BTCUSD",
50
+ "ETHUSD",
51
+ "XLMUSD"
52
+ ],
53
+ "contracts": {
54
+ "vault": {
55
+ "address": "CAX5JF7U7WFQDSX7CNEV6DDAQ5J5Q655NLATEUPU5D5GWIWT7T6SGYVO",
56
+ "startLedger": 2627197
57
+ },
58
+ "positionManager": {
59
+ "address": "CBKWIM7PG2RYZAURKIJIIDN33U4HJ5AK5FTUMPVVWSM5AHVUKZS47TTJ",
60
+ "startLedger": 2627199
61
+ },
62
+ "configManager": {
63
+ "address": "CDDOA6JJWVH4Q7SXTL7P6S56VFCVSIUKNPTBBXQYVD27V3P3PWSKBNBP",
64
+ "startLedger": 2627189
65
+ },
66
+ "oracleRouter": {
67
+ "address": "CCA6SWSBBNDVQRWYGYP7T6644K5OR3L35O7YGYLODDT2R2ZV7HG4GKBX",
68
+ "startLedger": 2627191
69
+ },
70
+ "oracle": {
71
+ "address": "CAACOFUFNVWOMBQU7MDKUKB3IGDW4EJGUZTTHN2Q4IDIA7WVDYXE54DG",
72
+ "startLedger": 2627193
73
+ },
74
+ "binanceOracle": {
75
+ "address": "CBTVRC6X5Q6KJGAC7SOQHAKBQS4RS5MTOERWKPH5M5OF6FLGVCO6OOHC",
76
+ "startLedger": 2627236
77
+ },
78
+ "kucoinOracle": {
79
+ "address": "CCNNEIHURTEROE7T34V2E5BDEPOLRBGZEB3V3A5F6A563IQR2E6VA5RV",
80
+ "startLedger": 2627237
81
+ },
82
+ "mockToken": {
83
+ "address": "CBI2GEK27L4OCKBSKUF3XW3EZYO5WAI4NKYOWO5ZXSIBRUY5ELTDVLQA",
84
+ "startLedger": 2627195
85
+ }
86
+ }
87
+ },
88
+ "mainnet": {
89
+ "rpcUrl": "https://soroban.stellar.org",
90
+ "networkPassphrase": "Public Global Stellar Network ; September 2015",
91
+ "tickers": [
92
+ "BTCUSD",
93
+ "ETHUSD",
94
+ "XLMUSD"
95
+ ],
96
+ "contracts": {
97
+ "vault": {
98
+ "address": "",
99
+ "startLedger": 0
100
+ },
101
+ "positionManager": {
102
+ "address": "",
103
+ "startLedger": 0
104
+ },
105
+ "configManager": {
106
+ "address": "",
107
+ "startLedger": 0
108
+ },
109
+ "oracleRouter": {
110
+ "address": "",
111
+ "startLedger": 0
112
+ },
113
+ "oracle": {
114
+ "address": "",
115
+ "startLedger": 0
116
+ },
117
+ "binanceOracle": {
118
+ "address": "",
119
+ "startLedger": 0
120
+ },
121
+ "kucoinOracle": {
122
+ "address": "",
123
+ "startLedger": 0
124
+ },
125
+ "mockToken": {
126
+ "address": "",
127
+ "startLedger": 0
128
+ }
129
+ }
130
+ }
131
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Single source of truth for off-chain numeric constants.
3
+ *
4
+ * Every TypeScript service (api / indexer / keeper / oracle publishers)
5
+ * imports from here. No service hardcodes its own copy of these values.
6
+ *
7
+ * Mirror of the on-chain `shared::constants` module for values that have an
8
+ * on-chain counterpart (BPS_DENOMINATOR, SECONDS_PER_YEAR).
9
+ */
10
+ export declare const BPS_DENOMINATOR = 10000;
11
+ export declare const SECONDS_PER_YEAR = 31536000;
12
+ export declare const SECONDS_PER_LEDGER = 5;
13
+ export declare const PRECISION = 10000000n;
14
+ /** Polling interval for CEX REST APIs. */
15
+ export declare const ORACLE_POLL_INTERVAL_MS = 1000;
16
+ /** Reject CEX prints whose embedded source-timestamp is older than this. */
17
+ export declare const ORACLE_KUCOIN_STALENESS_MS = 5000;
18
+ /** Per-tick sanity cap: reject prints whose delta vs the last published price
19
+ * exceeds this fraction of the prior price. Bounded so a single rogue print
20
+ * cannot poison the on-chain median. */
21
+ export declare const ORACLE_MAX_DELTA_BPS_PER_TICK = 200;
22
+ /** Minimum interval between two consecutive on-chain pushes for one symbol. */
23
+ export declare const ORACLE_MIN_INTERVAL_BETWEEN_PUSHES_MS = 500;
24
+ /** Hard upper bound on on-chain pushes per minute per symbol. */
25
+ export declare const ORACLE_MAX_PUSHES_PER_MINUTE = 60;
26
+ /** HTTP fetch timeout for upstream CEX calls. */
27
+ export declare const ORACLE_FETCH_TIMEOUT_MS = 2000;
28
+ /** Number of confirming samples a publisher must observe before pushing
29
+ * (defends against a single-tick anomaly). */
30
+ export declare const ORACLE_CONFIRMING_SAMPLES = 2;
31
+ /** User-Agent string sent to upstream CEX APIs. */
32
+ export declare const ORACLE_USER_AGENT = "stellars-oracle/0.1";
33
+ /** Max fee in stroops the keeper will pay per Soroban submission. */
34
+ export declare const KEEPER_MAX_FEE_STROOPS = 100000000;
35
+ /** Per-submission timeout. */
36
+ export declare const KEEPER_TX_TIMEOUT_SECONDS = 30;
37
+ /** Daily fee budget for the keeper (sum of accepted submission fees). */
38
+ export declare const KEEPER_DAILY_FEE_BUDGET_STROOPS = 10000000000;
39
+ /** Dedup TTL for liquidation / ADL submissions. */
40
+ export declare const KEEPER_LIQUIDATION_DEDUP_TTL_MS = 60000;
41
+ /** Dedup TTL for index updates. */
42
+ export declare const KEEPER_INDEX_UPDATE_DEDUP_TTL_MS = 5000;
43
+ /** Inclusion-poll cadence — how often we re-check getTransaction(hash). */
44
+ export declare const KEEPER_INCLUSION_POLL_INTERVAL_MS = 2000;
45
+ /** Maximum total wait time for ledger inclusion before treating a tx as failed. */
46
+ export declare const KEEPER_INCLUSION_MAX_WAIT_MS = 30000;
47
+ /** Heartbeat ping interval for every open SSE connection. */
48
+ export declare const SSE_HEARTBEAT_INTERVAL_MS = 15000;
49
+ /** Max events held in the per-subscriber broadcast queue before drop-oldest. */
50
+ export declare const SSE_BUFFER_MAX_LEN = 1000;
51
+ /** Default RPC polling interval — events catch-up cadence. */
52
+ export declare const INDEXER_POLL_INTERVAL_MS = 500;
53
+ /** Backoff start when RPC returns 429/5xx. */
54
+ export declare const INDEXER_RPC_RETRY_BASE_MS = 1000;
55
+ /** Maximum backoff (capped). */
56
+ export declare const INDEXER_RPC_RETRY_MAX_MS = 30000;
57
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC,eAAO,MAAM,gBAAgB,WAAa,CAAC;AAE3C,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,eAAO,MAAM,SAAS,YAAc,CAAC;AAMrC,0CAA0C;AAC1C,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C,4EAA4E;AAC5E,eAAO,MAAM,0BAA0B,OAAQ,CAAC;AAChD;;yCAEyC;AACzC,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,+EAA+E;AAC/E,eAAO,MAAM,qCAAqC,MAAM,CAAC;AACzD,iEAAiE;AACjE,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,iDAAiD;AACjD,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAC7C;+CAC+C;AAC/C,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,wBAAwB,CAAC;AAMvD,qEAAqE;AACrE,eAAO,MAAM,sBAAsB,YAAc,CAAC;AAClD,8BAA8B;AAC9B,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,yEAAyE;AACzE,eAAO,MAAM,+BAA+B,cAAiB,CAAC;AAC9D,mDAAmD;AACnD,eAAO,MAAM,+BAA+B,QAAS,CAAC;AACtD,mCAAmC;AACnC,eAAO,MAAM,gCAAgC,OAAQ,CAAC;AACtD,2EAA2E;AAC3E,eAAO,MAAM,iCAAiC,OAAQ,CAAC;AACvD,mFAAmF;AACnF,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAMnD,6DAA6D;AAC7D,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAChD,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AAMxC,8DAA8D;AAC9D,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,8CAA8C;AAC9C,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAC/C,gCAAgC;AAChC,eAAO,MAAM,wBAAwB,QAAS,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Single source of truth for off-chain numeric constants.
3
+ *
4
+ * Every TypeScript service (api / indexer / keeper / oracle publishers)
5
+ * imports from here. No service hardcodes its own copy of these values.
6
+ *
7
+ * Mirror of the on-chain `shared::constants` module for values that have an
8
+ * on-chain counterpart (BPS_DENOMINATOR, SECONDS_PER_YEAR).
9
+ */
10
+ // ---------------------------------------------------------------------------
11
+ // Math / time (mirror of on-chain shared::constants)
12
+ // ---------------------------------------------------------------------------
13
+ // Mirror of shared::constants::BPS — see docs/adr/0004
14
+ export const BPS_DENOMINATOR = 10_000;
15
+ // Mirror of shared::constants::SECONDS_PER_YEAR — see docs/adr/0004
16
+ export const SECONDS_PER_YEAR = 31_536_000;
17
+ // Mirror of shared::constants::SECONDS_PER_LEDGER — see docs/adr/0004
18
+ export const SECONDS_PER_LEDGER = 5;
19
+ // Mirror of shared::constants::PRECISION (1e7 on-chain price scale) — see docs/adr/0004
20
+ export const PRECISION = 10000000n;
21
+ // ---------------------------------------------------------------------------
22
+ // Oracle publishers
23
+ // ---------------------------------------------------------------------------
24
+ /** Polling interval for CEX REST APIs. */
25
+ export const ORACLE_POLL_INTERVAL_MS = 1_000;
26
+ /** Reject CEX prints whose embedded source-timestamp is older than this. */
27
+ export const ORACLE_KUCOIN_STALENESS_MS = 5_000;
28
+ /** Per-tick sanity cap: reject prints whose delta vs the last published price
29
+ * exceeds this fraction of the prior price. Bounded so a single rogue print
30
+ * cannot poison the on-chain median. */
31
+ export const ORACLE_MAX_DELTA_BPS_PER_TICK = 200;
32
+ /** Minimum interval between two consecutive on-chain pushes for one symbol. */
33
+ export const ORACLE_MIN_INTERVAL_BETWEEN_PUSHES_MS = 500;
34
+ /** Hard upper bound on on-chain pushes per minute per symbol. */
35
+ export const ORACLE_MAX_PUSHES_PER_MINUTE = 60;
36
+ /** HTTP fetch timeout for upstream CEX calls. */
37
+ export const ORACLE_FETCH_TIMEOUT_MS = 2_000;
38
+ /** Number of confirming samples a publisher must observe before pushing
39
+ * (defends against a single-tick anomaly). */
40
+ export const ORACLE_CONFIRMING_SAMPLES = 2;
41
+ /** User-Agent string sent to upstream CEX APIs. */
42
+ export const ORACLE_USER_AGENT = "stellars-oracle/0.1";
43
+ // ---------------------------------------------------------------------------
44
+ // Keeper
45
+ // ---------------------------------------------------------------------------
46
+ /** Max fee in stroops the keeper will pay per Soroban submission. */
47
+ export const KEEPER_MAX_FEE_STROOPS = 100_000_000; // 10 XLM ceiling
48
+ /** Per-submission timeout. */
49
+ export const KEEPER_TX_TIMEOUT_SECONDS = 30;
50
+ /** Daily fee budget for the keeper (sum of accepted submission fees). */
51
+ export const KEEPER_DAILY_FEE_BUDGET_STROOPS = 10_000_000_000; // 1_000 XLM
52
+ /** Dedup TTL for liquidation / ADL submissions. */
53
+ export const KEEPER_LIQUIDATION_DEDUP_TTL_MS = 60_000;
54
+ /** Dedup TTL for index updates. */
55
+ export const KEEPER_INDEX_UPDATE_DEDUP_TTL_MS = 5_000;
56
+ /** Inclusion-poll cadence — how often we re-check getTransaction(hash). */
57
+ export const KEEPER_INCLUSION_POLL_INTERVAL_MS = 2_000;
58
+ /** Maximum total wait time for ledger inclusion before treating a tx as failed. */
59
+ export const KEEPER_INCLUSION_MAX_WAIT_MS = 30_000;
60
+ // ---------------------------------------------------------------------------
61
+ // API + SSE
62
+ // ---------------------------------------------------------------------------
63
+ /** Heartbeat ping interval for every open SSE connection. */
64
+ export const SSE_HEARTBEAT_INTERVAL_MS = 15_000;
65
+ /** Max events held in the per-subscriber broadcast queue before drop-oldest. */
66
+ export const SSE_BUFFER_MAX_LEN = 1_000;
67
+ // ---------------------------------------------------------------------------
68
+ // Indexer
69
+ // ---------------------------------------------------------------------------
70
+ /** Default RPC polling interval — events catch-up cadence. */
71
+ export const INDEXER_POLL_INTERVAL_MS = 500;
72
+ /** Backoff start when RPC returns 429/5xx. */
73
+ export const INDEXER_RPC_RETRY_BASE_MS = 1_000;
74
+ /** Maximum backoff (capped). */
75
+ export const INDEXER_RPC_RETRY_MAX_MS = 30_000;
76
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,8EAA8E;AAC9E,qDAAqD;AACrD,8EAA8E;AAE9E,uDAAuD;AACvD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAC3C,sEAAsE;AACtE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,wFAAwF;AACxF,MAAM,CAAC,MAAM,SAAS,GAAG,SAAW,CAAC;AAErC,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,0CAA0C;AAC1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAC7C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD;;yCAEyC;AACzC,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AACjD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,qCAAqC,GAAG,GAAG,CAAC;AACzD,iEAAiE;AACjE,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAC/C,iDAAiD;AACjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAC7C;+CAC+C;AAC/C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,mDAAmD;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAEvD,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,qEAAqE;AACrE,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC,CAAC,iBAAiB;AACpE,8BAA8B;AAC9B,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,yEAAyE;AACzE,MAAM,CAAC,MAAM,+BAA+B,GAAG,cAAc,CAAC,CAAC,YAAY;AAC3E,mDAAmD;AACnD,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC;AACtD,mCAAmC;AACnC,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,CAAC;AACtD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iCAAiC,GAAG,KAAK,CAAC;AACvD,mFAAmF;AACnF,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC;AAEnD,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,6DAA6D;AAC7D,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAChD,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAExC,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,8CAA8C;AAC9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAC/C,gCAAgC;AAChC,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,32 @@
1
+ export type Network = "local" | "testnet" | "mainnet";
2
+ export interface ContractInfo {
3
+ /** Deployed contract address (C...). Empty string if not yet deployed. */
4
+ address: string;
5
+ /** Ledger sequence at which this contract was deployed. 0 if not yet deployed. */
6
+ startLedger: number;
7
+ }
8
+ export interface NetworkContracts {
9
+ vault: ContractInfo;
10
+ positionManager: ContractInfo;
11
+ configManager: ContractInfo;
12
+ oracleRouter: ContractInfo;
13
+ oracle: ContractInfo;
14
+ /** Per-source oracle instances populated by scripts/deploy-cex-oracles.sh. */
15
+ binanceOracle: ContractInfo;
16
+ kucoinOracle: ContractInfo;
17
+ /** Test-only mock USDC token. Empty address on mainnet. */
18
+ mockToken: ContractInfo;
19
+ }
20
+ export interface NetworkConfig {
21
+ rpcUrl: string;
22
+ networkPassphrase: string;
23
+ /** Markets supported on this network. Single source of truth for oracle
24
+ * publishers, indexer poller, frontend symbol picker, and deploy scripts. */
25
+ tickers: readonly string[];
26
+ contracts: NetworkContracts;
27
+ }
28
+ export type Addresses = Record<Network, NetworkConfig>;
29
+ export declare const config: Addresses;
30
+ export declare function getNetworkConfig(network: Network): NetworkConfig;
31
+ export * from "./constants.js";
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtD,MAAM,WAAW,YAAY;IAC3B,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,YAAY,CAAC;IACpB,eAAe,EAAE,YAAY,CAAC;IAC9B,aAAa,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,8EAA8E;IAC9E,aAAa,EAAE,YAAY,CAAC;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,2DAA2D;IAC3D,SAAS,EAAE,YAAY,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B;kFAC8E;IAC9E,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAgCvD,eAAO,MAAM,MAAM,EAAE,SAA2B,CAAC;AAEjD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAEhE;AAED,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ // Read the source addresses.json at runtime (not bundled into dist), so that
5
+ // `make deploy` updates are picked up without rebuilding this package.
6
+ //
7
+ // __dirname resolves to:
8
+ // - packages/config/dist when consumed as a built package (the normal case)
9
+ // - packages/config when imported directly from source (e.g. via bun)
10
+ const here = dirname(fileURLToPath(import.meta.url));
11
+ // Resolution order for the address/network registry:
12
+ // 1. ADDRESSES_JSON env path — the deployment-provided registry (per network).
13
+ // 2. the in-package addresses.json — local-dev fallback so the workspace runs
14
+ // without any env wiring.
15
+ function loadAddresses() {
16
+ const candidates = [
17
+ process.env.ADDRESSES_JSON,
18
+ resolve(here, "..", "addresses.json"),
19
+ resolve(here, "addresses.json"),
20
+ ].filter((p) => Boolean(p));
21
+ for (const path of candidates) {
22
+ try {
23
+ return JSON.parse(readFileSync(path, "utf8"));
24
+ }
25
+ catch {
26
+ // try next
27
+ }
28
+ }
29
+ throw new Error(`@win-trader/config: addresses.json not found. Looked in:\n ${candidates.join("\n ")}`);
30
+ }
31
+ export const config = loadAddresses();
32
+ export function getNetworkConfig(network) {
33
+ return config[network];
34
+ }
35
+ export * from "./constants.js";
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAmCzC,6EAA6E;AAC7E,uEAAuE;AACvE,EAAE;AACF,yBAAyB;AACzB,+EAA+E;AAC/E,8EAA8E;AAC9E,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAErD,qDAAqD;AACrD,iFAAiF;AACjF,gFAAgF;AAChF,+BAA+B;AAC/B,SAAS,aAAa;IACpB,MAAM,UAAU,GAAG;QACjB,OAAO,CAAC,GAAG,CAAC,cAAc;QAC1B,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC;QACrC,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC;KAChC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAc,CAAC;QAC7D,CAAC;QAAC,MAAM,CAAC;YACP,WAAW;QACb,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CACb,+DAA+D,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CACzF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAc,aAAa,EAAE,CAAC;AAEjD,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AAED,cAAc,gBAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@win-trader/config",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./addresses.json": "./addresses.json"
13
+ },
14
+ "devDependencies": {
15
+ "@types/node": "^22.19.15",
16
+ "typescript": "^5.7.0"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "addresses.json"
24
+ ],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/win-trader/contracts.git",
28
+ "directory": "packages/config"
29
+ },
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "typecheck": "tsc --noEmit"
33
+ }
34
+ }