Verified contractExactMIT
LuxSplit
Address0xd4b637cc81d5b5115cd0204a9ba6b60474f05e31
- Balance
0 ETH
- Transactions
2
- Compiler
solc 0.8.24
- Same code
1 more contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- paris
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,467,369
- Creation transaction
- 0xedd9a73682…5080c370ce
contracts/LuxSplit.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;
/// Divisione automatica dei pagamenti della piattaforma.
/// Il compratore paga una volta sola: nella stessa transazione il venditore riceve il suo prezzo
/// e la piattaforma riceve la commissione (FEE_BPS sul prezzo del venditore). Il contratto non
/// conserva mai fondi: non ha saldo, non ha proprietario, non si può modificare né fermare.
contract LuxSplit {
address public immutable treasury;
uint256 public immutable feeBps;
event Paid(
bytes32 indexed orderId,
address indexed buyer,
address indexed seller,
address token,
uint256 sellerAmount,
uint256 fee
);
error ZeroAddress();
error BadFee();
error WrongAmount();
error TransferFailed();
constructor(address treasury_, uint256 feeBps_) {
if (treasury_ == address(0)) revert ZeroAddress();
if (feeBps_ == 0 || feeBps_ > 3000) revert BadFee();
treasury = treasury_;
feeBps = feeBps_;
}
function feeFor(uint256 sellerAmount) public view returns (uint256) {
return (sellerAmount * feeBps) / 10000;
}
/// Pagamento in moneta nativa della rete (ETH, POL). msg.value = prezzo del venditore + commissione.
function payNative(bytes32 orderId, address payable seller, uint256 sellerAmount) external payable {
if (seller == address(0)) revert ZeroAddress();
uint256 fee = feeFor(sellerAmount);
if (msg.value != sellerAmount + fee) revert WrongAmount();
(bool ok1, ) = seller.call{value: sellerAmount}("");
if (!ok1) revert TransferFailed();
(bool ok2, ) = payable(treasury).call{value: fee}("");
if (!ok2) revert TransferFailed();
emit Paid(orderId, msg.sender, seller, address(0), sellerAmount, fee);
}
/// Pagamento con token ERC-20 (USDC, USDT). Serve prima approve(questo contratto, prezzo + commissione).
/// I token vanno dal compratore al venditore e alla piattaforma direttamente, senza passare dal contratto.
function payToken(bytes32 orderId, address token, address seller, uint256 sellerAmount) external {
if (seller == address(0) || token == address(0)) revert ZeroAddress();
if (sellerAmount == 0) revert WrongAmount();
uint256 fee = feeFor(sellerAmount);
_transferFrom(token, msg.sender, seller, sellerAmount);
_transferFrom(token, msg.sender, treasury, fee);
emit Paid(orderId, msg.sender, seller, token, sellerAmount, fee);
}
// USDT non restituisce un booleano: si accetta risposta vuota o true.
function _transferFrom(address token, address from, address to, uint256 amount) private {
if (amount == 0) return;
(bool ok, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, amount));
if (!ok || (data.length != 0 && !abi.decode(data, (bool)))) revert TransferFailed();
}
receive() external payable { revert WrongAmount(); }
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.