@hyperlane-xyz/metrics 0.1.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.
- package/LICENSE.md +195 -0
- package/dist/balance.d.ts +93 -0
- package/dist/balance.d.ts.map +1 -0
- package/dist/balance.js +230 -0
- package/dist/balance.js.map +1 -0
- package/dist/gauges.d.ts +41 -0
- package/dist/gauges.d.ts.map +1 -0
- package/dist/gauges.js +100 -0
- package/dist/gauges.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +45 -0
- package/dist/index.test.js.map +1 -0
- package/dist/pushgateway.d.ts +23 -0
- package/dist/pushgateway.d.ts.map +1 -0
- package/dist/pushgateway.js +54 -0
- package/dist/pushgateway.js.map +1 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +41 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/update.d.ts +51 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +163 -0
- package/dist/update.js.map +1 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +9 -0
- package/dist/utils.js.map +1 -0
- package/package.json +57 -0
- package/src/balance.ts +373 -0
- package/src/gauges.ts +136 -0
- package/src/index.test.ts +52 -0
- package/src/index.ts +53 -0
- package/src/pushgateway.ts +66 -0
- package/src/server.ts +47 -0
- package/src/types.ts +75 -0
- package/src/update.ts +239 -0
- package/src/utils.ts +10 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
_Version 2.0, January 2004_
|
|
5
|
+
_<<http://www.apache.org/licenses/>>_
|
|
6
|
+
|
|
7
|
+
### Terms and Conditions for use, reproduction, and distribution
|
|
8
|
+
|
|
9
|
+
#### 1. Definitions
|
|
10
|
+
|
|
11
|
+
“License” shall mean the terms and conditions for use, reproduction, and
|
|
12
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
“Licensor” shall mean the copyright owner or entity authorized by the copyright
|
|
15
|
+
owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
“Legal Entity” shall mean the union of the acting entity and all other entities
|
|
18
|
+
that control, are controlled by, or are under common control with that entity.
|
|
19
|
+
For the purposes of this definition, “control” means **(i)** the power, direct or
|
|
20
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
21
|
+
contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or **(iii)** beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
“You” (or “Your”) shall mean an individual or Legal Entity exercising
|
|
25
|
+
permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
“Source” form shall mean the preferred form for making modifications, including
|
|
28
|
+
but not limited to software source code, documentation source, and configuration
|
|
29
|
+
files.
|
|
30
|
+
|
|
31
|
+
“Object” form shall mean any form resulting from mechanical transformation or
|
|
32
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
33
|
+
generated documentation, and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
“Work” shall mean the work of authorship, whether in Source or Object form, made
|
|
36
|
+
available under the License, as indicated by a copyright notice that is included
|
|
37
|
+
in or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
“Derivative Works” shall mean any work, whether in Source or Object form, that
|
|
40
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
41
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
42
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
43
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
44
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
45
|
+
|
|
46
|
+
“Contribution” shall mean any work of authorship, including the original version
|
|
47
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
48
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
49
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
50
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
51
|
+
“submitted” means any form of electronic, verbal, or written communication sent
|
|
52
|
+
to the Licensor or its representatives, including but not limited to
|
|
53
|
+
communication on electronic mailing lists, source code control systems, and
|
|
54
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
55
|
+
the purpose of discussing and improving the Work, but excluding communication
|
|
56
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
57
|
+
owner as “Not a Contribution.”
|
|
58
|
+
|
|
59
|
+
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
|
|
60
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
61
|
+
incorporated within the Work.
|
|
62
|
+
|
|
63
|
+
#### 2. Grant of Copyright License
|
|
64
|
+
|
|
65
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
66
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
67
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
68
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
69
|
+
Derivative Works in Source or Object form.
|
|
70
|
+
|
|
71
|
+
#### 3. Grant of Patent License
|
|
72
|
+
|
|
73
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
74
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
75
|
+
irrevocable (except as stated in this section) patent license to make, have
|
|
76
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
77
|
+
such license applies only to those patent claims licensable by such Contributor
|
|
78
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
79
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
80
|
+
submitted. If You institute patent litigation against any entity (including a
|
|
81
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
82
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
|
83
|
+
patent infringement, then any patent licenses granted to You under this License
|
|
84
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
85
|
+
|
|
86
|
+
#### 4. Redistribution
|
|
87
|
+
|
|
88
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
89
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
90
|
+
provided that You meet the following conditions:
|
|
91
|
+
|
|
92
|
+
* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
|
|
93
|
+
this License; and
|
|
94
|
+
* **(b)** You must cause any modified files to carry prominent notices stating that You
|
|
95
|
+
changed the files; and
|
|
96
|
+
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
|
|
97
|
+
all copyright, patent, trademark, and attribution notices from the Source form
|
|
98
|
+
of the Work, excluding those notices that do not pertain to any part of the
|
|
99
|
+
Derivative Works; and
|
|
100
|
+
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
|
|
101
|
+
Derivative Works that You distribute must include a readable copy of the
|
|
102
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
103
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
104
|
+
following places: within a NOTICE text file distributed as part of the
|
|
105
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
106
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
107
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
108
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
109
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
110
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
111
|
+
provided that such additional attribution notices cannot be construed as
|
|
112
|
+
modifying the License.
|
|
113
|
+
|
|
114
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
115
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
116
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
117
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
118
|
+
with the conditions stated in this License.
|
|
119
|
+
|
|
120
|
+
#### 5. Submission of Contributions
|
|
121
|
+
|
|
122
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
123
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
124
|
+
conditions of this License, without any additional terms or conditions.
|
|
125
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
126
|
+
any separate license agreement you may have executed with Licensor regarding
|
|
127
|
+
such Contributions.
|
|
128
|
+
|
|
129
|
+
#### 6. Trademarks
|
|
130
|
+
|
|
131
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
132
|
+
service marks, or product names of the Licensor, except as required for
|
|
133
|
+
reasonable and customary use in describing the origin of the Work and
|
|
134
|
+
reproducing the content of the NOTICE file.
|
|
135
|
+
|
|
136
|
+
#### 7. Disclaimer of Warranty
|
|
137
|
+
|
|
138
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
139
|
+
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
|
140
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
141
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
142
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
143
|
+
solely responsible for determining the appropriateness of using or
|
|
144
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
145
|
+
permissions under this License.
|
|
146
|
+
|
|
147
|
+
#### 8. Limitation of Liability
|
|
148
|
+
|
|
149
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
150
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
151
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
152
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
153
|
+
or consequential damages of any character arising as a result of this License or
|
|
154
|
+
out of the use or inability to use the Work (including but not limited to
|
|
155
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
156
|
+
any and all other commercial damages or losses), even if such Contributor has
|
|
157
|
+
been advised of the possibility of such damages.
|
|
158
|
+
|
|
159
|
+
#### 9. Accepting Warranty or Additional Liability
|
|
160
|
+
|
|
161
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
162
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
163
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
164
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
165
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
166
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
167
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
168
|
+
accepting any such warranty or additional liability.
|
|
169
|
+
|
|
170
|
+
_END OF TERMS AND CONDITIONS_
|
|
171
|
+
|
|
172
|
+
### APPENDIX: How to apply the Apache License to your work
|
|
173
|
+
|
|
174
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
175
|
+
notice, with the fields enclosed by brackets `[]` replaced with your own
|
|
176
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
177
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
178
|
+
recommend that a file or class name and description of purpose be included on
|
|
179
|
+
the same “printed page” as the copyright notice for easier identification within
|
|
180
|
+
third-party archives.
|
|
181
|
+
|
|
182
|
+
Copyright [yyyy] [name of copyright owner]
|
|
183
|
+
|
|
184
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
185
|
+
you may not use this file except in compliance with the License.
|
|
186
|
+
You may obtain a copy of the License at
|
|
187
|
+
|
|
188
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
189
|
+
|
|
190
|
+
Unless required by applicable law or agreed to in writing, software
|
|
191
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
192
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
193
|
+
See the License for the specific language governing permissions and
|
|
194
|
+
limitations under the License.
|
|
195
|
+
|
|
@@ -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 '@hyperlane-xyz/sdk';
|
|
4
|
+
import { type Address } from '@hyperlane-xyz/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,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,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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"}
|
package/dist/balance.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { Contract } from 'ethers';
|
|
2
|
+
import { IXERC20VS__factory } from '@hyperlane-xyz/core';
|
|
3
|
+
import { EvmTokenAdapter, Token, TokenStandard, } from '@hyperlane-xyz/sdk';
|
|
4
|
+
import { ProtocolType } from '@hyperlane-xyz/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
|
+
throw new Error(`Unsupported XERC20 protocol type ${token.protocol}`);
|
|
88
|
+
}
|
|
89
|
+
if (token.standard === TokenStandard.EvmHypXERC20 ||
|
|
90
|
+
token.standard === TokenStandard.EvmHypVSXERC20) {
|
|
91
|
+
const adapter = token.getAdapter(warpCore.multiProvider);
|
|
92
|
+
return {
|
|
93
|
+
limits: await getXERC20Limit(token, adapter),
|
|
94
|
+
xERC20Address: (await adapter.getXERC20()).address,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
else if (token.standard === TokenStandard.EvmHypXERC20Lockbox ||
|
|
98
|
+
token.standard === TokenStandard.EvmHypVSXERC20Lockbox) {
|
|
99
|
+
const adapter = token.getAdapter(warpCore.multiProvider);
|
|
100
|
+
return {
|
|
101
|
+
limits: await getXERC20Limit(token, adapter),
|
|
102
|
+
xERC20Address: (await adapter.getXERC20()).address,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`Unsupported XERC20 token standard ${token.standard}`);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Gets xERC20 limits from an adapter.
|
|
109
|
+
*
|
|
110
|
+
* @param token - The token to get limits for
|
|
111
|
+
* @param xerc20 - The xERC20 adapter
|
|
112
|
+
* @returns The xERC20 limits
|
|
113
|
+
*/
|
|
114
|
+
export async function getXERC20Limit(token, xerc20) {
|
|
115
|
+
const [mintCurrent, mintMax, burnCurrent, burnMax] = await Promise.all([
|
|
116
|
+
xerc20.getMintLimit(),
|
|
117
|
+
xerc20.getMintMaxLimit(),
|
|
118
|
+
xerc20.getBurnLimit(),
|
|
119
|
+
xerc20.getBurnMaxLimit(),
|
|
120
|
+
]);
|
|
121
|
+
return {
|
|
122
|
+
mint: formatBigInt(token, mintCurrent),
|
|
123
|
+
mintMax: formatBigInt(token, mintMax),
|
|
124
|
+
burn: formatBigInt(token, burnCurrent),
|
|
125
|
+
burnMax: formatBigInt(token, burnMax),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets a managed lockbox contract instance.
|
|
130
|
+
*
|
|
131
|
+
* @param multiProvider - The multi-protocol provider
|
|
132
|
+
* @param chainName - The chain name
|
|
133
|
+
* @param lockboxAddress - The lockbox contract address
|
|
134
|
+
* @returns The Contract instance
|
|
135
|
+
*/
|
|
136
|
+
export function getManagedLockBox(multiProvider, chainName, lockboxAddress) {
|
|
137
|
+
const provider = multiProvider.getEthersV5Provider(chainName);
|
|
138
|
+
return new Contract(lockboxAddress, MANAGED_LOCKBOX_MINIMAL_ABI, provider);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Gets extra lockbox information for xERC20 tokens.
|
|
142
|
+
*
|
|
143
|
+
* @param multiProvider - The multi-protocol provider
|
|
144
|
+
* @param warpToken - The warp token
|
|
145
|
+
* @param lockboxAddress - The lockbox contract address
|
|
146
|
+
* @returns The xERC20 info for the lockbox
|
|
147
|
+
*/
|
|
148
|
+
export async function getExtraLockboxInfo(multiProvider, warpToken, lockboxAddress) {
|
|
149
|
+
const currentChainProvider = multiProvider.getEthersV5Provider(warpToken.chainName);
|
|
150
|
+
const lockboxInstance = getManagedLockBox(multiProvider, warpToken.chainName, lockboxAddress);
|
|
151
|
+
const xERC20Address = await lockboxInstance['XERC20']();
|
|
152
|
+
const vsXERC20Instance = IXERC20VS__factory.connect(xERC20Address, currentChainProvider);
|
|
153
|
+
const [mintMax, burnMax, mint, burn] = await Promise.all([
|
|
154
|
+
vsXERC20Instance.mintingMaxLimitOf(lockboxAddress),
|
|
155
|
+
vsXERC20Instance.burningMaxLimitOf(lockboxAddress),
|
|
156
|
+
vsXERC20Instance.mintingCurrentLimitOf(lockboxAddress),
|
|
157
|
+
vsXERC20Instance.burningCurrentLimitOf(lockboxAddress),
|
|
158
|
+
]);
|
|
159
|
+
return {
|
|
160
|
+
limits: {
|
|
161
|
+
burn: formatBigInt(warpToken, burn.toBigInt()),
|
|
162
|
+
burnMax: formatBigInt(warpToken, burnMax.toBigInt()),
|
|
163
|
+
mint: formatBigInt(warpToken, mint.toBigInt()),
|
|
164
|
+
mintMax: formatBigInt(warpToken, mintMax.toBigInt()),
|
|
165
|
+
},
|
|
166
|
+
xERC20Address,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Gets the balance of an extra lockbox.
|
|
171
|
+
*
|
|
172
|
+
* @param multiProvider - The multi-protocol provider
|
|
173
|
+
* @param warpToken - The warp token
|
|
174
|
+
* @param tokenPriceGetter - Price getter for calculating USD value
|
|
175
|
+
* @param lockboxAddress - The lockbox contract address
|
|
176
|
+
* @param logger - Logger instance
|
|
177
|
+
* @returns The balance information or undefined if not available
|
|
178
|
+
*/
|
|
179
|
+
export async function getExtraLockboxBalance(multiProvider, warpToken, tokenPriceGetter, lockboxAddress, logger) {
|
|
180
|
+
if (!warpToken.isXerc20()) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
const lockboxInstance = getManagedLockBox(multiProvider, warpToken.chainName, lockboxAddress);
|
|
184
|
+
const erc20TokenAddress = await lockboxInstance['ERC20']();
|
|
185
|
+
const erc20tokenAdapter = new EvmTokenAdapter(warpToken.chainName, multiProvider, {
|
|
186
|
+
token: erc20TokenAddress,
|
|
187
|
+
});
|
|
188
|
+
let balance;
|
|
189
|
+
try {
|
|
190
|
+
balance = await erc20tokenAdapter.getBalance(lockboxAddress);
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
logger.error({
|
|
194
|
+
err,
|
|
195
|
+
chain: warpToken.chainName,
|
|
196
|
+
token: warpToken.symbol,
|
|
197
|
+
lockboxAddress,
|
|
198
|
+
erc20TokenAddress,
|
|
199
|
+
}, 'Failed to get balance for contract at lockbox address');
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
const tokenPrice = await tokenPriceGetter.tryGetTokenPrice(warpToken);
|
|
203
|
+
const balanceNumber = formatBigInt(warpToken, balance);
|
|
204
|
+
return {
|
|
205
|
+
balance: balanceNumber,
|
|
206
|
+
valueUSD: tokenPrice ? balanceNumber * tokenPrice : undefined,
|
|
207
|
+
tokenAddress: erc20TokenAddress,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Gets collateral info for a managed lockbox.
|
|
212
|
+
*
|
|
213
|
+
* @param multiProvider - The multi-protocol provider
|
|
214
|
+
* @param warpToken - The warp token
|
|
215
|
+
* @param lockBoxAddress - The lockbox contract address
|
|
216
|
+
* @returns The token name and address of the collateral
|
|
217
|
+
*/
|
|
218
|
+
export async function getManagedLockBoxCollateralInfo(multiProvider, warpToken, lockBoxAddress) {
|
|
219
|
+
const lockBoxInstance = getManagedLockBox(multiProvider, warpToken.chainName, lockBoxAddress);
|
|
220
|
+
const collateralTokenAddress = await lockBoxInstance['ERC20']();
|
|
221
|
+
const collateralTokenAdapter = new EvmTokenAdapter(warpToken.chainName, multiProvider, {
|
|
222
|
+
token: collateralTokenAddress,
|
|
223
|
+
});
|
|
224
|
+
const { name } = await collateralTokenAdapter.getMetadata();
|
|
225
|
+
return {
|
|
226
|
+
tokenName: name,
|
|
227
|
+
tokenAddress: collateralTokenAddress,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
//# 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,qBAAqB,CAAC;AACzD,OAAO,EAGL,eAAe,EAIf,KAAK,EACL,aAAa,GAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAgB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQlE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,0CAA0C;IAC1C,yCAAyC;CACjC,CAAC;AASX;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,QAAkB,EAClB,KAAY,EACZ,gBAAkC,EAClC,MAAc,EACd,aAAsB;IAEtB,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,CAAC;QACxB,MAAM,CAAC,IAAI,CACT,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,EAC/C,uDAAuD,CACxD,CAAC;QACF,OAAO,SAA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AS;QAC7D,YAAY,EAAE,iBAAiB;KAChC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,aAAoC,EACpC,SAAgB,EAChB,cAAuB;IAEvB,MAAM,eAAe,GAAG,iBAAiB,CACvC,aAAa,EACb,SAAS,CAAC,SAAS,EACnB,cAAc,CACf,CAAC;IAEF,MAAM,sBAAsB,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;IAChE,MAAM,sBAAsB,GAAG,IAAI,eAAe,CAChD,SAAS,CAAC,SAAS,EACnB,aAAa,EACb;QACE,KAAK,EAAE,sBAAsB;KAC9B,CACF,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,sBAAsB,CAAC,WAAW,EAAE,CAAC;IAE5D,OAAO;QACL,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,sBAAsB;KACrC,CAAC;AACJ,CAAC"}
|
package/dist/gauges.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Gauge, type Registry } from 'prom-client';
|
|
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"}
|