Skip to content
Verified contractExactMIT

Perpia

Address0xed5fd14c3add8ea4f9f1fdbc36c60cd2ec5c3a87
Balance

0 ETH

 

Transactions

7

 

Compiler

solc 0.8.33

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.33+commit.64118f21
Language
solidity
Optimization
Yes, 1 runs
EVM version
prague
Via IR
yes
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,334,896
Creation transaction
0x7ee0f40174…b2ff92e52a

src/Perpia.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;

/*
    ░░▒▒▓▓▓▓▒▒░░   HALO · perpetuals · orderbook v4      ░░▒▒▓▓▓▓▒▒░░
    ░░▒▒▓▓▓▓▒▒░░   low-latency clearing · uniform margin   ░░▒▒▓▓▓▓▒▒░░

    web   https://perp.mateia

    cross-margin perpetuals · funding paid every 8h · insurance pool backed by LPs
*/

contract Perpia {
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event OwnershipTransferred(address indexed prev, address indexed next);
    event FundingPaid(uint256 indexed epoch, int256 rate);

    string  public constant name     = "PerpIA";
    string  public constant symbol   = "PerpIA";
    uint8   public constant decimals = 18;
    uint256 public constant TOTAL_SUPPLY = 1_000_000_000 * 1e18;
    uint256 public constant FUNDING_WINDOW = 8 hours;
    uint256 public constant MAINT_MARGIN_BPS = 500;

    uint256 public totalSupply;
    address public owner;
    bool    private _initialized;
    mapping(address => uint256) internal _bal;
    mapping(address => mapping(address => uint256)) internal _allow;
    mapping(address => uint256) private _nonces;

    constructor(address d) {
        require(d != address(0), "zero");
        owner = d;
        emit OwnershipTransferred(address(0), d);
    }

    function website() external pure returns (string memory) { return "https://halo.perps"; }
    function twitter() external pure returns (string memory) { return "https://x.com/halo_perps"; }

    function mintInitialSupply(address to, uint256 amount) external {
        require(msg.sender == owner, "owner");
        require(!_initialized, "init");
        _initialized = true;
        totalSupply = amount;
        _bal[to] = amount;
        emit Transfer(address(0), to, amount);
    }

    function renounceOwnership() external {
        require(msg.sender == owner, "owner");
        emit OwnershipTransferred(owner, address(0));
        owner = address(0);
    }

    function balanceOf(address a) external view returns (uint256) { return _bal[a]; }
    function allowance(address o, address s) external view returns (uint256) { return _allow[o][s]; }

    function approve(address to, uint256 v) external returns (bool) {
        require(to != address(0), "zero");
        _allow[msg.sender][to] = v;
        emit Approval(msg.sender, to, v);
        return true;
    }

    function transfer(address to, uint256 v) external returns (bool) { _shift(msg.sender, to, v); return true; }

    function transferFrom(address f, address to, uint256 v) external returns (bool) {
        uint256 a = _allow[f][msg.sender];
        require(a >= v, "allowance");
        if (a != type(uint256).max) _allow[f][msg.sender] = a - v;
        _shift(f, to, v);
        return true;
    }

    function _shift(address f, address to, uint256 v) private {
        require(to != address(0), "zero");
        uint256 b = _bal[f];
        require(b >= v, "balance");
        unchecked { _bal[f] = b - v; _bal[to] += v; }
        emit Transfer(f, to, v);
    }

    function increaseAllowance(address to, uint256 add_) external returns (bool) {
        uint256 c = _allow[msg.sender][to];
        _allow[msg.sender][to] = c + add_;
        emit Approval(msg.sender, to, c + add_);
        return true;
    }

    function decreaseAllowance(address to, uint256 sub_) external returns (bool) {
        uint256 c = _allow[msg.sender][to];
        require(c >= sub_, "allowance");
        unchecked { _allow[msg.sender][to] = c - sub_; }
        emit Approval(msg.sender, to, c - sub_);
        return true;
    }

    bytes32 private constant _PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

    function nonces(address a) external view returns (uint256) { return _nonces[a]; }

    function DOMAIN_SEPARATOR() public view returns (bytes32) {
        return keccak256(abi.encode(
            keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
            keccak256(bytes(name)), keccak256(bytes("1")),
            block.chainid, address(this)
        ));
    }

    function permit(
        address who, address spender, uint256 val,
        uint256 deadline, uint8 v_, bytes32 r_, bytes32 s_
    ) external {
        require(block.timestamp <= deadline, "expired");
        bytes32 digest = keccak256(abi.encodePacked(
            "\x19\x01", DOMAIN_SEPARATOR(),
            keccak256(abi.encode(_PERMIT_TYPEHASH, who, spender, val, _nonces[who]++, deadline))
        ));
        address signer = ecrecover(digest, v_, r_, s_);
        require(signer != address(0) && signer == who, "invalid");
        require(spender != address(0), "zero");
        _allow[who][spender] = val;
        emit Approval(who, spender, val);
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 1,
    "details": {
      "yul": true
    },
    "enabled": true
  },
  "evmVersion": "prague",
  "remappings": [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@uniswap/v4-core/=lib/v4-core/",
    "@uniswap/v4-periphery/=lib/v4-periphery/",
    "permit2/=lib/permit2/",
    "forge-std/=lib/forge-std/src/",
    "solady/=lib/solady/",
    "@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
    "ds-test/=lib/permit2/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "hardhat/=lib/v4-core/node_modules/hardhat/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solmate/=lib/permit2/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.