Repository navigation
feat(v2): Circle Refund Protocol adapter for PredgeRefundArbiterV2 (Arc Demo Day) - #8
Merged
Conversation
PredgeRefundArbiterV2 cannot drive Circle's RefundProtocol directly: Circle has no paymentInfo (it exposes payments(id) with to/refundTo), amounts are in USDC 6dp while the bond is sized in native wei, and Circle's arbiter is fixed in its constructor. CircleRefundProtocolAdapter is set as Circle's arbiter, accepts writes only from the bound Predge arbiter, maps refundTo->payer, to->payee, scales the amount, and treats an already-refunded payment as done. Adds our own ICircleRefundProtocol (signatures only, read from the public source), a local MockCircleRefundProtocol mirroring its behaviour, MockUSDC, 14 Foundry tests (release, refund on verdict, dispute overturned/upheld, edge cases) and an Arc testnet deploy script (simulation only, nothing broadcast). The deployed arbiter and the v2 plan are unchanged.
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.
Why
For Arc Demo Day (16 Nov) we want to show Predge as the
arbiterof Circle's Refund Protocol (circlefin/refund-protocol).PredgeRefundArbiterV2was built against ourMockRefundProtocolV2. To find out whether it works with Circle's real contract, we read Circle's publicsrc/RefundProtocol.sol. No Circle code was cloned, installed or run.Gap analysis: does the deployed arbiter work with Circle's contract as it is? No. It needs a small adapter.
PredgeRefundArbiterV2callsRefundProtocolpaymentInfo(id) -> (payer, payee, amount, releaseTimestamp)payments(id) -> (to, amount, releaseTimestamp, refundTo, withdrawnAmount, refunded)fileEvidenceandrulecall would revert.pay; refunds go torefundTo, andrefundTocan be changed withupdateRefundTorefundToamount, in native wei (sizes the bond)refundByArbiter(id)onlyArbiter; reverts on already refunded orInsufficientFunds; no check on release timesetLockupSeconds(r, s)onlyArbiter, cap is 180 daysarbiteris set once in Circle's constructor and has no setterNone)earlyWithdrawByArbiter,deposit/withdrawArbiterFundsfinalizereverts andexpirevoids the rulingThe live Arc/Base
PredgeRefundArbiterV2points immutably atMockRefundProtocolV2. Pointing at Circle's contract therefore needs a new arbiter instance withrefundProtocol = adapter. The bytecode does not change.What this PR adds
contracts/v2/interfaces/ICircleRefundProtocol.sol: our own interface, signatures only.contracts/v2/adapters/CircleRefundProtocolAdapter.sol: about 120 lines, no owner, holds no funds. A one-timebindchecks the wiring in both directions.contracts/v2/mocks/MockCircleRefundProtocol.solandMockUSDC.sol: our own local stand-ins that mirror Circle's interface and behaviour, for tests and demos only.test/foundry-v2/CircleRefundAdapter.t.sol: 14 tests covering release, refund on verdict, dispute (overturned to refund, refund upheld), the seller refunding first, already-refunded payments, zero lockup refused, the 180-day cap, arefundTochange after the ruling, and a 6-line demo log.scripts/foundry/DeployCircleRefundDemo.s.sol: deploy script for Arc testnet. Simulated only, nothing broadcast.No change to
PredgeRefundArbiterV2,config/set.v2.jsonor the deployed addresses.Tests
FOUNDRY_CONFIG=foundry-v2.toml forge test: 166/166 pass (14 new). The node testplan-v2.test.mjs#2 ("would collide with a v2.0 address") already fails onv2/contractswithout this PR and is unrelated.Before mainnet
The adapter and both mocks are unaudited. Circle's RefundProtocol is itself marked unaudited and educational. Do not merge this until it has been reviewed.