@humanode-hyperlane/metrics 0.0.0-stage → 0.2.8-humanode.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.
Files changed (53) hide show
  1. package/LICENSE.md +193 -0
  2. package/dist/balance.d.ts +93 -0
  3. package/dist/balance.d.ts.map +1 -0
  4. package/dist/balance.js +235 -0
  5. package/dist/balance.js.map +1 -0
  6. package/dist/gauges.d.ts +41 -0
  7. package/dist/gauges.d.ts.map +1 -0
  8. package/dist/gauges.js +100 -0
  9. package/dist/gauges.js.map +1 -0
  10. package/dist/index.d.ts +8 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +13 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/index.test.d.ts +2 -0
  15. package/dist/index.test.d.ts.map +1 -0
  16. package/dist/index.test.js +45 -0
  17. package/dist/index.test.js.map +1 -0
  18. package/dist/pushgateway.d.ts +23 -0
  19. package/dist/pushgateway.d.ts.map +1 -0
  20. package/dist/pushgateway.js +54 -0
  21. package/dist/pushgateway.js.map +1 -0
  22. package/dist/server.d.ts +15 -0
  23. package/dist/server.d.ts.map +1 -0
  24. package/dist/server.js +63 -0
  25. package/dist/server.js.map +1 -0
  26. package/dist/server.test.d.ts +2 -0
  27. package/dist/server.test.d.ts.map +1 -0
  28. package/dist/server.test.js +23 -0
  29. package/dist/server.test.js.map +1 -0
  30. package/dist/types.d.ts +64 -0
  31. package/dist/types.d.ts.map +1 -0
  32. package/dist/types.js +2 -0
  33. package/dist/types.js.map +1 -0
  34. package/dist/update.d.ts +51 -0
  35. package/dist/update.d.ts.map +1 -0
  36. package/dist/update.js +163 -0
  37. package/dist/update.js.map +1 -0
  38. package/dist/utils.d.ts +7 -0
  39. package/dist/utils.d.ts.map +1 -0
  40. package/dist/utils.js +9 -0
  41. package/dist/utils.js.map +1 -0
  42. package/package.json +52 -3
  43. package/src/balance.ts +380 -0
  44. package/src/gauges.ts +136 -0
  45. package/src/index.test.ts +52 -0
  46. package/src/index.ts +53 -0
  47. package/src/pushgateway.ts +66 -0
  48. package/src/server.test.ts +32 -0
  49. package/src/server.ts +76 -0
  50. package/src/types.ts +74 -0
  51. package/src/update.ts +239 -0
  52. package/src/utils.ts +10 -0
  53. package/README.md +0 -3
