HyperCore fee receiver (referral fees at destination) - #4
Open
0x4rde wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
RangoHyperCoreFeeReceiver, a standalone (non-diamond) receiver for HyperCore → EVM withdrawals that splits the withdrawn USDC between up to eight referrers and the recipient, atomically on the destination chain. Supersedes the earlierRangoCCTPV2HyperCoreMiddleware(removed here — it was never merged).Background
Withdrawals from HyperCore are burned by Circle's
CoreDepositWallet, not by a Rango contract, so there is no source-side hook and the fee must be taken at the destination. Circle caps user hook data at 1024 bytes and prepends a 60-byte envelope; a diamondonChainSwapscall does not fit that budget, so this contract uses a compact packed payload and pays out with direct transfers — no CALL, no whitelist dependency, noLibInterchainV2.Design
RangoBaseInterchainMiddlewareV2for ownership, pause, and refund. The base constructor setsowner = deployerat deploy time, so there is no initialization window to front-run.version,requestId,recipient,dAppTag) followed by a variable array of up to eight(referrer, bps)entries. The fee count is derived from the payload length, so there is no count field to disagree with the bytes.feeExecuted), with the combined take capped at 20%. Rounding dust goes to the recipient.processMessageAndTransferUSDC(onlyOwner) recovers any message the split flow cannot process, minting and delivering directly while ignoring the payload.destinationCalleris zero and the attested payload fully determines the payout.Notes
RangoCCTPV2HyperCoreMiddleware.solis removed.amount - feeExecuted; the payout is bounded to that, so pre-existing balances cannot be redirected by a crafted message.