Skip to content

Commit

Permalink
Merge pull request #77 from catalystdao/ack-failure-low-level-transfer
Browse files Browse the repository at this point in the history
feat: low level transfer call
  • Loading branch information
reednaa authored Feb 12, 2024
2 parents 884399b + 26ebb41 commit 9340077
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion evm/src/CatalystVaultCommon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,15 @@ abstract contract CatalystVaultCommon is
// This call provides re-entry protection against re-entering this call. Otherwise, this call can always be called.
address fallbackAddress = _releaseAssetEscrow(sendAssetHash, escrowAmount, escrowToken); // Only reverts for missing escrow,

ERC20(escrowToken).safeTransfer(fallbackAddress, escrowAmount); // Would fail if there is no balance. To protect against this, the escrow amount should be removed from what can be claimed by users.
// Make a low level call such that the transfer never fails. This is important for tokens
// that use block lists.
// This also implies that if you get blacklisted between when you initiated the swap and the swap failed, you
// would lose the tokens.
bytes memory payload = abi.encodeWithSignature("transfer(address,uint256)", fallbackAddress, escrowAmount);
assembly ("memory-safe") {
let success := call(gas(), escrowToken, 0, add(payload, 0x20), mload(payload), 0, 0)
// ERC20(escrowToken).safeTransfer(fallbackAddress, escrowAmount);
}

emit SendAssetFailure( // Never reverts.
channelId,
Expand Down

0 comments on commit 9340077

Please sign in to comment.