package/LICENSE.md ADDED
@@ -0,0 +1,193 @@
1
+ # Apache License
2
+
3
+ _Version 2.0, January 2004_
4
+ _&lt;<http://www.apache.org/licenses/>&gt;_
5
+
6
+ ### Terms and Conditions for use, reproduction, and distribution
7
+
8
+ #### 1. Definitions
9
+
10
+ “License” shall mean the terms and conditions for use, reproduction, and
11
+ distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ “Licensor” shall mean the copyright owner or entity authorized by the copyright
14
+ owner that is granting the License.
15
+
16
+ “Legal Entity” shall mean the union of the acting entity and all other entities
17
+ that control, are controlled by, or are under common control with that entity.
18
+ For the purposes of this definition, “control” means **(i)** the power, direct or
19
+ indirect, to cause the direction or management of such entity, whether by
20
+ contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or **(iii)** beneficial ownership of such entity.
22
+
23
+ “You” (or “Your”) shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ “Source” form shall mean the preferred form for making modifications, including
27
+ but not limited to software source code, documentation source, and configuration
28
+ files.
29
+
30
+ “Object” form shall mean any form resulting from mechanical transformation or
31
+ translation of a Source form, including but not limited to compiled object code,
32
+ generated documentation, and conversions to other media types.
33
+
34
+ “Work” shall mean the work of authorship, whether in Source or Object form, made
35
+ available under the License, as indicated by a copyright notice that is included
36
+ in or attached to the work (an example is provided in the Appendix below).
37
+
38
+ “Derivative Works” shall mean any work, whether in Source or Object form, that
39
+ is based on (or derived from) the Work and for which the editorial revisions,
40
+ annotations, elaborations, or other modifications represent, as a whole, an
41
+ original work of authorship. For the purposes of this License, Derivative Works
42
+ shall not include works that remain separable from, or merely link (or bind by
43
+ name) to the interfaces of, the Work and Derivative Works thereof.
44
+
45
+ “Contribution” shall mean any work of authorship, including the original version
46
+ of the Work and any modifications or additions to that Work or Derivative Works
47
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
48
+ by the copyright owner or by an individual or Legal Entity authorized to submit
49
+ on behalf of the copyright owner. For the purposes of this definition,
50
+ “submitted” means any form of electronic, verbal, or written communication sent
51
+ to the Licensor or its representatives, including but not limited to
52
+ communication on electronic mailing lists, source code control systems, and
53
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
54
+ the purpose of discussing and improving the Work, but excluding communication
55
+ that is conspicuously marked or otherwise designated in writing by the copyright
56
+ owner as “Not a Contribution.”
57
+
58
+ “Contributor” shall mean Licensor and any individual or Legal Entity on behalf
59
+ of whom a Contribution has been received by Licensor and subsequently
60
+ incorporated within the Work.
61
+
62
+ #### 2. Grant of Copyright License
63
+
64
+ Subject to the terms and conditions of this License, each Contributor hereby
65
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
66
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the Work and such
68
+ Derivative Works in Source or Object form.
69
+
70
+ #### 3. Grant of Patent License
71
+
72
+ Subject to the terms and conditions of this License, each Contributor hereby
73
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
74
+ irrevocable (except as stated in this section) patent license to make, have
75
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
76
+ such license applies only to those patent claims licensable by such Contributor
77
+ that are necessarily infringed by their Contribution(s) alone or by combination
78
+ of their Contribution(s) with the Work to which such Contribution(s) was
79
+ submitted. If You institute patent litigation against any entity (including a
80
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
81
+ Contribution incorporated within the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under this License
83
+ for that Work shall terminate as of the date such litigation is filed.
84
+
85
+ #### 4. Redistribution
86
+
87
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
88
+ in any medium, with or without modifications, and in Source or Object form,
89
+ provided that You meet the following conditions:
90
+
91
+ - **(a)** You must give any other recipients of the Work or Derivative Works a copy of
92
+ this License; and
93
+ - **(b)** You must cause any modified files to carry prominent notices stating that You
94
+ changed the files; and
95
+ - **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
96
+ all copyright, patent, trademark, and attribution notices from the Source form
97
+ of the Work, excluding those notices that do not pertain to any part of the
98
+ Derivative Works; and
99
+ - **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
100
+ Derivative Works that You distribute must include a readable copy of the
101
+ attribution notices contained within such NOTICE file, excluding those notices
102
+ that do not pertain to any part of the Derivative Works, in at least one of the
103
+ following places: within a NOTICE text file distributed as part of the
104
+ Derivative Works; within the Source form or documentation, if provided along
105
+ with the Derivative Works; or, within a display generated by the Derivative
106
+ Works, if and wherever such third-party notices normally appear. The contents of
107
+ the NOTICE file are for informational purposes only and do not modify the
108
+ License. You may add Your own attribution notices within Derivative Works that
109
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
110
+ provided that such additional attribution notices cannot be construed as
111
+ modifying the License.
112
+
113
+ You may add Your own copyright statement to Your modifications and may provide
114
+ additional or different license terms and conditions for use, reproduction, or
115
+ distribution of Your modifications, or for any such Derivative Works as a whole,
116
+ provided Your use, reproduction, and distribution of the Work otherwise complies
117
+ with the conditions stated in this License.
118
+
119
+ #### 5. Submission of Contributions
120
+
121
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
122
+ for inclusion in the Work by You to the Licensor shall be under the terms and
123
+ conditions of this License, without any additional terms or conditions.
124
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
125
+ any separate license agreement you may have executed with Licensor regarding
126
+ such Contributions.
127
+
128
+ #### 6. Trademarks
129
+
130
+ This License does not grant permission to use the trade names, trademarks,
131
+ service marks, or product names of the Licensor, except as required for
132
+ reasonable and customary use in describing the origin of the Work and
133
+ reproducing the content of the NOTICE file.
134
+
135
+ #### 7. Disclaimer of Warranty
136
+
137
+ Unless required by applicable law or agreed to in writing, Licensor provides the
138
+ Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
140
+ including, without limitation, any warranties or conditions of TITLE,
141
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
142
+ solely responsible for determining the appropriateness of using or
143
+ redistributing the Work and assume any risks associated with Your exercise of
144
+ permissions under this License.
145
+
146
+ #### 8. Limitation of Liability
147
+
148
+ In no event and under no legal theory, whether in tort (including negligence),
149
+ contract, or otherwise, unless required by applicable law (such as deliberate
150
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special, incidental,
152
+ or consequential damages of any character arising as a result of this License or
153
+ out of the use or inability to use the Work (including but not limited to
154
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
155
+ any and all other commercial damages or losses), even if such Contributor has
156
+ been advised of the possibility of such damages.
157
+
158
+ #### 9. Accepting Warranty or Additional Liability
159
+
160
+ While redistributing the Work or Derivative Works thereof, You may choose to
161
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
162
+ other liability obligations and/or rights consistent with this License. However,
163
+ in accepting such obligations, You may act only on Your own behalf and on Your
164
+ sole responsibility, not on behalf of any other Contributor, and only if You
165
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
166
+ incurred by, or claims asserted against, such Contributor by reason of your
167
+ accepting any such warranty or additional liability.
168
+
169
+ _END OF TERMS AND CONDITIONS_
170
+
171
+ ### APPENDIX: How to apply the Apache License to your work
172
+
173
+ To apply the Apache License to your work, attach the following boilerplate
174
+ notice, with the fields enclosed by brackets `[]` replaced with your own
175
+ identifying information. (Don't include the brackets!) The text should be
176
+ enclosed in the appropriate comment syntax for the file format. We also
177
+ recommend that a file or class name and description of purpose be included on
178
+ the same “printed page” as the copyright notice for easier identification within
179
+ third-party archives.
180
+
181
+ Copyright [yyyy] [name of copyright owner]
182
+
183
+ Licensed under the Apache License, Version 2.0 (the "License");
184
+ you may not use this file except in compliance with the License.
185
+ You may obtain a copy of the License at
186
+
187
+ http://www.apache.org/licenses/LICENSE-2.0
188
+
189
+ Unless required by applicable law or agreed to in writing, software
190
+ distributed under the License is distributed on an "AS IS" BASIS,
191
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ See the License for the specific language governing permissions and
193
+ limitations under the License.
@@ -0,0 +1,93 @@
1
+ import { Contract, type PopulatedTransaction } from 'ethers';
2
+ import type { Logger } from 'pino';
3
+ import { type IHypXERC20Adapter, type MultiProtocolProvider, Token, type WarpCore } from '@humanode-hyperlane/sdk';
4
+ import { type Address } from '@humanode-hyperlane/utils';
5
+ import type { NativeWalletBalance, WarpRouteBalance, XERC20Info, XERC20Limit } from './types.js';
6
+ /**
7
+ * Minimal ABI for managed lockbox contracts.
8
+ */
9
+ export declare const MANAGED_LOCKBOX_MINIMAL_ABI: readonly ["function XERC20() view returns (address)", "function ERC20() view returns (address)"];
10
+ /**
11
+ * Interface for token price getter to allow different implementations.
12
+ */
13
+ export interface TokenPriceGetter {
14
+ tryGetTokenPrice(token: Token): Promise<number | undefined>;
15
+ }
16
+ /**
17
+ * Gets the bridged balance and value of a token in a warp route.
18
+ *
19
+ * @param warpCore - The WarpCore instance for the route
20
+ * @param token - The token to get the balance for
21
+ * @param tokenPriceGetter - Price getter for calculating USD value
22
+ * @param logger - Logger instance
23
+ * @param bridgedSupply - Optional pre-fetched bridged supply
24
+ * @returns The balance information or undefined if not available
25
+ */
26
+ export declare function getTokenBridgedBalance(warpCore: WarpCore, token: Token, tokenPriceGetter: TokenPriceGetter, logger: Logger, bridgedSupply?: bigint): Promise<WarpRouteBalance | undefined>;
27
+ /**
28
+ * Gets the native balance of the ATA payer for Sealevel tokens.
29
+ *
30
+ * @param warpCore - The WarpCore instance for the route
31
+ * @param token - The Sealevel token
32
+ * @param warpRouteId - The warp route identifier
33
+ * @returns The native wallet balance information
34
+ */
35
+ export declare function getSealevelAtaPayerBalance(warpCore: WarpCore, token: Token, warpRouteId: string): Promise<NativeWalletBalance>;
36
+ /**
37
+ * Gets xERC20 information for a token.
38
+ *
39
+ * @param warpCore - The WarpCore instance for the route
40
+ * @param token - The xERC20 token
41
+ * @returns The xERC20 info including limits and address
42
+ */
43
+ export declare function getXERC20Info(warpCore: WarpCore, token: Token): Promise<XERC20Info>;
44
+ /**
45
+ * Gets xERC20 limits from an adapter.
46
+ *
47
+ * @param token - The token to get limits for
48
+ * @param xerc20 - The xERC20 adapter
49
+ * @returns The xERC20 limits
50
+ */
51
+ export declare function getXERC20Limit(token: Token, xerc20: IHypXERC20Adapter<PopulatedTransaction>): Promise<XERC20Limit>;
52
+ /**
53
+ * Gets a managed lockbox contract instance.
54
+ *
55
+ * @param multiProvider - The multi-protocol provider
56
+ * @param chainName - The chain name
57
+ * @param lockboxAddress - The lockbox contract address
58
+ * @returns The Contract instance
59
+ */
60
+ export declare function getManagedLockBox(multiProvider: MultiProtocolProvider, chainName: string, lockboxAddress: Address): Contract;
61
+ /**
62
+ * Gets extra lockbox information for xERC20 tokens.
63
+ *
64
+ * @param multiProvider - The multi-protocol provider
65
+ * @param warpToken - The warp token
66
+ * @param lockboxAddress - The lockbox contract address
67
+ * @returns The xERC20 info for the lockbox
68
+ */
69
+ export declare function getExtraLockboxInfo(multiProvider: MultiProtocolProvider, warpToken: Token, lockboxAddress: Address): Promise<XERC20Info>;
70
+ /**
71
+ * Gets the balance of an extra lockbox.
72
+ *
73
+ * @param multiProvider - The multi-protocol provider
74
+ * @param warpToken - The warp token
75
+ * @param tokenPriceGetter - Price getter for calculating USD value
76
+ * @param lockboxAddress - The lockbox contract address
77
+ * @param logger - Logger instance
78
+ * @returns The balance information or undefined if not available
79
+ */
80
+ export declare function getExtraLockboxBalance(multiProvider: MultiProtocolProvider, warpToken: Token, tokenPriceGetter: TokenPriceGetter, lockboxAddress: Address, logger: Logger): Promise<WarpRouteBalance | undefined>;
81
+ /**
82
+ * Gets collateral info for a managed lockbox.
83
+ *
84
+ * @param multiProvider - The multi-protocol provider
85
+ * @param warpToken - The warp token
86
+ * @param lockBoxAddress - The lockbox contract address
87
+ * @returns The token name and address of the collateral
88
+ */
89
+ export declare function getManagedLockBoxCollateralInfo(multiProvider: MultiProtocolProvider, warpToken: Token, lockBoxAddress: Address): Promise<{
90
+ tokenName: string;
91
+ tokenAddress: Address;
92
+ }>;
93
+ //# sourceMappingURL=balance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../src/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,EAIL,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAE1B,KAAK,EAEL,KAAK,QAAQ,EACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,OAAO,EAAgB,MAAM,2BAA2B,CAAC;AAEvE,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,WAAW,EACZ,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,eAAO,MAAM,2BAA2B,kGAG9B,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC7D;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CA+CvC;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,mBAAmB,CAAC,CAyB9B;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,UAAU,CAAC,CAqCrB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,GAC9C,OAAO,CAAC,WAAW,CAAC,CActB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,qBAAqB,EACpC,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,OAAO,GACtB,QAAQ,CAGV;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,qBAAqB,EACpC,SAAS,EAAE,KAAK,EAChB,cAAc,EAAE,OAAO,GACtB,OAAO,CAAC,UAAU,CAAC,CAgCrB;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,qBAAqB,EACpC,SAAS,EAAE,KAAK,EAChB,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,OAAO,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CA6CvC;AAED;;;;;;;GAOG;AACH,wBAAsB,+BAA+B,CACnD,aAAa,EAAE,qBAAqB,EACpC,SAAS,EAAE,KAAK,EAChB,cAAc,EAAE,OAAO,GACtB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAAC,CAsBvD"}
@@ -0,0 +1,235 @@
1
+ import { Contract } from 'ethers';
2
+ import { IXERC20VS__factory } from '@humanode-hyperlane/core';
3
+ import { EvmTokenAdapter, Token, TokenStandard, } from '@humanode-hyperlane/sdk';
4
+ import { ProtocolType } from '@humanode-hyperlane/utils';
5
+ import { formatBigInt } from './utils.js';
6
+ /**
7
+ * Minimal ABI for managed lockbox contracts.
8
+ */
9
+ export const MANAGED_LOCKBOX_MINIMAL_ABI = [
10
+ 'function XERC20() view returns (address)',
11
+ 'function ERC20() view returns (address)',
12
+ ];
13
+ /**
14
+ * Gets the bridged balance and value of a token in a warp route.
15
+ *
16
+ * @param warpCore - The WarpCore instance for the route
17
+ * @param token - The token to get the balance for
18
+ * @param tokenPriceGetter - Price getter for calculating USD value
19
+ * @param logger - Logger instance
20
+ * @param bridgedSupply - Optional pre-fetched bridged supply
21
+ * @returns The balance information or undefined if not available
22
+ */
23
+ export async function getTokenBridgedBalance(warpCore, token, tokenPriceGetter, logger, bridgedSupply) {
24
+ if (!token.isHypToken()) {
25
+ logger.warn({ token: token.symbol, chain: token.chainName }, 'No support for bridged balance on non-Hyperlane token');
26
+ return undefined;
27
+ }
28
+ const adapter = token.getHypAdapter(warpCore.multiProvider);
29
+ let tokenAddress = token.collateralAddressOrDenom ?? token.addressOrDenom;
30
+ // If bridged supply is not provided, fetch it
31
+ const supply = bridgedSupply ?? (await adapter.getBridgedSupply());
32
+ if (supply === undefined) {
33
+ logger.warn({ token: token.symbol, chain: token.chainName }, 'Failed to get bridged supply');
34
+ return undefined;
35
+ }
36
+ const balance = token.amount(supply).getDecimalFormattedAmount();
37
+ let tokenPrice;
38
+ // Only record value for collateralized and xERC20 lockbox tokens.
39
+ if (token.isCollateralized() ||
40
+ token.standard === TokenStandard.EvmHypXERC20Lockbox ||
41
+ token.standard === TokenStandard.EvmHypVSXERC20Lockbox) {
42
+ tokenPrice = await tokenPriceGetter.tryGetTokenPrice(token);
43
+ }
44
+ if (token.standard === TokenStandard.EvmHypXERC20Lockbox ||
45
+ token.standard === TokenStandard.EvmHypVSXERC20Lockbox) {
46
+ tokenAddress = (await adapter.getXERC20())
47
+ .address;
48
+ }
49
+ return {
50
+ balance,
51
+ valueUSD: tokenPrice ? balance * tokenPrice : undefined,
52
+ tokenAddress,
53
+ };
54
+ }
55
+ /**
56
+ * Gets the native balance of the ATA payer for Sealevel tokens.
57
+ *
58
+ * @param warpCore - The WarpCore instance for the route
59
+ * @param token - The Sealevel token
60
+ * @param warpRouteId - The warp route identifier
61
+ * @returns The native wallet balance information
62
+ */
63
+ export async function getSealevelAtaPayerBalance(warpCore, token, warpRouteId) {
64
+ if (token.protocol !== ProtocolType.Sealevel || token.isNative()) {
65
+ throw new Error(`Unsupported ATA payer protocol type ${token.protocol} or standard ${token.standard}`);
66
+ }
67
+ const adapter = token.getHypAdapter(warpCore.multiProvider);
68
+ const ataPayer = adapter.deriveAtaPayerAccount().toString();
69
+ const nativeToken = Token.FromChainMetadataNativeToken(warpCore.multiProvider.getChainMetadata(token.chainName));
70
+ const ataPayerBalance = await nativeToken.getBalance(warpCore.multiProvider, ataPayer);
71
+ return {
72
+ chain: token.chainName,
73
+ walletAddress: ataPayer.toString(),
74
+ walletName: `${warpRouteId}/ata-payer`,
75
+ balance: ataPayerBalance.getDecimalFormattedAmount(),
76
+ };
77
+ }
78
+ /**
79
+ * Gets xERC20 information for a token.
80
+ *
81
+ * @param warpCore - The WarpCore instance for the route
82
+ * @param token - The xERC20 token
83
+ * @returns The xERC20 info including limits and address
84
+ */
85
+ export async function getXERC20Info(warpCore, token) {
86
+ if (token.protocol !== ProtocolType.Ethereum &&
87
+ token.protocol !== ProtocolType.Tron) {
88
+ throw new Error(`Unsupported XERC20 protocol type ${token.protocol}`);
89
+ }
90
+ if (token.standard === TokenStandard.EvmHypXERC20 ||
91
+ token.standard === TokenStandard.EvmHypVSXERC20 ||
92
+ token.standard == TokenStandard.TronHypVSXERC20 ||
93
+ token.standard == TokenStandard.TronHypXERC20) {
94
+ const adapter = token.getAdapter(warpCore.multiProvider);
95
+ return {
96
+ limits: await getXERC20Limit(token, adapter),
97
+ xERC20Address: (await adapter.getXERC20()).address,
98
+ };
99
+ }
100
+ else if (token.standard === TokenStandard.EvmHypXERC20Lockbox ||
101
+ token.standard === TokenStandard.EvmHypVSXERC20Lockbox ||
102
+ token.standard === TokenStandard.TronHypXERC20Lockbox ||
103
+ token.standard === TokenStandard.TronHypVSXERC20Lockbox) {
104
+ const adapter = token.getAdapter(warpCore.multiProvider);
105
+ return {
106
+ limits: await getXERC20Limit(token, adapter),
107
+ xERC20Address: (await adapter.getXERC20()).address,
108
+ };
109
+ }
110
+ throw new Error(`Unsupported XERC20 token standard ${token.standard}`);
111
+ }
112
+ /**
113
+ * Gets xERC20 limits from an adapter.
114
+ *
115
+ * @param token - The token to get limits for
116
+ * @param xerc20 - The xERC20 adapter
117
+ * @returns The xERC20 limits
118
+ */
119
+ export async function getXERC20Limit(token, xerc20) {
120
+ const [mintCurrent, mintMax, burnCurrent, burnMax] = await Promise.all([
121
+ xerc20.getMintLimit(),
122
+ xerc20.getMintMaxLimit(),
123
+ xerc20.getBurnLimit(),
124
+ xerc20.getBurnMaxLimit(),
125
+ ]);
126
+ return {
127
+ mint: formatBigInt(token, mintCurrent),
128
+ mintMax: formatBigInt(token, mintMax),
129
+ burn: formatBigInt(token, burnCurrent),
130
+ burnMax: formatBigInt(token, burnMax),
131
+ };
132
+ }
133
+ /**
134
+ * Gets a managed lockbox contract instance.
135
+ *
136
+ * @param multiProvider - The multi-protocol provider
137
+ * @param chainName - The chain name
138
+ * @param lockboxAddress - The lockbox contract address
139
+ * @returns The Contract instance
140
+ */
141
+ export function getManagedLockBox(multiProvider, chainName, lockboxAddress) {
142
+ const provider = multiProvider.getEthersV5Provider(chainName);
143
+ return new Contract(lockboxAddress, MANAGED_LOCKBOX_MINIMAL_ABI, provider);
144
+ }
145
+ /**
146
+ * Gets extra lockbox information for xERC20 tokens.
147
+ *
148
+ * @param multiProvider - The multi-protocol provider
149
+ * @param warpToken - The warp token
150
+ * @param lockboxAddress - The lockbox contract address
151
+ * @returns The xERC20 info for the lockbox
152
+ */
153
+ export async function getExtraLockboxInfo(multiProvider, warpToken, lockboxAddress) {
154
+ const currentChainProvider = multiProvider.getEthersV5Provider(warpToken.chainName);
155
+ const lockboxInstance = getManagedLockBox(multiProvider, warpToken.chainName, lockboxAddress);
156
+ const xERC20Address = await lockboxInstance['XERC20']();
157
+ const vsXERC20Instance = IXERC20VS__factory.connect(xERC20Address, currentChainProvider);
158
+ const [mintMax, burnMax, mint, burn] = await Promise.all([
159
+ vsXERC20Instance.mintingMaxLimitOf(lockboxAddress),
160
+ vsXERC20Instance.burningMaxLimitOf(lockboxAddress),
161
+ vsXERC20Instance.mintingCurrentLimitOf(lockboxAddress),
162
+ vsXERC20Instance.burningCurrentLimitOf(lockboxAddress),
163
+ ]);
164
+ return {
165
+ limits: {
166
+ burn: formatBigInt(warpToken, burn.toBigInt()),
167
+ burnMax: formatBigInt(warpToken, burnMax.toBigInt()),
168
+ mint: formatBigInt(warpToken, mint.toBigInt()),
169
+ mintMax: formatBigInt(warpToken, mintMax.toBigInt()),
170
+ },
171
+ xERC20Address,
172
+ };
173
+ }
174
+ /**
175
+ * Gets the balance of an extra lockbox.
176
+ *
177
+ * @param multiProvider - The multi-protocol provider
178
+ * @param warpToken - The warp token
179
+ * @param tokenPriceGetter - Price getter for calculating USD value
180
+ * @param lockboxAddress - The lockbox contract address
181
+ * @param logger - Logger instance
182
+ * @returns The balance information or undefined if not available
183
+ */
184
+ export async function getExtraLockboxBalance(multiProvider, warpToken, tokenPriceGetter, lockboxAddress, logger) {
185
+ if (!warpToken.isXerc20()) {
186
+ return undefined;
187
+ }
188
+ const lockboxInstance = getManagedLockBox(multiProvider, warpToken.chainName, lockboxAddress);
189
+ const erc20TokenAddress = await lockboxInstance['ERC20']();
190
+ const erc20tokenAdapter = new EvmTokenAdapter(warpToken.chainName, multiProvider, {
191
+ token: erc20TokenAddress,
192
+ });
193
+ let balance;
194
+ try {
195
+ balance = await erc20tokenAdapter.getBalance(lockboxAddress);
196
+ }
197
+ catch (err) {
198
+ logger.error({
199
+ err,
200
+ chain: warpToken.chainName,
201
+ token: warpToken.symbol,
202
+ lockboxAddress,
203
+ erc20TokenAddress,
204
+ }, 'Failed to get balance for contract at lockbox address');
205
+ return undefined;
206
+ }
207
+ const tokenPrice = await tokenPriceGetter.tryGetTokenPrice(warpToken);
208
+ const balanceNumber = formatBigInt(warpToken, balance);
209
+ return {
210
+ balance: balanceNumber,
211
+ valueUSD: tokenPrice ? balanceNumber * tokenPrice : undefined,
212
+ tokenAddress: erc20TokenAddress,
213
+ };
214
+ }
215
+ /**
216
+ * Gets collateral info for a managed lockbox.
217
+ *
218
+ * @param multiProvider - The multi-protocol provider
219
+ * @param warpToken - The warp token
220
+ * @param lockBoxAddress - The lockbox contract address
221
+ * @returns The token name and address of the collateral
222
+ */
223
+ export async function getManagedLockBoxCollateralInfo(multiProvider, warpToken, lockBoxAddress) {
224
+ const lockBoxInstance = getManagedLockBox(multiProvider, warpToken.chainName, lockBoxAddress);
225
+ const collateralTokenAddress = await lockBoxInstance['ERC20']();
226
+ const collateralTokenAdapter = new EvmTokenAdapter(warpToken.chainName, multiProvider, {
227
+ token: collateralTokenAddress,
228
+ });
229
+ const { name } = await collateralTokenAdapter.getMetadata();
230
+ return {
231
+ tokenName: name,
232
+ tokenAddress: collateralTokenAddress,
233
+ };
234
+ }
235
+ //# sourceMappingURL=balance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balance.js","sourceRoot":"","sources":["../src/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6B,MAAM,QAAQ,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAGL,eAAe,EAIf,KAAK,EACL,aAAa,GAEd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAgB,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAQvE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,0CAA0C;IAC1C,yCAAyC;C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2
+ import type { WarpRouteMetricLabels, WarpRouteValueAtRiskMetricLabels } from './types.js';
3
+ /**
4
+ * Label names for warp route metrics.
5
+ */
6
+ export declare const warpRouteMetricLabels: (keyof WarpRouteMetricLabels)[];
7
+ /**
8
+ * Label names for value at risk metrics.
9
+ */
10
+ export declare const warpRouteValueAtRiskMetricLabels: (keyof WarpRouteValueAtRiskMetricLabels)[];
11
+ /**
12
+ * Wallet balance metric label names.
13
+ */
14
+ export declare const walletBalanceMetricLabels: readonly ["chain", "wallet_address", "wallet_name", "token_address", "token_symbol", "token_name"];
15
+ /**
16
+ * xERC20 limits metric label names.
17
+ */
18
+ export declare const xERC20LimitsMetricLabels: readonly ["chain_name", "limit_type", "token_name", "bridge_address", "token_address", "bridge_label"];
19
+ /**
20
+ * Collection of warp route Prometheus gauges.
21
+ */
22
+ export interface WarpMetricsGauges {
23
+ warpRouteTokenBalance: Gauge<string>;
24
+ warpRouteCollateralValue: Gauge<string>;
25
+ warpRouteValueAtRisk: Gauge<string>;
26
+ walletBalanceGauge: Gauge<string>;
27
+ xERC20LimitsGauge: Gauge<string>;
28
+ }
29
+ /**
30
+ * Creates a new wallet balance gauge with optional additional labels.
31
+ */
32
+ export declare function createWalletBalanceGauge(registry: Registry, additionalLabels?: string[]): Gauge<string>;
33
+ /**
34
+ * Creates all warp route metric gauges and registers them with the provided registry.
35
+ *
36
+ * @param registry - The Prometheus registry to register the gauges with
37
+ * @param walletBalanceAdditionalLabels - Optional additional labels for the wallet balance gauge
38
+ * @returns Collection of warp metric gauges
39
+ */
40
+ export declare function createWarpMetricsGauges(registry: Registry, walletBalanceAdditionalLabels?: string[]): WarpMetricsGauges;
41
+ //# sourceMappingURL=gauges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gauges.d.ts","sourceRoot":"","sources":["../src/gauges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EACV,qBAAqB,EACrB,gCAAgC,EACjC,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,CAAC,MAAM,qBAAqB,CAAC,EAQhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gCAAgC,EAAE,CAAC,MAAM,gCAAgC,CAAC,EAQpF,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,yBAAyB,oGAO5B,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,wBAAwB,wGAO3B,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,qBAAqB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,wBAAwB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxC,oBAAoB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,EAClB,gBAAgB,GAAE,MAAM,EAAO,GAC9B,KAAK,CAAC,MAAM,CAAC,CAQf;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,EAClB,6BAA6B,GAAE,MAAM,EAAO,GAC3C,iBAAiB,CAyCnB"}