-
Notifications
You must be signed in to change notification settings - Fork 101
chore: Refactor USDH Refiller to be more configurable #2800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| // Default minimum is 10 USDH. USDH only exists on HyperEVM and has 6 decimals. | ||
| this.minUsdhRebalanceAmount = toBNWei(MIN_USDH_REBALANCE_AMOUNT ?? "10", 6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would maybe even prefer to move MIN_USDH_REBALANCE_AMOUNT to REFILL_BALANCES object level and we will be able to decide if we should check origin or destination balances based on this and not checkOriginChainBalance
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's not a bad idea 👍
|
Before merging this PR, we should first update |
src/refiller/Refiller.ts
Outdated
| this.logger.debug({ | ||
| at: "Refiller#refillUsdh", | ||
| message: "Checking destination chain (HyperEVM) USDH balance", | ||
| destinationChainBalance: formatUnits(currentBalance, decimals), | ||
| triggerThreshold: formatUnits(triggerThreshold, decimals), | ||
| targetThreshold: formatUnits(targetThreshold, decimals), | ||
| shouldRefill, | ||
| }); | ||
|
|
||
| // Early exit if destination chain balance is above trigger | ||
| if (!shouldRefill) { | ||
| this.logger.debug({ | ||
| at: "Refiller#refillUsdh", | ||
| message: "Destination chain balance above trigger, skipping transfer", | ||
| destinationChainBalance: formatUnits(currentBalance, decimals), | ||
| triggerThreshold: formatUnits(triggerThreshold, decimals), | ||
| }); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it probably only makes sense to emit one of these messages, not both (i.e. in the case of !shouldRefill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pxrl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor questions - hopefully easy to resolve these so we can get this merged soon 👍
| message: "Rebalanced Arbitrum USDC to HyperEVM USDH", | ||
| nonMulticall: true, | ||
| mrkdwn: `Sent ${formatUnits(amountToTransfer, decimals)} USDC from Arbitrum to HyperEVM.`, | ||
| const originChainBalance = await usdc.balanceOf(this.baseSignerAddress.toNative()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be accountAddress instead? (Based on line ~410 it seems like they should be interchangeable). Does it make sense for us to assert equality on accountAddress and this.baseSignerAddress.toNative() ?
| const accountAddress = account.toNative(); | ||
|
|
||
| // Early exit check: If checking destination chain balance, verify it's below trigger | ||
| if (!checkOriginChainBalance && currentBalance.gt(triggerThreshold)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we simplify the checkOriginChainBalance logic by always checking it, and enforcing the minimum rebalance amount, but defaulting that amount to 0? Then we can increase that limit when we want to impose a minimum, and otherwise it'd effectively revert to always rebalancing.
| minThreshold: formatUnits(this.config.minUsdhRebalanceAmount, decimals), | ||
| amountToTransfer: formatUnits(amountToTransfer, decimals), | ||
| }); | ||
| return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we returned { usdc, amountToTransfer: bnZero, accountAddress } in this case? it's arguably simpler wherever this is used, because the caller only needs to check for amountToTransfer.gt(bnZero).
We want to make USDH Refiller more configurable so it can top-up address on HyperEVM with USDH based on balances on both origin and destination chains.