@hyperlane-xyz/cli 33.0.0 → 33.0.2
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/bundle/773.index.js +3 -0
- package/bundle/79.index.js +3 -0
- package/bundle/index.js +1392 -682
- package/package.json +15 -15
package/bundle/index.js
CHANGED
|
@@ -672930,6 +672930,9 @@ class AleoProtocolProvider {
|
|
|
672930
672930
|
: new _provablehq_sdk_testnet_js__WEBPACK_IMPORTED_MODULE_1__/* .AleoNetworkClient */ .zX(rpcUrl);
|
|
672931
672931
|
return new _validator_announce_validator_announce_artifact_manager_js__WEBPACK_IMPORTED_MODULE_7__/* .AleoValidatorAnnounceArtifactManager */ .q({ domainId: chainMetadata.domainId, aleoNetworkId }, aleoClient);
|
|
672932
672932
|
}
|
|
672933
|
+
createFeeArtifactManager(_chainMetadata) {
|
|
672934
|
+
return null;
|
|
672935
|
+
}
|
|
672933
672936
|
getMinGas() {
|
|
672934
672937
|
return {
|
|
672935
672938
|
CORE_DEPLOY_GAS: 0n,
|
|
@@ -681796,7 +681799,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
681796
681799
|
/* harmony export */ });
|
|
681797
681800
|
/* unused harmony export getContext */
|
|
681798
681801
|
/* harmony import */ var _inquirer_prompts__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(98720);
|
|
681799
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(
|
|
681802
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(56854);
|
|
681800
681803
|
/* harmony import */ var _hyperlane_xyz_provider_sdk__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(71280);
|
|
681801
681804
|
/* harmony import */ var _hyperlane_xyz_registry_fs__WEBPACK_IMPORTED_MODULE_13__ = __nccwpck_require__(84873);
|
|
681802
681805
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_15__ = __nccwpck_require__(3483);
|
|
@@ -682731,7 +682734,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
682731
682734
|
/* harmony export */ d: () => (/* binding */ validateCoreConfigForAltVM),
|
|
682732
682735
|
/* harmony export */ u: () => (/* reexport safe */ _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__.u_)
|
|
682733
682736
|
/* harmony export */ });
|
|
682734
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(
|
|
682737
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(56854);
|
|
682735
682738
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(38231);
|
|
682736
682739
|
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__]);
|
|
682737
682740
|
_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
@@ -682782,7 +682785,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
682782
682785
|
/* harmony export */ });
|
|
682783
682786
|
/* harmony import */ var yaml__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(10684);
|
|
682784
682787
|
/* harmony import */ var _hyperlane_xyz_core_buildArtifact_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(74119);
|
|
682785
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(
|
|
682788
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(56854);
|
|
682786
682789
|
/* harmony import */ var _hyperlane_xyz_provider_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(71280);
|
|
682787
682790
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(76939);
|
|
682788
682791
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_10__ = __nccwpck_require__(26492);
|
|
@@ -683285,7 +683288,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
683285
683288
|
/* harmony import */ var _inquirer_prompts__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(98720);
|
|
683286
683289
|
/* harmony import */ var yaml__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(10684);
|
|
683287
683290
|
/* harmony import */ var _hyperlane_xyz_core_buildArtifact_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(74119);
|
|
683288
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(
|
|
683291
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(56854);
|
|
683289
683292
|
/* harmony import */ var _hyperlane_xyz_deploy_sdk_AltVMFileSubmitter__WEBPACK_IMPORTED_MODULE_36__ = __nccwpck_require__(49988);
|
|
683290
683293
|
/* harmony import */ var _hyperlane_xyz_provider_sdk__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(71280);
|
|
683291
683294
|
/* harmony import */ var _hyperlane_xyz_provider_sdk_artifact__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(4287);
|
|
@@ -684624,7 +684627,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
684624
684627
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
684625
684628
|
/* harmony export */ C: () => (/* binding */ readHookConfig)
|
|
684626
684629
|
/* harmony export */ });
|
|
684627
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(
|
|
684630
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(56854);
|
|
684628
684631
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(69319);
|
|
684629
684632
|
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(16639);
|
|
684630
684633
|
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(73938);
|
|
@@ -684689,7 +684692,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
684689
684692
|
/* harmony export */ E: () => (/* binding */ runIsmDeploy)
|
|
684690
684693
|
/* harmony export */ });
|
|
684691
684694
|
/* harmony import */ var _hyperlane_xyz_core_buildArtifact_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(74119);
|
|
684692
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(
|
|
684695
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(56854);
|
|
684693
684696
|
/* harmony import */ var _hyperlane_xyz_provider_sdk_ism__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(96426);
|
|
684694
684697
|
/* harmony import */ var _hyperlane_xyz_provider_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(71280);
|
|
684695
684698
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(69352);
|
|
@@ -684833,7 +684836,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
684833
684836
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
684834
684837
|
/* harmony export */ Y: () => (/* binding */ readIsmConfig)
|
|
684835
684838
|
/* harmony export */ });
|
|
684836
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(
|
|
684839
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(56854);
|
|
684837
684840
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(60715);
|
|
684838
684841
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(22887);
|
|
684839
684842
|
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(16639);
|
|
@@ -684953,7 +684956,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
684953
684956
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
684954
684957
|
/* harmony export */ R: () => (/* binding */ executeCoreRead)
|
|
684955
684958
|
/* harmony export */ });
|
|
684956
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(
|
|
684959
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(56854);
|
|
684957
684960
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(80031);
|
|
684958
684961
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(22887);
|
|
684959
684962
|
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(21387);
|
|
@@ -685019,7 +685022,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
685019
685022
|
/* unused harmony exports getWarpRouteConfigsByCore, logXERC20Limits */
|
|
685020
685023
|
/* harmony import */ var ethers__WEBPACK_IMPORTED_MODULE_10__ = __nccwpck_require__(61934);
|
|
685021
685024
|
/* harmony import */ var _hyperlane_xyz_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(50653);
|
|
685022
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(
|
|
685025
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(56854);
|
|
685023
685026
|
/* harmony import */ var _hyperlane_xyz_provider_sdk__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(71280);
|
|
685024
685027
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(40945);
|
|
685025
685028
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(22887);
|
|
@@ -693924,7 +693927,7 @@ __webpack_async_result__();
|
|
|
693924
693927
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
693925
693928
|
/* harmony export */ x: () => (/* binding */ VERSION)
|
|
693926
693929
|
/* harmony export */ });
|
|
693927
|
-
const VERSION = '33.0.
|
|
693930
|
+
const VERSION = '33.0.2';
|
|
693928
693931
|
//# sourceMappingURL=version.js.map
|
|
693929
693932
|
|
|
693930
693933
|
/***/ }),
|
|
@@ -694001,6 +694004,9 @@ class CosmosNativeProtocolProvider {
|
|
|
694001
694004
|
// Cosmos does not support validator announce
|
|
694002
694005
|
return null;
|
|
694003
694006
|
}
|
|
694007
|
+
createFeeArtifactManager(_chainMetadata) {
|
|
694008
|
+
return null;
|
|
694009
|
+
}
|
|
694004
694010
|
getMinGas() {
|
|
694005
694011
|
return {
|
|
694006
694012
|
CORE_DEPLOY_GAS: BigInt(1e6),
|
|
@@ -712049,7 +712055,7 @@ class AltVMFileSubmitter {
|
|
|
712049
712055
|
|
|
712050
712056
|
/***/ }),
|
|
712051
712057
|
|
|
712052
|
-
/***/
|
|
712058
|
+
/***/ 56854:
|
|
712053
712059
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
712054
712060
|
|
|
712055
712061
|
|
|
@@ -712068,7 +712074,7 @@ __nccwpck_require__.d(__webpack_exports__, {
|
|
|
712068
712074
|
mM: () => (/* reexport */ validateIsmConfig)
|
|
712069
712075
|
});
|
|
712070
712076
|
|
|
712071
|
-
// UNUSED EXPORTS: CoreArtifactReader, CoreWriter, HookWriter, IsmWriter, UnsupportedIsmTypeError, WarpTokenReader, WarpTokenWriter, validateIsmType
|
|
712077
|
+
// UNUSED EXPORTS: CoreArtifactReader, CoreWriter, FeeReader, FeeWriter, HookWriter, IsmWriter, UnsupportedIsmTypeError, WarpTokenReader, WarpTokenWriter, createFeeReader, createFeeWriter, validateIsmType
|
|
712072
712078
|
|
|
712073
712079
|
// EXTERNAL MODULE: ../utils/dist/logging.js
|
|
712074
712080
|
var logging = __nccwpck_require__(94523);
|
|
@@ -712115,6 +712121,88 @@ class AltVMJsonRpcSubmitter {
|
|
|
712115
712121
|
//# sourceMappingURL=AltVMJsonRpcSubmitter.js.map
|
|
712116
712122
|
// EXTERNAL MODULE: ../provider-sdk/dist/index.js + 3 modules
|
|
712117
712123
|
var dist = __nccwpck_require__(71280);
|
|
712124
|
+
;// CONCATENATED MODULE: ../deploy-sdk/dist/fee/fee-reader.js
|
|
712125
|
+
|
|
712126
|
+
/**
|
|
712127
|
+
* Factory function to create a FeeReader instance.
|
|
712128
|
+
* Returns null if the protocol does not support fee programs.
|
|
712129
|
+
*
|
|
712130
|
+
* @param chainMetadata Chain metadata for the target chain
|
|
712131
|
+
* @param context Required fee read context with domains and routers to check
|
|
712132
|
+
* @returns A FeeReader instance, or null if the protocol does not support fees
|
|
712133
|
+
*/
|
|
712134
|
+
function createFeeReader(chainMetadata, context) {
|
|
712135
|
+
const protocolProvider = (0,dist/* getProtocolProvider */.IU)(chainMetadata.protocol);
|
|
712136
|
+
const artifactManager = protocolProvider.createFeeArtifactManager(chainMetadata);
|
|
712137
|
+
if (!artifactManager) {
|
|
712138
|
+
return null;
|
|
712139
|
+
}
|
|
712140
|
+
return new FeeReader(artifactManager, context);
|
|
712141
|
+
}
|
|
712142
|
+
/**
|
|
712143
|
+
* Generic Fee Reader that reads fee configurations from on-chain state.
|
|
712144
|
+
*
|
|
712145
|
+
* The FeeReadContext is required at construction time to ensure the reader always
|
|
712146
|
+
* knows which domains and routers to check (some fee contracts are not enumerable).
|
|
712147
|
+
*/
|
|
712148
|
+
class FeeReader {
|
|
712149
|
+
artifactManager;
|
|
712150
|
+
context;
|
|
712151
|
+
constructor(artifactManager, context) {
|
|
712152
|
+
this.artifactManager = artifactManager;
|
|
712153
|
+
this.context = context;
|
|
712154
|
+
}
|
|
712155
|
+
async read(address) {
|
|
712156
|
+
return this.artifactManager.readFee(address, this.context);
|
|
712157
|
+
}
|
|
712158
|
+
}
|
|
712159
|
+
//# sourceMappingURL=fee-reader.js.map
|
|
712160
|
+
;// CONCATENATED MODULE: ../deploy-sdk/dist/fee/fee-writer.js
|
|
712161
|
+
|
|
712162
|
+
|
|
712163
|
+
/**
|
|
712164
|
+
* Factory function to create a FeeWriter instance.
|
|
712165
|
+
* Returns null if the protocol does not support fee programs.
|
|
712166
|
+
*
|
|
712167
|
+
* @param chainMetadata Chain metadata for the target chain
|
|
712168
|
+
* @param signer Signer interface for signing transactions
|
|
712169
|
+
* @param context Required fee read context with domains and routers to check
|
|
712170
|
+
* @returns A FeeWriter instance, or null if the protocol does not support fees
|
|
712171
|
+
*/
|
|
712172
|
+
function createFeeWriter(chainMetadata, signer, context) {
|
|
712173
|
+
const protocolProvider = (0,dist/* getProtocolProvider */.IU)(chainMetadata.protocol);
|
|
712174
|
+
const artifactManager = protocolProvider.createFeeArtifactManager(chainMetadata);
|
|
712175
|
+
if (!artifactManager) {
|
|
712176
|
+
return null;
|
|
712177
|
+
}
|
|
712178
|
+
return new FeeWriter(artifactManager, context, signer);
|
|
712179
|
+
}
|
|
712180
|
+
/**
|
|
712181
|
+
* FeeWriter handles creation and updates of fee configurations using the Artifact API.
|
|
712182
|
+
* It delegates to protocol-specific artifact writers for individual fee types.
|
|
712183
|
+
*
|
|
712184
|
+
* Extends FeeReader to inherit read() functionality.
|
|
712185
|
+
* The FeeReadContext is required at construction time to ensure the reader always
|
|
712186
|
+
* knows which domains and routers to check (some fee contracts are not enumerable).
|
|
712187
|
+
*/
|
|
712188
|
+
class FeeWriter extends FeeReader {
|
|
712189
|
+
signer;
|
|
712190
|
+
constructor(artifactManager, context, signer) {
|
|
712191
|
+
super(artifactManager, context);
|
|
712192
|
+
this.signer = signer;
|
|
712193
|
+
}
|
|
712194
|
+
async create(artifact) {
|
|
712195
|
+
const { config } = artifact;
|
|
712196
|
+
const writer = this.artifactManager.createWriter(config.type, this.signer);
|
|
712197
|
+
return writer.create(artifact);
|
|
712198
|
+
}
|
|
712199
|
+
async update(artifact) {
|
|
712200
|
+
const { config } = artifact;
|
|
712201
|
+
const writer = this.artifactManager.createWriter(config.type, this.signer);
|
|
712202
|
+
return writer.update(artifact);
|
|
712203
|
+
}
|
|
712204
|
+
}
|
|
712205
|
+
//# sourceMappingURL=fee-writer.js.map
|
|
712118
712206
|
// EXTERNAL MODULE: ../provider-sdk/dist/artifact.js
|
|
712119
712207
|
var dist_artifact = __nccwpck_require__(4287);
|
|
712120
712208
|
// EXTERNAL MODULE: ../provider-sdk/dist/hook.js
|
|
@@ -713134,6 +713222,8 @@ class UnsupportedIsmTypeError extends Error {
|
|
|
713134
713222
|
}
|
|
713135
713223
|
}
|
|
713136
713224
|
//# sourceMappingURL=validation.js.map
|
|
713225
|
+
// EXTERNAL MODULE: ../utils/dist/validation.js
|
|
713226
|
+
var validation = __nccwpck_require__(21387);
|
|
713137
713227
|
// EXTERNAL MODULE: ../provider-sdk/dist/warp.js
|
|
713138
713228
|
var warp = __nccwpck_require__(17791);
|
|
713139
713229
|
;// CONCATENATED MODULE: ../deploy-sdk/dist/warp/warp-reader.js
|
|
@@ -713142,6 +713232,8 @@ var warp = __nccwpck_require__(17791);
|
|
|
713142
713232
|
|
|
713143
713233
|
|
|
713144
713234
|
|
|
713235
|
+
|
|
713236
|
+
|
|
713145
713237
|
/**
|
|
713146
713238
|
* Generic Warp Token Reader that can read any warp token type by detecting its type
|
|
713147
713239
|
* and expanding nested ISM artifacts if present.
|
|
@@ -713168,12 +713260,15 @@ class WarpTokenReader {
|
|
|
713168
713260
|
const expandedIsmArtifact = await this.expandIsmArtifact(rawArtifact.config.interchainSecurityModule);
|
|
713169
713261
|
// Expand nested Hook artifact if present
|
|
713170
713262
|
const expandedHookArtifact = await this.expandHookArtifact(hookReader, rawArtifact.config.hook);
|
|
713263
|
+
// Expand nested Fee artifact if present
|
|
713264
|
+
const expandedFeeArtifact = await this.expandFeeArtifact(rawArtifact.config, rawArtifact.config.fee);
|
|
713171
713265
|
return {
|
|
713172
713266
|
...rawArtifact,
|
|
713173
713267
|
config: {
|
|
713174
713268
|
...rawArtifact.config,
|
|
713175
713269
|
interchainSecurityModule: expandedIsmArtifact,
|
|
713176
713270
|
hook: expandedHookArtifact,
|
|
713271
|
+
fee: expandedFeeArtifact,
|
|
713177
713272
|
},
|
|
713178
713273
|
};
|
|
713179
713274
|
}
|
|
@@ -713215,6 +713310,28 @@ class WarpTokenReader {
|
|
|
713215
713310
|
// NEW state should not occur in read artifacts
|
|
713216
713311
|
throw new Error(`Unexpected Hook artifact state 'new' when reading warp token Hook configuration`);
|
|
713217
713312
|
}
|
|
713313
|
+
/**
|
|
713314
|
+
* Expands a Fee artifact by reading it if underived.
|
|
713315
|
+
* Builds FeeReadContext from the warp config's remote routers and CC routers.
|
|
713316
|
+
* Returns undefined only when no feeArtifact is provided. Deployed artifacts
|
|
713317
|
+
* are returned as-is. Underived artifacts are read via the fee reader.
|
|
713318
|
+
* Throws if a fee artifact exists but the protocol has no fee artifact manager.
|
|
713319
|
+
*/
|
|
713320
|
+
async expandFeeArtifact(warpConfig, feeArtifact) {
|
|
713321
|
+
if (!feeArtifact) {
|
|
713322
|
+
return undefined;
|
|
713323
|
+
}
|
|
713324
|
+
if ((0,dist_artifact/* isArtifactDeployed */.R)(feeArtifact)) {
|
|
713325
|
+
return feeArtifact;
|
|
713326
|
+
}
|
|
713327
|
+
if ((0,dist_artifact/* isArtifactUnderived */.l2)(feeArtifact)) {
|
|
713328
|
+
const context = (0,warp/* buildFeeReadContextFromWarpArtifactConfig */.oS)(warpConfig);
|
|
713329
|
+
const feeReader = createFeeReader(this.chainMetadata, context);
|
|
713330
|
+
(0,validation/* assert */.v)(feeReader, `Fee artifact present on warp config but protocol ${this.chainMetadata.protocol} has no fee artifact manager`);
|
|
713331
|
+
return feeReader.read(feeArtifact.deployed.address);
|
|
713332
|
+
}
|
|
713333
|
+
throw new Error(`Unexpected Fee artifact state 'new' when reading warp token Fee configuration`);
|
|
713334
|
+
}
|
|
713218
713335
|
/**
|
|
713219
713336
|
* Backward compatibility method that converts DeployedWarpArtifact to DerivedWarpConfig.
|
|
713220
713337
|
* This allows WarpTokenReader to be used as a drop-in replacement for the old AltVMWarpRouteReader.
|
|
@@ -713245,8 +713362,8 @@ function createWarpTokenReader(chainMetadata, chainLookup) {
|
|
|
713245
713362
|
return new WarpTokenReader(artifactManager, chainMetadata, chainLookup);
|
|
713246
713363
|
}
|
|
713247
713364
|
//# sourceMappingURL=warp-reader.js.map
|
|
713248
|
-
// EXTERNAL MODULE: ../
|
|
713249
|
-
var
|
|
713365
|
+
// EXTERNAL MODULE: ../provider-sdk/dist/fee.js
|
|
713366
|
+
var fee = __nccwpck_require__(26109);
|
|
713250
713367
|
// EXTERNAL MODULE: ../utils/dist/typeof.js
|
|
713251
713368
|
var dist_typeof = __nccwpck_require__(73689);
|
|
713252
713369
|
;// CONCATENATED MODULE: ../deploy-sdk/dist/warp/warp-writer.js
|
|
@@ -713258,6 +713375,9 @@ var dist_typeof = __nccwpck_require__(73689);
|
|
|
713258
713375
|
|
|
713259
713376
|
|
|
713260
713377
|
|
|
713378
|
+
|
|
713379
|
+
|
|
713380
|
+
|
|
713261
713381
|
/**
|
|
713262
713382
|
* Factory function to create a WarpTokenWriter instance.
|
|
713263
713383
|
*
|
|
@@ -713347,6 +713467,25 @@ class WarpTokenWriter extends WarpTokenReader {
|
|
|
713347
713467
|
}
|
|
713348
713468
|
}
|
|
713349
713469
|
}
|
|
713470
|
+
// Deploy Fee if configured as a NEW artifact
|
|
713471
|
+
// No FeeReadContext needed on create - deploying from scratch
|
|
713472
|
+
let onChainFeeArtifact;
|
|
713473
|
+
if (config.fee) {
|
|
713474
|
+
const feeWriter = createFeeWriter(this.chainMetadata, this.signer, {
|
|
713475
|
+
knownRoutersPerDomain: {},
|
|
713476
|
+
});
|
|
713477
|
+
if (!feeWriter) {
|
|
713478
|
+
logging/* rootLogger */.Jk.warn('Fee programs are not supported for this protocol. Fee configuration will be ignored.');
|
|
713479
|
+
}
|
|
713480
|
+
else if ((0,dist_artifact/* isArtifactNew */.v_)(config.fee)) {
|
|
713481
|
+
const [deployedFee, feeReceipts] = await feeWriter.create(config.fee);
|
|
713482
|
+
allReceipts.push(...feeReceipts);
|
|
713483
|
+
onChainFeeArtifact = deployedFee;
|
|
713484
|
+
}
|
|
713485
|
+
else {
|
|
713486
|
+
onChainFeeArtifact = config.fee;
|
|
713487
|
+
}
|
|
713488
|
+
}
|
|
713350
713489
|
// Convert to raw artifact config (flatten nested artifacts)
|
|
713351
713490
|
const rawArtifact = {
|
|
713352
713491
|
artifactState: dist_artifact/* ArtifactState */.O2.NEW,
|
|
@@ -713354,6 +713493,7 @@ class WarpTokenWriter extends WarpTokenReader {
|
|
|
713354
713493
|
...config,
|
|
713355
713494
|
interchainSecurityModule: onChainIsmArtifact,
|
|
713356
713495
|
hook: onChainHookArtifact,
|
|
713496
|
+
fee: onChainFeeArtifact,
|
|
713357
713497
|
},
|
|
713358
713498
|
};
|
|
713359
713499
|
// Delegate to protocol-specific writer
|
|
@@ -713368,6 +713508,7 @@ class WarpTokenWriter extends WarpTokenReader {
|
|
|
713368
713508
|
...artifact.config,
|
|
713369
713509
|
interchainSecurityModule: onChainIsmArtifact,
|
|
713370
713510
|
hook: onChainHookArtifact,
|
|
713511
|
+
fee: onChainFeeArtifact,
|
|
713371
713512
|
},
|
|
713372
713513
|
deployed: deployed.deployed,
|
|
713373
713514
|
},
|
|
@@ -713400,6 +713541,8 @@ class WarpTokenWriter extends WarpTokenReader {
|
|
|
713400
713541
|
(0,dist_artifact/* isArtifactDeployed */.R)(currentArtifact.config.interchainSecurityModule), `Expected Warp Reader to expand the ISM config`);
|
|
713401
713542
|
(0,validation/* assert */.v)((0,dist_typeof/* isNullish */.u)(currentArtifact.config.hook) ||
|
|
713402
713543
|
(0,dist_artifact/* isArtifactDeployed */.R)(currentArtifact.config.hook), `Expected Warp Reader to expand the Hook config`);
|
|
713544
|
+
(0,validation/* assert */.v)((0,dist_typeof/* isNullish */.u)(currentArtifact.config.fee) ||
|
|
713545
|
+
(0,dist_artifact/* isArtifactDeployed */.R)(currentArtifact.config.fee), `Expected Warp Reader to expand the Fee config`);
|
|
713403
713546
|
const updateTxs = [];
|
|
713404
713547
|
// Resolve ISM updates
|
|
713405
713548
|
const expectedIsm = config.interchainSecurityModule;
|
|
@@ -713463,13 +713606,47 @@ class WarpTokenWriter extends WarpTokenReader {
|
|
|
713463
713606
|
else {
|
|
713464
713607
|
onChainHookArtifact = expectedHook;
|
|
713465
713608
|
}
|
|
713466
|
-
//
|
|
713609
|
+
// Resolve Fee updates
|
|
713610
|
+
const expectedFee = config.fee;
|
|
713611
|
+
const currentFee = currentArtifact.config.fee;
|
|
713612
|
+
let onChainFeeArtifact;
|
|
713613
|
+
if (expectedFee && !(0,dist_artifact/* isArtifactUnderived */.l2)(expectedFee)) {
|
|
713614
|
+
const feeContext = (0,warp/* buildFeeReadContextFromWarpArtifactConfig */.oS)(config, currentArtifact.config);
|
|
713615
|
+
const feeWriter = createFeeWriter(this.chainMetadata, this.signer, feeContext);
|
|
713616
|
+
if (!feeWriter) {
|
|
713617
|
+
logging/* rootLogger */.Jk.warn('Fee programs are not supported for this protocol. Fee configuration will be ignored.');
|
|
713618
|
+
onChainFeeArtifact = currentFee;
|
|
713619
|
+
}
|
|
713620
|
+
else {
|
|
713621
|
+
const mergedFeeConfig = (0,fee/* mergeFeeArtifacts */.KA)(currentFee, expectedFee);
|
|
713622
|
+
if ((0,dist_artifact/* isArtifactNew */.v_)(mergedFeeConfig)) {
|
|
713623
|
+
const [deployedFee] = await feeWriter.create(mergedFeeConfig);
|
|
713624
|
+
onChainFeeArtifact = {
|
|
713625
|
+
artifactState: dist_artifact/* ArtifactState */.O2.UNDERIVED,
|
|
713626
|
+
deployed: { address: deployedFee.deployed.address },
|
|
713627
|
+
};
|
|
713628
|
+
}
|
|
713629
|
+
else if ((0,dist_artifact/* isArtifactDeployed */.R)(mergedFeeConfig)) {
|
|
713630
|
+
const txs = await feeWriter.update(mergedFeeConfig);
|
|
713631
|
+
updateTxs.push(...txs);
|
|
713632
|
+
onChainFeeArtifact = {
|
|
713633
|
+
artifactState: dist_artifact/* ArtifactState */.O2.UNDERIVED,
|
|
713634
|
+
deployed: { address: mergedFeeConfig.deployed.address },
|
|
713635
|
+
};
|
|
713636
|
+
}
|
|
713637
|
+
}
|
|
713638
|
+
}
|
|
713639
|
+
else {
|
|
713640
|
+
onChainFeeArtifact = expectedFee;
|
|
713641
|
+
}
|
|
713642
|
+
// Build raw artifact with flattened ISM, Hook, and Fee references
|
|
713467
713643
|
const rawArtifact = {
|
|
713468
713644
|
artifactState: dist_artifact/* ArtifactState */.O2.DEPLOYED,
|
|
713469
713645
|
config: {
|
|
713470
713646
|
...config,
|
|
713471
713647
|
interchainSecurityModule: onChainIsmArtifact,
|
|
713472
713648
|
hook: onChainHookArtifact,
|
|
713649
|
+
fee: onChainFeeArtifact,
|
|
713473
713650
|
},
|
|
713474
713651
|
deployed,
|
|
713475
713652
|
};
|
|
@@ -713496,6 +713673,8 @@ class WarpTokenWriter extends WarpTokenReader {
|
|
|
713496
713673
|
|
|
713497
713674
|
|
|
713498
713675
|
|
|
713676
|
+
|
|
713677
|
+
|
|
713499
713678
|
//# sourceMappingURL=index.js.map
|
|
713500
713679
|
|
|
713501
713680
|
/***/ }),
|
|
@@ -715214,6 +715393,229 @@ function artifactOnChainToAddress(artifact, formatter) {
|
|
|
715214
715393
|
|
|
715215
715394
|
/***/ }),
|
|
715216
715395
|
|
|
715396
|
+
/***/ 26109:
|
|
715397
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
715398
|
+
|
|
715399
|
+
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
715400
|
+
/* harmony export */ AY: () => (/* binding */ feeConfigToArtifact),
|
|
715401
|
+
/* harmony export */ KA: () => (/* binding */ mergeFeeArtifacts),
|
|
715402
|
+
/* harmony export */ X6: () => (/* binding */ feeArtifactToDerivedConfig)
|
|
715403
|
+
/* harmony export */ });
|
|
715404
|
+
/* unused harmony exports FeeStrategyType, FeeType, shouldDeployNewFee */
|
|
715405
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(94523);
|
|
715406
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(73689);
|
|
715407
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(73938);
|
|
715408
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(98474);
|
|
715409
|
+
/* harmony import */ var _artifact_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(4287);
|
|
715410
|
+
|
|
715411
|
+
|
|
715412
|
+
// These fee types model fees as a single contract/program with internal routing,
|
|
715413
|
+
// unlike the EVM implementation where RoutingFee and CrossCollateralRoutingFee
|
|
715414
|
+
// deploy separate fee contracts per destination domain. The upcoming SVM fee
|
|
715415
|
+
// program will handle all routing internally via PDAs within one program, and
|
|
715416
|
+
// these multi-VM types follow that single-entity model to avoid the complexity
|
|
715417
|
+
// of supporting both approaches simultaneously. This will be unified later to
|
|
715418
|
+
// support both models under a single interface.
|
|
715419
|
+
// ====== Strategy Types (shared between Config API and Artifact API) ======
|
|
715420
|
+
const FeeStrategyType = {
|
|
715421
|
+
linear: 'linear',
|
|
715422
|
+
regressive: 'regressive',
|
|
715423
|
+
progressive: 'progressive',
|
|
715424
|
+
offchainQuotedLinear: 'offchainQuotedLinear',
|
|
715425
|
+
};
|
|
715426
|
+
const FeeType = {
|
|
715427
|
+
linear: 'linear',
|
|
715428
|
+
regressive: 'regressive',
|
|
715429
|
+
progressive: 'progressive',
|
|
715430
|
+
offchainQuotedLinear: 'offchainQuotedLinear',
|
|
715431
|
+
routing: 'routing',
|
|
715432
|
+
crossCollateralRouting: 'crossCollateralRouting',
|
|
715433
|
+
};
|
|
715434
|
+
// ====== Config <-> Artifact Conversion ======
|
|
715435
|
+
const feeLogger = _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_1__/* .rootLogger */ .Jk.child({ module: 'fee-config-utils' });
|
|
715436
|
+
function convertRoutesToArtifact(routes, chainLookup) {
|
|
715437
|
+
const result = {};
|
|
715438
|
+
for (const [chainName, strategy] of Object.entries(routes)) {
|
|
715439
|
+
const domainId = chainLookup.getDomainId(chainName);
|
|
715440
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__/* .isNullish */ .u)(domainId)) {
|
|
715441
|
+
feeLogger.warn(`Skipping fee route for unknown chain: ${chainName}. ` +
|
|
715442
|
+
`Chain not found in chain lookup.`);
|
|
715443
|
+
continue;
|
|
715444
|
+
}
|
|
715445
|
+
result[domainId] = strategy;
|
|
715446
|
+
}
|
|
715447
|
+
return result;
|
|
715448
|
+
}
|
|
715449
|
+
function convertCCRoutesToArtifact(routes, chainLookup) {
|
|
715450
|
+
const result = {};
|
|
715451
|
+
for (const [chainName, routerMap] of Object.entries(routes)) {
|
|
715452
|
+
const domainId = chainLookup.getDomainId(chainName);
|
|
715453
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__/* .isNullish */ .u)(domainId)) {
|
|
715454
|
+
feeLogger.warn(`Skipping CC fee route for unknown chain: ${chainName}. ` +
|
|
715455
|
+
`Chain not found in chain lookup.`);
|
|
715456
|
+
continue;
|
|
715457
|
+
}
|
|
715458
|
+
result[domainId] = routerMap;
|
|
715459
|
+
}
|
|
715460
|
+
return result;
|
|
715461
|
+
}
|
|
715462
|
+
function convertRoutesToDerived(routes, chainLookup) {
|
|
715463
|
+
const result = {};
|
|
715464
|
+
for (const [domainIdStr, strategy] of Object.entries(routes)) {
|
|
715465
|
+
const domainId = parseInt(domainIdStr);
|
|
715466
|
+
const chainName = chainLookup.getChainName(domainId);
|
|
715467
|
+
if (!chainName) {
|
|
715468
|
+
feeLogger.warn(`Skipping fee route for unknown domain ID: ${domainId}. ` +
|
|
715469
|
+
`Domain not found in chain lookup.`);
|
|
715470
|
+
continue;
|
|
715471
|
+
}
|
|
715472
|
+
result[chainName] = strategy;
|
|
715473
|
+
}
|
|
715474
|
+
return result;
|
|
715475
|
+
}
|
|
715476
|
+
function convertCCRoutesToDerived(routes, chainLookup) {
|
|
715477
|
+
const result = {};
|
|
715478
|
+
for (const [domainIdStr, routerMap] of Object.entries(routes)) {
|
|
715479
|
+
const domainId = parseInt(domainIdStr);
|
|
715480
|
+
const chainName = chainLookup.getChainName(domainId);
|
|
715481
|
+
if (!chainName) {
|
|
715482
|
+
feeLogger.warn(`Skipping CC fee route for unknown domain ID: ${domainId}. ` +
|
|
715483
|
+
`Domain not found in chain lookup.`);
|
|
715484
|
+
continue;
|
|
715485
|
+
}
|
|
715486
|
+
result[chainName] = routerMap;
|
|
715487
|
+
}
|
|
715488
|
+
return result;
|
|
715489
|
+
}
|
|
715490
|
+
/**
|
|
715491
|
+
* Converts FeeConfig (Config API) to FeeArtifactConfig (Artifact API).
|
|
715492
|
+
* Chain names are converted to domain IDs for routing/CC routing fee types.
|
|
715493
|
+
* Direct fee types (linear, regressive, progressive) are passed through unchanged.
|
|
715494
|
+
*/
|
|
715495
|
+
function feeConfigToArtifact(config, chainLookup) {
|
|
715496
|
+
switch (config.type) {
|
|
715497
|
+
case FeeType.linear:
|
|
715498
|
+
case FeeType.regressive:
|
|
715499
|
+
case FeeType.progressive:
|
|
715500
|
+
case FeeType.offchainQuotedLinear:
|
|
715501
|
+
return {
|
|
715502
|
+
artifactState: _artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .ArtifactState */ .O2.NEW,
|
|
715503
|
+
config,
|
|
715504
|
+
};
|
|
715505
|
+
case FeeType.routing:
|
|
715506
|
+
return {
|
|
715507
|
+
artifactState: _artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .ArtifactState */ .O2.NEW,
|
|
715508
|
+
config: {
|
|
715509
|
+
type: config.type,
|
|
715510
|
+
owner: config.owner,
|
|
715511
|
+
beneficiary: config.beneficiary,
|
|
715512
|
+
routes: convertRoutesToArtifact(config.routes, chainLookup),
|
|
715513
|
+
},
|
|
715514
|
+
};
|
|
715515
|
+
case FeeType.crossCollateralRouting:
|
|
715516
|
+
return {
|
|
715517
|
+
artifactState: _artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .ArtifactState */ .O2.NEW,
|
|
715518
|
+
config: {
|
|
715519
|
+
type: config.type,
|
|
715520
|
+
owner: config.owner,
|
|
715521
|
+
beneficiary: config.beneficiary,
|
|
715522
|
+
routes: convertCCRoutesToArtifact(config.routes, chainLookup),
|
|
715523
|
+
},
|
|
715524
|
+
};
|
|
715525
|
+
default: {
|
|
715526
|
+
const invalidConfig = config;
|
|
715527
|
+
throw new Error(`Unsupported fee type for artifact API: ${JSON.stringify(invalidConfig)}`);
|
|
715528
|
+
}
|
|
715529
|
+
}
|
|
715530
|
+
}
|
|
715531
|
+
/**
|
|
715532
|
+
* Converts a DeployedFeeArtifact to DerivedFeeConfig format.
|
|
715533
|
+
* Domain IDs are converted back to chain names for routing/CC routing fee types.
|
|
715534
|
+
*/
|
|
715535
|
+
function feeArtifactToDerivedConfig(artifact, chainLookup) {
|
|
715536
|
+
const { config } = artifact;
|
|
715537
|
+
const address = artifact.deployed.address;
|
|
715538
|
+
switch (config.type) {
|
|
715539
|
+
case FeeType.linear:
|
|
715540
|
+
case FeeType.regressive:
|
|
715541
|
+
case FeeType.progressive:
|
|
715542
|
+
case FeeType.offchainQuotedLinear:
|
|
715543
|
+
return { ...config, address };
|
|
715544
|
+
case FeeType.routing:
|
|
715545
|
+
return {
|
|
715546
|
+
type: config.type,
|
|
715547
|
+
owner: config.owner,
|
|
715548
|
+
beneficiary: config.beneficiary,
|
|
715549
|
+
routes: convertRoutesToDerived(config.routes, chainLookup),
|
|
715550
|
+
address,
|
|
715551
|
+
};
|
|
715552
|
+
case FeeType.crossCollateralRouting:
|
|
715553
|
+
return {
|
|
715554
|
+
type: config.type,
|
|
715555
|
+
owner: config.owner,
|
|
715556
|
+
beneficiary: config.beneficiary,
|
|
715557
|
+
routes: convertCCRoutesToDerived(config.routes, chainLookup),
|
|
715558
|
+
address,
|
|
715559
|
+
};
|
|
715560
|
+
default: {
|
|
715561
|
+
const invalidConfig = config;
|
|
715562
|
+
throw new Error(`Unhandled fee type: ${JSON.stringify(invalidConfig)}`);
|
|
715563
|
+
}
|
|
715564
|
+
}
|
|
715565
|
+
}
|
|
715566
|
+
/**
|
|
715567
|
+
* Determines if a new fee should be deployed instead of updating the existing one.
|
|
715568
|
+
* Deploy new if fee type changed. For direct types (linear, regressive, progressive),
|
|
715569
|
+
* deploy new if config changed (immutable on EVM - constructor-set params).
|
|
715570
|
+
* Routing/CC routing types are mutable and can be updated in-place.
|
|
715571
|
+
*/
|
|
715572
|
+
function shouldDeployNewFee(actual, expected) {
|
|
715573
|
+
if (actual.type !== expected.type)
|
|
715574
|
+
return true;
|
|
715575
|
+
switch (expected.type) {
|
|
715576
|
+
case FeeType.linear:
|
|
715577
|
+
case FeeType.regressive:
|
|
715578
|
+
case FeeType.progressive:
|
|
715579
|
+
case FeeType.offchainQuotedLinear:
|
|
715580
|
+
return !(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__/* .deepEquals */ .c2)((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .normalizeConfig */ .I)(actual), (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .normalizeConfig */ .I)(expected));
|
|
715581
|
+
case FeeType.routing:
|
|
715582
|
+
case FeeType.crossCollateralRouting:
|
|
715583
|
+
return false;
|
|
715584
|
+
default: {
|
|
715585
|
+
const invalidConfig = expected;
|
|
715586
|
+
throw new Error(`Unhandled fee type in shouldDeployNewFee: ${JSON.stringify(invalidConfig)}`);
|
|
715587
|
+
}
|
|
715588
|
+
}
|
|
715589
|
+
}
|
|
715590
|
+
/**
|
|
715591
|
+
* Merges current on-chain fee artifact with expected fee artifact.
|
|
715592
|
+
* Determines whether to deploy a new fee or update/reuse existing one.
|
|
715593
|
+
*/
|
|
715594
|
+
function mergeFeeArtifacts(currentArtifact, expectedArtifact) {
|
|
715595
|
+
const expectedConfig = expectedArtifact.config;
|
|
715596
|
+
if (!currentArtifact) {
|
|
715597
|
+
return expectedArtifact;
|
|
715598
|
+
}
|
|
715599
|
+
const currentConfig = currentArtifact.config;
|
|
715600
|
+
if (shouldDeployNewFee(currentConfig, expectedConfig)) {
|
|
715601
|
+
return {
|
|
715602
|
+
artifactState: _artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .ArtifactState */ .O2.NEW,
|
|
715603
|
+
config: expectedConfig,
|
|
715604
|
+
};
|
|
715605
|
+
}
|
|
715606
|
+
const deployedAddress = (0,_artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .isArtifactDeployed */ .R)(expectedArtifact)
|
|
715607
|
+
? expectedArtifact.deployed
|
|
715608
|
+
: currentArtifact.deployed;
|
|
715609
|
+
return {
|
|
715610
|
+
artifactState: _artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .ArtifactState */ .O2.DEPLOYED,
|
|
715611
|
+
config: expectedConfig,
|
|
715612
|
+
deployed: deployedAddress,
|
|
715613
|
+
};
|
|
715614
|
+
}
|
|
715615
|
+
//# sourceMappingURL=fee.js.map
|
|
715616
|
+
|
|
715617
|
+
/***/ }),
|
|
715618
|
+
|
|
715217
715619
|
/***/ 77230:
|
|
715218
715620
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
715219
715621
|
|
|
@@ -716076,16 +716478,19 @@ function ismConfigToArtifact(config, chainLookup) {
|
|
|
716076
716478
|
/* harmony export */ Ob: () => (/* binding */ computeCCRouterGasConfigUpdates),
|
|
716077
716479
|
/* harmony export */ aq: () => (/* binding */ computeRemoteRoutersUpdates),
|
|
716078
716480
|
/* harmony export */ ks: () => (/* binding */ TokenType),
|
|
716079
|
-
/* harmony export */ ku: () => (/* binding */ warpConfigToArtifact)
|
|
716481
|
+
/* harmony export */ ku: () => (/* binding */ warpConfigToArtifact),
|
|
716482
|
+
/* harmony export */ oS: () => (/* binding */ buildFeeReadContextFromWarpArtifactConfig)
|
|
716080
716483
|
/* harmony export */ });
|
|
716081
|
-
/* harmony import */ var
|
|
716082
|
-
/* harmony import */ var
|
|
716083
|
-
/* harmony import */ var
|
|
716084
|
-
/* harmony import */ var
|
|
716085
|
-
/* harmony import */ var
|
|
716484
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(73689);
|
|
716485
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(21387);
|
|
716486
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(73938);
|
|
716487
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(93142);
|
|
716488
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(52193);
|
|
716086
716489
|
/* harmony import */ var _artifact_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(4287);
|
|
716087
|
-
/* harmony import */ var
|
|
716088
|
-
/* harmony import */ var
|
|
716490
|
+
/* harmony import */ var _fee_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(26109);
|
|
716491
|
+
/* harmony import */ var _hook_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(77230);
|
|
716492
|
+
/* harmony import */ var _ism_js__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(96426);
|
|
716493
|
+
|
|
716089
716494
|
|
|
716090
716495
|
|
|
716091
716496
|
|
|
@@ -716118,7 +716523,7 @@ function warpConfigToArtifact(config, chainLookup, logger) {
|
|
|
716118
716523
|
}
|
|
716119
716524
|
else {
|
|
716120
716525
|
// ISM config - convert using ismConfigToArtifact
|
|
716121
|
-
ismArtifact = (0,
|
|
716526
|
+
ismArtifact = (0,_ism_js__WEBPACK_IMPORTED_MODULE_3__/* .ismConfigToArtifact */ .HL)(config.interchainSecurityModule, chainLookup);
|
|
716122
716527
|
}
|
|
716123
716528
|
}
|
|
716124
716529
|
// Convert Hook config to artifact if present
|
|
@@ -716130,7 +716535,17 @@ function warpConfigToArtifact(config, chainLookup, logger) {
|
|
|
716130
716535
|
}
|
|
716131
716536
|
else {
|
|
716132
716537
|
// Hook config - convert using hookConfigToArtifact
|
|
716133
|
-
hookArtifact = (0,
|
|
716538
|
+
hookArtifact = (0,_hook_js__WEBPACK_IMPORTED_MODULE_2__/* .hookConfigToArtifact */ .hV)(config.hook, chainLookup);
|
|
716539
|
+
}
|
|
716540
|
+
}
|
|
716541
|
+
// Convert Fee config to artifact if present
|
|
716542
|
+
let feeArtifact;
|
|
716543
|
+
if (config.fee) {
|
|
716544
|
+
if (typeof config.fee === 'string') {
|
|
716545
|
+
feeArtifact = (0,_artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .addressToUnderivedArtifact */ .Se)(config.fee);
|
|
716546
|
+
}
|
|
716547
|
+
else {
|
|
716548
|
+
feeArtifact = (0,_fee_js__WEBPACK_IMPORTED_MODULE_1__/* .feeConfigToArtifact */ .AY)(config.fee, chainLookup);
|
|
716134
716549
|
}
|
|
716135
716550
|
}
|
|
716136
716551
|
// Convert remoteRouters from chain names to domain IDs
|
|
@@ -716138,7 +716553,7 @@ function warpConfigToArtifact(config, chainLookup, logger) {
|
|
|
716138
716553
|
if (config.remoteRouters) {
|
|
716139
716554
|
for (const [chainName, router] of Object.entries(config.remoteRouters)) {
|
|
716140
716555
|
const domainId = chainLookup.getDomainId(chainName);
|
|
716141
|
-
if ((0,
|
|
716556
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(domainId)) {
|
|
716142
716557
|
logger?.warn(`Skipping remote router for unknown chain: ${chainName}. ` +
|
|
716143
716558
|
`Chain not found in chain lookup.`);
|
|
716144
716559
|
continue;
|
|
@@ -716151,7 +716566,7 @@ function warpConfigToArtifact(config, chainLookup, logger) {
|
|
|
716151
716566
|
if (config.destinationGas) {
|
|
716152
716567
|
for (const [chainName, gas] of Object.entries(config.destinationGas)) {
|
|
716153
716568
|
const domainId = chainLookup.getDomainId(chainName);
|
|
716154
|
-
if ((0,
|
|
716569
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(domainId)) {
|
|
716155
716570
|
logger?.warn(`Skipping destination gas for unknown chain: ${chainName}. ` +
|
|
716156
716571
|
`Chain not found in chain lookup.`);
|
|
716157
716572
|
continue;
|
|
@@ -716164,6 +716579,7 @@ function warpConfigToArtifact(config, chainLookup, logger) {
|
|
|
716164
716579
|
mailbox: config.mailbox,
|
|
716165
716580
|
interchainSecurityModule: ismArtifact,
|
|
716166
716581
|
hook: hookArtifact,
|
|
716582
|
+
fee: feeArtifact,
|
|
716167
716583
|
remoteRouters,
|
|
716168
716584
|
destinationGas,
|
|
716169
716585
|
scale: config.scale,
|
|
@@ -716180,9 +716596,9 @@ function warpConfigToArtifact(config, chainLookup, logger) {
|
|
|
716180
716596
|
};
|
|
716181
716597
|
case 'synthetic':
|
|
716182
716598
|
// Validate required fields for synthetic token
|
|
716183
|
-
(0,
|
|
716184
|
-
(0,
|
|
716185
|
-
(0,
|
|
716599
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(config.name, 'name is required for synthetic token deployment');
|
|
716600
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(config.symbol, 'symbol is required for synthetic token deployment');
|
|
716601
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(config.decimals !== undefined, 'decimals is required for synthetic token deployment');
|
|
716186
716602
|
return {
|
|
716187
716603
|
artifactState: _artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .ArtifactState */ .O2.NEW,
|
|
716188
716604
|
config: {
|
|
@@ -716252,35 +716668,48 @@ function warpArtifactToDerivedConfig(artifact, chainLookup) {
|
|
|
716252
716668
|
destinationGas[chainName] = gas;
|
|
716253
716669
|
}
|
|
716254
716670
|
// Convert ISM artifact to config if present
|
|
716255
|
-
(0,
|
|
716671
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(config.interchainSecurityModule) ||
|
|
716256
716672
|
!(0,_artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .isArtifactNew */ .v_)(config.interchainSecurityModule), 'Expected ISM to be a deployed or underived artifact');
|
|
716257
716673
|
let ismConfig;
|
|
716258
|
-
if ((0,
|
|
716674
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(config.interchainSecurityModule)) {
|
|
716259
716675
|
ismConfig = '0x0000000000000000000000000000000000000000';
|
|
716260
716676
|
}
|
|
716261
716677
|
else if ((0,_artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .isArtifactDeployed */ .R)(config.interchainSecurityModule)) {
|
|
716262
|
-
ismConfig = (0,
|
|
716678
|
+
ismConfig = (0,_ism_js__WEBPACK_IMPORTED_MODULE_3__/* .ismArtifactToDerivedConfig */ .co)(config.interchainSecurityModule, chainLookup);
|
|
716263
716679
|
}
|
|
716264
716680
|
else {
|
|
716265
716681
|
ismConfig = config.interchainSecurityModule.deployed.address;
|
|
716266
716682
|
}
|
|
716267
716683
|
// Convert hook artifact to config if present
|
|
716268
|
-
(0,
|
|
716684
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(config.hook) || !(0,_artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .isArtifactNew */ .v_)(config.hook), 'Expected hook to be a deployed or underived artifact');
|
|
716269
716685
|
let hookConfig;
|
|
716270
|
-
if ((0,
|
|
716686
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(config.hook)) {
|
|
716271
716687
|
hookConfig = '0x0000000000000000000000000000000000000000';
|
|
716272
716688
|
}
|
|
716273
716689
|
else if ((0,_artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .isArtifactDeployed */ .R)(config.hook)) {
|
|
716274
|
-
hookConfig = (0,
|
|
716690
|
+
hookConfig = (0,_hook_js__WEBPACK_IMPORTED_MODULE_2__/* .hookArtifactToDerivedConfig */ .q6)(config.hook, chainLookup);
|
|
716275
716691
|
}
|
|
716276
716692
|
else {
|
|
716277
716693
|
hookConfig = config.hook.deployed.address;
|
|
716278
716694
|
}
|
|
716695
|
+
// Convert fee artifact to config if present
|
|
716696
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(config.fee) || !(0,_artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .isArtifactNew */ .v_)(config.fee), 'Expected fee to be a deployed or underived artifact');
|
|
716697
|
+
let feeConfig;
|
|
716698
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(config.fee)) {
|
|
716699
|
+
feeConfig = undefined;
|
|
716700
|
+
}
|
|
716701
|
+
else if ((0,_artifact_js__WEBPACK_IMPORTED_MODULE_0__/* .isArtifactDeployed */ .R)(config.fee)) {
|
|
716702
|
+
feeConfig = (0,_fee_js__WEBPACK_IMPORTED_MODULE_1__/* .feeArtifactToDerivedConfig */ .X6)(config.fee, chainLookup);
|
|
716703
|
+
}
|
|
716704
|
+
else {
|
|
716705
|
+
feeConfig = config.fee.deployed.address;
|
|
716706
|
+
}
|
|
716279
716707
|
const baseDerivedConfig = {
|
|
716280
716708
|
owner: config.owner,
|
|
716281
716709
|
mailbox: config.mailbox,
|
|
716282
716710
|
interchainSecurityModule: ismConfig,
|
|
716283
716711
|
hook: hookConfig,
|
|
716712
|
+
fee: feeConfig,
|
|
716284
716713
|
remoteRouters,
|
|
716285
716714
|
destinationGas,
|
|
716286
716715
|
name: config.name,
|
|
@@ -716326,7 +716755,7 @@ function convertCrossCollateralRoutersToArtifact(crossCollateralRouters, chainLo
|
|
|
716326
716755
|
return result;
|
|
716327
716756
|
for (const [chainName, routers] of Object.entries(crossCollateralRouters)) {
|
|
716328
716757
|
const domainId = chainLookup.getDomainId(chainName);
|
|
716329
|
-
if ((0,
|
|
716758
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(domainId)) {
|
|
716330
716759
|
logger?.warn(`Skipping cross-collateral routers for unknown chain: ${chainName}. ` +
|
|
716331
716760
|
`Chain not found in chain lookup.`);
|
|
716332
716761
|
continue;
|
|
@@ -716346,6 +716775,31 @@ function convertCrossCollateralRoutersToDerived(crossCollateralRouters, chainLoo
|
|
|
716346
716775
|
}
|
|
716347
716776
|
return result;
|
|
716348
716777
|
}
|
|
716778
|
+
// Fee Read Context Utilities
|
|
716779
|
+
/**
|
|
716780
|
+
* Builds a FeeReadContext by unioning domains/routers from the provided
|
|
716781
|
+
* WarpArtifactConfigs. Pass both expected and current configs so the fee
|
|
716782
|
+
* reader can discover routes from current state (for cleanup) and expected
|
|
716783
|
+
* state (for setup).
|
|
716784
|
+
*/
|
|
716785
|
+
function buildFeeReadContextFromWarpArtifactConfig(...configs) {
|
|
716786
|
+
const knownRoutersPerDomain = {};
|
|
716787
|
+
for (const config of configs) {
|
|
716788
|
+
for (const [domainStr, router] of Object.entries(config.remoteRouters)) {
|
|
716789
|
+
const domain = Number(domainStr);
|
|
716790
|
+
const existing = knownRoutersPerDomain[domain] ?? new Set();
|
|
716791
|
+
knownRoutersPerDomain[domain] = new Set([...existing, router.address]);
|
|
716792
|
+
}
|
|
716793
|
+
if (config.type === TokenType.crossCollateral) {
|
|
716794
|
+
for (const [domainStr, routers] of Object.entries(config.crossCollateralRouters)) {
|
|
716795
|
+
const domain = Number(domainStr);
|
|
716796
|
+
const existing = knownRoutersPerDomain[domain] ?? new Set();
|
|
716797
|
+
knownRoutersPerDomain[domain] = new Set([...existing, ...routers]);
|
|
716798
|
+
}
|
|
716799
|
+
}
|
|
716800
|
+
}
|
|
716801
|
+
return { knownRoutersPerDomain };
|
|
716802
|
+
}
|
|
716349
716803
|
/**
|
|
716350
716804
|
* Computes which routers need enrollment/unenrollment by diffing current and expected configs.
|
|
716351
716805
|
* Pure function - compares router addresses and destination gas to determine required updates.
|
|
@@ -716370,7 +716824,7 @@ function computeRemoteRoutersUpdates(currentRoutersConfig, expectedRoutersConfig
|
|
|
716370
716824
|
for (const [domainIdStr, expectedRemoteRouter] of Object.entries(expectedRoutersConfig.remoteRouters)) {
|
|
716371
716825
|
const domainId = parseInt(domainIdStr);
|
|
716372
716826
|
const expectedDestinationGas = expectedRoutersConfig.destinationGas[domainId];
|
|
716373
|
-
(0,
|
|
716827
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(!(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(expectedDestinationGas), `Missing destination gas for domain ${domainId} in expected router configuration`);
|
|
716374
716828
|
const currentRouterAddress = Object.prototype.hasOwnProperty.call(currentRoutersConfig.remoteRouters, domainId)
|
|
716375
716829
|
? currentRoutersConfig.remoteRouters[domainId].address
|
|
716376
716830
|
: undefined;
|
|
@@ -716395,18 +716849,18 @@ function computeRemoteRoutersUpdates(currentRoutersConfig, expectedRoutersConfig
|
|
|
716395
716849
|
* hex32 before comparison so callers don't need to normalize beforehand.
|
|
716396
716850
|
*/
|
|
716397
716851
|
function computeCrossCollateralRouterUpdates(current, expected) {
|
|
716398
|
-
const canonicalize = (routers) => (0,
|
|
716852
|
+
const canonicalize = (routers) => (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_6__/* .objMap */ .Yp)(routers, (_domain, routerSet) => new Set([...routerSet].map((r) => (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_7__/* .addressToBytes32 */ .In)(r).toLowerCase())));
|
|
716399
716853
|
const canonicalCurrent = canonicalize(current);
|
|
716400
716854
|
const canonicalExpected = canonicalize(expected);
|
|
716401
716855
|
const toUnenroll = {};
|
|
716402
716856
|
for (const [domainStr, currentSet] of Object.entries(canonicalCurrent)) {
|
|
716403
716857
|
const domain = Number(domainStr);
|
|
716404
716858
|
const expectedSet = canonicalExpected[domain];
|
|
716405
|
-
if ((0,
|
|
716859
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .isNullish */ .u)(expectedSet) || expectedSet.size === 0) {
|
|
716406
716860
|
toUnenroll[domain] = null;
|
|
716407
716861
|
}
|
|
716408
716862
|
else {
|
|
716409
|
-
const removed = (0,
|
|
716863
|
+
const removed = (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_8__/* .difference */ .iv)(currentSet, expectedSet);
|
|
716410
716864
|
if (removed.size > 0) {
|
|
716411
716865
|
toUnenroll[domain] = removed;
|
|
716412
716866
|
}
|
|
@@ -716416,7 +716870,7 @@ function computeCrossCollateralRouterUpdates(current, expected) {
|
|
|
716416
716870
|
for (const [domainStr, expectedSet] of Object.entries(canonicalExpected)) {
|
|
716417
716871
|
const domain = Number(domainStr);
|
|
716418
716872
|
const currentSet = canonicalCurrent[domain] ?? new Set();
|
|
716419
|
-
const added = (0,
|
|
716873
|
+
const added = (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_8__/* .difference */ .iv)(expectedSet, currentSet);
|
|
716420
716874
|
if (added.size > 0) {
|
|
716421
716875
|
toEnroll[domain] = added;
|
|
716422
716876
|
}
|
|
@@ -716525,6 +716979,9 @@ class RadixProtocolProvider {
|
|
|
716525
716979
|
const { gateway, base } = this.configureNetworkConnection(chainMetadata);
|
|
716526
716980
|
return new _validator_announce_validator_announce_artifact_manager_js__WEBPACK_IMPORTED_MODULE_6__/* .RadixValidatorAnnounceArtifactManager */ .x(gateway, base);
|
|
716527
716981
|
}
|
|
716982
|
+
createFeeArtifactManager(_chainMetadata) {
|
|
716983
|
+
return null;
|
|
716984
|
+
}
|
|
716528
716985
|
getMinGas() {
|
|
716529
716986
|
return {
|
|
716530
716987
|
CORE_DEPLOY_GAS: 0n,
|
|
@@ -734619,7 +735076,7 @@ class LiFiBridge {
|
|
|
734619
735076
|
slippage: (params.slippage ?? this.config.defaultSlippage ?? 0.005)
|
|
734620
735077
|
.toFixed(4)
|
|
734621
735078
|
.replace(/\.?0+$/, ''),
|
|
734622
|
-
order: '
|
|
735079
|
+
order: 'RECOMMENDED',
|
|
734623
735080
|
integrator: this.config.integrator,
|
|
734624
735081
|
});
|
|
734625
735082
|
if (this.config.apiKey) {
|
|
@@ -735381,23 +735838,24 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
735381
735838
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
735382
735839
|
/* harmony export */ c: () => (/* binding */ InventoryRebalancer)
|
|
735383
735840
|
/* harmony export */ });
|
|
735384
|
-
/* harmony import */ var
|
|
735385
|
-
/* harmony import */ var
|
|
735386
|
-
/* harmony import */ var
|
|
735387
|
-
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(95778);
|
|
735388
|
-
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(54194);
|
|
735841
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(4879);
|
|
735842
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(95778);
|
|
735843
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(54194);
|
|
735389
735844
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_12__ = __nccwpck_require__(25047);
|
|
735390
735845
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_13__ = __nccwpck_require__(71598);
|
|
735391
735846
|
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_14__ = __nccwpck_require__(59942);
|
|
735392
|
-
/* harmony import */ var
|
|
735393
|
-
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(
|
|
735394
|
-
/* harmony import */ var
|
|
735395
|
-
/* harmony import */ var
|
|
735847
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(21387);
|
|
735848
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(39196);
|
|
735849
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_10__ = __nccwpck_require__(16639);
|
|
735850
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_11__ = __nccwpck_require__(93142);
|
|
735851
|
+
/* harmony import */ var _utils_gasEstimation_js__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(47560);
|
|
735396
735852
|
/* harmony import */ var _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(46618);
|
|
735397
735853
|
/* harmony import */ var _utils_solanaKeyParser_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(20162);
|
|
735398
|
-
/* harmony import */ var
|
|
735399
|
-
var
|
|
735400
|
-
([_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__,
|
|
735854
|
+
/* harmony import */ var _utils_transactionUtils_js__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(32581);
|
|
735855
|
+
/* harmony import */ var _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(11369);
|
|
735856
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__, _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__, _utils_transactionUtils_js__WEBPACK_IMPORTED_MODULE_9__]);
|
|
735857
|
+
([_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__, _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__, _utils_transactionUtils_js__WEBPACK_IMPORTED_MODULE_9__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
735858
|
+
|
|
735401
735859
|
|
|
735402
735860
|
|
|
735403
735861
|
|
|
@@ -735421,6 +735879,46 @@ const GAS_COST_MULTIPLIER = 20n;
|
|
|
735421
735879
|
* If gas exceeds this threshold, the bridge is not economically worthwhile.
|
|
735422
735880
|
*/
|
|
735423
735881
|
const MAX_GAS_PERCENT_THRESHOLD = 10n;
|
|
735882
|
+
const RECOVERABLE_MAX_TRANSFER_ERROR_MESSAGES = [
|
|
735883
|
+
'balance may be insufficient',
|
|
735884
|
+
'transfer amount exceeds balance',
|
|
735885
|
+
'insufficient balance',
|
|
735886
|
+
];
|
|
735887
|
+
function hasRecoverableMaxTransferErrorMessage(message) {
|
|
735888
|
+
const normalized = message.toLowerCase();
|
|
735889
|
+
return (normalized.includes('unpredictable_gas_limit') ||
|
|
735890
|
+
RECOVERABLE_MAX_TRANSFER_ERROR_MESSAGES.some((pattern) => normalized.includes(pattern)));
|
|
735891
|
+
}
|
|
735892
|
+
function isRecoverableMaxTransferProbeError(error) {
|
|
735893
|
+
const seen = new Set();
|
|
735894
|
+
const stack = [error];
|
|
735895
|
+
while (stack.length > 0) {
|
|
735896
|
+
const current = stack.pop();
|
|
735897
|
+
if (current == null)
|
|
735898
|
+
continue;
|
|
735899
|
+
if (typeof current === 'string') {
|
|
735900
|
+
if (hasRecoverableMaxTransferErrorMessage(current))
|
|
735901
|
+
return true;
|
|
735902
|
+
continue;
|
|
735903
|
+
}
|
|
735904
|
+
if (typeof current !== 'object')
|
|
735905
|
+
continue;
|
|
735906
|
+
if (seen.has(current))
|
|
735907
|
+
continue;
|
|
735908
|
+
seen.add(current);
|
|
735909
|
+
const candidate = current;
|
|
735910
|
+
if (typeof candidate.code === 'string' &&
|
|
735911
|
+
candidate.code.toUpperCase() === 'UNPREDICTABLE_GAS_LIMIT') {
|
|
735912
|
+
return true;
|
|
735913
|
+
}
|
|
735914
|
+
if (typeof candidate.message === 'string' &&
|
|
735915
|
+
hasRecoverableMaxTransferErrorMessage(candidate.message)) {
|
|
735916
|
+
return true;
|
|
735917
|
+
}
|
|
735918
|
+
stack.push(candidate.cause, candidate.error);
|
|
735919
|
+
}
|
|
735920
|
+
return false;
|
|
735921
|
+
}
|
|
735424
735922
|
/**
|
|
735425
735923
|
* Executes inventory-based rebalances for chains that don't support MovableCollateralRouter.
|
|
735426
735924
|
*
|
|
@@ -735507,10 +736005,10 @@ class InventoryRebalancer {
|
|
|
735507
736005
|
if (!inventoryChainSet.has(token.chainName)) {
|
|
735508
736006
|
continue;
|
|
735509
736007
|
}
|
|
735510
|
-
if (!
|
|
736008
|
+
if (!_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_3__/* .TOKEN_COLLATERALIZED_STANDARDS */ .PP.includes(token.standard)) {
|
|
735511
736009
|
throw new Error(`InventoryRebalancer cannot be used with synthetic token on chain "${token.chainName}". ` +
|
|
735512
736010
|
`Token standard "${token.standard}" is not collateral-backed. ` +
|
|
735513
|
-
`Only collateral-backed standards are supported: ${
|
|
736011
|
+
`Only collateral-backed standards are supported: ${_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_3__/* .TOKEN_COLLATERALIZED_STANDARDS */ .PP.join(', ')}`);
|
|
735514
736012
|
}
|
|
735515
736013
|
}
|
|
735516
736014
|
}
|
|
@@ -735522,14 +736020,14 @@ class InventoryRebalancer {
|
|
|
735522
736020
|
}
|
|
735523
736021
|
getProtocolForChain(chainName) {
|
|
735524
736022
|
const metadata = this.warpCore.multiProvider.getChainMetadata?.(chainName) ?? undefined;
|
|
735525
|
-
(0,
|
|
735526
|
-
(0,
|
|
736023
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(metadata, `No chain metadata found for chain ${chainName}`);
|
|
736024
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(metadata.protocol, `No protocol type in metadata for chain ${chainName}`);
|
|
735527
736025
|
return metadata.protocol;
|
|
735528
736026
|
}
|
|
735529
736027
|
getInventorySignerAddress(chainName) {
|
|
735530
736028
|
const protocol = this.getProtocolForChain(chainName);
|
|
735531
736029
|
const signerConfig = this.config.inventorySigners[protocol];
|
|
735532
|
-
(0,
|
|
736030
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(signerConfig?.address, `Missing inventory signer address for protocol ${protocol} (chain ${chainName})`);
|
|
735533
736031
|
return signerConfig.address;
|
|
735534
736032
|
}
|
|
735535
736033
|
/**
|
|
@@ -735569,6 +736067,9 @@ class InventoryRebalancer {
|
|
|
735569
736067
|
}
|
|
735570
736068
|
return total;
|
|
735571
736069
|
}
|
|
736070
|
+
formatLocalAmount(amount, token) {
|
|
736071
|
+
return (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .fromWei */ .kX)(amount.toString(), token.decimals);
|
|
736072
|
+
}
|
|
735572
736073
|
/**
|
|
735573
736074
|
* Get the effective available inventory for a chain, accounting for
|
|
735574
736075
|
* inventory already consumed during this execution cycle.
|
|
@@ -735751,45 +736252,96 @@ class InventoryRebalancer {
|
|
|
735751
736252
|
this.logger.info({
|
|
735752
736253
|
strategyRoute: `${origin} (surplus) → ${destination} (deficit)`,
|
|
735753
736254
|
executionRoute: `transferRemote FROM ${destination} TO ${origin}`,
|
|
735754
|
-
|
|
736255
|
+
canonicalAmount: amount.toString(),
|
|
735755
736256
|
intentId: intent.id,
|
|
735756
736257
|
}, 'Executing inventory route');
|
|
736258
|
+
const sourceToken = this.getTokenForChain(destination);
|
|
736259
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(sourceToken, `No token found for source chain: ${destination}`);
|
|
736260
|
+
const requestedLocalAmount = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__/* .denormalizeToLocal */ .bK)(amount, sourceToken);
|
|
736261
|
+
const executionSender = this.getInventorySignerAddress(destination);
|
|
736262
|
+
const executionRecipient = this.getInventorySignerAddress(origin);
|
|
735757
736263
|
// Check available inventory on the DESTINATION (deficit) chain
|
|
735758
736264
|
// We need inventory here because transferRemote is called FROM this chain
|
|
735759
736265
|
const availableInventory = this.getEffectiveAvailableInventory(destination);
|
|
735760
736266
|
this.logger.info({
|
|
735761
736267
|
checkingChain: destination,
|
|
735762
736268
|
availableInventory: availableInventory.toString(),
|
|
735763
|
-
|
|
735764
|
-
requiredAmount:
|
|
735765
|
-
|
|
736269
|
+
availableInventoryFormatted: this.formatLocalAmount(availableInventory, sourceToken),
|
|
736270
|
+
requiredAmount: requestedLocalAmount.toString(),
|
|
736271
|
+
requiredAmountFormatted: this.formatLocalAmount(requestedLocalAmount, sourceToken),
|
|
735766
736272
|
}, 'Checking effective inventory on destination (deficit) chain');
|
|
735767
736273
|
// Calculate transfer costs including max transferable and min viable amounts
|
|
735768
736274
|
// transferRemote is called FROM destination TO origin (swapped direction)
|
|
735769
|
-
const costs = await (0,
|
|
736275
|
+
const costs = await (0,_utils_gasEstimation_js__WEBPACK_IMPORTED_MODULE_6__/* .calculateTransferCosts */ ._P)(destination, // FROM chain (where transferRemote is called)
|
|
735770
736276
|
origin, // TO chain (where Hyperlane message goes)
|
|
735771
|
-
availableInventory,
|
|
735772
|
-
const {
|
|
736277
|
+
availableInventory, requestedLocalAmount, this.multiProvider, this.warpCore.multiProvider, this.getTokenForChain.bind(this), executionSender, _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .isNativeTokenStandard */ .OJ, this.logger);
|
|
736278
|
+
const { minViableTransfer } = costs;
|
|
736279
|
+
let maxTransferable = costs.maxTransferable;
|
|
736280
|
+
if (!(0,_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .isNativeTokenStandard */ .OJ)(sourceToken.standard)) {
|
|
736281
|
+
if (availableInventory === 0n) {
|
|
736282
|
+
maxTransferable = 0n;
|
|
736283
|
+
this.logger.debug({
|
|
736284
|
+
fromChain: destination,
|
|
736285
|
+
toChain: origin,
|
|
736286
|
+
requestedAmount: requestedLocalAmount.toString(),
|
|
736287
|
+
}, 'Skipping fee-aware max transferable probe because destination inventory is zero');
|
|
736288
|
+
}
|
|
736289
|
+
else {
|
|
736290
|
+
try {
|
|
736291
|
+
const feeAwareMaxTransfer = await this.warpCore.getMaxTransferAmount({
|
|
736292
|
+
balance: sourceToken.amount(availableInventory),
|
|
736293
|
+
destination: origin,
|
|
736294
|
+
sender: executionSender,
|
|
736295
|
+
recipient: executionRecipient,
|
|
736296
|
+
});
|
|
736297
|
+
maxTransferable =
|
|
736298
|
+
feeAwareMaxTransfer.amount < requestedLocalAmount
|
|
736299
|
+
? feeAwareMaxTransfer.amount
|
|
736300
|
+
: requestedLocalAmount;
|
|
736301
|
+
this.logger.debug({
|
|
736302
|
+
fromChain: destination,
|
|
736303
|
+
toChain: origin,
|
|
736304
|
+
availableInventory: availableInventory.toString(),
|
|
736305
|
+
requestedAmount: requestedLocalAmount.toString(),
|
|
736306
|
+
feeAwareMaxTransferable: maxTransferable.toString(),
|
|
736307
|
+
}, 'Calculated fee-aware max transferable amount for non-native route');
|
|
736308
|
+
}
|
|
736309
|
+
catch (error) {
|
|
736310
|
+
if (!isRecoverableMaxTransferProbeError(error)) {
|
|
736311
|
+
throw error;
|
|
736312
|
+
}
|
|
736313
|
+
maxTransferable = 0n;
|
|
736314
|
+
this.logger.warn({
|
|
736315
|
+
fromChain: destination,
|
|
736316
|
+
toChain: origin,
|
|
736317
|
+
availableInventory: availableInventory.toString(),
|
|
736318
|
+
requestedAmount: requestedLocalAmount.toString(),
|
|
736319
|
+
error: error instanceof Error ? error.message : String(error),
|
|
736320
|
+
intentId: intent.id,
|
|
736321
|
+
}, 'Fee-aware max transferable probe failed due to insufficient balance, falling back to external bridge');
|
|
736322
|
+
}
|
|
736323
|
+
}
|
|
736324
|
+
}
|
|
735773
736325
|
// Calculate total inventory across all chains
|
|
735774
736326
|
// Note: consumedInventory tracking is handled separately within this cycle
|
|
735775
736327
|
const totalInventory = this.getTotalInventory([]);
|
|
735776
736328
|
this.logger.info({
|
|
735777
736329
|
fromChain: destination,
|
|
735778
736330
|
toChain: origin,
|
|
735779
|
-
|
|
735780
|
-
|
|
735781
|
-
|
|
735782
|
-
|
|
735783
|
-
|
|
735784
|
-
canFullyFulfill: maxTransferable >= amount,
|
|
736331
|
+
availableInventoryFormatted: this.formatLocalAmount(availableInventory, sourceToken),
|
|
736332
|
+
requestedAmountFormatted: this.formatLocalAmount(requestedLocalAmount, sourceToken),
|
|
736333
|
+
maxTransferableFormatted: this.formatLocalAmount(maxTransferable, sourceToken),
|
|
736334
|
+
minViableTransferFormatted: this.formatLocalAmount(minViableTransfer, sourceToken),
|
|
736335
|
+
canFullyFulfill: maxTransferable >= requestedLocalAmount,
|
|
735785
736336
|
canPartialFulfill: maxTransferable >= minViableTransfer,
|
|
736337
|
+
totalInventory: totalInventory.toString(),
|
|
735786
736338
|
}, 'Calculated max transferable amount with cost-based threshold');
|
|
735787
736339
|
// Early exit: If remaining amount is below minViableTransfer, complete the intent
|
|
735788
736340
|
// This prevents infinite loops when the remaining amount is too small to economically bridge
|
|
735789
|
-
if (
|
|
736341
|
+
if (requestedLocalAmount < minViableTransfer) {
|
|
735790
736342
|
this.logger.info({
|
|
735791
736343
|
intentId: intent.id,
|
|
735792
|
-
amount:
|
|
736344
|
+
amount: requestedLocalAmount.toString(),
|
|
735793
736345
|
minViableTransfer: minViableTransfer.toString(),
|
|
735794
736346
|
}, 'Remaining amount below minViableTransfer, completing intent with acceptable loss');
|
|
735795
736347
|
await this.actionTracker.completeRebalanceIntent(intent.id);
|
|
@@ -735805,156 +736357,199 @@ class InventoryRebalancer {
|
|
|
735805
736357
|
...route,
|
|
735806
736358
|
origin: destination, // transferRemote called FROM here
|
|
735807
736359
|
destination: origin, // Hyperlane message goes TO here
|
|
736360
|
+
amount: requestedLocalAmount,
|
|
735808
736361
|
};
|
|
735809
|
-
if (maxTransferable >=
|
|
736362
|
+
if (maxTransferable >= requestedLocalAmount) {
|
|
735810
736363
|
// Sufficient inventory on destination - execute transferRemote directly
|
|
735811
|
-
const
|
|
736364
|
+
const fulfilledCanonicalAmount = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__/* .normalizeToCanonical */ .R2)(requestedLocalAmount, sourceToken);
|
|
736365
|
+
const result = await this.executeTransferRemote(swappedRoute, intent, fulfilledCanonicalAmount);
|
|
735812
736366
|
// Return original strategy route in result (not the swapped execution route)
|
|
735813
736367
|
return { ...result, route };
|
|
735814
736368
|
}
|
|
735815
736369
|
else if (maxTransferable > 0n && maxTransferable >= minViableTransfer) {
|
|
735816
736370
|
// Partial transfer: Transfer available inventory when economically viable
|
|
735817
|
-
const
|
|
735818
|
-
|
|
735819
|
-
|
|
735820
|
-
};
|
|
735821
|
-
const result = await this.executeTransferRemote(partialSwappedRoute, intent, costs.gasQuote);
|
|
735822
|
-
this.logger.info({
|
|
735823
|
-
intentId: intent.id,
|
|
735824
|
-
partialAmount: maxTransferable.toString(),
|
|
735825
|
-
requestedAmount: amount.toString(),
|
|
735826
|
-
remainingAmount: (amount - maxTransferable).toString(),
|
|
735827
|
-
}, 'Executed partial inventory deposit, remaining will be handled in future cycles');
|
|
735828
|
-
// Return original strategy route in result (not the swapped execution route)
|
|
735829
|
-
return { ...result, route };
|
|
735830
|
-
}
|
|
735831
|
-
else {
|
|
735832
|
-
// Inventory below cost-based threshold - trigger ExternalBridge movement TO destination chain
|
|
735833
|
-
this.logger.info({
|
|
735834
|
-
targetChain: destination,
|
|
735835
|
-
maxTransferable: maxTransferable.toString(),
|
|
735836
|
-
minViableTransfer: minViableTransfer.toString(),
|
|
735837
|
-
costMultiplier: _utils_gasEstimation_js__WEBPACK_IMPORTED_MODULE_4__/* .MIN_VIABLE_COST_MULTIPLIER */ .hh.toString(),
|
|
735838
|
-
intentId: intent.id,
|
|
735839
|
-
}, 'Inventory below cost-based threshold on destination, triggering LiFi movement');
|
|
735840
|
-
// Get all available source chains with raw inventory
|
|
735841
|
-
const allSources = this.selectAllSourceChains(destination);
|
|
735842
|
-
if (allSources.length === 0) {
|
|
735843
|
-
this.logger.warn({
|
|
735844
|
-
origin,
|
|
735845
|
-
destination,
|
|
735846
|
-
amount: amount.toString(),
|
|
736371
|
+
const alignedExecution = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__/* .alignLocalToCanonical */ .gU)(maxTransferable, sourceToken);
|
|
736372
|
+
if (alignedExecution.messageAmount === 0n) {
|
|
736373
|
+
this.logger.info({
|
|
735847
736374
|
intentId: intent.id,
|
|
735848
|
-
|
|
735849
|
-
|
|
735850
|
-
route,
|
|
735851
|
-
success: false,
|
|
735852
|
-
error: 'No inventory available on any monitored chain',
|
|
735853
|
-
};
|
|
735854
|
-
}
|
|
735855
|
-
// NEW: Calculate max viable amount for each source chain
|
|
735856
|
-
// This uses the quote API to determine gas costs upfront
|
|
735857
|
-
const viableSources = [];
|
|
735858
|
-
for (const source of allSources) {
|
|
735859
|
-
const maxViable = await this.calculateMaxViableBridgeAmount(source.chain, destination, source.availableAmount, route.externalBridge);
|
|
735860
|
-
if (maxViable > 0n) {
|
|
735861
|
-
viableSources.push({ chain: source.chain, maxViable });
|
|
735862
|
-
}
|
|
736375
|
+
maxTransferable: maxTransferable.toString(),
|
|
736376
|
+
}, 'Skipping partial transferRemote because available local amount cannot produce canonical progress');
|
|
735863
736377
|
}
|
|
735864
|
-
|
|
735865
|
-
|
|
735866
|
-
|
|
735867
|
-
|
|
735868
|
-
targetChain: destination,
|
|
735869
|
-
sourcesChecked: allSources.length,
|
|
735870
|
-
intentId: intent.id,
|
|
735871
|
-
}, 'No viable bridge sources - all chains have insufficient inventory or high gas costs');
|
|
735872
|
-
return {
|
|
735873
|
-
route,
|
|
735874
|
-
success: false,
|
|
735875
|
-
error: 'No viable bridge sources available',
|
|
736378
|
+
else {
|
|
736379
|
+
const partialSwappedRoute = {
|
|
736380
|
+
...swappedRoute,
|
|
736381
|
+
amount: alignedExecution.localAmount,
|
|
735876
736382
|
};
|
|
736383
|
+
const result = await this.executeTransferRemote(partialSwappedRoute, intent, alignedExecution.messageAmount);
|
|
736384
|
+
this.logger.info({
|
|
736385
|
+
intentId: intent.id,
|
|
736386
|
+
partialAmount: alignedExecution.localAmount.toString(),
|
|
736387
|
+
partialAmountCanonical: alignedExecution.messageAmount.toString(),
|
|
736388
|
+
requestedAmount: requestedLocalAmount.toString(),
|
|
736389
|
+
requestedAmountCanonical: amount.toString(),
|
|
736390
|
+
remainingAmountCanonical: (amount > alignedExecution.messageAmount
|
|
736391
|
+
? amount - alignedExecution.messageAmount
|
|
736392
|
+
: 0n).toString(),
|
|
736393
|
+
}, 'Executed partial inventory deposit, remaining will be handled in future cycles');
|
|
736394
|
+
// Return original strategy route in result (not the swapped execution route)
|
|
736395
|
+
return { ...result, route };
|
|
736396
|
+
}
|
|
736397
|
+
}
|
|
736398
|
+
// Inventory below cost-based threshold - trigger ExternalBridge movement TO destination chain
|
|
736399
|
+
this.logger.info({
|
|
736400
|
+
targetChain: destination,
|
|
736401
|
+
maxTransferable: maxTransferable.toString(),
|
|
736402
|
+
minViableTransfer: minViableTransfer.toString(),
|
|
736403
|
+
costMultiplier: _utils_gasEstimation_js__WEBPACK_IMPORTED_MODULE_6__/* .MIN_VIABLE_COST_MULTIPLIER */ .hh.toString(),
|
|
736404
|
+
intentId: intent.id,
|
|
736405
|
+
}, 'Inventory below cost-based threshold on destination, triggering LiFi movement');
|
|
736406
|
+
// Get all available source chains with raw inventory
|
|
736407
|
+
const allSources = this.selectAllSourceChains(destination);
|
|
736408
|
+
if (allSources.length === 0) {
|
|
736409
|
+
this.logger.warn({
|
|
736410
|
+
origin,
|
|
736411
|
+
destination,
|
|
736412
|
+
amount: requestedLocalAmount.toString(),
|
|
736413
|
+
intentId: intent.id,
|
|
736414
|
+
}, 'No inventory available on any monitored chain');
|
|
736415
|
+
return {
|
|
736416
|
+
route,
|
|
736417
|
+
success: false,
|
|
736418
|
+
error: 'No inventory available on any monitored chain',
|
|
736419
|
+
};
|
|
736420
|
+
}
|
|
736421
|
+
// Calculate source capacities in destination-local units.
|
|
736422
|
+
const viableSources = [];
|
|
736423
|
+
for (const source of allSources) {
|
|
736424
|
+
const capacity = await this.calculateBridgeCapacity(source.chain, destination, source.availableAmount, route.externalBridge);
|
|
736425
|
+
if (capacity.maxTargetOutput > 0n) {
|
|
736426
|
+
viableSources.push({ chain: source.chain, ...capacity });
|
|
735877
736427
|
}
|
|
735878
|
-
|
|
735879
|
-
|
|
735880
|
-
|
|
735881
|
-
|
|
735882
|
-
|
|
735883
|
-
if (totalPlanned >= targetWithBuffer)
|
|
735884
|
-
break;
|
|
735885
|
-
const remaining = targetWithBuffer - totalPlanned;
|
|
735886
|
-
const amountFromSource = source.maxViable >= remaining ? remaining : source.maxViable; // Already gas-adjusted!
|
|
735887
|
-
bridgePlans.push({
|
|
735888
|
-
chain: source.chain,
|
|
735889
|
-
amount: amountFromSource,
|
|
735890
|
-
});
|
|
735891
|
-
totalPlanned += amountFromSource;
|
|
735892
|
-
}
|
|
735893
|
-
this.logger.info({
|
|
736428
|
+
}
|
|
736429
|
+
// Sort by destination output descending.
|
|
736430
|
+
viableSources.sort((a, b) => a.maxTargetOutput > b.maxTargetOutput ? -1 : 1);
|
|
736431
|
+
if (viableSources.length === 0) {
|
|
736432
|
+
this.logger.warn({
|
|
735894
736433
|
targetChain: destination,
|
|
735895
|
-
|
|
735896
|
-
chain: s.chain,
|
|
735897
|
-
maxViable: s.maxViable.toString(),
|
|
735898
|
-
maxViableEth: (Number(s.maxViable) / 1e18).toFixed(6),
|
|
735899
|
-
})),
|
|
735900
|
-
bridgePlans: bridgePlans.map((p) => ({
|
|
735901
|
-
chain: p.chain,
|
|
735902
|
-
amount: p.amount.toString(),
|
|
735903
|
-
amountEth: (Number(p.amount) / 1e18).toFixed(6),
|
|
735904
|
-
})),
|
|
735905
|
-
totalPlanned: totalPlanned.toString(),
|
|
735906
|
-
targetWithBuffer: targetWithBuffer.toString(),
|
|
736434
|
+
sourcesChecked: allSources.length,
|
|
735907
736435
|
intentId: intent.id,
|
|
735908
|
-
}, '
|
|
735909
|
-
|
|
735910
|
-
|
|
735911
|
-
|
|
735912
|
-
|
|
735913
|
-
|
|
735914
|
-
|
|
735915
|
-
|
|
735916
|
-
|
|
735917
|
-
|
|
735918
|
-
|
|
735919
|
-
|
|
735920
|
-
|
|
735921
|
-
|
|
735922
|
-
|
|
735923
|
-
|
|
735924
|
-
|
|
735925
|
-
|
|
735926
|
-
|
|
735927
|
-
|
|
735928
|
-
|
|
735929
|
-
|
|
735930
|
-
|
|
735931
|
-
|
|
735932
|
-
|
|
736436
|
+
}, 'No viable bridge sources - all chains have insufficient inventory or high gas costs');
|
|
736437
|
+
return {
|
|
736438
|
+
route,
|
|
736439
|
+
success: false,
|
|
736440
|
+
error: 'No viable bridge sources available',
|
|
736441
|
+
};
|
|
736442
|
+
}
|
|
736443
|
+
// Create bridge plans using destination-local output amounts.
|
|
736444
|
+
const shortfall = requestedLocalAmount > availableInventory
|
|
736445
|
+
? requestedLocalAmount - availableInventory
|
|
736446
|
+
: 0n;
|
|
736447
|
+
const targetWithBuffer = ((shortfall + costs.totalCost) * (100n + BRIDGE_BUFFER_PERCENT)) / 100n;
|
|
736448
|
+
const bridgePlans = [];
|
|
736449
|
+
let totalPlanned = 0n;
|
|
736450
|
+
for (const source of viableSources) {
|
|
736451
|
+
if (totalPlanned >= targetWithBuffer)
|
|
736452
|
+
break;
|
|
736453
|
+
const remaining = targetWithBuffer - totalPlanned;
|
|
736454
|
+
const targetOutput = source.maxTargetOutput >= remaining
|
|
736455
|
+
? remaining
|
|
736456
|
+
: source.maxTargetOutput;
|
|
736457
|
+
const quoteMode = source.maxTargetOutput > remaining ? 'reverse' : 'forward';
|
|
736458
|
+
bridgePlans.push({
|
|
736459
|
+
chain: source.chain,
|
|
736460
|
+
maxSourceInput: source.maxSourceInput,
|
|
736461
|
+
targetOutput,
|
|
736462
|
+
quoteMode,
|
|
736463
|
+
});
|
|
736464
|
+
totalPlanned += targetOutput;
|
|
736465
|
+
}
|
|
736466
|
+
this.logger.info({
|
|
736467
|
+
targetChain: destination,
|
|
736468
|
+
viableSources: viableSources.map((s) => ({
|
|
736469
|
+
chain: s.chain,
|
|
736470
|
+
maxSourceInput: s.maxSourceInput.toString(),
|
|
736471
|
+
maxTargetOutput: s.maxTargetOutput.toString(),
|
|
736472
|
+
})),
|
|
736473
|
+
bridgePlans: bridgePlans.map((p) => ({
|
|
736474
|
+
chain: p.chain,
|
|
736475
|
+
maxSourceInput: p.maxSourceInput.toString(),
|
|
736476
|
+
targetOutput: p.targetOutput.toString(),
|
|
736477
|
+
quoteMode: p.quoteMode,
|
|
736478
|
+
})),
|
|
736479
|
+
totalPlanned: totalPlanned.toString(),
|
|
736480
|
+
shortfall: shortfall.toString(),
|
|
736481
|
+
targetWithBuffer: targetWithBuffer.toString(),
|
|
736482
|
+
intentId: intent.id,
|
|
736483
|
+
}, 'Created bridge plans using gas-adjusted viable amounts');
|
|
736484
|
+
// Execute all bridges in parallel
|
|
736485
|
+
const bridgeResults = await Promise.allSettled(bridgePlans.map((plan) => this.executeInventoryMovement(plan.chain, destination, plan.targetOutput, plan.maxSourceInput, plan.quoteMode, intent, route.externalBridge)));
|
|
736486
|
+
// Process results
|
|
736487
|
+
let successCount = 0;
|
|
736488
|
+
let totalQuotedOutputMin = 0n;
|
|
736489
|
+
const failedErrors = [];
|
|
736490
|
+
for (let i = 0; i < bridgeResults.length; i++) {
|
|
736491
|
+
const result = bridgeResults[i];
|
|
736492
|
+
const plan = bridgePlans[i];
|
|
736493
|
+
if (result.status === 'fulfilled' && result.value.success) {
|
|
736494
|
+
successCount++;
|
|
736495
|
+
totalQuotedOutputMin += result.value.quotedOutputMin;
|
|
736496
|
+
this.logger.info({
|
|
736497
|
+
sourceChain: plan.chain,
|
|
736498
|
+
plannedTargetOutput: plan.targetOutput.toString(),
|
|
736499
|
+
quotedOutput: result.value.quotedOutput.toString(),
|
|
736500
|
+
quotedOutputMin: result.value.quotedOutputMin.toString(),
|
|
736501
|
+
quoteModeUsed: result.value.quoteModeUsed,
|
|
736502
|
+
txHash: result.value.txHash,
|
|
736503
|
+
}, 'Inventory movement succeeded');
|
|
736504
|
+
}
|
|
736505
|
+
else {
|
|
736506
|
+
let error;
|
|
736507
|
+
if (result.status === 'rejected') {
|
|
736508
|
+
if (result.reason instanceof Error) {
|
|
736509
|
+
error = result.reason.message;
|
|
736510
|
+
}
|
|
736511
|
+
else if (typeof result.reason === 'string') {
|
|
736512
|
+
error = result.reason;
|
|
736513
|
+
}
|
|
736514
|
+
else {
|
|
736515
|
+
try {
|
|
736516
|
+
error = JSON.stringify(result.reason) ?? String(result.reason);
|
|
736517
|
+
}
|
|
736518
|
+
catch {
|
|
736519
|
+
error = String(result.reason);
|
|
736520
|
+
}
|
|
735933
736521
|
}
|
|
735934
|
-
this.logger.warn({
|
|
735935
|
-
sourceChain: plan.chain,
|
|
735936
|
-
amount: plan.amount.toString(),
|
|
735937
|
-
error,
|
|
735938
|
-
}, 'Inventory movement failed');
|
|
735939
736522
|
}
|
|
736523
|
+
else if (!result.value.success) {
|
|
736524
|
+
error = result.value.error;
|
|
736525
|
+
}
|
|
736526
|
+
if (error) {
|
|
736527
|
+
failedErrors.push(`${plan.chain}: ${error}`);
|
|
736528
|
+
}
|
|
736529
|
+
this.logger.warn({
|
|
736530
|
+
sourceChain: plan.chain,
|
|
736531
|
+
plannedTargetOutput: plan.targetOutput.toString(),
|
|
736532
|
+
error,
|
|
736533
|
+
}, 'Inventory movement failed');
|
|
735940
736534
|
}
|
|
735941
|
-
if (successCount === 0) {
|
|
735942
|
-
const errorDetails = failedErrors.length > 0 ? ` (${failedErrors.join('; ')})` : '';
|
|
735943
|
-
return {
|
|
735944
|
-
route,
|
|
735945
|
-
success: false,
|
|
735946
|
-
error: `All inventory movements failed${errorDetails}`,
|
|
735947
|
-
};
|
|
735948
|
-
}
|
|
735949
|
-
this.logger.info({
|
|
735950
|
-
targetChain: destination,
|
|
735951
|
-
successCount,
|
|
735952
|
-
totalBridged: totalBridged.toString(),
|
|
735953
|
-
targetAmount: amount.toString(),
|
|
735954
|
-
intentId: intent.id,
|
|
735955
|
-
}, 'Parallel inventory movements completed, transferRemote will execute after bridges complete');
|
|
735956
|
-
return { route, success: true };
|
|
735957
736535
|
}
|
|
736536
|
+
if (successCount === 0) {
|
|
736537
|
+
const errorDetails = failedErrors.length > 0 ? ` (${failedErrors.join('; ')})` : '';
|
|
736538
|
+
return {
|
|
736539
|
+
route,
|
|
736540
|
+
success: false,
|
|
736541
|
+
error: `All inventory movements failed${errorDetails}`,
|
|
736542
|
+
};
|
|
736543
|
+
}
|
|
736544
|
+
this.logger.info({
|
|
736545
|
+
targetChain: destination,
|
|
736546
|
+
successCount,
|
|
736547
|
+
totalQuotedOutputMin: totalQuotedOutputMin.toString(),
|
|
736548
|
+
targetAmount: requestedLocalAmount.toString(),
|
|
736549
|
+
targetAmountCanonical: amount.toString(),
|
|
736550
|
+
intentId: intent.id,
|
|
736551
|
+
}, 'Parallel inventory movements completed, transferRemote will execute after bridges complete');
|
|
736552
|
+
return { route, success: true };
|
|
735958
736553
|
}
|
|
735959
736554
|
/**
|
|
735960
736555
|
* Execute a transferRemote to deposit collateral.
|
|
@@ -735969,50 +736564,23 @@ class InventoryRebalancer {
|
|
|
735969
736564
|
*
|
|
735970
736565
|
* @param route - The transfer route (swapped direction)
|
|
735971
736566
|
* @param intent - The rebalance intent being executed
|
|
735972
|
-
* @param gasQuote - Pre-calculated gas quote from calculateTransferCosts
|
|
735973
736567
|
*/
|
|
735974
|
-
async executeTransferRemote(route, intent,
|
|
736568
|
+
async executeTransferRemote(route, intent, fulfilledCanonicalAmount) {
|
|
735975
736569
|
const { origin, destination, amount } = route;
|
|
735976
736570
|
const originToken = this.getTokenForChain(origin);
|
|
735977
736571
|
if (!originToken) {
|
|
735978
736572
|
throw new Error(`No token found for origin chain: ${origin}`);
|
|
735979
736573
|
}
|
|
735980
736574
|
const destinationDomain = this.multiProvider.getDomainId(destination);
|
|
735981
|
-
this.logger.debug({
|
|
735982
|
-
origin,
|
|
735983
|
-
destination,
|
|
735984
|
-
amount: amount.toString(),
|
|
735985
|
-
gasQuote: {
|
|
735986
|
-
igpQuote: gasQuote.igpQuote.amount.toString(),
|
|
735987
|
-
tokenFeeQuote: gasQuote.tokenFeeQuote?.amount?.toString() ?? 'none',
|
|
735988
|
-
},
|
|
735989
|
-
}, 'Using pre-calculated gas quote for transferRemote');
|
|
735990
|
-
// Convert pre-calculated gas quote to TokenAmount for WarpCore
|
|
735991
|
-
const originChainMetadata = this.multiProvider.getChainMetadata(origin);
|
|
735992
|
-
const igpAddressOrDenom = gasQuote.igpQuote.addressOrDenom;
|
|
735993
|
-
const igpToken = !igpAddressOrDenom || (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .isZeroishAddress */ .Hi)(igpAddressOrDenom)
|
|
735994
|
-
? _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_6__/* .Token */ .o.FromChainMetadataNativeToken(originChainMetadata)
|
|
735995
|
-
: this.warpCore.findToken(origin, igpAddressOrDenom);
|
|
735996
|
-
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .v)(igpToken, `IGP fee token ${igpAddressOrDenom} is unknown`);
|
|
735997
|
-
const interchainFee = new _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_7__/* .TokenAmount */ .s(gasQuote.igpQuote.amount, igpToken);
|
|
735998
|
-
let tokenFeeQuote;
|
|
735999
|
-
if (gasQuote.tokenFeeQuote?.amount) {
|
|
736000
|
-
const feeAddress = gasQuote.tokenFeeQuote.addressOrDenom;
|
|
736001
|
-
const feeToken = !feeAddress || (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .isZeroishAddress */ .Hi)(feeAddress)
|
|
736002
|
-
? _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_6__/* .Token */ .o.FromChainMetadataNativeToken(originChainMetadata)
|
|
736003
|
-
: originToken;
|
|
736004
|
-
tokenFeeQuote = new _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_7__/* .TokenAmount */ .s(gasQuote.tokenFeeQuote.amount, feeToken);
|
|
736005
|
-
}
|
|
736575
|
+
this.logger.debug({ origin, destination, amount: amount.toString() }, 'Building transferRemote transactions for exact execution amount');
|
|
736006
736576
|
const originTokenAmount = originToken.amount(amount);
|
|
736007
736577
|
const transferTxs = await this.warpCore.getTransferRemoteTxs({
|
|
736008
736578
|
originTokenAmount,
|
|
736009
736579
|
destination,
|
|
736010
736580
|
sender: this.getInventorySignerAddress(origin),
|
|
736011
736581
|
recipient: this.getInventorySignerAddress(destination),
|
|
736012
|
-
interchainFee,
|
|
736013
|
-
tokenFeeQuote,
|
|
736014
736582
|
});
|
|
736015
|
-
(0,
|
|
736583
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(transferTxs.length > 0, 'Expected at least one transaction from WarpCore');
|
|
736016
736584
|
this.logger.info({
|
|
736017
736585
|
origin,
|
|
736018
736586
|
destination,
|
|
@@ -736023,14 +736591,14 @@ class InventoryRebalancer {
|
|
|
736023
736591
|
let transferTxHash;
|
|
736024
736592
|
for (const tx of transferTxs) {
|
|
736025
736593
|
const { txHash } = await this.sendAndConfirmInventoryTx(origin, tx);
|
|
736026
|
-
if (tx.category ===
|
|
736594
|
+
if (tx.category === _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_7__/* .WarpTxCategory */ .b.Transfer) {
|
|
736027
736595
|
transferTxHash = txHash;
|
|
736028
736596
|
}
|
|
736029
736597
|
}
|
|
736030
736598
|
const messageId = transferTxHash
|
|
736031
736599
|
? await this.extractDispatchedMessageId(origin, transferTxHash)
|
|
736032
736600
|
: undefined;
|
|
736033
|
-
(0,
|
|
736601
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(transferTxHash, 'No transfer transaction hash found');
|
|
736034
736602
|
if (!messageId) {
|
|
736035
736603
|
this.logger.warn({
|
|
736036
736604
|
origin,
|
|
@@ -736051,7 +736619,7 @@ class InventoryRebalancer {
|
|
|
736051
736619
|
intentId: intent.id,
|
|
736052
736620
|
origin: this.multiProvider.getDomainId(origin),
|
|
736053
736621
|
destination: destinationDomain,
|
|
736054
|
-
amount,
|
|
736622
|
+
amount: fulfilledCanonicalAmount,
|
|
736055
736623
|
type: 'inventory_deposit',
|
|
736056
736624
|
txHash: transferTxHash,
|
|
736057
736625
|
messageId,
|
|
@@ -736065,24 +736633,24 @@ class InventoryRebalancer {
|
|
|
736065
736633
|
async sendAndConfirmInventoryTx(chain, typedTx) {
|
|
736066
736634
|
const protocol = this.getProtocolForChain(chain);
|
|
736067
736635
|
const signerConfig = this.config.inventorySigners[protocol];
|
|
736068
|
-
(0,
|
|
736636
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(signerConfig?.key, `Missing signer key for protocol ${protocol} (chain ${chain})`);
|
|
736069
736637
|
const accountConfig = this.buildSignerAccountConfig(protocol, signerConfig.key, chain);
|
|
736070
|
-
const signer = await (0,
|
|
736638
|
+
const signer = await (0,_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_8__/* .getSignerForChain */ .h)(chain, accountConfig, this.warpCore.multiProvider);
|
|
736071
736639
|
const metadata = this.warpCore.multiProvider.getChainMetadata(chain);
|
|
736072
736640
|
const configuredConfirmations = metadata.blocks?.reorgPeriod ?? metadata.blocks?.confirmations;
|
|
736073
736641
|
let waitConfirmations = 1;
|
|
736074
736642
|
if (typeof configuredConfirmations === 'number') {
|
|
736075
736643
|
waitConfirmations = configuredConfirmations;
|
|
736076
736644
|
}
|
|
736077
|
-
const txHash = await signer.sendAndConfirmTransaction((0,
|
|
736645
|
+
const txHash = await signer.sendAndConfirmTransaction((0,_utils_transactionUtils_js__WEBPACK_IMPORTED_MODULE_9__/* .toProtocolTransaction */ .S)(typedTx, protocol), { waitConfirmations });
|
|
736078
736646
|
return { txHash };
|
|
736079
736647
|
}
|
|
736080
736648
|
buildSignerAccountConfig(protocol, key, chain) {
|
|
736081
736649
|
void chain;
|
|
736082
736650
|
switch (protocol) {
|
|
736083
|
-
case
|
|
736084
|
-
return { protocol, privateKey: (0,
|
|
736085
|
-
case
|
|
736651
|
+
case _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_10__/* .ProtocolType */ .Hb.Ethereum:
|
|
736652
|
+
return { protocol, privateKey: (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_11__/* .ensure0x */ .Ho)(key) };
|
|
736653
|
+
case _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_10__/* .ProtocolType */ .Hb.Sealevel:
|
|
736086
736654
|
return { protocol, privateKey: (0,_utils_solanaKeyParser_js__WEBPACK_IMPORTED_MODULE_1__/* .parseSolanaPrivateKey */ .E)(key) };
|
|
736087
736655
|
default:
|
|
736088
736656
|
throw new Error(`Unsupported protocol ${protocol} for inventory signer`);
|
|
@@ -736100,21 +736668,21 @@ class InventoryRebalancer {
|
|
|
736100
736668
|
if (!logs)
|
|
736101
736669
|
return undefined;
|
|
736102
736670
|
const parsed = _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_14__/* .SealevelCoreAdapter */ .M.parseMessageDispatchLogs(logs);
|
|
736103
|
-
return parsed[0]?.messageId ? (0,
|
|
736671
|
+
return parsed[0]?.messageId ? (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_11__/* .ensure0x */ .Ho)(parsed[0].messageId) : undefined;
|
|
736104
736672
|
}
|
|
736105
736673
|
return undefined;
|
|
736106
736674
|
}
|
|
736107
736675
|
async getTransactionReceipt(origin, txHash) {
|
|
736108
736676
|
try {
|
|
736109
736677
|
const protocol = this.getProtocolForChain(origin);
|
|
736110
|
-
if (protocol ===
|
|
736678
|
+
if (protocol === _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_10__/* .ProtocolType */ .Hb.Ethereum) {
|
|
736111
736679
|
const provider = this.warpCore.multiProvider.getEthersV5Provider(origin);
|
|
736112
736680
|
const receipt = await provider.getTransactionReceipt(txHash);
|
|
736113
736681
|
if (!receipt)
|
|
736114
736682
|
return undefined;
|
|
736115
736683
|
return { type: _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_12__/* .ProviderType */ .c.EthersV5, receipt };
|
|
736116
736684
|
}
|
|
736117
|
-
if (protocol ===
|
|
736685
|
+
if (protocol === _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_10__/* .ProtocolType */ .Hb.Sealevel) {
|
|
736118
736686
|
const provider = this.warpCore.multiProvider.getSolanaWeb3Provider(origin);
|
|
736119
736687
|
const receipt = await provider.getTransaction(txHash, {
|
|
736120
736688
|
commitment: 'confirmed',
|
|
@@ -736153,39 +736721,26 @@ class InventoryRebalancer {
|
|
|
736153
736721
|
return sources.sort((a, b) => a.availableAmount > b.availableAmount ? -1 : 1);
|
|
736154
736722
|
}
|
|
736155
736723
|
/**
|
|
736156
|
-
* Calculate the
|
|
736157
|
-
* Uses LiFi
|
|
736158
|
-
*
|
|
736159
|
-
*
|
|
736160
|
-
* This is the key method for the gas-aware planning approach:
|
|
736161
|
-
* - Gets a quote for the full raw inventory to determine actual gas costs
|
|
736162
|
-
* - Applies conservative 20x buffer (LiFi underestimates by ~14x historically)
|
|
736163
|
-
* - Returns 0 if gas > 10% of inventory (not worth bridging)
|
|
736164
|
-
* - Returns inventory - estimatedGas if viable
|
|
736724
|
+
* Calculate the bridge capacity from a source chain in destination-local units.
|
|
736725
|
+
* Uses LiFi quotes to conservatively estimate the destination output available
|
|
736726
|
+
* from the source chain's current local inventory.
|
|
736165
736727
|
*
|
|
736166
|
-
*
|
|
736167
|
-
*
|
|
736168
|
-
* @param rawInventory - Raw available inventory on source chain
|
|
736169
|
-
* @param externalBridgeType - External bridge type to use
|
|
736170
|
-
* @returns Maximum viable bridge amount (0 if not viable)
|
|
736728
|
+
* For native-token sources, gas is reserved from the source inventory and the
|
|
736729
|
+
* output capacity is re-quoted from the remaining source input.
|
|
736171
736730
|
*/
|
|
736172
|
-
async
|
|
736731
|
+
async calculateBridgeCapacity(sourceChain, targetChain, rawInventory, externalBridgeType) {
|
|
736173
736732
|
const sourceToken = this.getTokenForChain(sourceChain);
|
|
736174
736733
|
const targetToken = this.getTokenForChain(targetChain);
|
|
736175
|
-
|
|
736176
|
-
|
|
736177
|
-
// Only applies to native tokens (need gas from same balance)
|
|
736178
|
-
if (!(0,_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .isNativeTokenStandard */ .OJ)(sourceToken.standard)) {
|
|
736179
|
-
return rawInventory; // ERC20s don't compete with gas
|
|
736180
|
-
}
|
|
736734
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(sourceToken, `No token found for source chain: ${sourceChain}`);
|
|
736735
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(targetToken, `No token found for target chain: ${targetChain}`);
|
|
736181
736736
|
// Convert HypNative token addresses to the external bridge's native token representation
|
|
736182
|
-
const fromTokenAddress = this.getNativeTokenAddress(
|
|
736737
|
+
const fromTokenAddress = (0,_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .getExternalBridgeTokenAddress */ .iV)(sourceToken, externalBridgeType, this.getNativeTokenAddress.bind(this));
|
|
736183
736738
|
const toTokenAddress = (0,_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .getExternalBridgeTokenAddress */ .iV)(targetToken, externalBridgeType, this.getNativeTokenAddress.bind(this));
|
|
736184
736739
|
const sourceChainId = Number(this.multiProvider.getChainId(sourceChain));
|
|
736185
736740
|
const targetChainId = Number(this.multiProvider.getChainId(targetChain));
|
|
736186
736741
|
try {
|
|
736187
736742
|
const externalBridge = this.getExternalBridge(externalBridgeType);
|
|
736188
|
-
const
|
|
736743
|
+
const initialQuote = await externalBridge.quote({
|
|
736189
736744
|
fromChain: sourceChainId,
|
|
736190
736745
|
toChain: targetChainId,
|
|
736191
736746
|
fromToken: fromTokenAddress,
|
|
@@ -736194,62 +736749,74 @@ class InventoryRebalancer {
|
|
|
736194
736749
|
fromAddress: this.getInventorySignerAddress(sourceChain),
|
|
736195
736750
|
toAddress: this.getInventorySignerAddress(targetChain),
|
|
736196
736751
|
});
|
|
736197
|
-
|
|
736198
|
-
|
|
736199
|
-
|
|
736200
|
-
|
|
736201
|
-
|
|
736202
|
-
|
|
736203
|
-
|
|
736204
|
-
|
|
736205
|
-
|
|
736206
|
-
|
|
736207
|
-
|
|
736208
|
-
|
|
736209
|
-
|
|
736210
|
-
|
|
736211
|
-
|
|
736212
|
-
}
|
|
736213
|
-
|
|
736752
|
+
let maxSourceInput = rawInventory;
|
|
736753
|
+
let outputQuote = initialQuote;
|
|
736754
|
+
if ((0,_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .isNativeTokenStandard */ .OJ)(sourceToken.standard)) {
|
|
736755
|
+
const estimatedGas = initialQuote.gasCosts * GAS_COST_MULTIPLIER;
|
|
736756
|
+
const maxGasThreshold = rawInventory / MAX_GAS_PERCENT_THRESHOLD;
|
|
736757
|
+
if (estimatedGas > maxGasThreshold) {
|
|
736758
|
+
this.logger.info({
|
|
736759
|
+
sourceChain,
|
|
736760
|
+
targetChain,
|
|
736761
|
+
rawInventory: rawInventory.toString(),
|
|
736762
|
+
quotedGas: initialQuote.gasCosts.toString(),
|
|
736763
|
+
estimatedGas: estimatedGas.toString(),
|
|
736764
|
+
maxGasThreshold: maxGasThreshold.toString(),
|
|
736765
|
+
}, 'Bridge not viable - gas cost exceeds 10% of inventory');
|
|
736766
|
+
return { maxSourceInput: 0n, maxTargetOutput: 0n };
|
|
736767
|
+
}
|
|
736768
|
+
maxSourceInput = rawInventory - estimatedGas;
|
|
736769
|
+
if (maxSourceInput <= 0n) {
|
|
736770
|
+
return { maxSourceInput: 0n, maxTargetOutput: 0n };
|
|
736771
|
+
}
|
|
736772
|
+
outputQuote = await externalBridge.quote({
|
|
736773
|
+
fromChain: sourceChainId,
|
|
736774
|
+
toChain: targetChainId,
|
|
736775
|
+
fromToken: fromTokenAddress,
|
|
736776
|
+
toToken: toTokenAddress,
|
|
736777
|
+
fromAmount: maxSourceInput,
|
|
736778
|
+
fromAddress: this.getInventorySignerAddress(sourceChain),
|
|
736779
|
+
toAddress: this.getInventorySignerAddress(targetChain),
|
|
736780
|
+
});
|
|
736214
736781
|
}
|
|
736215
|
-
// Max viable = inventory minus estimated gas
|
|
736216
|
-
const maxViable = rawInventory - estimatedGas;
|
|
736217
736782
|
this.logger.info({
|
|
736218
736783
|
sourceChain,
|
|
736219
736784
|
targetChain,
|
|
736220
736785
|
rawInventory: rawInventory.toString(),
|
|
736221
|
-
|
|
736222
|
-
|
|
736223
|
-
|
|
736224
|
-
|
|
736225
|
-
|
|
736226
|
-
|
|
736227
|
-
}
|
|
736228
|
-
return maxViable;
|
|
736786
|
+
maxSourceInput: maxSourceInput.toString(),
|
|
736787
|
+
maxTargetOutput: outputQuote.toAmountMin.toString(),
|
|
736788
|
+
}, 'Calculated bridge capacity');
|
|
736789
|
+
return {
|
|
736790
|
+
maxSourceInput,
|
|
736791
|
+
maxTargetOutput: outputQuote.toAmountMin,
|
|
736792
|
+
};
|
|
736229
736793
|
}
|
|
736230
736794
|
catch (error) {
|
|
736231
736795
|
this.logger.warn({
|
|
736232
736796
|
sourceChain,
|
|
736233
736797
|
targetChain,
|
|
736234
736798
|
error: error.message,
|
|
736235
|
-
}, 'Failed to calculate
|
|
736236
|
-
return 0n;
|
|
736799
|
+
}, 'Failed to calculate bridge capacity, skipping chain');
|
|
736800
|
+
return { maxSourceInput: 0n, maxTargetOutput: 0n };
|
|
736237
736801
|
}
|
|
736238
736802
|
}
|
|
736239
736803
|
/**
|
|
736240
736804
|
* Execute inventory movement from source chain to target chain via LiFi bridge.
|
|
736241
736805
|
*
|
|
736242
|
-
*
|
|
736243
|
-
*
|
|
736806
|
+
* Quote mode is chosen during planning:
|
|
736807
|
+
* - `reverse`: request an exact target-chain output when the source has headroom
|
|
736808
|
+
* - `forward`: spend the source cap directly when source inventory is the limiter
|
|
736244
736809
|
*
|
|
736245
736810
|
* @param sourceChain - Chain to move inventory from
|
|
736246
736811
|
* @param targetChain - Chain to move inventory to (origin chain for rebalancing)
|
|
736247
|
-
* @param
|
|
736812
|
+
* @param targetOutputAmount - Destination-local amount to receive
|
|
736813
|
+
* @param maxSourceInput - Maximum source-local amount available for this plan
|
|
736814
|
+
* @param quoteMode - Whether to execute this bridge plan as exact-input or exact-output
|
|
736248
736815
|
* @param intent - Rebalance intent for tracking
|
|
736249
736816
|
* @param externalBridgeType - External bridge type to use
|
|
736250
736817
|
* @returns Result with success status and optional txHash/error
|
|
736251
736818
|
*/
|
|
736252
|
-
async executeInventoryMovement(sourceChain, targetChain,
|
|
736819
|
+
async executeInventoryMovement(sourceChain, targetChain, targetOutputAmount, maxSourceInput, quoteMode, intent, externalBridgeType) {
|
|
736253
736820
|
const sourceToken = this.getTokenForChain(sourceChain);
|
|
736254
736821
|
if (!sourceToken) {
|
|
736255
736822
|
return {
|
|
@@ -736278,59 +736845,65 @@ class InventoryRebalancer {
|
|
|
736278
736845
|
fromTokenAddress,
|
|
736279
736846
|
toTokenAddress,
|
|
736280
736847
|
}, 'Resolved token addresses for LiFi bridge');
|
|
736281
|
-
// Calculate minViableTransfer for the target chain
|
|
736282
|
-
// If bridging less than this, the received amount won't be enough to execute transferRemote
|
|
736283
|
-
// So we over-bridge to ensure we can complete the intent in the next cycle
|
|
736284
|
-
const costs = await (0,_utils_gasEstimation_js__WEBPACK_IMPORTED_MODULE_4__/* .calculateTransferCosts */ ._P)(targetChain, // FROM chain for transferRemote (the target of this bridge)
|
|
736285
|
-
sourceChain, // TO chain for transferRemote (Hyperlane message destination)
|
|
736286
|
-
amount, // availableInventory (not used for minViableTransfer calculation)
|
|
736287
|
-
amount, // requestedAmount
|
|
736288
|
-
this.multiProvider, this.warpCore.multiProvider, this.getTokenForChain.bind(this), this.getInventorySignerAddress(targetChain), _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .isNativeTokenStandard */ .OJ, this.logger);
|
|
736289
|
-
const { minViableTransfer } = costs;
|
|
736290
|
-
// If the requested amount is below minViableTransfer, adjust it up
|
|
736291
|
-
// This ensures we bridge enough to actually complete the final transferRemote
|
|
736292
|
-
const effectiveAmount = amount < minViableTransfer ? minViableTransfer : amount;
|
|
736293
|
-
if (effectiveAmount !== amount) {
|
|
736294
|
-
this.logger.info({
|
|
736295
|
-
originalAmount: amount.toString(),
|
|
736296
|
-
effectiveAmount: effectiveAmount.toString(),
|
|
736297
|
-
minViableTransfer: minViableTransfer.toString(),
|
|
736298
|
-
originalAmountEth: (Number(amount) / 1e18).toFixed(6),
|
|
736299
|
-
effectiveAmountEth: (Number(effectiveAmount) / 1e18).toFixed(6),
|
|
736300
|
-
minViableTransferEth: (Number(minViableTransfer) / 1e18).toFixed(6),
|
|
736301
|
-
adjustedUp: true,
|
|
736302
|
-
intentId: intent.id,
|
|
736303
|
-
}, 'Over-bridging to minViableTransfer to ensure final transferRemote can complete');
|
|
736304
|
-
}
|
|
736305
736848
|
try {
|
|
736306
736849
|
const externalBridge = this.getExternalBridge(externalBridgeType);
|
|
736307
|
-
const
|
|
736850
|
+
const fromAddress = this.getInventorySignerAddress(sourceChain);
|
|
736851
|
+
const toAddress = this.getInventorySignerAddress(targetChain);
|
|
736852
|
+
const quoteWithMode = async (mode) => externalBridge.quote({
|
|
736308
736853
|
fromChain: sourceChainId,
|
|
736309
736854
|
toChain: targetChainId,
|
|
736310
736855
|
fromToken: fromTokenAddress,
|
|
736311
736856
|
toToken: toTokenAddress,
|
|
736312
|
-
|
|
736313
|
-
|
|
736314
|
-
|
|
736857
|
+
...(mode === 'forward'
|
|
736858
|
+
? { fromAmount: maxSourceInput }
|
|
736859
|
+
: { toAmount: targetOutputAmount }),
|
|
736860
|
+
fromAddress,
|
|
736861
|
+
toAddress,
|
|
736315
736862
|
});
|
|
736863
|
+
let quoteModeUsed = quoteMode;
|
|
736864
|
+
let quote = await quoteWithMode(quoteModeUsed);
|
|
736865
|
+
if (quoteModeUsed === 'reverse' && quote.fromAmount > maxSourceInput) {
|
|
736866
|
+
this.logger.warn({
|
|
736867
|
+
sourceChain,
|
|
736868
|
+
targetChain,
|
|
736869
|
+
plannedQuoteMode: quoteMode,
|
|
736870
|
+
requestedTargetOutput: targetOutputAmount.toString(),
|
|
736871
|
+
quotedInput: quote.fromAmount.toString(),
|
|
736872
|
+
maxSourceInput: maxSourceInput.toString(),
|
|
736873
|
+
intentId: intent.id,
|
|
736874
|
+
}, 'Reverse bridge quote exceeded source capacity, retrying with forward quote');
|
|
736875
|
+
// Spend the full source cap on fallback; minor output drift is acceptable
|
|
736876
|
+
// and will be reconciled by later cycles rather than risking livelock.
|
|
736877
|
+
quoteModeUsed = 'forward';
|
|
736878
|
+
quote = await quoteWithMode(quoteModeUsed);
|
|
736879
|
+
}
|
|
736316
736880
|
const inputRequired = quote.fromAmount;
|
|
736881
|
+
if (inputRequired > maxSourceInput) {
|
|
736882
|
+
return {
|
|
736883
|
+
success: false,
|
|
736884
|
+
error: `Bridge input ${inputRequired} exceeded planned source capacity ${maxSourceInput}`,
|
|
736885
|
+
};
|
|
736886
|
+
}
|
|
736317
736887
|
this.logger.info({
|
|
736318
736888
|
sourceChain,
|
|
736319
736889
|
targetChain,
|
|
736320
736890
|
sourceChainId,
|
|
736321
736891
|
targetChainId,
|
|
736322
|
-
|
|
736323
|
-
|
|
736324
|
-
|
|
736325
|
-
|
|
736892
|
+
requestedTargetOutput: targetOutputAmount.toString(),
|
|
736893
|
+
requestedTargetOutputFormatted: this.formatLocalAmount(targetOutputAmount, targetToken),
|
|
736894
|
+
quoteModePlanned: quoteMode,
|
|
736895
|
+
quoteModeUsed,
|
|
736896
|
+
retriedAsForward: quoteMode === 'reverse' && quoteModeUsed === 'forward',
|
|
736326
736897
|
inputRequired: inputRequired.toString(),
|
|
736327
|
-
|
|
736328
|
-
|
|
736898
|
+
inputRequiredFormatted: this.formatLocalAmount(inputRequired, sourceToken),
|
|
736899
|
+
quotedOutput: quote.toAmount.toString(),
|
|
736900
|
+
quotedOutputMin: quote.toAmountMin.toString(),
|
|
736901
|
+
quotedOutputFormatted: this.formatLocalAmount(quote.toAmount, targetToken),
|
|
736902
|
+
quotedOutputMinFormatted: this.formatLocalAmount(quote.toAmountMin, targetToken),
|
|
736329
736903
|
gasCosts: quote.gasCosts.toString(),
|
|
736330
736904
|
feeCosts: quote.feeCosts.toString(),
|
|
736331
736905
|
intentId: intent.id,
|
|
736332
|
-
|
|
736333
|
-
}, 'Executing inventory movement via LiFi with pre-validated amount');
|
|
736906
|
+
}, 'Executing inventory movement via bridge quote');
|
|
736334
736907
|
this.logger.debug({
|
|
736335
736908
|
quoteId: quote.id,
|
|
736336
736909
|
tool: quote.tool,
|
|
@@ -736349,7 +736922,7 @@ class InventoryRebalancer {
|
|
|
736349
736922
|
}
|
|
736350
736923
|
}
|
|
736351
736924
|
const sourceProtocol = this.getProtocolForChain(sourceChain);
|
|
736352
|
-
(0,
|
|
736925
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .assert */ .v)(privateKeys[sourceProtocol], `Missing inventory signer key for protocol ${sourceProtocol} (chain ${sourceChain})`);
|
|
736353
736926
|
const result = await externalBridge.execute(quote, privateKeys);
|
|
736354
736927
|
this.logger.info({
|
|
736355
736928
|
sourceChain,
|
|
@@ -736357,6 +736930,8 @@ class InventoryRebalancer {
|
|
|
736357
736930
|
txHash: result.txHash,
|
|
736358
736931
|
intentId: intent.id,
|
|
736359
736932
|
}, 'Inventory movement transaction executed');
|
|
736933
|
+
// Keep bridge consumption in source-local units; intent fulfillment only
|
|
736934
|
+
// advances from canonical inventory_deposit amounts after transferRemote.
|
|
736360
736935
|
await this.actionTracker.createRebalanceAction({
|
|
736361
736936
|
intentId: intent.id,
|
|
736362
736937
|
origin: this.multiProvider.getDomainId(sourceChain),
|
|
@@ -736374,19 +736949,27 @@ class InventoryRebalancer {
|
|
|
736374
736949
|
amountConsumed: inputRequired.toString(),
|
|
736375
736950
|
totalConsumed: (currentConsumed + inputRequired).toString(),
|
|
736376
736951
|
}, 'Updated consumed inventory after LiFi bridge');
|
|
736377
|
-
return {
|
|
736952
|
+
return {
|
|
736953
|
+
success: true,
|
|
736954
|
+
txHash: result.txHash,
|
|
736955
|
+
inputRequired,
|
|
736956
|
+
quotedOutput: quote.toAmount,
|
|
736957
|
+
quotedOutputMin: quote.toAmountMin,
|
|
736958
|
+
quoteModeUsed,
|
|
736959
|
+
};
|
|
736378
736960
|
}
|
|
736379
736961
|
catch (error) {
|
|
736962
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
736380
736963
|
this.logger.error({
|
|
736381
736964
|
sourceChain,
|
|
736382
736965
|
targetChain,
|
|
736383
|
-
amount:
|
|
736966
|
+
amount: targetOutputAmount.toString(),
|
|
736384
736967
|
intentId: intent.id,
|
|
736385
|
-
error:
|
|
736968
|
+
error: errorMessage,
|
|
736386
736969
|
}, 'Failed to execute inventory movement');
|
|
736387
736970
|
return {
|
|
736388
736971
|
success: false,
|
|
736389
|
-
error:
|
|
736972
|
+
error: errorMessage,
|
|
736390
736973
|
};
|
|
736391
736974
|
}
|
|
736392
736975
|
}
|
|
@@ -736404,11 +736987,15 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
736404
736987
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
736405
736988
|
/* harmony export */ K: () => (/* binding */ Rebalancer)
|
|
736406
736989
|
/* harmony export */ });
|
|
736407
|
-
/* harmony import */ var
|
|
736408
|
-
/* harmony import */ var
|
|
736409
|
-
/* harmony import */ var
|
|
736410
|
-
/* harmony import */ var
|
|
736411
|
-
/* harmony import */ var
|
|
736990
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(21582);
|
|
736991
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(71598);
|
|
736992
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(14918);
|
|
736993
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(73689);
|
|
736994
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(93142);
|
|
736995
|
+
/* harmony import */ var _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(11369);
|
|
736996
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__]);
|
|
736997
|
+
_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
736998
|
+
|
|
736412
736999
|
|
|
736413
737000
|
|
|
736414
737001
|
class Rebalancer {
|
|
@@ -736466,7 +737053,8 @@ class Rebalancer {
|
|
|
736466
737053
|
for (const result of successfulResults) {
|
|
736467
737054
|
const token = this.tokensByChainName[result.route.origin];
|
|
736468
737055
|
if (token) {
|
|
736469
|
-
this.metrics.recordRebalanceAmount(result.route, token.amount(result.
|
|
737056
|
+
this.metrics.recordRebalanceAmount(result.route, token.amount(result.localAmount ??
|
|
737057
|
+
(0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .denormalizeToLocal */ .bK)(result.route.amount, token)));
|
|
736470
737058
|
}
|
|
736471
737059
|
}
|
|
736472
737060
|
}
|
|
@@ -736496,7 +737084,7 @@ class Rebalancer {
|
|
|
736496
737084
|
intentId,
|
|
736497
737085
|
origin: this.multiProvider.getDomainId(result.route.origin),
|
|
736498
737086
|
destination: this.multiProvider.getDomainId(result.route.destination),
|
|
736499
|
-
amount: result.route.amount,
|
|
737087
|
+
amount: result.canonicalAmount ?? result.route.amount,
|
|
736500
737088
|
type: 'rebalance_message',
|
|
736501
737089
|
messageId: result.messageId,
|
|
736502
737090
|
txHash: result.txHash,
|
|
@@ -736532,9 +737120,9 @@ class Rebalancer {
|
|
|
736532
737120
|
}
|
|
736533
737121
|
async prepareTransactions(routes) {
|
|
736534
737122
|
this.logger.info({ numRoutes: routes.length }, 'Preparing all rebalance transactions.');
|
|
736535
|
-
const { fulfilled, rejected } = await (0,
|
|
737123
|
+
const { fulfilled, rejected } = await (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_1__/* .mapAllSettled */ .bh)(routes, (route) => this.prepareTransaction(route), (_, i) => i);
|
|
736536
737124
|
// Filter out null results (validation failures logged internally)
|
|
736537
|
-
const preparedTransactions = Array.from(fulfilled.values()).filter((tx) => !(0,
|
|
737125
|
+
const preparedTransactions = Array.from(fulfilled.values()).filter((tx) => !(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__/* .isNullish */ .u)(tx));
|
|
736538
737126
|
// Create failure results for tracking
|
|
736539
737127
|
const preparationFailureResults = [];
|
|
736540
737128
|
for (const [i, error] of rejected) {
|
|
@@ -736548,7 +737136,7 @@ class Rebalancer {
|
|
|
736548
737136
|
}
|
|
736549
737137
|
// Also track null results (validation failures)
|
|
736550
737138
|
Array.from(fulfilled.entries()).forEach(([i, tx]) => {
|
|
736551
|
-
if ((0,
|
|
737139
|
+
if ((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__/* .isNullish */ .u)(tx)) {
|
|
736552
737140
|
preparationFailureResults.push({
|
|
736553
737141
|
route: routes[i],
|
|
736554
737142
|
intentId: routes[i].intentId,
|
|
@@ -736575,14 +737163,15 @@ class Rebalancer {
|
|
|
736575
737163
|
const originToken = this.tokensByChainName[origin];
|
|
736576
737164
|
const destinationToken = this.tokensByChainName[destination];
|
|
736577
737165
|
const destinationChainMeta = this.chainMetadata[destination];
|
|
736578
|
-
const
|
|
737166
|
+
const localAmount = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .denormalizeToLocal */ .bK)(amount, originToken);
|
|
737167
|
+
const originTokenAmount = originToken.amount(localAmount);
|
|
736579
737168
|
const decimalFormattedAmount = originTokenAmount.getDecimalFormattedAmount();
|
|
736580
737169
|
const originHypAdapter = originToken.getHypAdapter(this.warpCore.multiProvider);
|
|
736581
737170
|
const { bridge } = route;
|
|
736582
737171
|
// 2. Get quotes
|
|
736583
737172
|
let quotes;
|
|
736584
737173
|
try {
|
|
736585
|
-
quotes = await originHypAdapter.getRebalanceQuotes(bridge, destinationChainMeta.domainId, destinationToken.addressOrDenom,
|
|
737174
|
+
quotes = await originHypAdapter.getRebalanceQuotes(bridge, destinationChainMeta.domainId, destinationToken.addressOrDenom, localAmount);
|
|
736586
737175
|
}
|
|
736587
737176
|
catch (error) {
|
|
736588
737177
|
this.logger.error({
|
|
@@ -736597,7 +737186,7 @@ class Rebalancer {
|
|
|
736597
737186
|
// 3. Populate transaction
|
|
736598
737187
|
let populatedTx;
|
|
736599
737188
|
try {
|
|
736600
|
-
populatedTx = await originHypAdapter.populateRebalanceTx(destinationChainMeta.domainId,
|
|
737189
|
+
populatedTx = await originHypAdapter.populateRebalanceTx(destinationChainMeta.domainId, localAmount, bridge, quotes);
|
|
736601
737190
|
}
|
|
736602
737191
|
catch (error) {
|
|
736603
737192
|
this.logger.error({
|
|
@@ -736620,7 +737209,8 @@ class Rebalancer {
|
|
|
736620
737209
|
this.logger.error({ origin, destination, amount }, 'Route validation failed: origin token not found.');
|
|
736621
737210
|
return false;
|
|
736622
737211
|
}
|
|
736623
|
-
const
|
|
737212
|
+
const localAmount = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .denormalizeToLocal */ .bK)(amount, originToken);
|
|
737213
|
+
const originTokenAmount = originToken.amount(localAmount);
|
|
736624
737214
|
const decimalFormattedAmount = originTokenAmount.getDecimalFormattedAmount();
|
|
736625
737215
|
if (!destinationToken) {
|
|
736626
737216
|
this.logger.error({ origin, destination, amount: decimalFormattedAmount }, 'Route validation failed: destination token not found.');
|
|
@@ -736631,7 +737221,7 @@ class Rebalancer {
|
|
|
736631
737221
|
return false;
|
|
736632
737222
|
}
|
|
736633
737223
|
const originHypAdapter = originToken.getHypAdapter(this.warpCore.multiProvider);
|
|
736634
|
-
if (!(originHypAdapter instanceof
|
|
737224
|
+
if (!(originHypAdapter instanceof _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_3__/* .EvmMovableCollateralAdapter */ .vo)) {
|
|
736635
737225
|
this.logger.error({
|
|
736636
737226
|
origin,
|
|
736637
737227
|
destination,
|
|
@@ -736654,7 +737244,7 @@ class Rebalancer {
|
|
|
736654
737244
|
return false;
|
|
736655
737245
|
}
|
|
736656
737246
|
const allowedDestination = await originHypAdapter.getAllowedDestination(destinationDomain.domainId);
|
|
736657
|
-
if (!(0,
|
|
737247
|
+
if (!(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_4__/* .eqAddress */ .fv)(allowedDestination, destinationToken.addressOrDenom)) {
|
|
736658
737248
|
this.logger.error({
|
|
736659
737249
|
origin,
|
|
736660
737250
|
destination,
|
|
@@ -736816,7 +737406,7 @@ class Rebalancer {
|
|
|
736816
737406
|
*/
|
|
736817
737407
|
buildResult(transaction, receipt) {
|
|
736818
737408
|
const { origin, destination } = transaction.route;
|
|
736819
|
-
const dispatchedMessages =
|
|
737409
|
+
const dispatchedMessages = _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_5__/* .HyperlaneCore */ .K.getDispatchedMessages(receipt);
|
|
736820
737410
|
if (dispatchedMessages.length === 0) {
|
|
736821
737411
|
this.logger.error({ origin, destination, txHash: receipt.transactionHash }, 'No Dispatch event found in confirmed rebalance receipt');
|
|
736822
737412
|
return {
|
|
@@ -736834,6 +737424,8 @@ class Rebalancer {
|
|
|
736834
737424
|
success: true,
|
|
736835
737425
|
messageId: dispatchedMessages[0].id,
|
|
736836
737426
|
txHash: receipt.transactionHash,
|
|
737427
|
+
canonicalAmount: (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .normalizeToCanonical */ .R2)(transaction.originTokenAmount.amount, transaction.originTokenAmount.token),
|
|
737428
|
+
localAmount: transaction.originTokenAmount.amount,
|
|
736837
737429
|
};
|
|
736838
737430
|
}
|
|
736839
737431
|
getReorgPeriod(chainName) {
|
|
@@ -736892,7 +737484,7 @@ class RebalancerOrchestrator {
|
|
|
736892
737484
|
await Promise.all(event.tokensInfo.map((tokenInfo) => metrics.processToken(tokenInfo)));
|
|
736893
737485
|
}
|
|
736894
737486
|
await this.syncActionTracker(event.confirmedBlockTags);
|
|
736895
|
-
const rawBalances = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_1__/* .getRawBalances */ .
|
|
737487
|
+
const rawBalances = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_1__/* .getRawBalances */ .qb)((0,_config_types_js__WEBPACK_IMPORTED_MODULE_0__/* .getStrategyChainNames */ .zj)(this.rebalancerConfig.strategyConfig), event, this.logger);
|
|
736896
737488
|
this.logger.info({
|
|
736897
737489
|
balances: Object.entries(rawBalances).map(([chain, balance]) => ({
|
|
736898
737490
|
chain,
|
|
@@ -737025,14 +737617,15 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
737025
737617
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
737026
737618
|
/* harmony export */ $: () => (/* binding */ RebalancerService)
|
|
737027
737619
|
/* harmony export */ });
|
|
737028
|
-
/* harmony import */ var
|
|
737029
|
-
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(39196);
|
|
737620
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(21387);
|
|
737030
737621
|
/* harmony import */ var _config_types_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(75102);
|
|
737031
737622
|
/* harmony import */ var _factories_RebalancerContextFactory_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(84569);
|
|
737032
737623
|
/* harmony import */ var _interfaces_IMonitor_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(36513);
|
|
737033
|
-
/* harmony import */ var
|
|
737034
|
-
var
|
|
737035
|
-
|
|
737624
|
+
/* harmony import */ var _tracking_InflightContextAdapter_js__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(52209);
|
|
737625
|
+
/* harmony import */ var _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(11369);
|
|
737626
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_factories_RebalancerContextFactory_js__WEBPACK_IMPORTED_MODULE_1__, _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_3__]);
|
|
737627
|
+
([_factories_RebalancerContextFactory_js__WEBPACK_IMPORTED_MODULE_1__, _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
737628
|
+
|
|
737036
737629
|
|
|
737037
737630
|
|
|
737038
737631
|
|
|
@@ -737130,7 +737723,7 @@ class RebalancerService {
|
|
|
737130
737723
|
if (this.config.actionTracker) {
|
|
737131
737724
|
// Use externally provided ActionTracker (e.g., for simulation/testing)
|
|
737132
737725
|
this.actionTracker = this.config.actionTracker;
|
|
737133
|
-
this.inflightContextAdapter = new
|
|
737726
|
+
this.inflightContextAdapter = new _tracking_InflightContextAdapter_js__WEBPACK_IMPORTED_MODULE_4__/* .InflightContextAdapter */ .m(this.actionTracker, this.multiProvider);
|
|
737134
737727
|
await this.actionTracker.initialize();
|
|
737135
737728
|
this.logger.info('Using externally provided ActionTracker');
|
|
737136
737729
|
}
|
|
@@ -737185,7 +737778,7 @@ class RebalancerService {
|
|
|
737185
737778
|
*/
|
|
737186
737779
|
async executeManual(request) {
|
|
737187
737780
|
await this.initialize();
|
|
737188
|
-
(0,
|
|
737781
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(this.rebalancer, 'Rebalancer not available. MonitorOnly mode cannot execute manual rebalances.');
|
|
737189
737782
|
const { origin, destination, amount } = request;
|
|
737190
737783
|
this.logger.info(`Manual rebalance strategy selected. Origin: ${origin}, Destination: ${destination}, Amount: ${amount}`);
|
|
737191
737784
|
const warpCore = this.contextFactory.getWarpCore();
|
|
@@ -737197,17 +737790,17 @@ class RebalancerService {
|
|
|
737197
737790
|
}
|
|
737198
737791
|
// Validate amount
|
|
737199
737792
|
const amountNum = Number(amount);
|
|
737200
|
-
(0,
|
|
737201
|
-
(0,
|
|
737793
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(!isNaN(amountNum), 'Amount must be a valid number');
|
|
737794
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(amountNum > 0, 'Amount must be greater than 0');
|
|
737202
737795
|
const originConfig = (0,_config_types_js__WEBPACK_IMPORTED_MODULE_0__/* .getStrategyChainConfig */ .nt)(this.rebalancerConfig.strategyConfig, origin);
|
|
737203
|
-
(0,
|
|
737796
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(originConfig?.bridge, `No bridge configured for origin chain ${origin}`);
|
|
737204
737797
|
// Use destination-specific bridge override if configured, otherwise use default
|
|
737205
737798
|
const bridge = originConfig.override?.[destination]?.bridge ?? originConfig.bridge;
|
|
737206
737799
|
try {
|
|
737207
737800
|
const manualRoute = {
|
|
737208
737801
|
origin,
|
|
737209
737802
|
destination,
|
|
737210
|
-
amount:
|
|
737803
|
+
amount: (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_3__/* .normalizeConfiguredAmount */ .k9)(amount, originToken),
|
|
737211
737804
|
executionType: 'movableCollateral',
|
|
737212
737805
|
bridge,
|
|
737213
737806
|
intentId: `manual-${Date.now()}`,
|
|
@@ -737228,7 +737821,7 @@ class RebalancerService {
|
|
|
737228
737821
|
throw new Error('start() can only be called in daemon mode');
|
|
737229
737822
|
}
|
|
737230
737823
|
await this.initialize();
|
|
737231
|
-
(0,
|
|
737824
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .v)(this.monitor, 'Monitor must be initialized for daemon mode');
|
|
737232
737825
|
// Setup monitor event listeners
|
|
737233
737826
|
this.monitor
|
|
737234
737827
|
.on(_interfaces_IMonitor_js__WEBPACK_IMPORTED_MODULE_2__/* .MonitorEventType */ .nE.TokenInfo, this.onTokenInfo.bind(this))
|
|
@@ -737315,29 +737908,30 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
737315
737908
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
737316
737909
|
/* harmony export */ n: () => (/* binding */ RebalancerContextFactory)
|
|
737317
737910
|
/* harmony export */ });
|
|
737318
|
-
/* harmony import */ var
|
|
737319
|
-
/* harmony import */ var
|
|
737320
|
-
/* harmony import */ var
|
|
737321
|
-
/* harmony import */ var
|
|
737322
|
-
/* harmony import */ var
|
|
737323
|
-
/* harmony import */ var
|
|
737324
|
-
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_20__ = __nccwpck_require__(21387);
|
|
737911
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_14__ = __nccwpck_require__(95176);
|
|
737912
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_15__ = __nccwpck_require__(9035);
|
|
737913
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_19__ = __nccwpck_require__(32772);
|
|
737914
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_12__ = __nccwpck_require__(73938);
|
|
737915
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_13__ = __nccwpck_require__(16639);
|
|
737916
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_16__ = __nccwpck_require__(21387);
|
|
737325
737917
|
/* harmony import */ var _bridges_LiFiBridge_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(70311);
|
|
737326
737918
|
/* harmony import */ var _config_types_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(75102);
|
|
737327
737919
|
/* harmony import */ var _core_InventoryRebalancer_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(13081);
|
|
737328
|
-
/* harmony import */ var
|
|
737329
|
-
/* harmony import */ var
|
|
737330
|
-
/* harmony import */ var
|
|
737331
|
-
/* harmony import */ var
|
|
737332
|
-
/* harmony import */ var
|
|
737333
|
-
/* harmony import */ var
|
|
737334
|
-
/* harmony import */ var
|
|
737335
|
-
/* harmony import */ var
|
|
737336
|
-
/* harmony import */ var
|
|
737337
|
-
/* harmony import */ var
|
|
737338
|
-
/* harmony import */ var
|
|
737339
|
-
|
|
737340
|
-
([_core_InventoryRebalancer_js__WEBPACK_IMPORTED_MODULE_2__,
|
|
737920
|
+
/* harmony import */ var _core_Rebalancer_js__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(3903);
|
|
737921
|
+
/* harmony import */ var _core_RebalancerOrchestrator_js__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(67279);
|
|
737922
|
+
/* harmony import */ var _metrics_Metrics_js__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(42575);
|
|
737923
|
+
/* harmony import */ var _metrics_PriceGetter_js__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(81708);
|
|
737924
|
+
/* harmony import */ var _monitor_Monitor_js__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(14135);
|
|
737925
|
+
/* harmony import */ var _strategy_StrategyFactory_js__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(88757);
|
|
737926
|
+
/* harmony import */ var _tracking_ActionTracker_js__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(60732);
|
|
737927
|
+
/* harmony import */ var _tracking_InflightContextAdapter_js__WEBPACK_IMPORTED_MODULE_20__ = __nccwpck_require__(52209);
|
|
737928
|
+
/* harmony import */ var _tracking_store_index_js__WEBPACK_IMPORTED_MODULE_17__ = __nccwpck_require__(98867);
|
|
737929
|
+
/* harmony import */ var _utils_ExplorerClient_js__WEBPACK_IMPORTED_MODULE_18__ = __nccwpck_require__(14660);
|
|
737930
|
+
/* harmony import */ var _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_10__ = __nccwpck_require__(11369);
|
|
737931
|
+
/* harmony import */ var _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_11__ = __nccwpck_require__(46618);
|
|
737932
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_core_InventoryRebalancer_js__WEBPACK_IMPORTED_MODULE_2__, _core_Rebalancer_js__WEBPACK_IMPORTED_MODULE_3__, _core_RebalancerOrchestrator_js__WEBPACK_IMPORTED_MODULE_4__, _metrics_Metrics_js__WEBPACK_IMPORTED_MODULE_5__, _metrics_PriceGetter_js__WEBPACK_IMPORTED_MODULE_6__, _strategy_StrategyFactory_js__WEBPACK_IMPORTED_MODULE_8__, _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_10__, _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_11__, _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_14__, _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_15__]);
|
|
737933
|
+
([_core_InventoryRebalancer_js__WEBPACK_IMPORTED_MODULE_2__, _core_Rebalancer_js__WEBPACK_IMPORTED_MODULE_3__, _core_RebalancerOrchestrator_js__WEBPACK_IMPORTED_MODULE_4__, _metrics_Metrics_js__WEBPACK_IMPORTED_MODULE_5__, _metrics_PriceGetter_js__WEBPACK_IMPORTED_MODULE_6__, _strategy_StrategyFactory_js__WEBPACK_IMPORTED_MODULE_8__, _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_10__, _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_11__, _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_14__, _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_15__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
737934
|
+
|
|
737341
737935
|
|
|
737342
737936
|
|
|
737343
737937
|
|
|
@@ -737369,7 +737963,7 @@ class RebalancerContextFactory {
|
|
|
737369
737963
|
* @param warpCore - An instance of `WarpCore` configured for the specified `warpRouteId`.
|
|
737370
737964
|
* @param tokensByChainName - A map of chain->token to ease the lookup of token by chain
|
|
737371
737965
|
* @param multiProvider - MultiProvider instance (for movable collateral operations)
|
|
737372
|
-
* @param multiProtocolProvider -
|
|
737966
|
+
* @param multiProtocolProvider - MultiProtocolProvider instance (with mailbox metadata)
|
|
737373
737967
|
* @param registry - IRegistry instance
|
|
737374
737968
|
* @param logger - Logger instance
|
|
737375
737969
|
*/
|
|
@@ -737386,7 +737980,7 @@ class RebalancerContextFactory {
|
|
|
737386
737980
|
/**
|
|
737387
737981
|
* @param config - The rebalancer config
|
|
737388
737982
|
* @param multiProvider - MultiProvider instance (for movable collateral operations)
|
|
737389
|
-
* @param multiProtocolProvider -
|
|
737983
|
+
* @param multiProtocolProvider - MultiProtocolProvider instance (optional, created from multiProvider if not provided)
|
|
737390
737984
|
* @param registry - IRegistry instance
|
|
737391
737985
|
* @param logger - Logger instance
|
|
737392
737986
|
*/
|
|
@@ -737398,7 +737992,7 @@ class RebalancerContextFactory {
|
|
|
737398
737992
|
const addresses = await registry.getAddresses();
|
|
737399
737993
|
// The Sealevel warp adapters require the Mailbox address, so we
|
|
737400
737994
|
// get mailboxes for all chains and merge them with the chain metadata.
|
|
737401
|
-
const mailboxes = (0,
|
|
737995
|
+
const mailboxes = (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_12__/* .objMap */ .Yp)(addresses, (_, { mailbox }) => ({ mailbox }));
|
|
737402
737996
|
// Fetch warp route config FIRST to get chain list
|
|
737403
737997
|
const warpCoreConfig = warpCoreConfigOverride ??
|
|
737404
737998
|
(await registry.getWarpRoute(config.warpRouteId));
|
|
@@ -737413,17 +738007,17 @@ class RebalancerContextFactory {
|
|
|
737413
738007
|
...new Set(warpCoreConfig.tokens.map((t) => t.chainName)),
|
|
737414
738008
|
];
|
|
737415
738009
|
for (const chain of warpChains) {
|
|
737416
|
-
if (multiProvider.getProtocol(chain) !==
|
|
738010
|
+
if (multiProvider.getProtocol(chain) !== _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_13__/* .ProtocolType */ .Hb.Ethereum) {
|
|
737417
738011
|
logger.debug({ chain }, 'Skipping provider init for non-EVM chain');
|
|
737418
738012
|
continue;
|
|
737419
738013
|
}
|
|
737420
738014
|
multiProvider.getProvider(chain);
|
|
737421
738015
|
}
|
|
737422
|
-
// Create
|
|
738016
|
+
// Create MultiProtocolProvider (convert from MultiProvider if not provided)
|
|
737423
738017
|
const mpp = multiProtocolProvider ??
|
|
737424
|
-
|
|
738018
|
+
_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_14__/* .MultiProtocolProvider */ .f.fromMultiProvider(multiProvider);
|
|
737425
738019
|
const extendedMultiProtocolProvider = mpp.extendChainMetadata(mailboxes);
|
|
737426
|
-
const warpCore =
|
|
738020
|
+
const warpCore = _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_15__/* .WarpCore */ .u.FromConfig(extendedMultiProtocolProvider, warpCoreConfig);
|
|
737427
738021
|
const tokensByChainName = Object.fromEntries(warpCore.tokens.map((t) => [t.chainName, t]));
|
|
737428
738022
|
logger.debug({
|
|
737429
738023
|
warpRouteId: config.warpRouteId,
|
|
@@ -737438,16 +738032,16 @@ class RebalancerContextFactory {
|
|
|
737438
738032
|
}
|
|
737439
738033
|
async createMetrics(coingeckoApiKey) {
|
|
737440
738034
|
this.logger.debug({ warpRouteId: this.config.warpRouteId }, 'Creating Metrics');
|
|
737441
|
-
const tokenPriceGetter =
|
|
738035
|
+
const tokenPriceGetter = _metrics_PriceGetter_js__WEBPACK_IMPORTED_MODULE_6__/* .PriceGetter */ .z.create(this.multiProvider.metadata, this.logger, coingeckoApiKey);
|
|
737442
738036
|
const warpDeployConfig = await this.registry.getWarpDeployConfig(this.config.warpRouteId);
|
|
737443
|
-
return new
|
|
738037
|
+
return new _metrics_Metrics_js__WEBPACK_IMPORTED_MODULE_5__/* .Metrics */ .K(tokenPriceGetter, warpDeployConfig, this.warpCore, this.config.warpRouteId, this.logger);
|
|
737444
738038
|
}
|
|
737445
738039
|
createMonitor(checkFrequency, inventoryConfig) {
|
|
737446
738040
|
this.logger.debug({
|
|
737447
738041
|
warpRouteId: this.config.warpRouteId,
|
|
737448
738042
|
checkFrequency: checkFrequency,
|
|
737449
738043
|
}, 'Creating Monitor');
|
|
737450
|
-
return new
|
|
738044
|
+
return new _monitor_Monitor_js__WEBPACK_IMPORTED_MODULE_7__/* .Monitor */ .V(checkFrequency, this.warpCore, this.logger, inventoryConfig);
|
|
737451
738045
|
}
|
|
737452
738046
|
async createStrategy(metrics) {
|
|
737453
738047
|
const strategyTypes = this.config.strategyConfig.map((s) => s.rebalanceStrategy);
|
|
@@ -737463,27 +738057,27 @@ class RebalancerContextFactory {
|
|
|
737463
738057
|
const chainConfig = (0,_config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .getStrategyChainConfig */ .nt)(this.config.strategyConfig, chainName);
|
|
737464
738058
|
if (chainConfig?.bridgeMinAcceptedAmount) {
|
|
737465
738059
|
const token = this.tokensByChainName[chainName];
|
|
737466
|
-
|
|
737467
|
-
minAmountsByChain[chainName] =
|
|
738060
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_16__/* .assert */ .v)(token, `No token found for configured strategy chain ${chainName} in warp route ${this.config.warpRouteId}`);
|
|
738061
|
+
minAmountsByChain[chainName] = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_10__/* .normalizeConfiguredAmount */ .k9)(chainConfig.bridgeMinAcceptedAmount, token);
|
|
737468
738062
|
}
|
|
737469
738063
|
}
|
|
737470
738064
|
this.logger.debug({
|
|
737471
738065
|
minAmountsByChain: Object.fromEntries(Object.entries(minAmountsByChain).map(([k, v]) => [k, v.toString()])),
|
|
737472
738066
|
}, 'Built minimum amounts by chain for strategy');
|
|
737473
|
-
return
|
|
738067
|
+
return _strategy_StrategyFactory_js__WEBPACK_IMPORTED_MODULE_8__/* .StrategyFactory */ .M.createStrategy(this.config.strategyConfig, this.tokensByChainName, await this.getInitialTotalCollateral(), this.logger, metrics, minAmountsByChain);
|
|
737474
738068
|
}
|
|
737475
738069
|
createMovableCollateralRebalancer(actionTracker, metrics) {
|
|
737476
738070
|
this.logger.debug({ warpRouteId: this.config.warpRouteId }, 'Creating Rebalancer');
|
|
737477
|
-
const rebalancer = new
|
|
738071
|
+
const rebalancer = new _core_Rebalancer_js__WEBPACK_IMPORTED_MODULE_3__/* .Rebalancer */ .K(this.warpCore, this.multiProvider.metadata, this.tokensByChainName, this.multiProvider, actionTracker, this.logger, metrics);
|
|
737478
738072
|
return rebalancer;
|
|
737479
738073
|
}
|
|
737480
738074
|
async createActionTracker(explorerUrlOrClient = DEFAULT_EXPLORER_URL) {
|
|
737481
738075
|
this.logger.debug({ warpRouteId: this.config.warpRouteId }, 'Creating ActionTracker');
|
|
737482
|
-
const transferStore = new
|
|
737483
|
-
const intentStore = new
|
|
737484
|
-
const actionStore = new
|
|
738076
|
+
const transferStore = new _tracking_store_index_js__WEBPACK_IMPORTED_MODULE_17__/* .InMemoryStore */ .A();
|
|
738077
|
+
const intentStore = new _tracking_store_index_js__WEBPACK_IMPORTED_MODULE_17__/* .InMemoryStore */ .A();
|
|
738078
|
+
const actionStore = new _tracking_store_index_js__WEBPACK_IMPORTED_MODULE_17__/* .InMemoryStore */ .A();
|
|
737485
738079
|
const explorerClient = typeof explorerUrlOrClient === 'string'
|
|
737486
|
-
? new
|
|
738080
|
+
? new _utils_ExplorerClient_js__WEBPACK_IMPORTED_MODULE_18__/* .ExplorerClient */ .x(explorerUrlOrClient, (domain) => this.multiProvider.getProtocol(domain))
|
|
737487
738081
|
: explorerUrlOrClient;
|
|
737488
738082
|
// 3. Get MultiProtocolCore from registry (supports all VM types)
|
|
737489
738083
|
// Only fetch/validate addresses for warp route chains (not all registry chains)
|
|
@@ -737496,7 +738090,7 @@ class RebalancerContextFactory {
|
|
|
737496
738090
|
}
|
|
737497
738091
|
coreAddresses[chain] = addrs;
|
|
737498
738092
|
}
|
|
737499
|
-
const multiProtocolCore =
|
|
738093
|
+
const multiProtocolCore = _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_19__/* .MultiProtocolCore */ .n.fromAddressesMap(coreAddresses, this.multiProtocolProvider);
|
|
737500
738094
|
// 4. Get rebalancer address from signer
|
|
737501
738095
|
// Use the first chain in the strategy to get the signer address
|
|
737502
738096
|
const chainNames = (0,_config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .getStrategyChainNames */ .zj)(this.config.strategyConfig);
|
|
@@ -737518,7 +738112,7 @@ class RebalancerContextFactory {
|
|
|
737518
738112
|
rebalancerAddress,
|
|
737519
738113
|
inventorySignerAddresses: this.config.inventorySigners
|
|
737520
738114
|
? Object.entries(this.config.inventorySigners)
|
|
737521
|
-
.filter(([protocol]) => protocol ===
|
|
738115
|
+
.filter(([protocol]) => protocol === _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_13__/* .ProtocolType */ .Hb.Ethereum)
|
|
737522
738116
|
.map(([, signerConfig]) => signerConfig)
|
|
737523
738117
|
.map((s) => s.address)
|
|
737524
738118
|
.filter(Boolean)
|
|
@@ -737526,9 +738120,9 @@ class RebalancerContextFactory {
|
|
|
737526
738120
|
intentTTL: this.config.intentTTL,
|
|
737527
738121
|
};
|
|
737528
738122
|
// 6. Create ActionTracker
|
|
737529
|
-
const tracker = new
|
|
738123
|
+
const tracker = new _tracking_ActionTracker_js__WEBPACK_IMPORTED_MODULE_9__/* .ActionTracker */ .N(transferStore, intentStore, actionStore, explorerClient, multiProtocolCore, trackerConfig, this.logger);
|
|
737530
738124
|
// 7. Create InflightContextAdapter
|
|
737531
|
-
const adapter = new
|
|
738125
|
+
const adapter = new _tracking_InflightContextAdapter_js__WEBPACK_IMPORTED_MODULE_20__/* .InflightContextAdapter */ .m(tracker, this.multiProvider);
|
|
737532
738126
|
this.logger.debug({
|
|
737533
738127
|
warpRouteId: this.config.warpRouteId,
|
|
737534
738128
|
routerCount: Object.keys(routersByDomain).length,
|
|
@@ -737565,31 +738159,34 @@ class RebalancerContextFactory {
|
|
|
737565
738159
|
this.logger.debug('No inventory chains configured');
|
|
737566
738160
|
return null;
|
|
737567
738161
|
}
|
|
738162
|
+
for (const chain of allRelevantChains) {
|
|
738163
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_16__/* .assert */ .v)(this.tokensByChainName[chain], `No token found for inventory-relevant chain ${chain} in warp route ${this.config.warpRouteId}`);
|
|
738164
|
+
}
|
|
737568
738165
|
const requiredProtocols = new Set(allRelevantChains.map((chain) => {
|
|
737569
738166
|
const metadata = this.warpCore.multiProvider.getChainMetadata(chain);
|
|
737570
|
-
(0,
|
|
738167
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_16__/* .assert */ .v)(metadata?.protocol, `No protocol in chain metadata for ${chain}`);
|
|
737571
738168
|
return metadata.protocol;
|
|
737572
738169
|
}));
|
|
737573
738170
|
const SUPPORTED_INVENTORY_PROTOCOLS = new Set([
|
|
737574
|
-
|
|
737575
|
-
|
|
738171
|
+
_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_13__/* .ProtocolType */ .Hb.Ethereum,
|
|
738172
|
+
_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_13__/* .ProtocolType */ .Hb.Sealevel,
|
|
737576
738173
|
]);
|
|
737577
738174
|
for (const protocol of requiredProtocols) {
|
|
737578
738175
|
const chainsForProtocol = allRelevantChains.filter((chain) => this.warpCore.multiProvider.getChainMetadata(chain).protocol ===
|
|
737579
738176
|
protocol);
|
|
737580
|
-
(0,
|
|
738177
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_16__/* .assert */ .v)(SUPPORTED_INVENTORY_PROTOCOLS.has(protocol), `Inventory rebalancing does not support protocol '${protocol}' (chains: ${chainsForProtocol.join(', ')}). Supported: ethereum, sealevel`);
|
|
737581
738178
|
}
|
|
737582
738179
|
for (const protocol of requiredProtocols) {
|
|
737583
738180
|
const chainsForProtocol = allRelevantChains.filter((chain) => this.warpCore.multiProvider.getChainMetadata(chain).protocol ===
|
|
737584
738181
|
protocol);
|
|
737585
|
-
(0,
|
|
738182
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_16__/* .assert */ .v)(this.config.inventorySigners?.[protocol]?.key ??
|
|
737586
738183
|
this.inventorySignerKeysByProtocol?.[protocol], `Missing inventory signer key for protocol ${protocol} (required by inventory chains: ${chainsForProtocol.join(', ')})`);
|
|
737587
738184
|
}
|
|
737588
738185
|
// Validate inventory address coverage for all required protocols
|
|
737589
738186
|
for (const protocol of requiredProtocols) {
|
|
737590
738187
|
const chainsForProtocol = allRelevantChains.filter((chain) => this.warpCore.multiProvider.getChainMetadata(chain).protocol ===
|
|
737591
738188
|
protocol);
|
|
737592
|
-
(0,
|
|
738189
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_16__/* .assert */ .v)(inventorySigners[protocol]?.address, `Missing inventory address for protocol ${protocol} (required by inventory chains: ${chainsForProtocol.join(', ')})`);
|
|
737593
738190
|
}
|
|
737594
738191
|
const externalBridgeRegistry = externalBridgeRegistryOverride ?? this.buildExternalBridgeRegistry();
|
|
737595
738192
|
if (Object.keys(externalBridgeRegistry).length === 0) {
|
|
@@ -737713,7 +738310,7 @@ class RebalancerContextFactory {
|
|
|
737713
738310
|
*/
|
|
737714
738311
|
createOrchestrator(options) {
|
|
737715
738312
|
this.logger.debug({ warpRouteId: this.config.warpRouteId }, 'Creating RebalancerOrchestrator');
|
|
737716
|
-
return new
|
|
738313
|
+
return new _core_RebalancerOrchestrator_js__WEBPACK_IMPORTED_MODULE_4__/* .RebalancerOrchestrator */ .E({
|
|
737717
738314
|
strategy: options.strategy,
|
|
737718
738315
|
actionTracker: options.actionTracker,
|
|
737719
738316
|
inflightContextAdapter: options.inflightContextAdapter,
|
|
@@ -737747,11 +738344,12 @@ class RebalancerContextFactory {
|
|
|
737747
738344
|
let initialTotalCollateral = 0n;
|
|
737748
738345
|
const chainNames = new Set((0,_config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .getStrategyChainNames */ .zj)(this.config.strategyConfig));
|
|
737749
738346
|
await Promise.all(this.warpCore.tokens.map(async (token) => {
|
|
737750
|
-
if ((0,
|
|
738347
|
+
if ((0,_utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_11__/* .isCollateralizedTokenEligibleForRebalancing */ .rC)(token) &&
|
|
737751
738348
|
chainNames.has(token.chainName)) {
|
|
737752
738349
|
const adapter = token.getHypAdapter(this.warpCore.multiProvider);
|
|
737753
738350
|
const bridgedSupply = await adapter.getBridgedSupply();
|
|
737754
|
-
|
|
738351
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_16__/* .assert */ .v)(bridgedSupply !== undefined, `Missing bridged supply for ${token.chainName} while computing initial total collateral for warp route ${this.config.warpRouteId}`);
|
|
738352
|
+
initialTotalCollateral += (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_10__/* .normalizeToCanonical */ .R2)(bridgedSupply, token);
|
|
737755
738353
|
}
|
|
737756
738354
|
}));
|
|
737757
738355
|
return initialTotalCollateral;
|
|
@@ -737769,24 +738367,26 @@ __webpack_async_result__();
|
|
|
737769
738367
|
__nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
737770
738368
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
737771
738369
|
/* harmony export */ $X: () => (/* reexport safe */ _core_RebalancerService_js__WEBPACK_IMPORTED_MODULE_0__.$),
|
|
737772
|
-
/* harmony export */ Wo: () => (/* reexport safe */
|
|
737773
|
-
/* harmony export */ zj: () => (/* reexport safe */
|
|
738370
|
+
/* harmony export */ Wo: () => (/* reexport safe */ _config_RebalancerConfig_js__WEBPACK_IMPORTED_MODULE_2__.W),
|
|
738371
|
+
/* harmony export */ zj: () => (/* reexport safe */ _config_types_js__WEBPACK_IMPORTED_MODULE_3__.zj)
|
|
737774
738372
|
/* harmony export */ });
|
|
737775
738373
|
/* harmony import */ var _core_RebalancerService_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(42248);
|
|
737776
|
-
/* harmony import */ var
|
|
737777
|
-
/* harmony import */ var
|
|
737778
|
-
/* harmony import */ var
|
|
737779
|
-
/* harmony import */ var
|
|
737780
|
-
/* harmony import */ var
|
|
737781
|
-
/* harmony import */ var
|
|
737782
|
-
/* harmony import */ var
|
|
737783
|
-
/* harmony import */ var
|
|
737784
|
-
/* harmony import */ var
|
|
737785
|
-
/* harmony import */ var
|
|
737786
|
-
/* harmony import */ var
|
|
737787
|
-
/* harmony import */ var
|
|
737788
|
-
|
|
737789
|
-
|
|
738374
|
+
/* harmony import */ var _core_Rebalancer_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(3903);
|
|
738375
|
+
/* harmony import */ var _config_RebalancerConfig_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(37562);
|
|
738376
|
+
/* harmony import */ var _config_types_js__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(75102);
|
|
738377
|
+
/* harmony import */ var _strategy_BaseStrategy_js__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(94598);
|
|
738378
|
+
/* harmony import */ var _strategy_WeightedStrategy_js__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(64438);
|
|
738379
|
+
/* harmony import */ var _strategy_MinAmountStrategy_js__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(82833);
|
|
738380
|
+
/* harmony import */ var _strategy_StrategyFactory_js__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(88757);
|
|
738381
|
+
/* harmony import */ var _monitor_Monitor_js__WEBPACK_IMPORTED_MODULE_8__ = __nccwpck_require__(14135);
|
|
738382
|
+
/* harmony import */ var _metrics_Metrics_js__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(42575);
|
|
738383
|
+
/* harmony import */ var _metrics_PriceGetter_js__WEBPACK_IMPORTED_MODULE_10__ = __nccwpck_require__(81708);
|
|
738384
|
+
/* harmony import */ var _interfaces_IMonitor_js__WEBPACK_IMPORTED_MODULE_11__ = __nccwpck_require__(36513);
|
|
738385
|
+
/* harmony import */ var _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_12__ = __nccwpck_require__(11369);
|
|
738386
|
+
/* harmony import */ var _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_13__ = __nccwpck_require__(46618);
|
|
738387
|
+
/* harmony import */ var _factories_RebalancerContextFactory_js__WEBPACK_IMPORTED_MODULE_14__ = __nccwpck_require__(84569);
|
|
738388
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_core_RebalancerService_js__WEBPACK_IMPORTED_MODULE_0__, _core_Rebalancer_js__WEBPACK_IMPORTED_MODULE_1__, _strategy_BaseStrategy_js__WEBPACK_IMPORTED_MODULE_4__, _strategy_WeightedStrategy_js__WEBPACK_IMPORTED_MODULE_5__, _strategy_MinAmountStrategy_js__WEBPACK_IMPORTED_MODULE_6__, _strategy_StrategyFactory_js__WEBPACK_IMPORTED_MODULE_7__, _metrics_Metrics_js__WEBPACK_IMPORTED_MODULE_9__, _metrics_PriceGetter_js__WEBPACK_IMPORTED_MODULE_10__, _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_12__, _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_13__, _factories_RebalancerContextFactory_js__WEBPACK_IMPORTED_MODULE_14__]);
|
|
738389
|
+
([_core_RebalancerService_js__WEBPACK_IMPORTED_MODULE_0__, _core_Rebalancer_js__WEBPACK_IMPORTED_MODULE_1__, _strategy_BaseStrategy_js__WEBPACK_IMPORTED_MODULE_4__, _strategy_WeightedStrategy_js__WEBPACK_IMPORTED_MODULE_5__, _strategy_MinAmountStrategy_js__WEBPACK_IMPORTED_MODULE_6__, _strategy_StrategyFactory_js__WEBPACK_IMPORTED_MODULE_7__, _metrics_Metrics_js__WEBPACK_IMPORTED_MODULE_9__, _metrics_PriceGetter_js__WEBPACK_IMPORTED_MODULE_10__, _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_12__, _utils_tokenUtils_js__WEBPACK_IMPORTED_MODULE_13__, _factories_RebalancerContextFactory_js__WEBPACK_IMPORTED_MODULE_14__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
737790
738390
|
/**
|
|
737791
738391
|
* @hyperlane-xyz/rebalancer
|
|
737792
738392
|
*
|
|
@@ -738218,7 +738818,8 @@ __webpack_async_result__();
|
|
|
738218
738818
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
738219
738819
|
/* harmony export */ V: () => (/* binding */ Monitor)
|
|
738220
738820
|
/* harmony export */ });
|
|
738221
|
-
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(
|
|
738821
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(39196);
|
|
738822
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(14918);
|
|
738222
738823
|
/* harmony import */ var _interfaces_IMonitor_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(36513);
|
|
738223
738824
|
/* harmony import */ var _utils_blockTag_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(82167);
|
|
738224
738825
|
|
|
@@ -738305,13 +738906,21 @@ class Monitor {
|
|
|
738305
738906
|
const inventoryBalances = await this.fetchInventoryBalances();
|
|
738306
738907
|
if (Object.keys(inventoryBalances).length > 0) {
|
|
738307
738908
|
event.inventoryBalances = inventoryBalances;
|
|
738909
|
+
const tokensByChain = new Map(this.warpCore.tokens.map((token) => [token.chainName, token]));
|
|
738910
|
+
// CAST: inventoryBalances keys come from configured monitor chains,
|
|
738911
|
+
// but Object.entries widens them to string.
|
|
738912
|
+
const inventoryBalanceEntries = Object.entries(inventoryBalances);
|
|
738308
738913
|
this.logger.info({
|
|
738309
738914
|
chainsMonitored: Object.keys(inventoryBalances).length,
|
|
738310
|
-
balances:
|
|
738311
|
-
chain
|
|
738312
|
-
|
|
738313
|
-
|
|
738314
|
-
|
|
738915
|
+
balances: inventoryBalanceEntries.map(([chain, balance]) => {
|
|
738916
|
+
const token = tokensByChain.get(chain);
|
|
738917
|
+
return {
|
|
738918
|
+
chain,
|
|
738919
|
+
tokenSymbol: token?.symbol,
|
|
738920
|
+
balance: balance.toString(),
|
|
738921
|
+
balanceFormatted: (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__/* .fromWei */ .kX)(balance.toString(), token?.decimals),
|
|
738922
|
+
};
|
|
738923
|
+
}),
|
|
738315
738924
|
}, 'Inventory balances fetched');
|
|
738316
738925
|
}
|
|
738317
738926
|
if (this.tokenInfoHandler) {
|
|
@@ -738326,7 +738935,7 @@ class Monitor {
|
|
|
738326
738935
|
const elapsed = Date.now() - cycleStart;
|
|
738327
738936
|
const remaining = this.checkFrequency - elapsed;
|
|
738328
738937
|
if (remaining > 0) {
|
|
738329
|
-
await (0,
|
|
738938
|
+
await (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__/* .sleep */ .yy)(remaining);
|
|
738330
738939
|
}
|
|
738331
738940
|
// If elapsed >= checkFrequency, start next cycle immediately
|
|
738332
738941
|
}
|
|
@@ -738436,13 +739045,16 @@ class Monitor {
|
|
|
738436
739045
|
/***/ }),
|
|
738437
739046
|
|
|
738438
739047
|
/***/ 94598:
|
|
738439
|
-
/***/ ((
|
|
739048
|
+
/***/ ((__webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
738440
739049
|
|
|
739050
|
+
__nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
738441
739051
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
738442
739052
|
/* harmony export */ Z: () => (/* binding */ BaseStrategy)
|
|
738443
739053
|
/* harmony export */ });
|
|
738444
|
-
/* harmony import */ var
|
|
738445
|
-
/* harmony import */ var
|
|
739054
|
+
/* harmony import */ var _utils_bridgeUtils_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(88688);
|
|
739055
|
+
/* harmony import */ var _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(11369);
|
|
739056
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__]);
|
|
739057
|
+
_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
738446
739058
|
|
|
738447
739059
|
|
|
738448
739060
|
/**
|
|
@@ -738466,7 +739078,7 @@ class BaseStrategy {
|
|
|
738466
739078
|
this.tokensByChainName = tokensByChainName;
|
|
738467
739079
|
}
|
|
738468
739080
|
getBridgeConfigForRoute(origin, destination) {
|
|
738469
|
-
return (0,
|
|
739081
|
+
return (0,_utils_bridgeUtils_js__WEBPACK_IMPORTED_MODULE_1__/* .getBridgeConfig */ .Yf)(this.bridgeConfigs, origin, destination);
|
|
738470
739082
|
}
|
|
738471
739083
|
/**
|
|
738472
739084
|
* Main method to get rebalancing routes
|
|
@@ -738548,7 +739160,7 @@ class BaseStrategy {
|
|
|
738548
739160
|
// Get bridge config for this route (with destination-specific overrides)
|
|
738549
739161
|
const bridgeConfig = this.getBridgeConfigForRoute(surplus.chain, deficit.chain);
|
|
738550
739162
|
// Create appropriate route type based on execution type
|
|
738551
|
-
routes.push((0,
|
|
739163
|
+
routes.push((0,_utils_bridgeUtils_js__WEBPACK_IMPORTED_MODULE_1__/* .createStrategyRoute */ .vT)(bridgeConfig, surplus.chain, deficit.chain, transferAmount));
|
|
738552
739164
|
}
|
|
738553
739165
|
// Decreases the amounts for the following iterations
|
|
738554
739166
|
deficit.amount -= transferAmount;
|
|
@@ -738767,16 +739379,18 @@ class BaseStrategy {
|
|
|
738767
739379
|
const token = this.tokensByChainName[route.origin];
|
|
738768
739380
|
if (token) {
|
|
738769
739381
|
const bridgeConfig = this.getBridgeConfigForRoute(route.origin, route.destination);
|
|
738770
|
-
|
|
738771
|
-
|
|
738772
|
-
|
|
738773
|
-
|
|
738774
|
-
|
|
738775
|
-
|
|
738776
|
-
|
|
738777
|
-
|
|
738778
|
-
|
|
738779
|
-
|
|
739382
|
+
if (bridgeConfig.bridgeMinAcceptedAmount != null) {
|
|
739383
|
+
const minAmount = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_0__/* .normalizeConfiguredAmount */ .k9)(bridgeConfig.bridgeMinAcceptedAmount, token);
|
|
739384
|
+
if (route.amount < minAmount) {
|
|
739385
|
+
this.logger.info({
|
|
739386
|
+
context: this.constructor.name,
|
|
739387
|
+
origin: route.origin,
|
|
739388
|
+
destination: route.destination,
|
|
739389
|
+
amount: route.amount.toString(),
|
|
739390
|
+
minAmount: minAmount.toString(),
|
|
739391
|
+
}, 'Dropping route below bridgeMinAcceptedAmount');
|
|
739392
|
+
return false;
|
|
739393
|
+
}
|
|
738780
739394
|
}
|
|
738781
739395
|
}
|
|
738782
739396
|
}
|
|
@@ -738785,152 +739399,24 @@ class BaseStrategy {
|
|
|
738785
739399
|
}
|
|
738786
739400
|
}
|
|
738787
739401
|
//# sourceMappingURL=BaseStrategy.js.map
|
|
739402
|
+
__webpack_async_result__();
|
|
739403
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
738788
739404
|
|
|
738789
739405
|
/***/ }),
|
|
738790
739406
|
|
|
738791
|
-
/***/
|
|
738792
|
-
/***/ ((
|
|
739407
|
+
/***/ 22532:
|
|
739408
|
+
/***/ ((__webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
738793
739409
|
|
|
739410
|
+
__nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
738794
739411
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
738795
|
-
/* harmony export */
|
|
739412
|
+
/* harmony export */ v: () => (/* binding */ CollateralDeficitStrategy)
|
|
738796
739413
|
/* harmony export */ });
|
|
738797
|
-
/* harmony import */ var
|
|
738798
|
-
/* harmony import */ var
|
|
738799
|
-
/* harmony import */ var
|
|
739414
|
+
/* harmony import */ var _config_types_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(75102);
|
|
739415
|
+
/* harmony import */ var _utils_bridgeUtils_js__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(88688);
|
|
739416
|
+
/* harmony import */ var _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(11369);
|
|
738800
739417
|
/* harmony import */ var _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(94598);
|
|
738801
|
-
|
|
738802
|
-
|
|
738803
|
-
|
|
738804
|
-
|
|
738805
|
-
/**
|
|
738806
|
-
* Strategy implementation that rebalance based on minimum amounts
|
|
738807
|
-
* It ensures each chain has at least the specified minimum amount
|
|
738808
|
-
*/
|
|
738809
|
-
class MinAmountStrategy extends _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_2__/* .BaseStrategy */ .Z {
|
|
738810
|
-
name = _config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .RebalancerStrategyOptions */ .t$.MinAmount;
|
|
738811
|
-
config = {};
|
|
738812
|
-
logger;
|
|
738813
|
-
constructor(config, tokensByChainName, initialTotalCollateral, logger, bridgeConfigs, metrics) {
|
|
738814
|
-
const chains = Object.keys(config);
|
|
738815
|
-
const log = logger.child({ class: MinAmountStrategy.name });
|
|
738816
|
-
super(chains, log, bridgeConfigs, metrics, tokensByChainName);
|
|
738817
|
-
this.logger = log;
|
|
738818
|
-
const minAmountType = config[chains[0]].minAmount.type;
|
|
738819
|
-
this.validateAmounts(initialTotalCollateral, minAmountType, config);
|
|
738820
|
-
for (const chain of chains) {
|
|
738821
|
-
const { min, target } = config[chain].minAmount;
|
|
738822
|
-
// check range constraints
|
|
738823
|
-
if ((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(target).lt(min)) {
|
|
738824
|
-
throw new Error(`Target (${target}) must be greater than or equal to min (${min}) for chain ${chain}`);
|
|
738825
|
-
}
|
|
738826
|
-
if ((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(min).lt(0)) {
|
|
738827
|
-
throw new Error(`Minimum amount (${min}) cannot be negative for chain ${chain}`);
|
|
738828
|
-
}
|
|
738829
|
-
if ((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(target).lt(0)) {
|
|
738830
|
-
throw new Error(`Target amount (${target}) cannot be negative for chain ${chain}`);
|
|
738831
|
-
}
|
|
738832
|
-
}
|
|
738833
|
-
this.config = config;
|
|
738834
|
-
this.logger.info('MinAmountStrategy created');
|
|
738835
|
-
}
|
|
738836
|
-
/**
|
|
738837
|
-
* Gets balances categorized by surplus and deficit based on minimum amounts and targets
|
|
738838
|
-
* - For absolute values: Uses exact token amounts
|
|
738839
|
-
* - For relative values: Uses percentages of total balance across all chains
|
|
738840
|
-
*
|
|
738841
|
-
* Simulates both types of rebalances before calculating surpluses/deficits:
|
|
738842
|
-
* - pendingRebalances: in-flight intents (origin tx confirmed, add to destination only)
|
|
738843
|
-
* - proposedRebalances: routes from earlier strategies (subtract from origin AND add to destination)
|
|
738844
|
-
*
|
|
738845
|
-
* This prevents over-rebalancing when multiple strategies run in sequence.
|
|
738846
|
-
*/
|
|
738847
|
-
getCategorizedBalances(rawBalances, pendingRebalances, proposedRebalances) {
|
|
738848
|
-
// Step 1: Simulate pending rebalances (in-flight, origin already deducted on-chain)
|
|
738849
|
-
let simulatedBalances = this.simulatePendingRebalances(rawBalances, pendingRebalances ?? []);
|
|
738850
|
-
// Step 2: Simulate proposed rebalances (from earlier strategies, not yet executed)
|
|
738851
|
-
simulatedBalances = this.simulateProposedRebalances(simulatedBalances, proposedRebalances ?? []);
|
|
738852
|
-
const totalCollateral = this.chains.reduce((sum, chain) => sum + simulatedBalances[chain], 0n);
|
|
738853
|
-
return this.chains.reduce((acc, chain) => {
|
|
738854
|
-
const chainConfig = this.config[chain];
|
|
738855
|
-
const balance = simulatedBalances[chain];
|
|
738856
|
-
let minAmount;
|
|
738857
|
-
let targetAmount;
|
|
738858
|
-
if (chainConfig.minAmount.type === _config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .RebalancerMinAmountType */ .gK.Absolute) {
|
|
738859
|
-
const token = this.getTokenByChainName(chain);
|
|
738860
|
-
minAmount = BigInt((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__/* .toWei */ .fq)(chainConfig.minAmount.min, token.decimals));
|
|
738861
|
-
targetAmount = BigInt((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__/* .toWei */ .fq)(chainConfig.minAmount.target, token.decimals));
|
|
738862
|
-
}
|
|
738863
|
-
else {
|
|
738864
|
-
minAmount = BigInt((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(totalCollateral.toString())
|
|
738865
|
-
.times(chainConfig.minAmount.min)
|
|
738866
|
-
.toFixed(0, bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g.ROUND_FLOOR));
|
|
738867
|
-
targetAmount = BigInt((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(totalCollateral.toString())
|
|
738868
|
-
.times(chainConfig.minAmount.target)
|
|
738869
|
-
.toFixed(0, bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g.ROUND_FLOOR));
|
|
738870
|
-
}
|
|
738871
|
-
// If balance is less than minAmount, it has a deficit
|
|
738872
|
-
if (balance < minAmount) {
|
|
738873
|
-
acc.deficits.push({ chain, amount: targetAmount - balance });
|
|
738874
|
-
}
|
|
738875
|
-
else {
|
|
738876
|
-
// Any chain with more than minAmount potentially has surplus
|
|
738877
|
-
const surplus = balance - minAmount;
|
|
738878
|
-
if (surplus > 0n) {
|
|
738879
|
-
acc.surpluses.push({ chain, amount: surplus });
|
|
738880
|
-
}
|
|
738881
|
-
}
|
|
738882
|
-
return acc;
|
|
738883
|
-
}, {
|
|
738884
|
-
surpluses: [],
|
|
738885
|
-
deficits: [],
|
|
738886
|
-
});
|
|
738887
|
-
}
|
|
738888
|
-
getTokenByChainName(chainName) {
|
|
738889
|
-
const token = this.tokensByChainName[chainName];
|
|
738890
|
-
if (token === undefined) {
|
|
738891
|
-
throw new Error(`Token not found for chain ${chainName}`);
|
|
738892
|
-
}
|
|
738893
|
-
return token;
|
|
738894
|
-
}
|
|
738895
|
-
validateAmounts(totalCollateral, minAmountType, config) {
|
|
738896
|
-
config ??= this.config;
|
|
738897
|
-
if (minAmountType === _config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .RebalancerMinAmountType */ .gK.Absolute) {
|
|
738898
|
-
let totalTargets = 0n;
|
|
738899
|
-
let decimals = 0;
|
|
738900
|
-
for (const chainName of this.chains) {
|
|
738901
|
-
const token = this.getTokenByChainName(chainName);
|
|
738902
|
-
// all the tokens have the same amount of decimals
|
|
738903
|
-
decimals = token.decimals;
|
|
738904
|
-
totalTargets += BigInt((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__/* .toWei */ .fq)(config[chainName].minAmount.target, token.decimals));
|
|
738905
|
-
}
|
|
738906
|
-
if (totalTargets > totalCollateral) {
|
|
738907
|
-
throw new Error(`Consider reducing the targets as the sum (${(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__/* .fromWei */ .kX)(totalTargets.toString(), decimals)}) is greater than sum of collaterals (${(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_3__/* .fromWei */ .kX)(totalCollateral.toString(), decimals)})`);
|
|
738908
|
-
}
|
|
738909
|
-
}
|
|
738910
|
-
}
|
|
738911
|
-
}
|
|
738912
|
-
//# sourceMappingURL=MinAmountStrategy.js.map
|
|
738913
|
-
|
|
738914
|
-
/***/ }),
|
|
738915
|
-
|
|
738916
|
-
/***/ 52154:
|
|
738917
|
-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
738918
|
-
|
|
738919
|
-
|
|
738920
|
-
// EXPORTS
|
|
738921
|
-
__nccwpck_require__.d(__webpack_exports__, {
|
|
738922
|
-
M: () => (/* binding */ StrategyFactory)
|
|
738923
|
-
});
|
|
738924
|
-
|
|
738925
|
-
// EXTERNAL MODULE: ../rebalancer/dist/config/types.js
|
|
738926
|
-
var types = __nccwpck_require__(75102);
|
|
738927
|
-
// EXTERNAL MODULE: ../utils/dist/amount.js
|
|
738928
|
-
var amount = __nccwpck_require__(39196);
|
|
738929
|
-
// EXTERNAL MODULE: ../rebalancer/dist/utils/bridgeUtils.js
|
|
738930
|
-
var bridgeUtils = __nccwpck_require__(88688);
|
|
738931
|
-
// EXTERNAL MODULE: ../rebalancer/dist/strategy/BaseStrategy.js
|
|
738932
|
-
var BaseStrategy = __nccwpck_require__(94598);
|
|
738933
|
-
;// CONCATENATED MODULE: ../rebalancer/dist/strategy/CollateralDeficitStrategy.js
|
|
739418
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_1__, _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_2__]);
|
|
739419
|
+
([_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_1__, _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
738934
739420
|
|
|
738935
739421
|
|
|
738936
739422
|
|
|
@@ -738945,8 +739431,8 @@ var BaseStrategy = __nccwpck_require__(94598);
|
|
|
738945
739431
|
* 3. Negative simulated balance = deficit (magnitude + buffer)
|
|
738946
739432
|
* 4. Positive simulated balance = potential surplus
|
|
738947
739433
|
*/
|
|
738948
|
-
class CollateralDeficitStrategy extends
|
|
738949
|
-
name =
|
|
739434
|
+
class CollateralDeficitStrategy extends _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_2__/* .BaseStrategy */ .Z {
|
|
739435
|
+
name = _config_types_js__WEBPACK_IMPORTED_MODULE_0__/* .RebalancerStrategyOptions */ .t$.CollateralDeficit;
|
|
738950
739436
|
config;
|
|
738951
739437
|
logger;
|
|
738952
739438
|
constructor(config, tokensByChainName, logger, bridgeConfigs, metrics) {
|
|
@@ -738985,7 +739471,7 @@ class CollateralDeficitStrategy extends BaseStrategy/* BaseStrategy */.Z {
|
|
|
738985
739471
|
for (const chain of this.chains) {
|
|
738986
739472
|
const balance = simulatedBalances[chain];
|
|
738987
739473
|
const token = this.getTokenByChainName(chain);
|
|
738988
|
-
const bufferWei =
|
|
739474
|
+
const bufferWei = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_1__/* .normalizeConfiguredAmount */ .k9)(this.config[chain].buffer, token);
|
|
738989
739475
|
if (balance < 0n) {
|
|
738990
739476
|
// Negative balance indicates deficit
|
|
738991
739477
|
const deficitAmount = -balance + bufferWei;
|
|
@@ -739074,7 +739560,7 @@ class CollateralDeficitStrategy extends BaseStrategy/* BaseStrategy */.Z {
|
|
|
739074
739560
|
const transferAmount = surplus.amount > deficit.amount ? deficit.amount : surplus.amount;
|
|
739075
739561
|
if (transferAmount > 0n) {
|
|
739076
739562
|
const bridgeConfig = this.getBridgeConfigForRoute(surplus.chain, deficit.chain);
|
|
739077
|
-
routes.push((0,
|
|
739563
|
+
routes.push((0,_utils_bridgeUtils_js__WEBPACK_IMPORTED_MODULE_3__/* .createStrategyRoute */ .vT)(bridgeConfig, surplus.chain, deficit.chain, transferAmount));
|
|
739078
739564
|
}
|
|
739079
739565
|
deficit.amount -= transferAmount;
|
|
739080
739566
|
surplus.amount -= transferAmount;
|
|
@@ -739111,12 +739597,12 @@ class CollateralDeficitStrategy extends BaseStrategy/* BaseStrategy */.Z {
|
|
|
739111
739597
|
const bridgeConfig = this.getBridgeConfigForRoute(rebalance.origin, rebalance.destination);
|
|
739112
739598
|
// For movableCollateral routes: match bridge address
|
|
739113
739599
|
if ('bridge' in rebalance && rebalance.bridge) {
|
|
739114
|
-
return ((0,
|
|
739600
|
+
return ((0,_utils_bridgeUtils_js__WEBPACK_IMPORTED_MODULE_3__/* .isMovableCollateralConfig */ .iT)(bridgeConfig) &&
|
|
739115
739601
|
bridgeConfig.bridge === rebalance.bridge);
|
|
739116
739602
|
}
|
|
739117
739603
|
// For inventory routes: match externalBridge type
|
|
739118
739604
|
if ('externalBridge' in rebalance && rebalance.externalBridge) {
|
|
739119
|
-
return ((0,
|
|
739605
|
+
return ((0,_utils_bridgeUtils_js__WEBPACK_IMPORTED_MODULE_3__/* .isInventoryConfig */ .pm)(bridgeConfig) &&
|
|
739120
739606
|
bridgeConfig.externalBridge === rebalance.externalBridge);
|
|
739121
739607
|
}
|
|
739122
739608
|
// Recovered intents without bridge info - include to be safe
|
|
@@ -739184,7 +739670,17 @@ class CollateralDeficitStrategy extends BaseStrategy/* BaseStrategy */.Z {
|
|
|
739184
739670
|
}
|
|
739185
739671
|
}
|
|
739186
739672
|
//# sourceMappingURL=CollateralDeficitStrategy.js.map
|
|
739187
|
-
|
|
739673
|
+
__webpack_async_result__();
|
|
739674
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
739675
|
+
|
|
739676
|
+
/***/ }),
|
|
739677
|
+
|
|
739678
|
+
/***/ 93282:
|
|
739679
|
+
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
739680
|
+
|
|
739681
|
+
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
739682
|
+
/* harmony export */ l: () => (/* binding */ CompositeStrategy)
|
|
739683
|
+
/* harmony export */ });
|
|
739188
739684
|
/**
|
|
739189
739685
|
* Composite strategy that runs multiple sub-strategies sequentially.
|
|
739190
739686
|
*
|
|
@@ -739248,11 +739744,159 @@ class CompositeStrategy {
|
|
|
739248
739744
|
}
|
|
739249
739745
|
}
|
|
739250
739746
|
//# sourceMappingURL=CompositeStrategy.js.map
|
|
739251
|
-
|
|
739252
|
-
|
|
739253
|
-
|
|
739254
|
-
|
|
739255
|
-
|
|
739747
|
+
|
|
739748
|
+
/***/ }),
|
|
739749
|
+
|
|
739750
|
+
/***/ 82833:
|
|
739751
|
+
/***/ ((__webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
739752
|
+
|
|
739753
|
+
__nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
739754
|
+
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
739755
|
+
/* harmony export */ I: () => (/* binding */ MinAmountStrategy)
|
|
739756
|
+
/* harmony export */ });
|
|
739757
|
+
/* harmony import */ var bignumber_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(62033);
|
|
739758
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(27043);
|
|
739759
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(39196);
|
|
739760
|
+
/* harmony import */ var _config_types_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(75102);
|
|
739761
|
+
/* harmony import */ var _utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(11369);
|
|
739762
|
+
/* harmony import */ var _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(94598);
|
|
739763
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__, _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_3__]);
|
|
739764
|
+
([_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__, _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
739765
|
+
|
|
739766
|
+
|
|
739767
|
+
|
|
739768
|
+
|
|
739769
|
+
|
|
739770
|
+
|
|
739771
|
+
/**
|
|
739772
|
+
* Strategy implementation that rebalance based on minimum amounts
|
|
739773
|
+
* It ensures each chain has at least the specified minimum amount
|
|
739774
|
+
*/
|
|
739775
|
+
class MinAmountStrategy extends _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_3__/* .BaseStrategy */ .Z {
|
|
739776
|
+
name = _config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .RebalancerStrategyOptions */ .t$.MinAmount;
|
|
739777
|
+
config = {};
|
|
739778
|
+
logger;
|
|
739779
|
+
constructor(config, tokensByChainName, initialTotalCollateral, logger, bridgeConfigs, metrics) {
|
|
739780
|
+
const chains = Object.keys(config);
|
|
739781
|
+
const log = logger.child({ class: MinAmountStrategy.name });
|
|
739782
|
+
super(chains, log, bridgeConfigs, metrics, tokensByChainName);
|
|
739783
|
+
this.logger = log;
|
|
739784
|
+
const minAmountType = config[chains[0]].minAmount.type;
|
|
739785
|
+
this.validateAmounts(initialTotalCollateral, minAmountType, config);
|
|
739786
|
+
for (const chain of chains) {
|
|
739787
|
+
const { min, target } = config[chain].minAmount;
|
|
739788
|
+
// check range constraints
|
|
739789
|
+
if ((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(target).lt(min)) {
|
|
739790
|
+
throw new Error(`Target (${target}) must be greater than or equal to min (${min}) for chain ${chain}`);
|
|
739791
|
+
}
|
|
739792
|
+
if ((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(min).lt(0)) {
|
|
739793
|
+
throw new Error(`Minimum amount (${min}) cannot be negative for chain ${chain}`);
|
|
739794
|
+
}
|
|
739795
|
+
if ((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(target).lt(0)) {
|
|
739796
|
+
throw new Error(`Target amount (${target}) cannot be negative for chain ${chain}`);
|
|
739797
|
+
}
|
|
739798
|
+
}
|
|
739799
|
+
this.config = config;
|
|
739800
|
+
this.logger.info('MinAmountStrategy created');
|
|
739801
|
+
}
|
|
739802
|
+
/**
|
|
739803
|
+
* Gets balances categorized by surplus and deficit based on minimum amounts and targets
|
|
739804
|
+
* - For absolute values: Uses exact token amounts
|
|
739805
|
+
* - For relative values: Uses percentages of total balance across all chains
|
|
739806
|
+
*
|
|
739807
|
+
* Simulates both types of rebalances before calculating surpluses/deficits:
|
|
739808
|
+
* - pendingRebalances: in-flight intents (origin tx confirmed, add to destination only)
|
|
739809
|
+
* - proposedRebalances: routes from earlier strategies (subtract from origin AND add to destination)
|
|
739810
|
+
*
|
|
739811
|
+
* This prevents over-rebalancing when multiple strategies run in sequence.
|
|
739812
|
+
*/
|
|
739813
|
+
getCategorizedBalances(rawBalances, pendingRebalances, proposedRebalances) {
|
|
739814
|
+
// Step 1: Simulate pending rebalances (in-flight, origin already deducted on-chain)
|
|
739815
|
+
let simulatedBalances = this.simulatePendingRebalances(rawBalances, pendingRebalances ?? []);
|
|
739816
|
+
// Step 2: Simulate proposed rebalances (from earlier strategies, not yet executed)
|
|
739817
|
+
simulatedBalances = this.simulateProposedRebalances(simulatedBalances, proposedRebalances ?? []);
|
|
739818
|
+
const totalCollateral = this.chains.reduce((sum, chain) => sum + simulatedBalances[chain], 0n);
|
|
739819
|
+
return this.chains.reduce((acc, chain) => {
|
|
739820
|
+
const chainConfig = this.config[chain];
|
|
739821
|
+
const balance = simulatedBalances[chain];
|
|
739822
|
+
let minAmount;
|
|
739823
|
+
let targetAmount;
|
|
739824
|
+
if (chainConfig.minAmount.type === _config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .RebalancerMinAmountType */ .gK.Absolute) {
|
|
739825
|
+
const token = this.getTokenByChainName(chain);
|
|
739826
|
+
minAmount = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__/* .normalizeConfiguredAmount */ .k9)(chainConfig.minAmount.min, token);
|
|
739827
|
+
targetAmount = (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__/* .normalizeConfiguredAmount */ .k9)(chainConfig.minAmount.target, token);
|
|
739828
|
+
}
|
|
739829
|
+
else {
|
|
739830
|
+
minAmount = BigInt((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(totalCollateral.toString())
|
|
739831
|
+
.times(chainConfig.minAmount.min)
|
|
739832
|
+
.toFixed(0, bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g.ROUND_FLOOR));
|
|
739833
|
+
targetAmount = BigInt((0,bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g)(totalCollateral.toString())
|
|
739834
|
+
.times(chainConfig.minAmount.target)
|
|
739835
|
+
.toFixed(0, bignumber_js__WEBPACK_IMPORTED_MODULE_0__/* .BigNumber */ .g.ROUND_FLOOR));
|
|
739836
|
+
}
|
|
739837
|
+
// If balance is less than minAmount, it has a deficit
|
|
739838
|
+
if (balance < minAmount) {
|
|
739839
|
+
acc.deficits.push({ chain, amount: targetAmount - balance });
|
|
739840
|
+
}
|
|
739841
|
+
else {
|
|
739842
|
+
// Any chain with more than minAmount potentially has surplus
|
|
739843
|
+
const surplus = balance - minAmount;
|
|
739844
|
+
if (surplus > 0n) {
|
|
739845
|
+
acc.surpluses.push({ chain, amount: surplus });
|
|
739846
|
+
}
|
|
739847
|
+
}
|
|
739848
|
+
return acc;
|
|
739849
|
+
}, {
|
|
739850
|
+
surpluses: [],
|
|
739851
|
+
deficits: [],
|
|
739852
|
+
});
|
|
739853
|
+
}
|
|
739854
|
+
getTokenByChainName(chainName) {
|
|
739855
|
+
const token = this.tokensByChainName[chainName];
|
|
739856
|
+
if (token === undefined) {
|
|
739857
|
+
throw new Error(`Token not found for chain ${chainName}`);
|
|
739858
|
+
}
|
|
739859
|
+
return token;
|
|
739860
|
+
}
|
|
739861
|
+
validateAmounts(totalCollateral, minAmountType, config) {
|
|
739862
|
+
config ??= this.config;
|
|
739863
|
+
if (minAmountType === _config_types_js__WEBPACK_IMPORTED_MODULE_1__/* .RebalancerMinAmountType */ .gK.Absolute) {
|
|
739864
|
+
let totalTargets = 0n;
|
|
739865
|
+
const displayToken = this.getTokenByChainName(this.chains[0]);
|
|
739866
|
+
for (const chainName of this.chains) {
|
|
739867
|
+
const token = this.getTokenByChainName(chainName);
|
|
739868
|
+
totalTargets += (0,_utils_balanceUtils_js__WEBPACK_IMPORTED_MODULE_2__/* .normalizeConfiguredAmount */ .k9)(config[chainName].minAmount.target, token);
|
|
739869
|
+
}
|
|
739870
|
+
if (totalTargets > totalCollateral) {
|
|
739871
|
+
throw new Error(`Consider reducing the targets as the sum (${this.formatCanonicalAmount(totalTargets, displayToken)}) is greater than sum of collaterals (${this.formatCanonicalAmount(totalCollateral, displayToken)})`);
|
|
739872
|
+
}
|
|
739873
|
+
}
|
|
739874
|
+
}
|
|
739875
|
+
formatCanonicalAmount(amount, token) {
|
|
739876
|
+
const localAmount = (0,_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_4__/* .localAmountFromMessage */ .Vd)(amount, token.scale);
|
|
739877
|
+
return (0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_5__/* .fromWei */ .kX)(localAmount.toString(), token.decimals);
|
|
739878
|
+
}
|
|
739879
|
+
}
|
|
739880
|
+
//# sourceMappingURL=MinAmountStrategy.js.map
|
|
739881
|
+
__webpack_async_result__();
|
|
739882
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
739883
|
+
|
|
739884
|
+
/***/ }),
|
|
739885
|
+
|
|
739886
|
+
/***/ 88757:
|
|
739887
|
+
/***/ ((__webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
739888
|
+
|
|
739889
|
+
__nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
739890
|
+
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
739891
|
+
/* harmony export */ M: () => (/* binding */ StrategyFactory)
|
|
739892
|
+
/* harmony export */ });
|
|
739893
|
+
/* harmony import */ var _config_types_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(75102);
|
|
739894
|
+
/* harmony import */ var _CollateralDeficitStrategy_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(22532);
|
|
739895
|
+
/* harmony import */ var _CompositeStrategy_js__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(93282);
|
|
739896
|
+
/* harmony import */ var _MinAmountStrategy_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(82833);
|
|
739897
|
+
/* harmony import */ var _WeightedStrategy_js__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(64438);
|
|
739898
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_CollateralDeficitStrategy_js__WEBPACK_IMPORTED_MODULE_1__, _MinAmountStrategy_js__WEBPACK_IMPORTED_MODULE_2__, _WeightedStrategy_js__WEBPACK_IMPORTED_MODULE_3__]);
|
|
739899
|
+
([_CollateralDeficitStrategy_js__WEBPACK_IMPORTED_MODULE_1__, _MinAmountStrategy_js__WEBPACK_IMPORTED_MODULE_2__, _WeightedStrategy_js__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
739256
739900
|
|
|
739257
739901
|
|
|
739258
739902
|
|
|
@@ -739282,7 +739926,7 @@ class StrategyFactory {
|
|
|
739282
739926
|
}
|
|
739283
739927
|
// Multiple strategies - create CompositeStrategy
|
|
739284
739928
|
const subStrategies = strategyConfigs.map((config) => this.createSingleStrategy(config, tokensByChainName, initialTotalCollateral, logger, metrics, minAmountsByChain));
|
|
739285
|
-
return new CompositeStrategy(subStrategies, logger);
|
|
739929
|
+
return new _CompositeStrategy_js__WEBPACK_IMPORTED_MODULE_4__/* .CompositeStrategy */ .l(subStrategies, logger);
|
|
739286
739930
|
}
|
|
739287
739931
|
/**
|
|
739288
739932
|
* Create a single strategy from config.
|
|
@@ -739290,14 +739934,14 @@ class StrategyFactory {
|
|
|
739290
739934
|
static createSingleStrategy(strategyConfig, tokensByChainName, initialTotalCollateral, logger, metrics, _minAmountsByChain) {
|
|
739291
739935
|
const bridgeConfigs = this.extractBridgeConfigs(strategyConfig);
|
|
739292
739936
|
switch (strategyConfig.rebalanceStrategy) {
|
|
739293
|
-
case
|
|
739294
|
-
return new
|
|
739937
|
+
case _config_types_js__WEBPACK_IMPORTED_MODULE_0__/* .RebalancerStrategyOptions */ .t$.Weighted: {
|
|
739938
|
+
return new _WeightedStrategy_js__WEBPACK_IMPORTED_MODULE_3__/* .WeightedStrategy */ .T(strategyConfig.chains, logger, bridgeConfigs, metrics, tokensByChainName);
|
|
739295
739939
|
}
|
|
739296
|
-
case
|
|
739297
|
-
return new
|
|
739940
|
+
case _config_types_js__WEBPACK_IMPORTED_MODULE_0__/* .RebalancerStrategyOptions */ .t$.MinAmount: {
|
|
739941
|
+
return new _MinAmountStrategy_js__WEBPACK_IMPORTED_MODULE_2__/* .MinAmountStrategy */ .I(strategyConfig.chains, tokensByChainName, initialTotalCollateral, logger, bridgeConfigs, metrics);
|
|
739298
739942
|
}
|
|
739299
|
-
case
|
|
739300
|
-
return new CollateralDeficitStrategy(strategyConfig.chains, tokensByChainName, logger, bridgeConfigs, metrics);
|
|
739943
|
+
case _config_types_js__WEBPACK_IMPORTED_MODULE_0__/* .RebalancerStrategyOptions */ .t$.CollateralDeficit: {
|
|
739944
|
+
return new _CollateralDeficitStrategy_js__WEBPACK_IMPORTED_MODULE_1__/* .CollateralDeficitStrategy */ .v(strategyConfig.chains, tokensByChainName, logger, bridgeConfigs, metrics);
|
|
739301
739945
|
}
|
|
739302
739946
|
default: {
|
|
739303
739947
|
throw new Error('Unsupported strategy type');
|
|
@@ -739310,8 +739954,8 @@ class StrategyFactory {
|
|
|
739310
739954
|
const baseConfig = {
|
|
739311
739955
|
bridgeMinAcceptedAmount: config.bridgeMinAcceptedAmount ?? 0,
|
|
739312
739956
|
};
|
|
739313
|
-
const executionType = config.executionType ??
|
|
739314
|
-
if (executionType ===
|
|
739957
|
+
const executionType = config.executionType ?? _config_types_js__WEBPACK_IMPORTED_MODULE_0__/* .ExecutionType */ .Pf.MovableCollateral;
|
|
739958
|
+
if (executionType === _config_types_js__WEBPACK_IMPORTED_MODULE_0__/* .ExecutionType */ .Pf.Inventory) {
|
|
739315
739959
|
bridgeConfigs[chain] = {
|
|
739316
739960
|
...baseConfig,
|
|
739317
739961
|
executionType: 'inventory',
|
|
@@ -739332,17 +739976,22 @@ class StrategyFactory {
|
|
|
739332
739976
|
}
|
|
739333
739977
|
}
|
|
739334
739978
|
//# sourceMappingURL=StrategyFactory.js.map
|
|
739979
|
+
__webpack_async_result__();
|
|
739980
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
739335
739981
|
|
|
739336
739982
|
/***/ }),
|
|
739337
739983
|
|
|
739338
739984
|
/***/ 64438:
|
|
739339
|
-
/***/ ((
|
|
739985
|
+
/***/ ((__webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
739340
739986
|
|
|
739987
|
+
__nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
739341
739988
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
739342
739989
|
/* harmony export */ T: () => (/* binding */ WeightedStrategy)
|
|
739343
739990
|
/* harmony export */ });
|
|
739344
739991
|
/* harmony import */ var _config_types_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(75102);
|
|
739345
739992
|
/* harmony import */ var _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(94598);
|
|
739993
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_BaseStrategy_js__WEBPACK_IMPORTED_MODULE_1__]);
|
|
739994
|
+
_BaseStrategy_js__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
739346
739995
|
|
|
739347
739996
|
|
|
739348
739997
|
/**
|
|
@@ -739416,6 +740065,8 @@ class WeightedStrategy extends _BaseStrategy_js__WEBPACK_IMPORTED_MODULE_1__/* .
|
|
|
739416
740065
|
}
|
|
739417
740066
|
}
|
|
739418
740067
|
//# sourceMappingURL=WeightedStrategy.js.map
|
|
740068
|
+
__webpack_async_result__();
|
|
740069
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
739419
740070
|
|
|
739420
740071
|
/***/ }),
|
|
739421
740072
|
|
|
@@ -739873,7 +740524,8 @@ class ActionTracker {
|
|
|
739873
740524
|
lastBridgeStatus: movement.lastBridgeStatus,
|
|
739874
740525
|
}, 'Failing stale inventory movement to unblock intent');
|
|
739875
740526
|
}
|
|
739876
|
-
//
|
|
740527
|
+
// Only inventory_deposit amounts advance fulfillment. inventory_movement
|
|
740528
|
+
// amounts stay in source-local units and only gate retries/stale cleanup.
|
|
739877
740529
|
const completedAmount = actions
|
|
739878
740530
|
.filter((a) => a.status === 'complete' && a.type === 'inventory_deposit')
|
|
739879
740531
|
.reduce((sum, a) => sum + a.amount, 0n);
|
|
@@ -740587,12 +741239,46 @@ class ExplorerClient {
|
|
|
740587
741239
|
|
|
740588
741240
|
__nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
740589
741241
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
740590
|
-
/* harmony export */
|
|
741242
|
+
/* harmony export */ R2: () => (/* binding */ normalizeToCanonical),
|
|
741243
|
+
/* harmony export */ bK: () => (/* binding */ denormalizeToLocal),
|
|
741244
|
+
/* harmony export */ gU: () => (/* binding */ alignLocalToCanonical),
|
|
741245
|
+
/* harmony export */ k9: () => (/* binding */ normalizeConfiguredAmount),
|
|
741246
|
+
/* harmony export */ qb: () => (/* binding */ getRawBalances)
|
|
740591
741247
|
/* harmony export */ });
|
|
741248
|
+
/* unused harmony exports getTokenScale, isIdentityScale */
|
|
741249
|
+
/* harmony import */ var _hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(27043);
|
|
741250
|
+
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(39196);
|
|
740592
741251
|
/* harmony import */ var _tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(46618);
|
|
740593
741252
|
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__]);
|
|
740594
741253
|
_tokenUtils_js__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
740595
741254
|
|
|
741255
|
+
|
|
741256
|
+
|
|
741257
|
+
function getTokenScale(token) {
|
|
741258
|
+
return (0,_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__/* .normalizeScale */ .EM)(token.scale);
|
|
741259
|
+
}
|
|
741260
|
+
function isIdentityScale(token) {
|
|
741261
|
+
return (0,_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__/* .scalesEqual */ .gm)(token.scale, undefined);
|
|
741262
|
+
}
|
|
741263
|
+
function normalizeToCanonical(localAmount, tokenOrScale) {
|
|
741264
|
+
return (0,_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__/* .messageAmountFromLocal */ .TI)(localAmount, getScaleInput(tokenOrScale));
|
|
741265
|
+
}
|
|
741266
|
+
function denormalizeToLocal(canonicalAmount, tokenOrScale) {
|
|
741267
|
+
// Use ceil semantics so the returned local amount always produces at least
|
|
741268
|
+
// the requested canonical progress once the token router floors on outbound.
|
|
741269
|
+
return (0,_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__/* .minLocalAmountForMessage */ .ol)(canonicalAmount, getScaleInput(tokenOrScale));
|
|
741270
|
+
}
|
|
741271
|
+
function alignLocalToCanonical(localAmount, tokenOrScale) {
|
|
741272
|
+
return (0,_hyperlane_xyz_sdk__WEBPACK_IMPORTED_MODULE_1__/* .alignLocalAmountToMessage */ .pD)(localAmount, getScaleInput(tokenOrScale));
|
|
741273
|
+
}
|
|
741274
|
+
function normalizeConfiguredAmount(amount, token) {
|
|
741275
|
+
return normalizeToCanonical(BigInt((0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_2__/* .toWei */ .fq)(amount, token.decimals)), token);
|
|
741276
|
+
}
|
|
741277
|
+
function getScaleInput(tokenOrScale) {
|
|
741278
|
+
return 'numerator' in tokenOrScale && 'denominator' in tokenOrScale
|
|
741279
|
+
? tokenOrScale
|
|
741280
|
+
: tokenOrScale.scale;
|
|
741281
|
+
}
|
|
740596
741282
|
/**
|
|
740597
741283
|
* Returns the raw balances required by the strategies from the monitor event
|
|
740598
741284
|
* @param chains - The chains that should be included in the raw balances (e.g. the chains in the rebalancer config)
|
|
@@ -740627,7 +741313,18 @@ function getRawBalances(chains, event, logger) {
|
|
|
740627
741313
|
if (bridgedSupply === undefined) {
|
|
740628
741314
|
throw new Error(`bridgedSupply should not be undefined for collateralized token ${token.addressOrDenom}`);
|
|
740629
741315
|
}
|
|
740630
|
-
|
|
741316
|
+
const normalizedBalance = normalizeToCanonical(bridgedSupply, token);
|
|
741317
|
+
balances[token.chainName] = normalizedBalance;
|
|
741318
|
+
if (!isIdentityScale(token)) {
|
|
741319
|
+
logger.debug({
|
|
741320
|
+
context: getRawBalances.name,
|
|
741321
|
+
chain: token.chainName,
|
|
741322
|
+
tokenSymbol: token.symbol,
|
|
741323
|
+
bridgedSupply: bridgedSupply.toString(),
|
|
741324
|
+
normalizedBalance: normalizedBalance.toString(),
|
|
741325
|
+
scale: getTokenScale(token),
|
|
741326
|
+
}, 'Normalized bridged supply to canonical units');
|
|
741327
|
+
}
|
|
740631
741328
|
}
|
|
740632
741329
|
return balances;
|
|
740633
741330
|
}
|
|
@@ -740651,7 +741348,7 @@ __webpack_async_result__();
|
|
|
740651
741348
|
* Get the confirmed block tag for a chain, accounting for reorg period.
|
|
740652
741349
|
* Returns a block number that is safe from reorgs, or a named tag like 'finalized'.
|
|
740653
741350
|
*
|
|
740654
|
-
* @param multiProvider -
|
|
741351
|
+
* @param multiProvider - Provider registry with chain metadata and ethers access
|
|
740655
741352
|
* @param chainName - Name of the chain
|
|
740656
741353
|
* @param logger - Optional logger for warnings
|
|
740657
741354
|
* @returns Confirmed block tag (number, named tag, or undefined on error)
|
|
@@ -746629,7 +747326,7 @@ const SEALEVEL_PRIORITY_FEES = {
|
|
|
746629
747326
|
/* harmony export */ g: () => (/* binding */ multiProtocolTestChainMetadata),
|
|
746630
747327
|
/* harmony export */ hR: () => (/* binding */ testChainMetadata)
|
|
746631
747328
|
/* harmony export */ });
|
|
746632
|
-
/* unused harmony exports TestChainName, test1, test2, test3, test4, testXERC20, testVSXERC20, testXERC20Lockbox, testScale1, testScale2, testCollateralFiat, testCosmosChain, testSealevelChain, testStarknetChain,
|
|
747329
|
+
/* unused harmony exports TestChainName, test1, test2, test3, test4, testXERC20, testVSXERC20, testXERC20Lockbox, testScale1, testScale2, testCollateralFiat, testCosmosChain, testSealevelChain, testStarknetChain, KNOWN_ETHEREUM_TIMELOCK_CONTRACT, ethereumTestChain, multiProtocolTestChains */
|
|
746633
747330
|
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(16639);
|
|
746634
747331
|
/* harmony import */ var _metadata_chainMetadataTypes_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(1430);
|
|
746635
747332
|
|
|
@@ -746806,24 +747503,27 @@ const testStarknetChain = {
|
|
|
746806
747503
|
},
|
|
746807
747504
|
],
|
|
746808
747505
|
};
|
|
746809
|
-
// Address of
|
|
746810
|
-
|
|
746811
|
-
//
|
|
746812
|
-
|
|
747506
|
+
// Address of the ENS DAO TimelockController contract on Ethereum mainnet,
|
|
747507
|
+
// used for integration tests that exercise the block explorer path.
|
|
747508
|
+
// Chosen because Base's Blockscout `getcontractcreation` endpoint has been
|
|
747509
|
+
// observed to hang in CI, while eth.blockscout.com is reliable.
|
|
747510
|
+
const KNOWN_ETHEREUM_TIMELOCK_CONTRACT = '0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7';
|
|
747511
|
+
// Ethereum mainnet metadata for testing with a live block explorer
|
|
747512
|
+
const ethereumTestChain = {
|
|
746813
747513
|
blockExplorers: [
|
|
746814
747514
|
{
|
|
746815
|
-
apiUrl: 'https://
|
|
747515
|
+
apiUrl: 'https://eth.blockscout.com/api',
|
|
746816
747516
|
family: _metadata_chainMetadataTypes_js__WEBPACK_IMPORTED_MODULE_0__/* .ExplorerFamily */ .id.Blockscout,
|
|
746817
|
-
name: '
|
|
746818
|
-
url: 'https://
|
|
747517
|
+
name: 'Ethereum Explorer',
|
|
747518
|
+
url: 'https://eth.blockscout.com',
|
|
746819
747519
|
},
|
|
746820
747520
|
],
|
|
746821
|
-
blocks: { confirmations: 3, estimateBlockTime:
|
|
746822
|
-
chainId:
|
|
746823
|
-
displayName: '
|
|
746824
|
-
domainId:
|
|
747521
|
+
blocks: { confirmations: 3, estimateBlockTime: 12, reorgPeriod: 14 },
|
|
747522
|
+
chainId: 1,
|
|
747523
|
+
displayName: 'Ethereum',
|
|
747524
|
+
domainId: 1,
|
|
746825
747525
|
gasCurrencyCoinGeckoId: 'ethereum',
|
|
746826
|
-
name: '
|
|
747526
|
+
name: 'ethereum',
|
|
746827
747527
|
nativeToken: {
|
|
746828
747528
|
decimals: 18,
|
|
746829
747529
|
name: 'Ether',
|
|
@@ -746831,15 +747531,12 @@ const baseTestChain = {
|
|
|
746831
747531
|
},
|
|
746832
747532
|
protocol: _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_1__/* .ProtocolType */ .Hb.Ethereum,
|
|
746833
747533
|
rpcUrls: [
|
|
746834
|
-
{ http: 'https://
|
|
746835
|
-
{ http: 'https://
|
|
746836
|
-
{ http: 'https://
|
|
746837
|
-
{ http: 'https://
|
|
746838
|
-
{ http: 'https://
|
|
746839
|
-
{ http: 'https://1rpc.io/base' },
|
|
746840
|
-
{ http: 'https://base-pokt.nodies.app' },
|
|
747534
|
+
{ http: 'https://ethereum-rpc.publicnode.com' },
|
|
747535
|
+
{ http: 'https://eth.llamarpc.com' },
|
|
747536
|
+
{ http: 'https://1rpc.io/eth' },
|
|
747537
|
+
{ http: 'https://ethereum.blockpi.network/v1/rpc/public' },
|
|
747538
|
+
{ http: 'https://eth.drpc.org' },
|
|
746841
747539
|
],
|
|
746842
|
-
technicalStack: _metadata_chainMetadataTypes_js__WEBPACK_IMPORTED_MODULE_0__/* .ChainTechnicalStack */ .DU.OpStack,
|
|
746843
747540
|
};
|
|
746844
747541
|
const multiProtocolTestChainMetadata = {
|
|
746845
747542
|
...testChainMetadata,
|
|
@@ -751030,7 +751727,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
751030
751727
|
/* harmony export */ });
|
|
751031
751728
|
/* harmony import */ var _hyperlane_xyz_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(50653);
|
|
751032
751729
|
/* harmony import */ var _hyperlane_xyz_core_buildArtifact_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(74119);
|
|
751033
|
-
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(
|
|
751730
|
+
/* harmony import */ var _hyperlane_xyz_deploy_sdk__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(56854);
|
|
751034
751731
|
/* harmony import */ var _hyperlane_xyz_provider_sdk__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(71280);
|
|
751035
751732
|
/* harmony import */ var _hyperlane_xyz_provider_sdk_artifact__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(4287);
|
|
751036
751733
|
/* harmony import */ var _hyperlane_xyz_provider_sdk_hook__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(77230);
|
|
@@ -803133,8 +803830,7 @@ class TokenMetadata {
|
|
|
803133
803830
|
return _TokenStandard_js__WEBPACK_IMPORTED_MODULE_1__/* .TOKEN_MULTI_CHAIN_STANDARDS */ .NR.includes(this.standard);
|
|
803134
803831
|
}
|
|
803135
803832
|
isCrossCollateralToken() {
|
|
803136
|
-
return
|
|
803137
|
-
this.standard === _TokenStandard_js__WEBPACK_IMPORTED_MODULE_1__/* .TokenStandard */ .ph.TronHypCrossCollateralRouter);
|
|
803833
|
+
return _TokenStandard_js__WEBPACK_IMPORTED_MODULE_1__/* .TOKEN_CROSS_COLLATERAL_STANDARDS */ .kK.has(this.standard);
|
|
803138
803834
|
}
|
|
803139
803835
|
getConnections() {
|
|
803140
803836
|
return this.connections || [];
|
|
@@ -815418,10 +816114,13 @@ async function contractHasString(provider, address, searchFor) {
|
|
|
815418
816114
|
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
|
|
815419
816115
|
/* harmony export */ EM: () => (/* binding */ normalizeScale),
|
|
815420
816116
|
/* harmony export */ TI: () => (/* binding */ messageAmountFromLocal),
|
|
816117
|
+
/* harmony export */ Vd: () => (/* binding */ localAmountFromMessage),
|
|
815421
816118
|
/* harmony export */ gm: () => (/* binding */ scalesEqual),
|
|
815422
|
-
/* harmony export */ k: () => (/* binding */ verifyScale)
|
|
816119
|
+
/* harmony export */ k: () => (/* binding */ verifyScale),
|
|
816120
|
+
/* harmony export */ ol: () => (/* binding */ minLocalAmountForMessage),
|
|
816121
|
+
/* harmony export */ pD: () => (/* binding */ alignLocalAmountToMessage)
|
|
815423
816122
|
/* harmony export */ });
|
|
815424
|
-
/* unused harmony
|
|
816123
|
+
/* unused harmony export DEFAULT_SCALE */
|
|
815425
816124
|
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(21387);
|
|
815426
816125
|
/* harmony import */ var _hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(73938);
|
|
815427
816126
|
|
|
@@ -815447,8 +816146,8 @@ function assertValidScale(scale) {
|
|
|
815447
816146
|
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .v)(scale.numerator > 0n && scale.denominator > 0n, `Scale must be positive, got ${scale.numerator}/${scale.denominator}`);
|
|
815448
816147
|
}
|
|
815449
816148
|
function ceilDiv(numerator, denominator) {
|
|
815450
|
-
assert(denominator > 0n, 'Denominator must be positive');
|
|
815451
|
-
assert(numerator >= 0n, 'Numerator must be non-negative');
|
|
816149
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .v)(denominator > 0n, 'Denominator must be positive');
|
|
816150
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .v)(numerator >= 0n, 'Numerator must be non-negative');
|
|
815452
816151
|
if (numerator === 0n)
|
|
815453
816152
|
return 0n;
|
|
815454
816153
|
return (numerator + denominator - 1n) / denominator;
|
|
@@ -815460,19 +816159,19 @@ function messageAmountFromLocal(localAmount, scale) {
|
|
|
815460
816159
|
return (localAmount * normalized.numerator) / normalized.denominator;
|
|
815461
816160
|
}
|
|
815462
816161
|
function localAmountFromMessage(messageAmount, scale) {
|
|
815463
|
-
assert(messageAmount >= 0n, 'Message amount must be non-negative');
|
|
816162
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .v)(messageAmount >= 0n, 'Message amount must be non-negative');
|
|
815464
816163
|
const normalized = normalizeScale(scale);
|
|
815465
816164
|
assertValidScale(normalized);
|
|
815466
816165
|
return (messageAmount * normalized.denominator) / normalized.numerator;
|
|
815467
816166
|
}
|
|
815468
816167
|
function minLocalAmountForMessage(messageAmount, scale) {
|
|
815469
|
-
assert(messageAmount >= 0n, 'Message amount must be non-negative');
|
|
816168
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .v)(messageAmount >= 0n, 'Message amount must be non-negative');
|
|
815470
816169
|
const normalized = normalizeScale(scale);
|
|
815471
816170
|
assertValidScale(normalized);
|
|
815472
816171
|
return ceilDiv(messageAmount * normalized.denominator, normalized.numerator);
|
|
815473
816172
|
}
|
|
815474
816173
|
function alignLocalAmountToMessage(localAmount, scale) {
|
|
815475
|
-
assert(localAmount >= 0n, 'Local amount must be non-negative');
|
|
816174
|
+
(0,_hyperlane_xyz_utils__WEBPACK_IMPORTED_MODULE_0__/* .assert */ .v)(localAmount >= 0n, 'Local amount must be non-negative');
|
|
815476
816175
|
const messageAmount = messageAmountFromLocal(localAmount, scale);
|
|
815477
816176
|
if (messageAmount === 0n) {
|
|
815478
816177
|
return {
|
|
@@ -817602,6 +818301,9 @@ class TronProtocolProvider {
|
|
|
817602
818301
|
// @TODO Implement in a follow up PR
|
|
817603
818302
|
throw Error('Not implemented');
|
|
817604
818303
|
}
|
|
818304
|
+
createFeeArtifactManager(_chainMetadata) {
|
|
818305
|
+
return null;
|
|
818306
|
+
}
|
|
817605
818307
|
getMinGas() {
|
|
817606
818308
|
return {
|
|
817607
818309
|
CORE_DEPLOY_GAS: BigInt(1e9),
|
|
@@ -902868,25 +903570,7 @@ function setRootLogger(logger) {
|
|
|
902868
903570
|
return rootLogger;
|
|
902869
903571
|
}
|
|
902870
903572
|
function createHyperlanePinoLogger(logLevel, logFormat) {
|
|
902871
|
-
|
|
902872
|
-
// but only if the log format is 'pretty'. This allows for JSON logs
|
|
902873
|
-
// in development as well if explicitly configured.
|
|
902874
|
-
if (process.env.NODE_ENV === 'development' &&
|
|
902875
|
-
logFormat === LogFormat.Pretty) {
|
|
902876
|
-
return (0,pino__WEBPACK_IMPORTED_MODULE_0__.pino)({
|
|
902877
|
-
level: logLevel,
|
|
902878
|
-
transport: {
|
|
902879
|
-
target: 'pino-pretty',
|
|
902880
|
-
options: {
|
|
902881
|
-
colorize: true,
|
|
902882
|
-
translateTime: 'SYS:standard',
|
|
902883
|
-
ignore: 'pid,hostname',
|
|
902884
|
-
},
|
|
902885
|
-
},
|
|
902886
|
-
});
|
|
902887
|
-
}
|
|
902888
|
-
// In production (or other envs), use the original hook-based logger
|
|
902889
|
-
return (0,pino__WEBPACK_IMPORTED_MODULE_0__.pino)({
|
|
903573
|
+
const createFallbackLogger = () => (0,pino__WEBPACK_IMPORTED_MODULE_0__.pino)({
|
|
902890
903574
|
level: logLevel,
|
|
902891
903575
|
name: 'hyperlane',
|
|
902892
903576
|
formatters: {
|
|
@@ -902909,6 +903593,32 @@ function createHyperlanePinoLogger(logLevel, logFormat) {
|
|
|
902909
903593
|
},
|
|
902910
903594
|
},
|
|
902911
903595
|
});
|
|
903596
|
+
// In development, pino-pretty is used for a better dev experience,
|
|
903597
|
+
// but only if the log format is 'pretty'. This allows for JSON logs
|
|
903598
|
+
// in development as well if explicitly configured.
|
|
903599
|
+
if (process.env.NODE_ENV === 'development' &&
|
|
903600
|
+
logFormat === LogFormat.Pretty) {
|
|
903601
|
+
try {
|
|
903602
|
+
return (0,pino__WEBPACK_IMPORTED_MODULE_0__.pino)({
|
|
903603
|
+
level: logLevel,
|
|
903604
|
+
transport: {
|
|
903605
|
+
target: 'pino-pretty',
|
|
903606
|
+
options: {
|
|
903607
|
+
colorize: true,
|
|
903608
|
+
translateTime: 'SYS:standard',
|
|
903609
|
+
ignore: 'pid,hostname',
|
|
903610
|
+
},
|
|
903611
|
+
},
|
|
903612
|
+
});
|
|
903613
|
+
}
|
|
903614
|
+
catch (err) {
|
|
903615
|
+
const fallbackLogger = createFallbackLogger();
|
|
903616
|
+
fallbackLogger.warn(err, 'Could not initialize pino-pretty, falling back to built-in pretty logger');
|
|
903617
|
+
return fallbackLogger;
|
|
903618
|
+
}
|
|
903619
|
+
}
|
|
903620
|
+
// In production (or other envs), use the original hook-based logger
|
|
903621
|
+
return createFallbackLogger();
|
|
902912
903622
|
}
|
|
902913
903623
|
function ethersBigNumberSerializer(key, value) {
|
|
902914
903624
|
// Check if the value looks like a serialized BigNumber
|
|
@@ -905476,7 +906186,7 @@ module.exports = /*#__PURE__*/JSON.parse('[{"type":"function","name":"proveL2Lea
|
|
|
905476
906186
|
/***/ 99468:
|
|
905477
906187
|
/***/ ((module) => {
|
|
905478
906188
|
|
|
905479
|
-
module.exports = {"rE":"33.0.
|
|
906189
|
+
module.exports = {"rE":"33.0.2"};
|
|
905480
906190
|
|
|
905481
906191
|
/***/ })
|
|
905482
906192
|
|