Verified contractPartialMIT
ArkRouter
Address0xca90864f79bc2ecc6d970f2ff2cabbd180eaeb2f
- Balance
0 ETH
- Transactions
13
- 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
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,100,064
- Creation transaction
- 0x483151ef9c…57363953a7
15 files
- src/periphery/ArkRouter.solmain2.02 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
- src/boarding/ArkBoarding.sol12.17 KB
- src/boarding/ArkPass.sol3.22 KB
- src/interfaces/IArkFeeRouter.sol171 B
- src/interfaces/IArkLaunchExposureGuard.sol1.9 KB
- src/interfaces/IArkVault.sol842 B
- src/interfaces/IERC20.sol708 B
- src/libraries/ArkRoutes.sol314 B
- src/security/ArkOwnable.sol474 B
- src/security/ArkRecoverable.sol1.68 KB
- src/security/ArkReentrancyGuard.sol912 B
- src/token/ArkBark.sol2.39 KB
src/periphery/ArkRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {ArkBoarding} from "../boarding/ArkBoarding.sol";
import {IERC20} from "../interfaces/IERC20.sol";
import {ArkRecoverable} from "../security/ArkRecoverable.sol";
contract ArkRouter is ArkRecoverable {
error ZeroAddress();
error ZeroAmount();
error DeadlineExpired();
error TransferFailed();
address public immutable tokenAsset;
ArkBoarding public immutable boarding;
constructor(address tokenAsset_, ArkBoarding boarding_, address initialOwner)
ArkRecoverable(initialOwner)
{
if (tokenAsset_ == address(0)) revert ZeroAddress();
if (address(boarding_) == address(0)) revert ZeroAddress();
tokenAsset = tokenAsset_;
boarding = boarding_;
}
function board(uint256 amount, address receiver, uint256 deadline)
external
nonReentrant
returns (uint256 positionId)
{
return _joinWithToken(amount, receiver, deadline);
}
function joinWithToken(uint256 amount, address receiver, uint256 deadline)
public
nonReentrant
returns (uint256 positionId)
{
return _joinWithToken(amount, receiver, deadline);
}
function _joinWithToken(uint256 amount, address receiver, uint256 deadline)
internal
returns (uint256 positionId)
{
_checkDeadline(deadline);
if (amount == 0) revert ZeroAmount();
if (receiver == address(0)) revert ZeroAddress();
if (!IERC20(tokenAsset).transferFrom(msg.sender, address(this), amount)) {
revert TransferFailed();
}
if (!IERC20(tokenAsset).approve(address(boarding), amount)) revert TransferFailed();
positionId = boarding.board(amount, receiver);
if (!IERC20(tokenAsset).approve(address(boarding), 0)) revert TransferFailed();
}
function _checkDeadline(uint256 deadline) internal view {
if (block.timestamp > deadline) revert DeadlineExpired();
}
}
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;
}
}
src/boarding/ArkBoarding.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {IERC20} from "../interfaces/IERC20.sol";
import {IArkFeeRouter} from "../interfaces/IArkFeeRouter.sol";
import {IArkLaunchExposureGuard} from "../interfaces/IArkLaunchExposureGuard.sol";
import {IArkVault} from "../interfaces/IArkVault.sol";
import {ArkRoutes} from "../libraries/ArkRoutes.sol";
import {ArkRecoverable} from "../security/ArkRecoverable.sol";
import {ArkBark} from "../token/ArkBark.sol";
import {ArkPass} from "./ArkPass.sol";
contract ArkBoarding is ArkRecoverable {
error ZeroAddress();
error ZeroAmount();
error InvalidFee();
error InvalidDecayDuration();
error NotPositionOwner();
error PositionClosed();
error AmountExceedsPrincipal();
error ExitLeavesDust(uint256 remaining);
error TransferFailed();
error Unauthorized();
error VaultAlreadySet();
error LaunchExposureGuardAlreadySet();
error EmptyBatch();
error BatchTooLarge(uint256 size, uint256 maxSize);
error ArrayLengthMismatch();
event Boarded(
address indexed user, uint256 indexed positionId, uint256 amount, uint256 timestamp
);
event Exited(
address indexed user,
uint256 indexed positionId,
uint256 grossAmount,
uint256 feeAmount,
uint256 netAmount
);
event VaultSet(address indexed vault);
event LaunchExposureGuardSet(address indexed guard);
event PositionAmountUpdated(uint256 indexed positionId, uint256 oldAmount, uint256 newAmount);
event OperatorSet(address indexed owner, address indexed operator, bool approved);
struct Position {
address owner;
uint256 principal;
uint256 activeBoardedAmount;
uint64 boardedAt;
bool closed;
}
uint256 public constant BPS = 10_000;
uint256 public constant EXIT_DUST_THRESHOLD = 10_000_000_000;
uint256 public constant MAX_EXIT_BATCH_SIZE = 20;
IERC20 public immutable token;
ArkBark public immutable receipt;
ArkPass public immutable pass;
address public immutable feeRouter;
uint256 public immutable maxExitFeeBps;
uint256 public immutable decayDuration;
uint256 public nextPositionId = 1;
uint256 public activeTotalBoarded;
address public vault;
IArkLaunchExposureGuard public launchExposureGuard;
mapping(uint256 positionId => Position position) public positions;
mapping(address owner => uint256[] positionIds) private ownerPositions;
mapping(address owner => mapping(address operator => bool approved)) public isOperatorFor;
constructor(
IERC20 token_,
ArkBark receipt_,
ArkPass pass_,
address feeRouter_,
uint256 maxExitFeeBps_,
uint256 decayDuration_,
address initialOwner
) ArkRecoverable(initialOwner) {
if (address(token_) == address(0)) revert ZeroAddress();
if (address(receipt_) == address(0)) revert ZeroAddress();
if (address(pass_) == address(0)) revert ZeroAddress();
if (feeRouter_ == address(0)) revert ZeroAddress();
if (maxExitFeeBps_ > BPS) revert InvalidFee();
if (decayDuration_ == 0) revert InvalidDecayDuration();
token = token_;
receipt = receipt_;
pass = pass_;
feeRouter = feeRouter_;
maxExitFeeBps = maxExitFeeBps_;
decayDuration = decayDuration_;
}
function _isRecoverableToken(address asset) internal view override returns (bool) {
return asset != address(token);
}
modifier onlyVault() {
if (msg.sender != vault) revert Unauthorized();
_;
}
function setVault(address vault_) external onlyOwner {
if (vault_ == address(0)) revert ZeroAddress();
if (vault != address(0)) revert VaultAlreadySet();
vault = vault_;
emit VaultSet(vault_);
}
function setLaunchExposureGuard(IArkLaunchExposureGuard guard_) external onlyOwner {
if (address(guard_) == address(0)) revert ZeroAddress();
if (address(launchExposureGuard) != address(0)) revert LaunchExposureGuardAlreadySet();
launchExposureGuard = guard_;
emit LaunchExposureGuardSet(address(guard_));
}
function board(uint256 amount, address receiver)
external
nonReentrant
returns (uint256 positionId)
{
if (amount == 0) revert ZeroAmount();
if (receiver == address(0)) revert ZeroAddress();
if (vault != address(0)) {
IArkVault(vault).beforePositionCreated();
}
if (!token.transferFrom(msg.sender, address(this), amount)) revert TransferFailed();
if (address(launchExposureGuard) != address(0)) {
launchExposureGuard.increaseBoarded(receiver, msg.sender, amount);
}
positionId = nextPositionId++;
positions[positionId] = Position({
owner: receiver,
principal: amount,
activeBoardedAmount: amount,
boardedAt: uint64(block.timestamp),
closed: false
});
ownerPositions[receiver].push(positionId);
activeTotalBoarded += amount;
receipt.mint(receiver, amount);
pass.mint(receiver, positionId);
if (vault != address(0)) {
IArkVault(vault).onPositionCreated(positionId);
}
emit Boarded(receiver, positionId, amount, block.timestamp);
}
function exit(uint256 positionId, uint256 amount, address receiver) external nonReentrant {
_exit(positionId, amount, receiver, msg.sender);
}
function exitFrom(uint256 positionId, uint256 amount, address receiver) external nonReentrant {
_exit(positionId, amount, receiver, msg.sender);
}
function exitMany(uint256[] calldata positionIds, uint256[] calldata amounts, address receiver)
external
nonReentrant
{
uint256 count = positionIds.length;
if (count == 0) revert EmptyBatch();
if (count > MAX_EXIT_BATCH_SIZE) revert BatchTooLarge(count, MAX_EXIT_BATCH_SIZE);
if (count != amounts.length) revert ArrayLengthMismatch();
for (uint256 i = 0; i < count; i++) {
_exit(positionIds[i], amounts[i], receiver, msg.sender);
}
}
function exitAll(uint256 positionId, address receiver) external nonReentrant {
_exitAll(positionId, receiver, msg.sender);
}
function exitAllFrom(uint256 positionId, address receiver) external nonReentrant {
_exitAll(positionId, receiver, msg.sender);
}
function exitAllMany(uint256[] calldata positionIds, address receiver) external nonReentrant {
uint256 count = positionIds.length;
if (count == 0) revert EmptyBatch();
if (count > MAX_EXIT_BATCH_SIZE) revert BatchTooLarge(count, MAX_EXIT_BATCH_SIZE);
for (uint256 i = 0; i < count; i++) {
_exitAll(positionIds[i], receiver, msg.sender);
}
}
function setOperator(address operator, bool approved) external {
if (operator == address(0)) revert ZeroAddress();
isOperatorFor[msg.sender][operator] = approved;
emit OperatorSet(msg.sender, operator, approved);
}
function _exitAll(uint256 positionId, address receiver, address actor) internal {
Position storage position = positions[positionId];
_exit(positionId, position.principal, receiver, actor);
}
function _exit(uint256 positionId, uint256 amount, address receiver, address actor) internal {
if (amount == 0) revert ZeroAmount();
if (receiver == address(0)) revert ZeroAddress();
Position storage position = positions[positionId];
address owner = position.owner;
if (owner != actor && !isOperatorFor[owner][actor]) revert NotPositionOwner();
if (position.closed) revert PositionClosed();
if (amount > position.principal) revert AmountExceedsPrincipal();
uint256 remaining = position.principal - amount;
if (remaining != 0 && remaining < EXIT_DUST_THRESHOLD) revert ExitLeavesDust(remaining);
uint256 oldAmount = position.activeBoardedAmount;
if (vault != address(0)) {
IArkVault(vault).beforePositionAmountChange(positionId);
}
uint256 feeAmount = exitFee(positionId, amount);
uint256 netAmount = amount - feeAmount;
position.principal -= amount;
position.activeBoardedAmount -= amount;
activeTotalBoarded -= amount;
if (address(launchExposureGuard) != address(0)) {
launchExposureGuard.decreaseBoarded(owner, amount);
}
if (position.principal == 0) {
position.closed = true;
pass.burn(positionId);
}
receipt.burn(owner, amount);
if (feeAmount != 0) {
if (!token.transfer(feeRouter, feeAmount)) revert TransferFailed();
IArkFeeRouter(feeRouter)
.routeReceived(ArkRoutes.EXIT_FEE_ROUTE, address(token), feeAmount);
}
if (address(launchExposureGuard) != address(0)) {
launchExposureGuard.allowTokenRelease(owner, receiver, netAmount);
}
if (!token.transfer(receiver, netAmount)) revert TransferFailed();
if (vault != address(0)) {
IArkVault(vault).claimPositionRewardFromBoarding(positionId, receiver);
if (position.closed) {
IArkVault(vault).onPositionClosed(positionId);
}
}
emit PositionAmountUpdated(positionId, oldAmount, position.activeBoardedAmount);
emit Exited(owner, positionId, amount, feeAmount, netAmount);
}
function addPrincipalFromVault(uint256 positionId, uint256 amount)
external
nonReentrant
onlyVault
{
if (amount == 0) revert ZeroAmount();
Position storage position = positions[positionId];
if (position.closed) revert PositionClosed();
uint256 oldAmount = position.activeBoardedAmount;
if (!token.transferFrom(msg.sender, address(this), amount)) revert TransferFailed();
if (address(launchExposureGuard) != address(0)) {
launchExposureGuard.increaseBoardedFromReward(position.owner, amount);
}
position.principal += amount;
position.activeBoardedAmount += amount;
activeTotalBoarded += amount;
receipt.mint(position.owner, amount);
emit PositionAmountUpdated(positionId, oldAmount, position.activeBoardedAmount);
}
function exitFee(uint256 positionId, uint256 amount) public view returns (uint256) {
Position storage position = positions[positionId];
if (position.closed) return 0;
uint256 elapsed = block.timestamp - uint256(position.boardedAt);
if (elapsed >= decayDuration) return 0;
uint256 remaining = decayDuration - elapsed;
return amount * maxExitFeeBps * remaining / decayDuration / BPS;
}
function timeUntilFreeExit(uint256 positionId) external view returns (uint256) {
Position storage position = positions[positionId];
if (position.closed) return 0;
uint256 elapsed = block.timestamp - uint256(position.boardedAt);
if (elapsed >= decayDuration) return 0;
return decayDuration - elapsed;
}
function activeBoardedAmount(uint256 positionId) public view returns (uint256) {
return positions[positionId].activeBoardedAmount;
}
function positionPrincipal(uint256 positionId) external view returns (uint256) {
return positions[positionId].principal;
}
function totalBoarded() external view returns (uint256) {
return activeTotalBoarded;
}
function positionsOf(address owner) external view returns (uint256[] memory) {
return ownerPositions[owner];
}
function positionOwner(uint256 positionId) external view returns (address) {
return positions[positionId].owner;
}
function isPositionActive(uint256 positionId) external view returns (bool) {
return !positions[positionId].closed && positions[positionId].owner != address(0);
}
}
src/boarding/ArkPass.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {ArkOwnable} from "../security/ArkOwnable.sol";
contract ArkPass is ArkOwnable {
error ZeroAddress();
error EmptyMetadata();
error Unauthorized();
error BoardingAlreadySet();
error TokenAlreadyMinted();
error TokenDoesNotExist();
error TransfersDisabled();
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
event BoardingSet(address indexed boarding);
string public name;
string public symbol;
address public boarding;
mapping(uint256 tokenId => address owner) public ownerOf;
mapping(address owner => uint256 balance) public balanceOf;
constructor(address initialOwner, string memory name_, string memory symbol_)
ArkOwnable(initialOwner)
{
if (bytes(name_).length == 0 || bytes(symbol_).length == 0) revert EmptyMetadata();
name = name_;
symbol = symbol_;
}
modifier onlyBoarding() {
if (msg.sender != boarding) revert Unauthorized();
_;
}
function setBoarding(address boarding_) external onlyOwner {
if (boarding_ == address(0)) revert ZeroAddress();
if (boarding != address(0)) revert BoardingAlreadySet();
boarding = boarding_;
emit BoardingSet(boarding_);
}
function mint(address to, uint256 tokenId) external onlyBoarding {
if (to == address(0)) revert ZeroAddress();
if (ownerOf[tokenId] != address(0)) revert TokenAlreadyMinted();
ownerOf[tokenId] = to;
balanceOf[to] += 1;
emit Transfer(address(0), to, tokenId);
}
function burn(uint256 tokenId) external onlyBoarding {
address owner = ownerOf[tokenId];
if (owner == address(0)) revert TokenDoesNotExist();
delete ownerOf[tokenId];
balanceOf[owner] -= 1;
emit Transfer(owner, address(0), tokenId);
}
function isActive(uint256 tokenId) external view returns (bool) {
return ownerOf[tokenId] != address(0);
}
function isActivePassHolder(address account) external view returns (bool) {
return balanceOf[account] != 0;
}
function getApproved(uint256 tokenId) external view returns (address) {
if (ownerOf[tokenId] == address(0)) revert TokenDoesNotExist();
return address(0);
}
function isApprovedForAll(address, address) external pure returns (bool) {
return false;
}
function approve(address, uint256) external pure {
revert TransfersDisabled();
}
function setApprovalForAll(address, bool) external pure {
revert TransfersDisabled();
}
function transferFrom(address, address, uint256) external pure {
revert TransfersDisabled();
}
function safeTransferFrom(address, address, uint256) external pure {
revert TransfersDisabled();
}
function safeTransferFrom(address, address, uint256, bytes calldata) external pure {
revert TransfersDisabled();
}
}
src/interfaces/IArkFeeRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
interface IArkFeeRouter {
function routeReceived(bytes32 routeId, address asset, uint256 amount) external;
}
src/interfaces/IArkLaunchExposureGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
interface IArkLaunchExposureGuard {
function token() external view returns (address);
function boarding() external view returns (address);
function vault() external view returns (address);
function exposureCap() external view returns (uint256);
function limitsDisabled() external view returns (bool);
function boardedExposure(address account) external view returns (uint256);
function lockedExposure(address account) external view returns (uint256);
function releaseCredit(address source, address receiver) external view returns (uint256);
function isExempt(address account) external view returns (bool);
function exemptCount() external view returns (uint256);
function exemptAt(uint256 index) external view returns (address);
function exposureOf(address account) external view returns (uint256);
function remainingExposure(address account) external view returns (uint256);
function setBoarding(address boarding_) external;
function setVault(address vault_) external;
function setExempt(address account, bool exempt) external;
function disableLimits() external;
function validateTokenReceive(
address from,
address to,
uint256 amount,
uint256 nextLiquidBalance
) external;
function increaseBoarded(address owner, address source, uint256 amount) external;
function increaseBoardedFromReward(address owner, uint256 amount) external;
function decreaseBoarded(address owner, uint256 amount) external;
function increaseLocked(address owner, address source, uint256 amount) external;
function increaseLockedFromReward(address owner, uint256 amount) external;
function decreaseLocked(address owner, uint256 amount) external;
function allowTokenRelease(address owner, address receiver, uint256 amount) external;
}
src/interfaces/IArkVault.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
interface IArkVault {
function notifyBaseReward(address asset, uint256 amount) external;
function notifyLockedReward(address asset, uint256 amount) external;
function beforePositionCreated() external;
function onPositionCreated(uint256 positionId) external;
function beforePositionAmountChange(uint256 positionId) external;
function onPositionClosed(uint256 positionId) external;
function claimPositionRewardFromBoarding(uint256 positionId, address receiver) external;
function claimMany(uint256[] calldata positionIds, uint256[] calldata lockIds, address receiver)
external;
function unlockMany(uint256[] calldata lockIds, address receiver) external;
function unlockManyAsWeth(uint256[] calldata lockIds, address receiver) external;
}
src/interfaces/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
src/libraries/ArkRoutes.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
library ArkRoutes {
bytes32 internal constant EXIT_FEE_ROUTE = keccak256("ARK_EXIT_FEE");
bytes32 internal constant HOOK_FEE_ROUTE = keccak256("ARK_HOOK_FEE");
bytes32 internal constant BUYBACK_OUTPUT_ROUTE = keccak256("ARK_BUYBACK_OUTPUT");
}
src/security/ArkOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
abstract contract ArkOwnable is Ownable2Step {
error OwnershipRenounceDisabled();
constructor(address initialOwner) Ownable(initialOwner) {}
function renounceOwnership() public view override onlyOwner {
revert OwnershipRenounceDisabled();
}
}
src/security/ArkRecoverable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {IERC20} from "../interfaces/IERC20.sol";
import {ArkOwnable} from "./ArkOwnable.sol";
import {ArkReentrancyGuard} from "./ArkReentrancyGuard.sol";
abstract contract ArkRecoverable is ArkOwnable, ArkReentrancyGuard {
error NoRecoverableBalance();
error ProtectedRecoveryAsset();
error RecoveryTransferFailed();
event NativeRecovered(address indexed recipient, uint256 amount);
event TokenRecovered(address indexed asset, address indexed recipient, uint256 amount);
constructor(address initialOwner) ArkOwnable(initialOwner) {}
function recoverNative() external nonReentrant onlyOwner returns (uint256 amount) {
amount = address(this).balance;
if (amount == 0) revert NoRecoverableBalance();
address recipient = owner();
(bool success,) = payable(recipient).call{value: amount}("");
if (!success) revert RecoveryTransferFailed();
emit NativeRecovered(recipient, amount);
}
function recoverToken(address asset) external nonReentrant onlyOwner returns (uint256 amount) {
if (asset == address(0)) revert ProtectedRecoveryAsset();
if (!_isRecoverableToken(asset)) revert ProtectedRecoveryAsset();
amount = IERC20(asset).balanceOf(address(this));
if (amount == 0) revert NoRecoverableBalance();
address recipient = owner();
if (!IERC20(asset).transfer(recipient, amount)) revert RecoveryTransferFailed();
emit TokenRecovered(asset, recipient, amount);
}
function _isRecoverableToken(address) internal view virtual returns (bool) {
return true;
}
}
src/security/ArkReentrancyGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
abstract contract ArkReentrancyGuard {
error ReentrantCall();
uint256 private constant ENTERED = 1;
bytes32 private constant REENTRANCY_GUARD_SLOT =
0x3a6f8673abc4ff4f17461e886ecbdb6f0f20d51c49db9bac70360d14b8040ec4;
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
bytes32 slot = REENTRANCY_GUARD_SLOT;
uint256 status;
assembly ("memory-safe") {
status := tload(slot)
}
if (status == ENTERED) revert ReentrantCall();
assembly ("memory-safe") {
tstore(slot, ENTERED)
}
}
function _nonReentrantAfter() private {
bytes32 slot = REENTRANCY_GUARD_SLOT;
assembly ("memory-safe") {
tstore(slot, 0)
}
}
}
src/token/ArkBark.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {IERC20} from "../interfaces/IERC20.sol";
import {ArkOwnable} from "../security/ArkOwnable.sol";
contract ArkBark is IERC20, ArkOwnable {
error ZeroAddress();
error EmptyMetadata();
error Unauthorized();
error BoardingAlreadySet();
error TransfersDisabled();
error InsufficientBalance();
event BoardingSet(address indexed boarding);
string public name;
string public symbol;
uint8 public constant decimals = 18;
address public boarding;
uint256 public override totalSupply;
mapping(address account => uint256 balance) public override balanceOf;
constructor(address initialOwner, string memory name_, string memory symbol_)
ArkOwnable(initialOwner)
{
if (bytes(name_).length == 0 || bytes(symbol_).length == 0) revert EmptyMetadata();
name = name_;
symbol = symbol_;
}
modifier onlyBoarding() {
if (msg.sender != boarding) revert Unauthorized();
_;
}
function setBoarding(address boarding_) external onlyOwner {
if (boarding_ == address(0)) revert ZeroAddress();
if (boarding != address(0)) revert BoardingAlreadySet();
boarding = boarding_;
emit BoardingSet(boarding_);
}
function mint(address to, uint256 amount) external onlyBoarding {
if (to == address(0)) revert ZeroAddress();
totalSupply += amount;
balanceOf[to] += amount;
emit Transfer(address(0), to, amount);
}
function burn(address from, uint256 amount) external onlyBoarding {
uint256 balance = balanceOf[from];
if (balance < amount) revert InsufficientBalance();
unchecked {
balanceOf[from] = balance - amount;
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
function allowance(address, address) external pure override returns (uint256) {
return 0;
}
function transfer(address, uint256) external pure override returns (bool) {
revert TransfersDisabled();
}
function approve(address, uint256) external pure override returns (bool) {
revert TransfersDisabled();
}
function transferFrom(address, address, uint256) external pure override returns (bool) {
revert TransfersDisabled();
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": false,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/v4-core/lib/openzeppelin-contracts/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"ds-test/=lib/v4-core/lib/forge-std/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/",
"forge-std/=lib/v4-core/lib/forge-std/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/v4-core/lib/openzeppelin-contracts/",
"permit2/=lib/v4-periphery/lib/permit2/",
"solmate/=lib/v4-core/lib/solmate/",
"v4-core/=lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.