Skip to content

Commit

Permalink
pay contract: rename handoff to intent
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewliu08 committed Oct 10, 2024
1 parent 576fe76 commit 59ad6c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/contract/src/pay/DaimoPay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import "./PayIntentFactory.sol";
import "./TokenUtils.sol";

// A Daimo Pay transfer has 4 steps:
// 1. Alice sends (tokenIn, amountIn) to handoff address on chain A -- simple erc20 transfer
// 1. Alice sends (tokenIn, amountIn) to intent address on chain A -- simple erc20 transfer
// 2. Relayer swaps tokenIn to bridgeTokenIn and burns on chain A -- relayer runs this in sendAndSelfDestruct
// - relayer doesnt need approve or anything else, just quote and swap.
// - quote comes from the handoff address which commits to the destination bridgeTokenOut amount, and therefore bridgeTokenIn amount.
// - quote comes from the intent address which commits to the destination bridgeTokenOut amount, and therefore bridgeTokenIn amount.
// - relayer has to fetch swap from Uniswap or similar

// Fork: fastFinish, then claim
Expand Down Expand Up @@ -121,7 +121,7 @@ contract DaimoPay {
) public {
require(intent.toChainId == block.chainid, "DP: wrong chain");

// Calculate handoff address
// Calculate intent address
address intentAddr = intentFactory.getIntentAddress(intent);

// Optimistic fast finish is only for transfers which haven't already
Expand Down
2 changes: 1 addition & 1 deletion packages/contract/src/pay/PayIntent.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ contract PayIntentContract is Initializable {
amount: amount
});

// This use of SELFDESTRUCT is compatible with EIP-6780. Handoff
// This use of SELFDESTRUCT is compatible with EIP-6780. Intent
// contracts are deployed, then destroyed in the same transaction.
// solhint-disable-next-line
selfdestruct(intent.escrow);
Expand Down
10 changes: 5 additions & 5 deletions packages/contract/test/DaimoPay.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ contract DaimoPayTest is Test {
console.log("TestUSDC (toToken) address:", address(_toToken));
}

function testGetHandoffAddr() public view {
function testGetIntentAddr() public view {
PayIntent memory baseIntent = PayIntent({
toChainId: _baseChainId,
bridgeTokenOut: TokenAmount({token: _toToken, amount: _toAmount}),
Expand Down Expand Up @@ -446,7 +446,7 @@ contract DaimoPayTest is Test {
// Wait for CCTP to relay the message
vm.warp(block.timestamp + 20 minutes);

// CCTP receiveMessage() sends funds to the handoff address
// CCTP receiveMessage() sends funds to the intent address
_toToken.transfer(BASE_INTENT_ADDR, _toAmount);

// Then, LP claims the funds
Expand All @@ -470,7 +470,7 @@ contract DaimoPayTest is Test {

dp.claimIntent({intent: intent, calls: new Call[](0)});

// LP received funds from handoff, and handoff is destroyed
// LP received funds from intent, and intent is destroyed
assertEq(_toToken.balanceOf(BASE_INTENT_ADDR), 0);
assertEq(_toToken.balanceOf(_lp), _lpToTokenInitBalance);
assertEq(_toToken.balanceOf(_bob), _toAmount);
Expand All @@ -483,7 +483,7 @@ contract DaimoPayTest is Test {
// Wait for CCTP to relay the message
vm.warp(block.timestamp + 20 minutes);

// CCTP receiveMessage() sends funds to the handoff address
// CCTP receiveMessage() sends funds to the intent address
_toToken.transfer(BASE_INTENT_ADDR, _toAmount);

// Then, a third party calls claimIntent
Expand Down Expand Up @@ -514,7 +514,7 @@ contract DaimoPayTest is Test {

dp.claimIntent({intent: intent, calls: new Call[](0)});

// LP doesn't receive funds, handoff is destroyed, and funds are sent
// LP doesn't receive funds, intent is destroyed, and funds are sent
// to the final recipient
assertEq(_toToken.balanceOf(BASE_INTENT_ADDR), 0);
assertEq(_toToken.balanceOf(_lp), 0);
Expand Down

0 comments on commit 59ad6c1

Please sign in to comment.