@vultisig/rujira 1.0.0

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +254 -0
  3. package/dist/assets/amount.d.ts +80 -0
  4. package/dist/assets/amount.d.ts.map +1 -0
  5. package/dist/assets/amount.js +186 -0
  6. package/dist/assets/asset.d.ts +43 -0
  7. package/dist/assets/asset.d.ts.map +1 -0
  8. package/dist/assets/asset.js +1 -0
  9. package/dist/assets/formats.d.ts +54 -0
  10. package/dist/assets/formats.d.ts.map +1 -0
  11. package/dist/assets/formats.js +164 -0
  12. package/dist/assets/index.d.ts +27 -0
  13. package/dist/assets/index.d.ts.map +1 -0
  14. package/dist/assets/index.js +45 -0
  15. package/dist/assets/registry.d.ts +37 -0
  16. package/dist/assets/registry.d.ts.map +1 -0
  17. package/dist/assets/registry.js +487 -0
  18. package/dist/assets/router.d.ts +44 -0
  19. package/dist/assets/router.d.ts.map +1 -0
  20. package/dist/assets/router.js +142 -0
  21. package/dist/client.d.ts +70 -0
  22. package/dist/client.d.ts.map +1 -0
  23. package/dist/client.js +250 -0
  24. package/dist/config/constants.d.ts +25 -0
  25. package/dist/config/constants.d.ts.map +1 -0
  26. package/dist/config/constants.js +36 -0
  27. package/dist/config.d.ts +41 -0
  28. package/dist/config.d.ts.map +1 -0
  29. package/dist/config.js +72 -0
  30. package/dist/discovery/discovery.d.ts +39 -0
  31. package/dist/discovery/discovery.d.ts.map +1 -0
  32. package/dist/discovery/discovery.js +250 -0
  33. package/dist/discovery/graphql-client.d.ts +46 -0
  34. package/dist/discovery/graphql-client.d.ts.map +1 -0
  35. package/dist/discovery/graphql-client.js +137 -0
  36. package/dist/discovery/index.d.ts +9 -0
  37. package/dist/discovery/index.d.ts.map +1 -0
  38. package/dist/discovery/index.js +7 -0
  39. package/dist/discovery/types.d.ts +62 -0
  40. package/dist/discovery/types.d.ts.map +1 -0
  41. package/dist/discovery/types.js +5 -0
  42. package/dist/easy-routes.d.ts +216 -0
  43. package/dist/easy-routes.d.ts.map +1 -0
  44. package/dist/easy-routes.js +241 -0
  45. package/dist/errors.d.ts +65 -0
  46. package/dist/errors.d.ts.map +1 -0
  47. package/dist/errors.js +184 -0
  48. package/dist/index.d.ts +46 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +46 -0
  51. package/dist/modules/assets.d.ts +68 -0
  52. package/dist/modules/assets.d.ts.map +1 -0
  53. package/dist/modules/assets.js +127 -0
  54. package/dist/modules/deposit.d.ts +152 -0
  55. package/dist/modules/deposit.d.ts.map +1 -0
  56. package/dist/modules/deposit.js +233 -0
  57. package/dist/modules/index.d.ts +12 -0
  58. package/dist/modules/index.d.ts.map +1 -0
  59. package/dist/modules/index.js +9 -0
  60. package/dist/modules/orderbook.d.ts +80 -0
  61. package/dist/modules/orderbook.d.ts.map +1 -0
  62. package/dist/modules/orderbook.js +320 -0
  63. package/dist/modules/swap.d.ts +48 -0
  64. package/dist/modules/swap.d.ts.map +1 -0
  65. package/dist/modules/swap.js +318 -0
  66. package/dist/modules/withdraw.d.ts +46 -0
  67. package/dist/modules/withdraw.d.ts.map +1 -0
  68. package/dist/modules/withdraw.js +218 -0
  69. package/dist/services/fee-estimator.d.ts +14 -0
  70. package/dist/services/fee-estimator.d.ts.map +1 -0
  71. package/dist/services/fee-estimator.js +89 -0
  72. package/dist/services/price-impact.d.ts +11 -0
  73. package/dist/services/price-impact.d.ts.map +1 -0
  74. package/dist/services/price-impact.js +58 -0
  75. package/dist/signer/index.d.ts +3 -0
  76. package/dist/signer/index.d.ts.map +1 -0
  77. package/dist/signer/index.js +1 -0
  78. package/dist/signer/keysign-builder.d.ts +21 -0
  79. package/dist/signer/keysign-builder.d.ts.map +1 -0
  80. package/dist/signer/keysign-builder.js +106 -0
  81. package/dist/signer/types.d.ts +81 -0
  82. package/dist/signer/types.d.ts.map +1 -0
  83. package/dist/signer/types.js +8 -0
  84. package/dist/signer/vultisig-provider.d.ts +33 -0
  85. package/dist/signer/vultisig-provider.d.ts.map +1 -0
  86. package/dist/signer/vultisig-provider.js +242 -0
  87. package/dist/types.d.ts +375 -0
  88. package/dist/types.d.ts.map +1 -0
  89. package/dist/types.js +18 -0
  90. package/dist/utils/cache.d.ts +87 -0
  91. package/dist/utils/cache.d.ts.map +1 -0
  92. package/dist/utils/cache.js +124 -0
  93. package/dist/utils/denom-conversion.d.ts +47 -0
  94. package/dist/utils/denom-conversion.d.ts.map +1 -0
  95. package/dist/utils/denom-conversion.js +105 -0
  96. package/dist/utils/encoding.d.ts +17 -0
  97. package/dist/utils/encoding.d.ts.map +1 -0
  98. package/dist/utils/encoding.js +55 -0
  99. package/dist/utils/format.d.ts +108 -0
  100. package/dist/utils/format.d.ts.map +1 -0
  101. package/dist/utils/format.js +213 -0
  102. package/dist/utils/index.d.ts +10 -0
  103. package/dist/utils/index.d.ts.map +1 -0
  104. package/dist/utils/index.js +9 -0
  105. package/dist/utils/memo.d.ts +107 -0
  106. package/dist/utils/memo.d.ts.map +1 -0
  107. package/dist/utils/memo.js +190 -0
  108. package/dist/utils/rate-limiter.d.ts +38 -0
  109. package/dist/utils/rate-limiter.d.ts.map +1 -0
  110. package/dist/utils/rate-limiter.js +67 -0
  111. package/dist/utils/type-guards.d.ts +22 -0
  112. package/dist/utils/type-guards.d.ts.map +1 -0
  113. package/dist/utils/type-guards.js +27 -0
  114. package/dist/validation/address-validator.d.ts +15 -0
  115. package/dist/validation/address-validator.d.ts.map +1 -0
  116. package/dist/validation/address-validator.js +75 -0
  117. package/package.json +98 -0
  118. package/src/__tests__/live/README.md +47 -0
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Easy Swap Routes - Simplified DeFi interface
3
+ */
4
+ export declare const EASY_ROUTES: {
5
+ readonly RUNE_TO_USDC: {
6
+ readonly from: string;
7
+ readonly to: string;
8
+ readonly name: "RUNE → USDC";
9
+ readonly description: "Swap RUNE to USDC (Ethereum)";
10
+ readonly liquidity: "deep";
11
+ readonly typicalTime: "10-30 seconds";
12
+ };
13
+ readonly USDC_TO_RUNE: {
14
+ readonly from: string;
15
+ readonly to: string;
16
+ readonly name: "USDC → RUNE";
17
+ readonly description: "Swap USDC to RUNE";
18
+ readonly liquidity: "deep";
19
+ readonly typicalTime: "10-30 seconds";
20
+ };
21
+ readonly RUNE_TO_BTC: {
22
+ readonly from: string;
23
+ readonly to: string;
24
+ readonly name: "RUNE → BTC";
25
+ readonly description: "Swap RUNE to native Bitcoin";
26
+ readonly liquidity: "deep";
27
+ readonly typicalTime: "10-60 minutes (Bitcoin confirmations)";
28
+ };
29
+ readonly BTC_TO_RUNE: {
30
+ readonly from: string;
31
+ readonly to: string;
32
+ readonly name: "BTC → RUNE";
33
+ readonly description: "Swap native Bitcoin to RUNE";
34
+ readonly liquidity: "deep";
35
+ readonly typicalTime: "10-60 minutes (Bitcoin confirmations)";
36
+ };
37
+ readonly RUNE_TO_ETH: {
38
+ readonly from: string;
39
+ readonly to: string;
40
+ readonly name: "RUNE → ETH";
41
+ readonly description: "Swap RUNE to native Ethereum";
42
+ readonly liquidity: "deep";
43
+ readonly typicalTime: "10-30 seconds";
44
+ };
45
+ readonly ETH_TO_RUNE: {
46
+ readonly from: string;
47
+ readonly to: string;
48
+ readonly name: "ETH → RUNE";
49
+ readonly description: "Swap native Ethereum to RUNE";
50
+ readonly liquidity: "deep";
51
+ readonly typicalTime: "10-30 seconds";
52
+ };
53
+ readonly USDC_TO_USDT: {
54
+ readonly from: string;
55
+ readonly to: string;
56
+ readonly name: "USDC → USDT";
57
+ readonly description: "Swap USDC to USDT (via RUNE)";
58
+ readonly liquidity: "deep";
59
+ readonly typicalTime: "15-45 seconds";
60
+ };
61
+ readonly USDT_TO_USDC: {
62
+ readonly from: string;
63
+ readonly to: string;
64
+ readonly name: "USDT → USDC";
65
+ readonly description: "Swap USDT to USDC (via RUNE)";
66
+ readonly liquidity: "deep";
67
+ readonly typicalTime: "15-45 seconds";
68
+ };
69
+ readonly BTC_TO_USDC: {
70
+ readonly from: string;
71
+ readonly to: string;
72
+ readonly name: "BTC → USDC";
73
+ readonly description: "Swap native Bitcoin to USDC";
74
+ readonly liquidity: "deep";
75
+ readonly typicalTime: "10-60 minutes (Bitcoin confirmations)";
76
+ };
77
+ readonly USDC_TO_BTC: {
78
+ readonly from: string;
79
+ readonly to: string;
80
+ readonly name: "USDC → BTC";
81
+ readonly description: "Swap USDC to native Bitcoin";
82
+ readonly liquidity: "deep";
83
+ readonly typicalTime: "10-60 minutes (Bitcoin confirmations)";
84
+ };
85
+ readonly ETH_TO_USDC: {
86
+ readonly from: string;
87
+ readonly to: string;
88
+ readonly name: "ETH → USDC";
89
+ readonly description: "Swap ETH to USDC";
90
+ readonly liquidity: "deep";
91
+ readonly typicalTime: "10-30 seconds";
92
+ };
93
+ readonly USDC_TO_ETH: {
94
+ readonly from: string;
95
+ readonly to: string;
96
+ readonly name: "USDC → ETH";
97
+ readonly description: "Swap USDC to ETH";
98
+ readonly liquidity: "deep";
99
+ readonly typicalTime: "10-30 seconds";
100
+ };
101
+ readonly BTC_TO_ETH: {
102
+ readonly from: string;
103
+ readonly to: string;
104
+ readonly name: "BTC → ETH";
105
+ readonly description: "Swap native Bitcoin to native Ethereum";
106
+ readonly liquidity: "deep";
107
+ readonly typicalTime: "10-60 minutes (Bitcoin confirmations)";
108
+ };
109
+ readonly ETH_TO_BTC: {
110
+ readonly from: string;
111
+ readonly to: string;
112
+ readonly name: "ETH → BTC";
113
+ readonly description: "Swap native Ethereum to native Bitcoin";
114
+ readonly liquidity: "deep";
115
+ readonly typicalTime: "10-60 minutes (Bitcoin confirmations)";
116
+ };
117
+ };
118
+ export type EasyRouteName = keyof typeof EASY_ROUTES;
119
+ export type EasyRoute = (typeof EASY_ROUTES)[EasyRouteName];
120
+ /**
121
+ * Common asset denoms - use these to avoid typos
122
+ * All denoms are in FIN format from the asset registry
123
+ */
124
+ export declare const ASSETS: {
125
+ readonly RUNE: string;
126
+ readonly BTC: string;
127
+ readonly ETH: string;
128
+ readonly AVAX: string;
129
+ readonly ATOM: string;
130
+ readonly DOGE: string;
131
+ readonly LTC: string;
132
+ readonly BCH: string;
133
+ readonly BNB: string;
134
+ readonly USDC: string;
135
+ readonly USDT: string;
136
+ readonly RUJI: string;
137
+ readonly TCY: string;
138
+ };
139
+ export type AssetName = keyof typeof ASSETS;
140
+ export type EasyAsset = (typeof ASSETS)[AssetName];
141
+ /**
142
+ * List all available easy routes
143
+ * Perfect for agents to discover swap options
144
+ */
145
+ export declare function listEasyRoutes(): Array<{
146
+ id: EasyRouteName;
147
+ name: string;
148
+ from: string;
149
+ to: string;
150
+ description: string;
151
+ liquidity: string;
152
+ typicalTime: string;
153
+ }>;
154
+ /**
155
+ * Get a route by name
156
+ */
157
+ export declare function getRoute(routeName: EasyRouteName): EasyRoute;
158
+ /**
159
+ * Find routes for a given asset pair
160
+ */
161
+ export declare function findRoute(from: string, to: string): EasyRoute | undefined;
162
+ /**
163
+ * Get routes that involve a specific asset
164
+ */
165
+ export declare function routesForAsset(asset: string): EasyRoute[];
166
+ /**
167
+ * Get all routes from a specific asset
168
+ */
169
+ export declare function routesFrom(asset: string): EasyRoute[];
170
+ /**
171
+ * Get all routes to a specific asset
172
+ */
173
+ export declare function routesTo(asset: string): EasyRoute[];
174
+ /**
175
+ * Simple swap request - all an agent needs
176
+ */
177
+ export type EasySwapRequest = {
178
+ /** Route name (e.g., 'RUNE_TO_USDC') or custom from/to */
179
+ route?: EasyRouteName;
180
+ from?: string;
181
+ to?: string;
182
+ /** Amount to swap in base units (e.g., '100000000' for 1 RUNE) */
183
+ amount: string;
184
+ /** Destination address */
185
+ destination: string;
186
+ /** Max slippage in percent (default: 1%) */
187
+ maxSlippagePercent?: number;
188
+ };
189
+ /**
190
+ * Simple quote response
191
+ */
192
+ export type EasyQuoteResponse = {
193
+ /** Input amount (human readable) */
194
+ inputAmount: string;
195
+ /** Input asset */
196
+ inputAsset: string;
197
+ /** Expected output (human readable) */
198
+ expectedOutput: string;
199
+ /** Output asset */
200
+ outputAsset: string;
201
+ /** Slippage in percent */
202
+ slippagePercent: number;
203
+ /** Estimated time */
204
+ estimatedTime: string;
205
+ /** Fees breakdown */
206
+ fees: {
207
+ network: string;
208
+ affiliate: string;
209
+ };
210
+ /** Is this a good trade? (slippage < 2%) */
211
+ recommended: boolean;
212
+ /** Warning message if any */
213
+ warning?: string;
214
+ };
215
+ export declare function getRoutesSummary(): string;
216
+ //# sourceMappingURL=easy-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"easy-routes.d.ts","sourceRoot":"","sources":["../src/easy-routes.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0Hd,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,WAAW,CAAA;AACpD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,aAAa,CAAC,CAAA;AAI3D;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;CAmBT,CAAA;AAEV,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,MAAM,CAAA;AAC3C,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAA;AAIlD;;;GAGG;AACH,wBAAgB,cAAc,IAAI,KAAK,CAAC;IACtC,EAAE,EAAE,aAAa,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAC,CAUD;AAED;;GAEG;AACH,wBAA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M,CAAA;CACjB,CAAA;AAID,wBAAgB,gBAAgB,IAAI,MAAM,CAgCzC"}
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Easy Swap Routes - Simplified DeFi interface
3
+ */
4
+ import { KNOWN_ASSETS } from './assets/index.js';
5
+ import { denomToTicker } from './utils/denom-conversion.js';
6
+ function getFinFormat(assetId) {
7
+ const asset = KNOWN_ASSETS[assetId];
8
+ if (!asset) {
9
+ throw new Error(`Unknown asset: ${assetId}`);
10
+ }
11
+ return asset.formats.fin;
12
+ }
13
+ export const EASY_ROUTES = {
14
+ // === RUNE Gateway Routes ===
15
+ RUNE_TO_USDC: {
16
+ from: getFinFormat('rune'),
17
+ to: getFinFormat('usdc_eth'),
18
+ name: 'RUNE → USDC',
19
+ description: 'Swap RUNE to USDC (Ethereum)',
20
+ liquidity: 'deep',
21
+ typicalTime: '10-30 seconds',
22
+ },
23
+ USDC_TO_RUNE: {
24
+ from: getFinFormat('usdc_eth'),
25
+ to: getFinFormat('rune'),
26
+ name: 'USDC → RUNE',
27
+ description: 'Swap USDC to RUNE',
28
+ liquidity: 'deep',
29
+ typicalTime: '10-30 seconds',
30
+ },
31
+ RUNE_TO_BTC: {
32
+ from: getFinFormat('rune'),
33
+ to: getFinFormat('btc'),
34
+ name: 'RUNE → BTC',
35
+ description: 'Swap RUNE to native Bitcoin',
36
+ liquidity: 'deep',
37
+ typicalTime: '10-60 minutes (Bitcoin confirmations)',
38
+ },
39
+ BTC_TO_RUNE: {
40
+ from: getFinFormat('btc'),
41
+ to: getFinFormat('rune'),
42
+ name: 'BTC → RUNE',
43
+ description: 'Swap native Bitcoin to RUNE',
44
+ liquidity: 'deep',
45
+ typicalTime: '10-60 minutes (Bitcoin confirmations)',
46
+ },
47
+ RUNE_TO_ETH: {
48
+ from: getFinFormat('rune'),
49
+ to: getFinFormat('eth'),
50
+ name: 'RUNE → ETH',
51
+ description: 'Swap RUNE to native Ethereum',
52
+ liquidity: 'deep',
53
+ typicalTime: '10-30 seconds',
54
+ },
55
+ ETH_TO_RUNE: {
56
+ from: getFinFormat('eth'),
57
+ to: getFinFormat('rune'),
58
+ name: 'ETH → RUNE',
59
+ description: 'Swap native Ethereum to RUNE',
60
+ liquidity: 'deep',
61
+ typicalTime: '10-30 seconds',
62
+ },
63
+ // === Stablecoin Routes ===
64
+ USDC_TO_USDT: {
65
+ from: getFinFormat('usdc_eth'),
66
+ to: getFinFormat('usdt_eth'),
67
+ name: 'USDC → USDT',
68
+ description: 'Swap USDC to USDT (via RUNE)',
69
+ liquidity: 'deep',
70
+ typicalTime: '15-45 seconds',
71
+ },
72
+ USDT_TO_USDC: {
73
+ from: getFinFormat('usdt_eth'),
74
+ to: getFinFormat('usdc_eth'),
75
+ name: 'USDT → USDC',
76
+ description: 'Swap USDT to USDC (via RUNE)',
77
+ liquidity: 'deep',
78
+ typicalTime: '15-45 seconds',
79
+ },
80
+ // === BTC-Stable Routes ===
81
+ BTC_TO_USDC: {
82
+ from: getFinFormat('btc'),
83
+ to: getFinFormat('usdc_eth'),
84
+ name: 'BTC → USDC',
85
+ description: 'Swap native Bitcoin to USDC',
86
+ liquidity: 'deep',
87
+ typicalTime: '10-60 minutes (Bitcoin confirmations)',
88
+ },
89
+ USDC_TO_BTC: {
90
+ from: getFinFormat('usdc_eth'),
91
+ to: getFinFormat('btc'),
92
+ name: 'USDC → BTC',
93
+ description: 'Swap USDC to native Bitcoin',
94
+ liquidity: 'deep',
95
+ typicalTime: '10-60 minutes (Bitcoin confirmations)',
96
+ },
97
+ // === ETH-Stable Routes ===
98
+ ETH_TO_USDC: {
99
+ from: getFinFormat('eth'),
100
+ to: getFinFormat('usdc_eth'),
101
+ name: 'ETH → USDC',
102
+ description: 'Swap ETH to USDC',
103
+ liquidity: 'deep',
104
+ typicalTime: '10-30 seconds',
105
+ },
106
+ USDC_TO_ETH: {
107
+ from: getFinFormat('usdc_eth'),
108
+ to: getFinFormat('eth'),
109
+ name: 'USDC → ETH',
110
+ description: 'Swap USDC to ETH',
111
+ liquidity: 'deep',
112
+ typicalTime: '10-30 seconds',
113
+ },
114
+ // === Cross-Chain Routes ===
115
+ BTC_TO_ETH: {
116
+ from: getFinFormat('btc'),
117
+ to: getFinFormat('eth'),
118
+ name: 'BTC → ETH',
119
+ description: 'Swap native Bitcoin to native Ethereum',
120
+ liquidity: 'deep',
121
+ typicalTime: '10-60 minutes (Bitcoin confirmations)',
122
+ },
123
+ ETH_TO_BTC: {
124
+ from: getFinFormat('eth'),
125
+ to: getFinFormat('btc'),
126
+ name: 'ETH → BTC',
127
+ description: 'Swap native Ethereum to native Bitcoin',
128
+ liquidity: 'deep',
129
+ typicalTime: '10-60 minutes (Bitcoin confirmations)',
130
+ },
131
+ };
132
+ // COMMON ASSETS (shortcuts)
133
+ /**
134
+ * Common asset denoms - use these to avoid typos
135
+ * All denoms are in FIN format from the asset registry
136
+ */
137
+ export const ASSETS = {
138
+ // Native chain assets
139
+ RUNE: getFinFormat('rune'),
140
+ BTC: getFinFormat('btc'),
141
+ ETH: getFinFormat('eth'),
142
+ AVAX: getFinFormat('avax'),
143
+ ATOM: getFinFormat('atom'),
144
+ DOGE: getFinFormat('doge'),
145
+ LTC: getFinFormat('ltc'),
146
+ BCH: getFinFormat('bch'),
147
+ BNB: getFinFormat('bnb'),
148
+ // Stablecoins (Ethereum)
149
+ USDC: getFinFormat('usdc_eth'),
150
+ USDT: getFinFormat('usdt_eth'),
151
+ // Rujira native tokens
152
+ RUJI: getFinFormat('ruji'),
153
+ TCY: getFinFormat('tcy'),
154
+ };
155
+ // HELPER FUNCTIONS
156
+ /**
157
+ * List all available easy routes
158
+ * Perfect for agents to discover swap options
159
+ */
160
+ export function listEasyRoutes() {
161
+ return Object.entries(EASY_ROUTES).map(([id, route]) => ({
162
+ id: id,
163
+ name: route.name,
164
+ from: route.from,
165
+ to: route.to,
166
+ description: route.description,
167
+ liquidity: route.liquidity,
168
+ typicalTime: route.typicalTime,
169
+ }));
170
+ }
171
+ /**
172
+ * Get a route by name
173
+ */
174
+ export function getRoute(routeName) {
175
+ return EASY_ROUTES[routeName];
176
+ }
177
+ /**
178
+ * Find routes for a given asset pair
179
+ */
180
+ export function findRoute(from, to) {
181
+ const normalizedFrom = from.toLowerCase();
182
+ const normalizedTo = to.toLowerCase();
183
+ for (const route of Object.values(EASY_ROUTES)) {
184
+ if (route.from === normalizedFrom && route.to === normalizedTo) {
185
+ return route;
186
+ }
187
+ }
188
+ return undefined;
189
+ }
190
+ /**
191
+ * Get routes that involve a specific asset
192
+ */
193
+ export function routesForAsset(asset) {
194
+ const normalized = asset.toLowerCase();
195
+ return Object.values(EASY_ROUTES).filter(route => route.from === normalized || route.to === normalized);
196
+ }
197
+ /**
198
+ * Get all routes from a specific asset
199
+ */
200
+ export function routesFrom(asset) {
201
+ const normalized = asset.toLowerCase();
202
+ return Object.values(EASY_ROUTES).filter(route => route.from === normalized);
203
+ }
204
+ /**
205
+ * Get all routes to a specific asset
206
+ */
207
+ export function routesTo(asset) {
208
+ const normalized = asset.toLowerCase();
209
+ return Object.values(EASY_ROUTES).filter(route => route.to === normalized);
210
+ }
211
+ // DOCUMENTATION HELPERS
212
+ export function getRoutesSummary() {
213
+ const lines = [
214
+ '# Easy Swap Routes',
215
+ '',
216
+ 'Battle-tested routes with deep liquidity:',
217
+ '',
218
+ '| Route | From | To | Time |',
219
+ '|-------|------|-----|------|',
220
+ ];
221
+ for (const [id, route] of Object.entries(EASY_ROUTES)) {
222
+ // Extract readable name from denom
223
+ const fromShort = denomToTicker(route.from);
224
+ const toShort = denomToTicker(route.to);
225
+ lines.push(`| ${id} | ${fromShort} | ${toShort} | ${route.typicalTime} |`);
226
+ }
227
+ lines.push('', '## Quick Start', '');
228
+ lines.push('```typescript');
229
+ lines.push("import { EASY_ROUTES, RujiraClient } from '@vultisig/rujira';");
230
+ lines.push('');
231
+ lines.push("const client = new RujiraClient({ network: 'mainnet' });");
232
+ lines.push('const route = EASY_ROUTES.RUNE_TO_USDC;');
233
+ lines.push('');
234
+ lines.push('const quote = await client.swap.getQuote({');
235
+ lines.push(' fromAsset: route.from,');
236
+ lines.push(' toAsset: route.to,');
237
+ lines.push(" amount: '10000000000' // 100 RUNE (8 decimals)");
238
+ lines.push('});');
239
+ lines.push('```');
240
+ return lines.join('\n');
241
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Error types for Rujira SDK
3
+ * @module errors
4
+ */
5
+ /**
6
+ * Error codes for Rujira operations
7
+ */
8
+ export declare enum RujiraErrorCode {
9
+ NETWORK_ERROR = "NETWORK_ERROR",
10
+ RPC_ERROR = "RPC_ERROR",
11
+ TIMEOUT = "TIMEOUT",
12
+ NOT_CONNECTED = "NOT_CONNECTED",
13
+ INVALID_ASSET = "INVALID_ASSET",
14
+ INVALID_AMOUNT = "INVALID_AMOUNT",
15
+ INVALID_ADDRESS = "INVALID_ADDRESS",
16
+ INVALID_PAIR = "INVALID_PAIR",
17
+ INVALID_SLIPPAGE = "INVALID_SLIPPAGE",
18
+ INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
19
+ INSUFFICIENT_GAS = "INSUFFICIENT_GAS",
20
+ NO_ROUTE = "NO_ROUTE",
21
+ SLIPPAGE_EXCEEDED = "SLIPPAGE_EXCEEDED",
22
+ QUOTE_EXPIRED = "QUOTE_EXPIRED",
23
+ PRICE_IMPACT_TOO_HIGH = "PRICE_IMPACT_TOO_HIGH",
24
+ ORDER_NOT_FOUND = "ORDER_NOT_FOUND",
25
+ INVALID_PRICE = "INVALID_PRICE",
26
+ MIN_ORDER_SIZE = "MIN_ORDER_SIZE",
27
+ ORDER_ALREADY_FILLED = "ORDER_ALREADY_FILLED",
28
+ SIGNING_FAILED = "SIGNING_FAILED",
29
+ BROADCAST_FAILED = "BROADCAST_FAILED",
30
+ TX_FAILED = "TX_FAILED",
31
+ TX_NOT_FOUND = "TX_NOT_FOUND",
32
+ CONTRACT_NOT_FOUND = "CONTRACT_NOT_FOUND",
33
+ CONTRACT_ERROR = "CONTRACT_ERROR",
34
+ INVALID_CONFIG = "INVALID_CONFIG",
35
+ MISSING_SIGNER = "MISSING_SIGNER"
36
+ }
37
+ /**
38
+ * Base error class for Rujira SDK
39
+ */
40
+ export declare class RujiraError extends Error {
41
+ /** Error code for programmatic handling */
42
+ readonly code: RujiraErrorCode;
43
+ /** Additional error details */
44
+ readonly details?: unknown;
45
+ /** Whether this error is retryable */
46
+ readonly retryable: boolean;
47
+ constructor(code: RujiraErrorCode, message: string, details?: unknown, retryable?: boolean);
48
+ /**
49
+ * Create a user-friendly error message
50
+ */
51
+ toUserMessage(): string;
52
+ /**
53
+ * Convert to JSON for logging
54
+ */
55
+ toJSON(): Record<string, unknown>;
56
+ }
57
+ /**
58
+ * Check if an error is retryable
59
+ */
60
+ export declare function isRetryableError(error: unknown): boolean;
61
+ /**
62
+ * Wrap an error in RujiraError
63
+ */
64
+ export declare function wrapError(error: unknown, defaultCode?: RujiraErrorCode): RujiraError;
65
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,oBAAY,eAAe;IAEzB,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAG/B,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IAGrC,oBAAoB,yBAAyB;IAC7C,gBAAgB,qBAAqB;IAGrC,QAAQ,aAAa;IACrB,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;IAC/B,qBAAqB,0BAA0B;IAG/C,eAAe,oBAAoB;IACnC,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,oBAAoB,yBAAyB;IAG7C,cAAc,mBAAmB;IACjC,gBAAgB,qBAAqB;IACrC,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAG7B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