@hyperlane-xyz/rebalancer 27.2.11 → 27.2.13
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/dist/core/InventoryRebalancer.d.ts +11 -19
- package/dist/core/InventoryRebalancer.d.ts.map +1 -1
- package/dist/core/InventoryRebalancer.js +336 -268
- package/dist/core/InventoryRebalancer.js.map +1 -1
- package/dist/core/InventoryRebalancer.test.js +397 -23
- package/dist/core/InventoryRebalancer.test.js.map +1 -1
- package/dist/core/Rebalancer.d.ts.map +1 -1
- package/dist/core/Rebalancer.js +12 -6
- package/dist/core/Rebalancer.js.map +1 -1
- package/dist/core/Rebalancer.test.js +51 -0
- package/dist/core/Rebalancer.test.js.map +1 -1
- package/dist/core/RebalancerOrchestrator.test.js +0 -1
- package/dist/core/RebalancerOrchestrator.test.js.map +1 -1
- package/dist/core/RebalancerService.d.ts +2 -3
- package/dist/core/RebalancerService.d.ts.map +1 -1
- package/dist/core/RebalancerService.js +3 -2
- package/dist/core/RebalancerService.js.map +1 -1
- package/dist/core/RebalancerService.test.js +24 -0
- package/dist/core/RebalancerService.test.js.map +1 -1
- package/dist/e2e/harness/TestHelpers.js +1 -2
- package/dist/e2e/harness/TestHelpers.js.map +1 -1
- package/dist/factories/RebalancerContextFactory.d.ts +4 -5
- package/dist/factories/RebalancerContextFactory.d.ts.map +1 -1
- package/dist/factories/RebalancerContextFactory.js +12 -7
- package/dist/factories/RebalancerContextFactory.js.map +1 -1
- package/dist/factories/RebalancerContextFactory.test.js +99 -2
- package/dist/factories/RebalancerContextFactory.test.js.map +1 -1
- package/dist/interfaces/IRebalancer.d.ts +4 -2
- package/dist/interfaces/IRebalancer.d.ts.map +1 -1
- package/dist/metrics/scripts/metrics.d.ts +1 -1
- package/dist/monitor/Monitor.d.ts.map +1 -1
- package/dist/monitor/Monitor.js +14 -6
- package/dist/monitor/Monitor.js.map +1 -1
- package/dist/strategy/BaseStrategy.d.ts.map +1 -1
- package/dist/strategy/BaseStrategy.js +13 -11
- package/dist/strategy/BaseStrategy.js.map +1 -1
- package/dist/strategy/CollateralDeficitStrategy.d.ts.map +1 -1
- package/dist/strategy/CollateralDeficitStrategy.js +2 -2
- package/dist/strategy/CollateralDeficitStrategy.js.map +1 -1
- package/dist/strategy/MinAmountStrategy.d.ts +1 -0
- package/dist/strategy/MinAmountStrategy.d.ts.map +1 -1
- package/dist/strategy/MinAmountStrategy.js +12 -8
- package/dist/strategy/MinAmountStrategy.js.map +1 -1
- package/dist/strategy/MinAmountStrategy.test.js +189 -2
- package/dist/strategy/MinAmountStrategy.test.js.map +1 -1
- package/dist/test/helpers.d.ts +11 -3
- package/dist/test/helpers.d.ts.map +1 -1
- package/dist/test/helpers.js +9 -11
- package/dist/test/helpers.js.map +1 -1
- package/dist/test/lifiMocks.d.ts.map +1 -1
- package/dist/test/lifiMocks.js +5 -2
- package/dist/test/lifiMocks.js.map +1 -1
- package/dist/tracking/ActionTracker.d.ts.map +1 -1
- package/dist/tracking/ActionTracker.js +2 -1
- package/dist/tracking/ActionTracker.js.map +1 -1
- package/dist/tracking/ActionTracker.test.js +39 -0
- package/dist/tracking/ActionTracker.test.js.map +1 -1
- package/dist/utils/balanceUtils.d.ts +7 -1
- package/dist/utils/balanceUtils.d.ts.map +1 -1
- package/dist/utils/balanceUtils.js +39 -1
- package/dist/utils/balanceUtils.js.map +1 -1
- package/dist/utils/balanceUtils.test.js +55 -1
- package/dist/utils/balanceUtils.test.js.map +1 -1
- package/dist/utils/blockTag.d.ts +3 -3
- package/dist/utils/blockTag.d.ts.map +1 -1
- package/dist/utils/blockTag.js +1 -1
- package/dist/utils/blockTag.js.map +1 -1
- package/package.json +7 -7
- package/src/core/InventoryRebalancer.test.ts +503 -38
- package/src/core/InventoryRebalancer.ts +483 -350
- package/src/core/Rebalancer.test.ts +84 -0
- package/src/core/Rebalancer.ts +22 -6
- package/src/core/RebalancerOrchestrator.test.ts +0 -1
- package/src/core/RebalancerService.test.ts +35 -0
- package/src/core/RebalancerService.ts +9 -5
- package/src/e2e/harness/TestHelpers.ts +3 -3
- package/src/factories/RebalancerContextFactory.test.ts +143 -6
- package/src/factories/RebalancerContextFactory.ts +29 -17
- package/src/interfaces/IRebalancer.ts +4 -1
- package/src/monitor/Monitor.ts +19 -6
- package/src/strategy/BaseStrategy.ts +18 -15
- package/src/strategy/CollateralDeficitStrategy.ts +4 -3
- package/src/strategy/MinAmountStrategy.test.ts +238 -2
- package/src/strategy/MinAmountStrategy.ts +29 -17
- package/src/test/helpers.ts +13 -12
- package/src/test/lifiMocks.ts +5 -2
- package/src/tracking/ActionTracker.test.ts +47 -0
- package/src/tracking/ActionTracker.ts +2 -1
- package/src/utils/balanceUtils.test.ts +87 -1
- package/src/utils/balanceUtils.ts +73 -2
- package/src/utils/blockTag.ts +9 -4
|
@@ -94,6 +94,7 @@ export declare class InventoryRebalancer implements IInventoryRebalancer {
|
|
|
94
94
|
* Calculate total inventory across all chains, excluding specified chains.
|
|
95
95
|
*/
|
|
96
96
|
private getTotalInventory;
|
|
97
|
+
private formatLocalAmount;
|
|
97
98
|
/**
|
|
98
99
|
* Get the effective available inventory for a chain, accounting for
|
|
99
100
|
* inventory already consumed during this execution cycle.
|
|
@@ -153,7 +154,6 @@ export declare class InventoryRebalancer implements IInventoryRebalancer {
|
|
|
153
154
|
*
|
|
154
155
|
* @param route - The transfer route (swapped direction)
|
|
155
156
|
* @param intent - The rebalance intent being executed
|
|
156
|
-
* @param gasQuote - Pre-calculated gas quote from calculateTransferCosts
|
|
157
157
|
*/
|
|
158
158
|
private executeTransferRemote;
|
|
159
159
|
private sendAndConfirmInventoryTx;
|
|
@@ -166,32 +166,24 @@ export declare class InventoryRebalancer implements IInventoryRebalancer {
|
|
|
166
166
|
*/
|
|
167
167
|
private selectAllSourceChains;
|
|
168
168
|
/**
|
|
169
|
-
* Calculate the
|
|
170
|
-
* Uses LiFi
|
|
171
|
-
*
|
|
169
|
+
* Calculate the bridge capacity from a source chain in destination-local units.
|
|
170
|
+
* Uses LiFi quotes to conservatively estimate the destination output available
|
|
171
|
+
* from the source chain's current local inventory.
|
|
172
172
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* - Applies conservative 20x buffer (LiFi underestimates by ~14x historically)
|
|
176
|
-
* - Returns 0 if gas > 10% of inventory (not worth bridging)
|
|
177
|
-
* - Returns inventory - estimatedGas if viable
|
|
178
|
-
*
|
|
179
|
-
* @param sourceChain - Chain to bridge from
|
|
180
|
-
* @param targetChain - Chain to bridge to
|
|
181
|
-
* @param rawInventory - Raw available inventory on source chain
|
|
182
|
-
* @param externalBridgeType - External bridge type to use
|
|
183
|
-
* @returns Maximum viable bridge amount (0 if not viable)
|
|
173
|
+
* For native-token sources, gas is reserved from the source inventory and the
|
|
174
|
+
* output capacity is re-quoted from the remaining source input.
|
|
184
175
|
*/
|
|
185
|
-
private
|
|
176
|
+
private calculateBridgeCapacity;
|
|
186
177
|
/**
|
|
187
178
|
* Execute inventory movement from source chain to target chain via LiFi bridge.
|
|
188
179
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
180
|
+
* Uses reverse quotes (`toAmount`) so plans are expressed in target-chain local
|
|
181
|
+
* units and source-local spend is discovered by the bridge quote.
|
|
191
182
|
*
|
|
192
183
|
* @param sourceChain - Chain to move inventory from
|
|
193
184
|
* @param targetChain - Chain to move inventory to (origin chain for rebalancing)
|
|
194
|
-
* @param
|
|
185
|
+
* @param targetOutputAmount - Destination-local amount to receive
|
|
186
|
+
* @param maxSourceInput - Maximum source-local amount available for this plan
|
|
195
187
|
* @param intent - Rebalance intent for tracking
|
|
196
188
|
* @param externalBridgeType - External bridge type to use
|
|
197
189
|
* @returns Result with success status and optional txHash/error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InventoryRebalancer.d.ts","sourceRoot":"","sources":["../../src/core/InventoryRebalancer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM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