Verified contractExactMIT
SpinrV2SettlementPort
Address0xa9cdd4c076ccfd4f85b0fc978fdec47664c98b5f
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- shanghai
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,229,496
- Creation transaction
- 0xb2ce41285e…d1ee5a9e1b
SpinrV2SettlementPort.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
interface ISpinrV2Core {
function acquisitions(uint256) external view returns(address,uint256,uint256,uint256,uint8);
function listings(uint256) external view returns(address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,uint64,uint8);
function quoteAcquisitionPrice() external view returns(uint256,uint256,uint256);
function acquisitionRefundCredit(address) external view returns(uint256);
function withdrawAcquisitionRefund() external returns(uint256);
function settlementDiscountBps() external view returns(uint256);
function keepNFT(uint256) external;
function acceptDepositorBid(uint256) external;
function recoverStuckNFT(uint256) external;
function stuckNFTRecipient(uint256) external view returns(address);
}
interface ISpinrV2PortRound {
function fwaPort() external view returns(address);
function pool() external view returns(address);
function builder() external view returns(address);
function executeBuilderPurchase() external returns(uint256[] memory);
function executeProtocolCall(bytes calldata) external returns(bytes memory);
function protocolReceivedWei() external view returns(uint256);
}
interface ISpinrV2PortBuilder {function pool() external view returns(address);}
interface ISpinrFloorQuote {
// Quote must belong to the requested collection on this deployment's chain.
function quote(address collection) external view returns(uint256 floorWei,uint256 updatedAt);
}
interface ISpinrV2PortNFT {function ownerOf(uint256) external view returns(address);}
/// @notice V2 core adapter. No custody, owner, arbitrary settlement or withdrawals.
/// @dev Collection floor oracle remains a trust boundary. Not deployment audited.
contract SpinrV2SettlementPort {
ISpinrV2Core public immutable pool;
address public immutable builder;
ISpinrFloorQuote public immutable floorOracle;
mapping(address=>bool) public purchased;
mapping(address=>uint256) public roundRequest;
uint256 public constant MAX_FLOOR_AGE=300;
bool private entered;
modifier guarded(){require(!entered,"Reentrancy");entered=true;_;entered=false;}
constructor(ISpinrV2Core pool_,address builder_,ISpinrFloorQuote oracle_){
require(address(pool_).code.length>0 && builder_.code.length>0 && address(oracle_).code.length>0,"Invalid dependencies");
require(ISpinrV2PortBuilder(builder_).pool()==address(pool_),"Builder pool mismatch");
pool=pool_;builder=builder_;floorOracle=oracle_;
}
function quote() external view returns(uint256 totalWei){(,,totalWei)=pool.quoteAcquisitionPrice();}
function buyForRound(uint256,uint256,uint256,uint256) external payable guarded returns(uint256 id){
require(msg.value==0,"Funds must go through round callback");
ISpinrV2PortRound round=ISpinrV2PortRound(msg.sender);
require(!purchased[msg.sender] && round.fwaPort()==address(this) && round.pool()==address(pool) && round.builder()==builder,"Invalid round binding");
purchased[msg.sender]=true;
uint256[] memory ids=round.executeBuilderPurchase();require(ids.length==1,"Expected one request");id=ids[0];
(address purchaser,,,,uint8 status)=pool.acquisitions(id);
require(purchaser==msg.sender && status!=0,"Incorrect purchaser");roundRequest[msg.sender]=id;
}
function resolve(uint256 id) external guarded returns(uint8 result,address collection,uint256 tokenId,uint256 netETH){
require(purchased[msg.sender] && roundRequest[msg.sender]==id,"Unknown round request");
(address purchaser,,,uint256 listingId,uint8 status)=pool.acquisitions(id);
require(purchaser==msg.sender,"Incorrect purchaser");
ISpinrV2PortRound round=ISpinrV2PortRound(msg.sender);
if(status==1 || status==5 || status==6)return(0,address(0),0,0);
if(status==3 || status==4){
require(pool.acquisitionRefundCredit(msg.sender)>0,"Refund credit unavailable");
bytes memory output=round.executeProtocolCall(abi.encodeCall(pool.withdrawAcquisitionRefund,()));
uint256 withdrawn=abi.decode(output,(uint256));
require(withdrawn>0 && round.protocolReceivedWei()>=withdrawn,"Refund not delivered");
return(3,address(0),0,withdrawn);
}
require(status==2,"Unexpected acquisition status");
address listingPurchaser;uint256 backingWei;uint8 listingStatus;
(collection,,listingPurchaser,tokenId,,backingWei,,,,,listingStatus)=pool.listings(listingId);
require(listingPurchaser==msg.sender,"Listing purchaser mismatch");
if(listingStatus==2){
(uint256 floorWei,uint256 updatedAt)=floorOracle.quote(collection);
require(floorWei>0 && updatedAt<=block.timestamp && block.timestamp-updatedAt<=MAX_FLOOR_AGE,"Invalid or stale floor");
uint256 rate=pool.settlementDiscountBps();
require(rate>=8000 && rate<=9500,"Unexpected ETH cashout rate");
// Compare spendable proceeds, not gross backing. The floor is only
// a reference, not a guaranteed bid or token-specific appraisal.
uint256 cashoutWei=backingWei*rate/10000;
if(cashoutWei>=floorWei){
uint256 beforeReceived=round.protocolReceivedWei();
round.executeProtocolCall(abi.encodeCall(pool.acceptDepositorBid,(listingId)));
netETH=round.protocolReceivedWei()-beforeReceived;require(netETH>0,"ETH not delivered");
return(1,address(0),0,netETH);
}
round.executeProtocolCall(abi.encodeCall(pool.keepNFT,(listingId)));
}else{
require(listingStatus==4,"Unexpected listing status");
// Depositor ETH settlement or public NFT timeout can precede resolve.
netETH=round.protocolReceivedWei();if(netETH>0)return(1,address(0),0,netETH);
if(pool.stuckNFTRecipient(listingId)==msg.sender)round.executeProtocolCall(abi.encodeCall(pool.recoverStuckNFT,(listingId)));
}
require(collection.code.length>0 && ISpinrV2PortNFT(collection).ownerOf(tokenId)==msg.sender,"NFT not delivered");
return(2,collection,tokenId,0);
}
}
Compiler settingsShow
{
"viaIR": true,
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "shanghai"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.