mirror of
https://github.com/luxfhe/example-dapps.git
synced 2026-10-30 18:13:32 +00:00
24 lines
897 B
Solidity
24 lines
897 B
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.24;
|
|
|
|
import {FHE, externalEuint64, euint64} from "@fhevm/solidity/lib/FHE.sol";
|
|
import {IERC7984} from "openzeppelin-confidential-contracts/contracts/interfaces/IERC7984.sol";
|
|
|
|
contract SwapERC7984ToERC7984 {
|
|
function swapConfidentialForConfidential(
|
|
IERC7984 fromToken,
|
|
IERC7984 toToken,
|
|
externalEuint64 amountInput,
|
|
bytes calldata inputProof
|
|
) public virtual {
|
|
require(fromToken.isOperator(msg.sender, address(this)));
|
|
|
|
euint64 amount = FHE.fromExternal(amountInput, inputProof);
|
|
|
|
FHE.allowTransient(amount, address(fromToken));
|
|
euint64 amountTransferred = fromToken.confidentialTransferFrom(msg.sender, address(this), amount);
|
|
|
|
FHE.allowTransient(amountTransferred, address(toToken));
|
|
toToken.confidentialTransfer(msg.sender, amountTransferred);
|
|
}
|
|
} |