Verified contractPartialMIT
MigrationReward
Address0x31267d2dcefb6174b9c2cff8ae328a9b2dd510af
- Balance
0 ETH
- Transactions
7
- 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
- cancun
- Via IR
- yes
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,306,857
- Creation transaction
- 0x36f518f33a…516bb662ea
5 files
- src/MigrationReward.solmain6.18 KB
- lib/v4-core/lib/openzeppelin-contracts/contracts/access/Ownable.sol3.1 KB
- lib/v4-core/lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol1.99 KB
- lib/v4-core/lib/openzeppelin-contracts/contracts/utils/Context.sol963 B
- lib/v4-core/lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol3.24 KB
src/MigrationReward.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {Ownable2Step, Ownable} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
interface ISa1tHook {
function phaseOf(bytes32 id) external view returns (uint8);
}
interface ICreatorFeeNFT {
function ownerOf(uint256 tokenId) external view returns (address);
}
interface IXFactory {
function listed(address token) external view returns (bool);
function creatorOf(address token) external view returns (address);
}
/// @title MigrationReward — pays a token's creator a fixed ETH bounty when their token
/// successfully migrates (graduates from the bonding curve to a real pool) on the
/// sa1t or xsa1t platforms.
/// @notice The deployer funds this contract (e.g. 0.5 ETH) and can withdraw the balance at
/// any time. Anyone (typically the keeper that already calls `graduate`) can then
/// trigger `reward(token)` once per token; the contract VERIFIES the migration
/// on-chain and pays the creator — never the caller — so it can't be farmed:
///
/// • sa1t : poolId = keccak256(abi.encode(0, token, 0, 60, hook));
/// graduated == hook.phaseOf(poolId) == 3 (Phase.AMM);
/// creator == creatorFeeNFT.ownerOf(uint256(poolId)).
/// • xsa1t: graduated == factory.listed(token);
/// creator == factory.creatorOf(token).
///
/// Graduating a token requires real volume (selling out the curve / hitting the
/// grad threshold), which costs far more than the bounty — so there's no incentive
/// to launch-and-graduate purely to claim it.
contract MigrationReward is Ownable2Step, ReentrancyGuard {
// sa1t platform (ETH curve → Uniswap v4 AMM)
address public sa1tHook;
address public sa1tCreatorNFT;
// xsa1t platform (USDC curve → pegged listed market)
address public xsa1tFactory;
uint8 public constant SA1T_GRADUATED = 3; // Sa1tHook Phase.AMM
uint24 internal constant SA1T_FEE = 0;
int24 internal constant SA1T_TICK_SPACING = 60;
uint256 public rewardWei = 0.1 ether;
mapping(address token => bool) public rewarded;
event Rewarded(address indexed token, address indexed creator, uint256 amount, string platform);
event Funded(address indexed from, uint256 amount);
event Withdrawn(address indexed to, uint256 amount);
event RewardWeiSet(uint256 amount);
event PlatformsSet(address sa1tHook, address sa1tCreatorNFT, address xsa1tFactory);
error AlreadyRewarded();
error NotMigrated();
error NoCreator();
error InsufficientFunds();
error SendFailed();
constructor(address owner_, address sa1tHook_, address sa1tCreatorNFT_, address xsa1tFactory_) Ownable(owner_) {
sa1tHook = sa1tHook_;
sa1tCreatorNFT = sa1tCreatorNFT_;
xsa1tFactory = xsa1tFactory_;
}
receive() external payable { emit Funded(msg.sender, msg.value); }
// ── owner ──
function setRewardWei(uint256 v) external onlyOwner { rewardWei = v; emit RewardWeiSet(v); }
function setPlatforms(address hook_, address nft_, address xfactory_) external onlyOwner {
sa1tHook = hook_; sa1tCreatorNFT = nft_; xsa1tFactory = xfactory_;
emit PlatformsSet(hook_, nft_, xfactory_);
}
/// Pull funds back to the deployer/owner.
function withdraw(uint256 amount) external onlyOwner nonReentrant {
_send(owner(), amount);
emit Withdrawn(owner(), amount);
}
function withdrawAll() external onlyOwner nonReentrant {
uint256 bal = address(this).balance;
_send(owner(), bal);
emit Withdrawn(owner(), bal);
}
// ── views ──
function sa1tPoolId(address token) public view returns (bytes32) {
return keccak256(abi.encode(address(0), token, SA1T_FEE, SA1T_TICK_SPACING, sa1tHook));
}
/// Resolve the migration status + payable creator for a token, trying both platforms.
/// platform: "" (none / not migrated), "sa1t", or "xsa1t".
function migrationOf(address token) public view returns (string memory platform, address creator) {
// sa1t: a graduated pool reports Phase.AMM; absent pools report NONE (0)
try ISa1tHook(sa1tHook).phaseOf(sa1tPoolId(token)) returns (uint8 ph) {
if (ph == SA1T_GRADUATED) {
try ICreatorFeeNFT(sa1tCreatorNFT).ownerOf(uint256(sa1tPoolId(token))) returns (address c) {
return ("sa1t", c);
} catch { return ("sa1t", address(0)); }
}
} catch {}
// xsa1t
try IXFactory(xsa1tFactory).listed(token) returns (bool l) {
if (l) return ("xsa1t", IXFactory(xsa1tFactory).creatorOf(token));
} catch {}
return ("", address(0));
}
/// True if `token` has migrated and hasn't been rewarded yet (and we can identify a creator).
function rewardable(address token) external view returns (bool) {
if (rewarded[token]) return false;
(string memory p, address c) = migrationOf(token);
return bytes(p).length > 0 && c != address(0);
}
// ── reward (permissionless; pays the creator, not the caller) ──
/// Reward the creator of `token` if it has migrated on either platform. One payout per token.
function reward(address token) external nonReentrant {
if (rewarded[token]) revert AlreadyRewarded();
(string memory platform, address creator) = migrationOf(token);
if (bytes(platform).length == 0) revert NotMigrated();
if (creator == address(0)) revert NoCreator();
uint256 amount = rewardWei;
if (address(this).balance < amount) revert InsufficientFunds();
rewarded[token] = true; // effects before interaction
_send(creator, amount);
emit Rewarded(token, creator, amount, platform);
}
function _send(address to, uint256 amount) internal {
(bool ok,) = to.call{value: amount}("");
if (!ok) revert SendFailed();
}
}
lib/v4-core/lib/openzeppelin-contracts/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
lib/v4-core/lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
lib/v4-core/lib/openzeppelin-contracts/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
lib/v4-core/lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@prb/math/=lib/prb-math/",
"v4-core/=lib/v4-core/",
"@uniswap/v4-core/=lib/v4-core/",
"v4-periphery/=lib/v4-periphery/",
"solmate/=lib/solmate/",
"forge-std/=lib/forge-std/src/",
"permit2/=lib/v4-periphery/lib/permit2/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-core/lib/openzeppelin-contracts/",
"ds-test/=lib/solmate/lib/ds-test/src/",
"erc4626-tests/=lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/v4-core/lib/openzeppelin-contracts/",
"prb-math/=lib/prb-math/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.