Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x75e6304d62385FD3590cb9c5AD5d7a729aE91dC7
Balance 0 ETH
Nonce 1
Code Size 10231 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

10231 bytes
0x60806040818152600480361015610014575f80fd5b5f92833560e01c90816301ffc9a714611297575080630e18b681146110bd5780631f899a2114611071578063213e2c531461101e578063248a9ca314610fd75780632f2ff15d14610eed5780633319225d14610ea157806334a1817514610e6457806336568abe14610da15780633f26091314610c9957806357ed7ae314610c2a57806361b0a56e14610b2557806375829def14610a475780637c18b7c1146109ee5780638da5cb5b1461099b57806391d148541461092c57806393684e0b146108ef5780639de9dc541461089a5780639e70846d146106c1578063a217fddf14610688578063a2c8e8a214610616578063aa084af6146105d9578063aa8ee18114610566578063c8cc5cd8146102435763d547741f14610133575f80fd5b3461023f57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f5780359161016c611354565b9161017561139e565b831561021857508284528360205273ffffffffffffffffffffffffffffffffffffffff81852092169182855260205260ff81852054166101b3578380f35b8284528360205280842082855260205283207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00815416905533917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b8480a45f80808380f35b90517f6317a0fa000000000000000000000000000000000000000000000000000000008152fd5b8280fd5b50903461023f576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105625761027d611d47565b7f30cc2fcab974a5a2540213c549fc919ac7160838938e5a3a04b40906b512611a808552848252828520338652825260ff8386205416156102cb57846102c38535611dfa565b600160035580f35b6102d894919294336117a8565b8551916102e483611676565b60428352848301936060368637835115610536576030855383519060019182101561050a5790607860218601536041915b818311610442575050506103e6576103e29386936103b4936103a56048946103709a519a857f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008d978801528251928391603789019101611614565b8401917f206973206d697373696e6720726f6c6520000000000000000000000000000000603784015251809386840190611614565b01036028810187520185611692565b519283927f08c379a000000000000000000000000000000000000000000000000000000000845283016116d3565b0390fd5b5050508060649351927f08c379a000000000000000000000000000000000000000000000000000000000845283015260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b909192600f811660108110156104de577f3031323334353637383961626364656600000000000000000000000000000000901a61047f858861176a565b53881c9280156104b2577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019190610315565b60248260118b7f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b60248360328c7f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b806032897f4e487b71000000000000000000000000000000000000000000000000000000006024945252fd5b806032887f4e487b71000000000000000000000000000000000000000000000000000000006024945252fd5b8380fd5b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d5576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000cad51a95ad91fe0912df7b5f5150f622a7fadafd168152f35b5080fd5b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d5576020906007549051908152f35b503461023f5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f5780359161065161139e565b612710831161066257505060075580f35b517f6a43f8d1000000000000000000000000000000000000000000000000000000008152fd5b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d55751908152602090f35b50903461023f5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f576106fa61137b565b9061070361139e565b73ffffffffffffffffffffffffffffffffffffffff808316801561087257600580547fffffffffffffffffffffffff000000000000000000000000000000000000000016909117905581517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523094810194855273ffffffffffffffffffffffffffffffffffffffff84166020868101919091527f000000000000000000000000c6694e05b750015f54ac646544a4a9d33cbe40869092169490929190839081906040015b0381875afa90811561086957508490610818575b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff915003610809578280f35b6108129161192c565b5f808280f35b506020813d8211610861575b8161083160209383611692565b81010312610562577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90516107dd565b3d9150610824565b513d86823e3d90fd5b8483517fe6c4247b000000000000000000000000000000000000000000000000000000008152fd5b5091346108ec57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126108ec575073ffffffffffffffffffffffffffffffffffffffff60209254169051908152f35b80fd5b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d5576020906006549051908152f35b503461023f57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f578160209360ff9261096a611354565b9035825281865273ffffffffffffffffffffffffffffffffffffffff83832091168252855220541690519015158152f35b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d55760209073ffffffffffffffffffffffffffffffffffffffff600154169051908152f35b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d557602090517f30cc2fcab974a5a2540213c549fc919ac7160838938e5a3a04b40906b512611a8152f35b503461023f5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f57610a7f61137b565b90610a8861139e565b73ffffffffffffffffffffffffffffffffffffffff80921692338414610aff575050817fffffffffffffffffffffffff00000000000000000000000000000000000000006002541617600255600154167fefdcbba819467e00b0262c12892dda980bac68580b72178e57a162368b8087668380a380f35b517f6317a0fa000000000000000000000000000000000000000000000000000000008152fd5b5050346105d55760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d557610b5e61137b565b6044359073ffffffffffffffffffffffffffffffffffffffff908183168303610c2657610c20610bf4936102c395610b94611d47565b610b9c61139e565b517fa9059cbb00000000000000000000000000000000000000000000000000000000602082015273ffffffffffffffffffffffffffffffffffffffff9091166024808301919091523560448201529384906064820190565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101855284611692565b16611ac2565b8480fd5b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d5576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c6694e05b750015f54ac646544a4a9d33cbe4086168152f35b50903461023f5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f57610cd261137b565b90610cdb61139e565b73ffffffffffffffffffffffffffffffffffffffff80831680156108725784547fffffffffffffffffffffffff00000000000000000000000000000000000000001617845581517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523094810194855273ffffffffffffffffffffffffffffffffffffffff84166020868101919091527f000000000000000000000000c6694e05b750015f54ac646544a4a9d33cbe40869092169490929190839081906040016107c9565b5091346108ec57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126108ec5750610dda611354565b50813515610aff5790602060849251917f08c379a00000000000000000000000000000000000000000000000000000000083528201526024808201527f52656e6f756e636520726f6c652069732064697361626c656420666f7220736160448201527f66657479000000000000000000000000000000000000000000000000000000006064820152fd5b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d5576020906008549051908152f35b503461023f5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f57803591610edc61139e565b612710831161066257505060065580f35b503461023f57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f57803591610f27611354565b91610f3061139e565b831561021857508284528360205273ffffffffffffffffffffffffffffffffffffffff81852092169182855260205260ff818520541615610f6f578380f35b82845283602052808420828552602052832060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8480a45f80808380f35b503461023f5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f57816020936001923581528085522001549051908152f35b5050346105d557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105d55760209073ffffffffffffffffffffffffffffffffffffffff600554169051908152f35b503461023f5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f578035916110ac61139e565b612710831161066257505060085580f35b503461023f57827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f5773ffffffffffffffffffffffffffffffffffffffff908160025416330361127057506001541633817ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec68580a3828052602090838252828420818552825260ff838520541661120c575b507fffffffffffffffffffffffff00000000000000000000000000000000000000003381600154161760015560025416600255828052828152818320338452815260ff8284205416156111a6578280f35b8280528281528183209033845252812060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790553333827f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a45f808280f35b83805283825282842081855282528284207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541690553390847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b8180a45f611155565b82517f058d9a1b000000000000000000000000000000000000000000000000000000008152fd5b9250503461023f5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261023f57357fffffffff00000000000000000000000000000000000000000000000000000000811680910361023f57602092507f7965db0b00000000000000000000000000000000000000000000000000000000811490811561132a575b5015158152f35b7f01ffc9a7000000000000000000000000000000000000000000000000000000009150145f611323565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361137757565b5f80fd5b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361137757565b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602090815260408083205490929060ff16156113df57505050565b6113e8336117a8565b835190826113f583611676565b604283528483019360603686378351156115e757603085538351906001918210156115e75790607860218601536041915b81831161151c575050506114c057610370938593611490936114816048946103e2995198857f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008b978801528251928391603789019101611614565b01036028810185520183611692565b519182917f08c379a0000000000000000000000000000000000000000000000000000000008352600483016116d3565b6064848651907f08c379a000000000000000000000000000000000000000000000000000000000825280600483015260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b909192600f811660108110156115ba577f3031323334353637383961626364656600000000000000000000000000000000901a611559858861176a565b5360041c92801561158d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019190611426565b6024827f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b807f4e487b7100000000000000000000000000000000000000000000000000000000602492526032600452fd5b5f5b8381106116255750505f910152565b8181015183820152602001611616565b67ffffffffffffffff811161164957604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6080810190811067ffffffffffffffff82111761164957604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761164957604052565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f604093602084526117168151809281602088015260208888019101611614565b0116010190565b8181029291811591840414171561173057565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b9190820180921161173057565b90815181101561177b570160200190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b604051906060820182811067ffffffffffffffff82111761164957604052602a825260208201604036823782511561177b5760309053815160019081101561177b57607860218401536029905b8082116118635750506118055790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b9091600f811660108110156118ff577f3031323334353637383961626364656600000000000000000000000000000000901a61189f848661176a565b5360041c9180156118d2577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01906117f5565b60245f7f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b60245f7f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff83811660248301529293926020929183816044818686165afa908115611ab7575f91611a8a575b50611a0657611a0493947f095ea7b300000000000000000000000000000000000000000000000000000000604051948501521660248301527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6044830152604482526119ff82611676565b611ac2565b565b608483604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152fd5b908482813d8311611ab0575b611aa08183611692565b810103126108ec5750515f611994565b503d611a96565b6040513d5f823e3d90fd5b73ffffffffffffffffffffffffffffffffffffffff16906040516040810167ffffffffffffffff9082811082821117611649576040526020938483527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858401525f808587829751910182855af1903d15611c78573d928311611c4b5790611b8893929160405192611b7b887fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160185611692565b83523d868885013e611c83565b805191821591848315611c27575b505050905015611ba35750565b608490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b9193818094500103126105d5578201519081151582036108ec5750805f8084611b96565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b90611b889392506060915b91929015611cfe5750815115611c97575090565b3b15611ca05790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b825190915015611d115750805190602001fd5b6103e2906040519182917f08c379a0000000000000000000000000000000000000000000000000000000008352600483016116d3565b600260035414611d58576002600355565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b8115611dc0570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b9190820391821161173057565b612710808210612797576004908154925f9373ffffffffffffffffffffffffffffffffffffffff8091161580809161278b575b6127625780612755575b6125e05780845416801515806125d4575b61242a5750807f000000000000000000000000c6694e05b750015f54ac646544a4a9d33cbe408616916040938451917f18160ddd000000000000000000000000000000000000000000000000000000009485845260209081858a81845afa9485156123c9578a956123fb575b508385106123d357875196875281878a81897f000000000000000000000000cad51a95ad91fe0912df7b5f5150f622a7fadafd165afa9687156123c9578a9761239a575b5083871061237257858954169488519583878c817f01e1d11400000000000000000000000000000000000000000000000000000000948582525afa968715612339578c97612343575b50838860055416918c8c518094819382525afa938415612339578c94612309575b50508486028681048614871517156122dd5790611f7e91611db6565b968483028381048614841517156122dd578591611f9a91611db6565b95109081806122d4575b6122ac57803b156122a85788517f06ddf8b900000000000000000000000000000000000000000000000000000000815230818c019081526020810186905290918c9183919082908490829060400103925af1801561229e57908b91612286575b5050808061227c575b61222557839015918261221b575b50506121b657816120b06120ab926120ab6120748461206c6120658261205d6120566120b69d9c61204e6006548b61171d565b048099611ded565b9e8861171d565b048096611ded565b988c61171d565b04809a611ded565b916120a5612090866120886007548761171d565b048095611ded565b9561209d6008548a61171d565b048098611ded565b9061175d565b61175d565b9561175d565b918061213e575b50816120cb575b5050505050565b6005541692833b15610c2657906024859283855196879485937fc80ef1100000000000000000000000000000000000000000000000000000000085528401525af19081156121355750612121575b8080806120c4565b61212b8291611635565b6108ec5780612119565b513d84823e3d90fd5b8185541690813b156121b257869160248392875194859384927fc80ef1100000000000000000000000000000000000000000000000000000000084528b8401525af180156121a857908691612194575b506120bd565b61219d90611635565b610c2657845f61218e565b84513d88823e3d90fd5b8680fd5b9350505083541692833b15610c2657906024859283855196879485937fc80ef1100000000000000000000000000000000000000000000000000000000085528401525af1908115612135575061220a575050565b6122148291611635565b6108ec5750565b109050825f61201b565b5050935050506005541692833b15610c2657906024859283855196879485937fc80ef1100000000000000000000000000000000000000000000000000000000085528401525af1908115612135575061220a575050565b508382101561200d565b61228f90611635565b61229a57895f612004565b8980fd5b89513d8d823e3d90fd5b8a80fd5b8989517fb02b23c0000000000000000000000000000000000000000000000000000000008152fd5b50848310611fa4565b60248c60118d7f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b9080929450813d8311612332575b6123218183611692565b810103126113775751915f80611f62565b503d612317565b8a513d8e823e3d90fd5b9096508381813d831161236b575b61235b8183611692565b810103126113775751955f611f41565b503d612351565b8888517f2439532f000000000000000000000000000000000000000000000000000000008152fd5b9096508181813d83116123c2575b6123b28183611692565b810103126113775751955f611ef8565b503d6123a8565b88513d8c823e3d90fd5b8888517fe14215b9000000000000000000000000000000000000000000000000000000008152fd5b9094508181813d8311612423575b6124138183611692565b810103126113775751935f611eb4565b503d612409565b928460206040958651928380927f01e1d1140000000000000000000000000000000000000000000000000000000082525afa9081156125ca578791612599575b501061257157807f000000000000000000000000c6694e05b750015f54ac646544a4a9d33cbe408616803b1561256d5785845180927f06ddf8b90000000000000000000000000000000000000000000000000000000082528183816124f589308d84016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03925af180156121a857908691612559575b505083541692833b15610c2657906024859283855196879485937fc80ef1100000000000000000000000000000000000000000000000000000000085528401525af1908115612135575061220a575050565b61256290611635565b610c2657845f612507565b8580fd5b5050517fb02b23c0000000000000000000000000000000000000000000000000000000008152fd5b90506020813d82116125c2575b816125b360209383611692565b8101031261137757515f61246a565b3d91506125a6565b85513d89823e3d90fd5b50816005541615611e48565b8060055416928460206040958651928380927f01e1d1140000000000000000000000000000000000000000000000000000000082525afa9081156125ca578791612724575b501061257157807f000000000000000000000000c6694e05b750015f54ac646544a4a9d33cbe408616803b1561256d5785845180927f06ddf8b90000000000000000000000000000000000000000000000000000000082528183816126b089308d84016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03925af180156121a857612711575b506005541692833b15610c2657906024859283855196879485937fc80ef1100000000000000000000000000000000000000000000000000000000085528401525af1908115612135575061220a575050565b61271d90959195611635565b935f6126bf565b90506020813d821161274d575b8161273e60209383611692565b810103126121b257515f612625565b3d9150612731565b5080600554161515611e37565b846040517fd311bc39000000000000000000000000000000000000000000000000000000008152fd5b50816005541615611e2d565b60046040517f88d2fae8000000000000000000000000000000000000000000000000000000008152fdfea2646970667358221220a85a7baf71a31697475135562ca38c07abed2e50aebbfc235cd5cd0dea8e20e264736f6c63430008140033

Verified Source Code Full Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: Yes (65536 runs)
YieldDistributor.sol 352 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IBTCD.sol";
import "./interfaces/IBTCDStaking.sol";
import "./interfaces/IFISCStaking.sol";
import "./StakingSingleAdminAccessControl.sol";

/// @title Yield Distributor
/// @notice Manages yield distribution between BTCD and FISC staking pools with configurable split rates
/// @dev Implements a dual-token staking yield system that distributes yield based on stakeholder composition
///
/// YIELD DISTRIBUTION MECHANISM:
///   The contract distributes yield across BTCD and FISC staking contracts using a three-stage split system:
///
/// STAGE 1 - Primary Split:
///   Incoming BTCD yield is split between BTCD and FISC based on BTCDTakeRate.
///   - BTCDTakeRate % of yield goes to BTCD (configurable, base = 100%)
///   - Remaining % goes to FISC (100% - BTCDTakeRate)
///
/// STAGE 2 - Staking Ratio Split:
///   Each token's allocation is further split between staked and unstaked holders based on staking ratios.
///   - Staked holders receive: allocation * (stakedAmount / totalSupply)
///   - Unstaked holders receive: allocation * (1 - stakedAmount / totalSupply)
///
/// STAGE 3 - Cross-Pool Redistribution:
///   Unstaked portions can be redirected to the other staking pool:
///   - FISCUnstakedToBTCDStakersRate % of FISC's unstaked portion → BTCD stakers
///   - BTCDUnstakedToFISCStakersRate % of BTCD's unstaked portion → FISC stakers
///   - Remaining unstaked portions go to their respective staking pools
///
/// VALIDATION:
///   - Minimum yield amount required (MIN_AMOUNT = 10,000) to prevent dust distributions
///   - Both BTCD and FISC must have total supply > MIN_AMOUNT
///   - At least one staking pool must have active stakers (stakedRatio > 0)
///
/// ROLE-BASED ACCESS CONTROL:
///
/// DEFAULT_ADMIN_ROLE:
///   - setBTCDTakeRate(uint256): Configure percentage of yield allocated to BTCD (0-10000)
///   - setFISCUnstakedToBTCDStakersRate(uint256): Configure FISC unstaked redirect rate
///   - setBTCDUnstakedToFISCStakersRate(uint256): Configure BTCD unstaked redirect rate
///   - recoverTokens(address, uint256, address): Rescue accidentally sent tokens
///   - grantRole(bytes32, address): Assign roles to addresses
///   - revokeRole(bytes32, address): Remove roles from addresses
///   - transferOwnership(address): Initiate two-step ownership transfer
///
/// YIELD_DISTRIBUTOR_ROLE:
///   - distributeYield(uint256): Distribute yield across staking pools

contract YieldDistributor is StakingSingleAdminAccessControl, ReentrancyGuard {
    using SafeERC20 for IERC20;
    /* --------------- CONSTANTS --------------- */

    /// @notice The role which enables yield distribution
    bytes32 public constant YIELD_DISTRIBUTOR_ROLE =
        keccak256("YIELD_DISTRIBUTOR_ROLE");

    /// @notice Scalar for rate calculations (10,000 = 100%)
    uint256 private constant SCALAR = 100_00;

    /// @notice Minimum yield amount to prevent dust distributions
    uint256 private constant MIN_AMOUNT = SCALAR;

    /* --------------- ERRORS --------------- */

    /// @notice Rate exceeds maximum allowed (SCALAR = 10,000)
    error InvalidRate();

    /// @notice BTCD total supply is below minimum required
    error NoBTCDSupply();

    /// @notice FISC total supply is below minimum required
    error NoFISCSupply();

    /// @notice Neither BTCD nor FISC has sufficient staked amounts
    error NotEnoughStakers();

    /// @notice Yield amount is below minimum threshold (MIN_AMOUNT)
    error YieldBelowMinAllowed();

    /// @notice Invalid address provided (zero address)
    error InvalidAddress();

    /// @notice Contract not properly configured for yield distribution
    error NotConfigured();

    /* --------------- STATE VARIABLES --------------- */

    /// @notice BTCD token contract
    IBTCD public immutable BTCD;

    /// @notice FISC token contract
    IERC20 public immutable FISC;

    /// @notice BTCD staking contract
    IBTCDStaking public BTCDStaking;

    /// @notice FISC staking contract
    IFISCStaking public FISCStaking;

    /// @notice Percentage of yield allocated to BTCD in stage 1 split (basis points, 0-10000)
    /// @dev 10000 = 100%, yield goes to BTCD; 5000 = 50/50 split between BTCD and FISC
    uint256 public BTCDTakeRate;

    /// @notice Percentage of FISC's unstaked yield redirected to BTCD stakers (basis points, 0-10000)
    /// @dev Applied in stage 3 cross-pool redistribution
    uint256 public FISCUnstakedToBTCDStakersRate;

    /// @notice Percentage of BTCD's unstaked yield redirected to FISC stakers (basis points, 0-10000)
    /// @dev Applied in stage 3 cross-pool redistribution
    uint256 public BTCDUnstakedToFISCStakersRate;

    /* --------------- CONSTRUCTOR --------------- */

    /// @notice Initializes the yield distributor with token and staking contract references
    /// @param _owner Address to grant DEFAULT_ADMIN_ROLE
    /// @param _BTCD Address of BTCD token contract
    /// @param _FISC Address of FISC token contract
    constructor(address _owner, address _BTCD, address _FISC) {
        if (
            _owner == address(0) || _BTCD == address(0) || _FISC == address(0)
        ) {
            revert InvalidAddress();
        }
        _grantRole(DEFAULT_ADMIN_ROLE, _owner);
        BTCD = IBTCD(_BTCD);
        FISC = IERC20(_FISC);
    }

    ////////////////////////////////////////////////////////////
    //// PRIVILEGED ROLE ACTIONS ///////////////////////////////
    ////////////////////////////////////////////////////////////

    /* --------------- DEFAULT_ADMIN_ROLE ------------- */

    /// @notice Sets the BTCD staking contract address
    /// @param _BTCDStaking Address of the BTCD staking contract
    function setBTCDStaking(
        address _BTCDStaking
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (_BTCDStaking == address(0)) {
            revert InvalidAddress();
        }
        BTCDStaking = IBTCDStaking(_BTCDStaking);
        // CRITICAL: BTCD staking contract receives BTCD as rewards
        // Only approve if not already approved to max to save gas
        if (BTCD.allowance(address(this), _BTCDStaking) != type(uint256).max) {
            IERC20(address(BTCD)).safeApprove(_BTCDStaking, type(uint256).max);
        }
    }

    /// @notice Sets the FISC staking contract address
    /// @param _FISCStaking Address of the FISC staking contract
    function setFISCStaking(
        address _FISCStaking
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (_FISCStaking == address(0)) {
            revert InvalidAddress();
        }
        FISCStaking = IFISCStaking(_FISCStaking);
        // CRITICAL: FISC staking contract receives BTCD as rewards, never FISC
        // Only approve if not already approved to max to save gas
        if (BTCD.allowance(address(this), _FISCStaking) != type(uint256).max) {
            IERC20(address(BTCD)).safeApprove(_FISCStaking, type(uint256).max);
        }
    }

    /// @notice Sets the percentage of yield allocated to BTCD stakers in stage 1 split
    /// @param _rate Basis points (0-10000), where 10000 = 100% to BTCD, 5000 = 50/50 split
    function setBTCDTakeRate(
        uint256 _rate
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (_rate > SCALAR) {
            revert InvalidRate();
        }
        BTCDTakeRate = _rate;
    }

    /// @notice Sets the percentage of FISC's unstaked yield redirected to BTCD stakers
    /// @param _rate Basis points (0-10000), where 10000 = 100% redirected, 0 = none redirected
    function setFISCUnstakedToBTCDStakersRate(
        uint256 _rate
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (_rate > SCALAR) {
            revert InvalidRate();
        }
        FISCUnstakedToBTCDStakersRate = _rate;
    }

    /// @notice Sets the percentage of BTCD's unstaked yield redirected to FISC stakers
    /// @param _rate Basis points (0-10000), where 10000 = 100% redirected, 0 = none redirected
    function setBTCDUnstakedToFISCStakersRate(
        uint256 _rate
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (_rate > SCALAR) {
            revert InvalidRate();
        }
        BTCDUnstakedToFISCStakersRate = _rate;
    }

    /// @notice Rescues accidentally sent tokens from the distributor
    /// @param _token The token contract to rescue from
    /// @param _amount The amount to rescue
    /// @param _to The recipient address
    function recoverTokens(
        address _token,
        uint256 _amount,
        address _to
    ) external nonReentrant onlyRole(DEFAULT_ADMIN_ROLE) {
        IERC20 _erc20token = IERC20(_token);
        _erc20token.safeTransfer(_to, _amount);
    }

    ////////////////////////////////////////////////////////////
    //// PUBLIC YIELD DISTRIBUTION /////////////////////////////
    ////////////////////////////////////////////////////////////

    /* --------------- YIELD_DISTRIBUTOR_ROLE ------------- */

    /// @notice Distributes yield across BTCD and FISC staking pools based on configured rates
    /// @dev Three-stage split process:
    ///      1. Initial split between BTCD and FISC based on BTCDTakeRate
    ///      2. Split each token's allocation between staked and unstaked holders
    ///      3. Redirect unstaked portions based on cross-pool rates
    /// @param _amountBTCD Total BTCD yield to distribute
    function distributeYield(
        uint256 _amountBTCD
    ) external nonReentrant onlyRole(YIELD_DISTRIBUTOR_ROLE) {
        // Validate minimum yield amount
        if (_amountBTCD < MIN_AMOUNT) {
            revert YieldBelowMinAllowed();
        }

        if (
            address(BTCDStaking) == address(0) &&
            address(FISCStaking) == address(0)
        ) {
            revert NotConfigured();
        }
        if (
            address(BTCDStaking) == address(0) &&
            address(FISCStaking) != address(0)
        ) {
            if (FISCStaking.totalAssets() < MIN_AMOUNT) {
                revert NotEnoughStakers();
            }
            BTCD.mintYield(address(this), _amountBTCD);
            FISCStaking.transferInRewards(_amountBTCD);
            return;
        }
        if (
            address(BTCDStaking) != address(0) &&
            address(FISCStaking) == address(0)
        ) {
            if (BTCDStaking.totalAssets() < MIN_AMOUNT) {
                revert NotEnoughStakers();
            }
            BTCD.mintYield(address(this), _amountBTCD);
            BTCDStaking.transferInRewards(_amountBTCD);
            return;
        }
        // Implies (address(BTCDStaking) != address(0) && address(FISCStaking) != address(0))
        // below this line - go to two staking split logic

        // Get total supplies and revert if insufficient supply
        uint256 totalSupplyBTCD = BTCD.totalSupply();
        if (totalSupplyBTCD < MIN_AMOUNT) {
            revert NoBTCDSupply();
        }
        uint256 totalSupplyFISC = FISC.totalSupply();
        if (totalSupplyFISC < MIN_AMOUNT) {
            revert NoFISCSupply();
        }
        // since we can only do distribute yield when vesting is over
        // totalAssets will be equals to btcd or fisc balance of staking contract
        uint256 stakedBTCD = BTCDStaking.totalAssets();
        uint256 stakedFISC = FISCStaking.totalAssets();

        // Calculate staking ratios and split staked vs unstaked
        uint256 BTCDStakingRatio = ((stakedBTCD * SCALAR) / totalSupplyBTCD);
        uint256 FISCStakingRatio = ((stakedFISC * SCALAR) / totalSupplyFISC);

        // Validate that at least one pool has stakers
        if (stakedBTCD < MIN_AMOUNT && stakedFISC < MIN_AMOUNT) {
            revert NotEnoughStakers();
        }

        // Mint the yield tokens to this contract
        BTCD.mintYield(address(this), _amountBTCD);

        // Edge case: Only FISC stakers present
        if (stakedBTCD < MIN_AMOUNT && stakedFISC >= MIN_AMOUNT) {
            // distribute to FISC stakers only
            FISCStaking.transferInRewards(_amountBTCD);
            return;
        }

        // Edge case: Only BTCD stakers present
        if (stakedBTCD >= MIN_AMOUNT && stakedFISC < MIN_AMOUNT) {
            // distribute to BTCD stakers only
            BTCDStaking.transferInRewards(_amountBTCD);
            return;
        }

        // Both pools have stakers: Execute full three-stage split

        // STAGE 1: Split between BTCD and FISC based on BTCDTakeRate
        uint256 BTCDYieldFirstSplit = (_amountBTCD * BTCDTakeRate) / SCALAR;
        uint256 FISCYieldFirstSplit = _amountBTCD - BTCDYieldFirstSplit;

        // STAGE 2: Split each token's allocation between staked and unstaked holders
        uint256 BTCDStakedYield = (BTCDYieldFirstSplit * BTCDStakingRatio) /
            SCALAR;
        uint256 BTCDUnstakedYield = BTCDYieldFirstSplit - BTCDStakedYield;

        uint256 FISCStakedYield = (FISCYieldFirstSplit * FISCStakingRatio) /
            SCALAR;
        uint256 FISCUnstakedYield = FISCYieldFirstSplit - FISCStakedYield;

        // STAGE 3: Apply cross-pool redistribution rates
        uint256 FISCUnstakedToBTCDStakers = (FISCUnstakedYield *
            FISCUnstakedToBTCDStakersRate) / SCALAR;
        uint256 FISCUnstakedToFISCStakers = FISCUnstakedYield -
            FISCUnstakedToBTCDStakers;

        uint256 BTCDUnstakedToFISCStakers = (BTCDUnstakedYield *
            BTCDUnstakedToFISCStakersRate) / SCALAR;
        uint256 BTCDUnstakedToBTCDStakers = BTCDUnstakedYield -
            BTCDUnstakedToFISCStakers;

        // Aggregate yields for each staking pool
        uint256 yieldToBTCDStakers = BTCDStakedYield +
            BTCDUnstakedToBTCDStakers +
            FISCUnstakedToBTCDStakers;

        uint256 yieldToFISCStakers = FISCStakedYield +
            FISCUnstakedToFISCStakers +
            BTCDUnstakedToFISCStakers;

        // Distribute yields to the respective staking contracts
        if (yieldToBTCDStakers > 0) {
            BTCDStaking.transferInRewards(yieldToBTCDStakers);
        }
        if (yieldToFISCStakers > 0) {
            FISCStaking.transferInRewards(yieldToFISCStakers);
        }
    }
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @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;

    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
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // 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;
    }
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}
IBTCD.sol 22 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";

interface IBTCD is IERC20, IERC20Permit, IERC20Metadata {
    function mint(address _to, uint256 _amount) external;

    function burn(uint256 _amount) external;

    function burnFrom(address account, uint256 amount) external;

    function grantRole(bytes32 role, address account) external;

    function setMinter(address newMinter) external;

    function setYieldMinter(address newYieldMinter) external;

    function mintYield(address to, uint256 amount) external;
}
IBTCDStaking.sol 63 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import "./IBaseStaking.sol";

interface IBTCDStaking {
    // Events //
    /// @notice Event emitted when the rewards are received
    event RewardsReceived(uint256 amount);
    /// @notice Event emitted when the balance from an FULL_RESTRICTED_STAKER_ROLE user are redistributed
    event LockedAmountRedistributed(
        address indexed from,
        address indexed to,
        uint256 amount
    );
    event LockedAmountSiloRedistributed(
        address indexed from,
        address indexed to,
        uint256 amount
    );
    // @notice Event emitted when cooldown duration updates
    event CooldownDurationUpdated(uint24 previousDuration, uint24 newDuration);
    /// @notice Event emitted when vesting duration updates
    event VestingDurationUpdated(uint24 previousDuration, uint24 newDuration);

    // Errors //
    /// @notice Error emitted shares or assets equal zero.
    error InvalidAmount();
    /// @notice Error emitted when owner attempts to rescue USDe tokens.
    error InvalidToken();
    /// @notice Error emitted when a small non-zero share amount remains, which risks donations attack
    error MinSharesViolation();
    /// @notice Error emitted when owner is not allowed to perform an operation
    error OperationNotAllowed();
    /// @notice Error emitted when there is still unvested amount
    error StillVesting();
    /// @notice Error emitted when owner or blacklist manager attempts to blacklist owner
    error CantBlacklistOwner();
    /// @notice Error emitted when the shares amount to redeem is greater than the shares balance of the owner
    error ExcessiveRedeemAmount();
    /// @notice Error emitted when the shares amount to withdraw is greater than the shares balance of the owner
    error ExcessiveWithdrawAmount();
    /// @notice Error emitted when cooldown value is invalid
    error InvalidCooldown();
    /// @notice Error emitted when vesting period is invalid
    error InvalidVestingPeriod();

    function cooldownAssets(uint256 assets) external returns (uint256 shares);

    function cooldownShares(uint256 shares) external returns (uint256 assets);

    function unstake(address receiver) external;

    function setCooldownDuration(uint24 duration) external;

    function transferInRewards(uint256 amount) external;

    function rescueTokens(address token, uint256 amount, address to) external;

    function getUnvestedAmount() external view returns (uint256);

    function totalAssets() external view returns (uint256);
}
IFISCStaking.sol 74 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "./IBaseStaking.sol";

interface IFISCStaking {
    // Events //
    /// @notice Event emitted when the rewards are received
    event RewardsReceived(uint256 amount);
    /// @notice Event emitted when the balance from an FULL_RESTRICTED_STAKER_ROLE user are redistributed
    event LockedAmountRedistributed(
        address indexed from,
        address indexed to,
        uint256 amount
    );
    // @notice Event emitted when cooldown duration updates
    event CooldownDurationUpdated(uint24 previousDuration, uint24 newDuration);
    /// @notice Event emitted when vesting duration updates
    event VestingDurationUpdated(uint24 previousDuration, uint24 newDuration);
    /// @notice Event emitted when a user claims BTCD rewards
    event RewardsClaimed(
        address indexed user,
        address indexed receiver,
        uint256 amount
    );

    // Errors //
    /// @notice Error emitted shares or assets equal zero.
    error InvalidAmount();
    /// @notice Error emitted when owner attempts to rescue USDe tokens.
    error InvalidToken();
    /// @notice Error emitted when a small non-zero share amount remains, which risks donations attack
    error MinSharesViolation();
    /// @notice Error emitted when owner is not allowed to perform an operation
    error OperationNotAllowed();
    /// @notice Error emitted when there is still unvested amount
    error StillVesting();
    /// @notice Error emitted when owner or blacklist manager attempts to blacklist owner
    error CantBlacklistOwner();
    /// @notice Error emitted when the shares amount to redeem is greater than the shares balance of the owner
    error ExcessiveRedeemAmount();
    /// @notice Error emitted when the shares amount to withdraw is greater than the shares balance of the owner
    error ExcessiveWithdrawAmount();
    /// @notice Error emitted when cooldown value is invalid
    error InvalidCooldown();
    /// @notice Error emitted when vesting period is invalid
    error InvalidVestingPeriod();
    /// @notice Error emitted when reward rate would be zero
    error InvalidRewardRate();

    function cooldownAssets(uint256 assets) external returns (uint256 shares);

    function cooldownShares(uint256 shares) external returns (uint256 assets);

    function unstake(address receiver) external;

    function setCooldownDuration(uint24 duration) external;

    function transferInRewards(uint256 amount) external;

    function rescueTokens(address token, uint256 amount, address to) external;

    function getUnvestedAmount() external view returns (uint256);

    function totalAssets() external view returns (uint256);

    function claimRewards(address receiver) external returns (uint256 amount);

    function getClaimableRewards(address account) external view returns (uint256);

    function rewardToken() external view returns (IERC20);
}
StakingSingleAdminAccessControl.sol 95 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/interfaces/IERC5313.sol";
import "./interfaces/ISingleAdminAccessControl.sol";

/**
 * @title SingleAdminAccessControl
 * @notice SingleAdminAccessControl is a contract that provides a single admin role
 * @notice This contract is a simplified alternative to OpenZeppelin's AccessControlDefaultAdminRules
 */
abstract contract StakingSingleAdminAccessControl is
    IERC5313,
    ISingleAdminAccessControl,
    AccessControl
{
    address private _currentDefaultAdmin;
    address private _pendingDefaultAdmin;

    modifier notAdmin(bytes32 role) {
        if (role == DEFAULT_ADMIN_ROLE) revert InvalidAdminChange();
        _;
    }

    /// @notice Transfer the admin role to a new address
    /// @notice This can ONLY be executed by the current admin
    /// @param newAdmin address
    function transferAdmin(
        address newAdmin
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        if (newAdmin == msg.sender) revert InvalidAdminChange();
        _pendingDefaultAdmin = newAdmin;
        emit AdminTransferRequested(_currentDefaultAdmin, newAdmin);
    }

    function acceptAdmin() external {
        if (msg.sender != _pendingDefaultAdmin) revert NotPendingAdmin();
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /// @notice grant a role
    /// @notice can only be executed by the current single admin
    /// @notice admin role cannot be granted externally
    /// @param role bytes32
    /// @param account address
    function grantRole(
        bytes32 role,
        address account
    ) public override onlyRole(DEFAULT_ADMIN_ROLE) notAdmin(role) {
        _grantRole(role, account);
    }

    /// @notice revoke a role
    /// @notice can only be executed by the current admin
    /// @notice admin role cannot be revoked
    /// @param role bytes32
    /// @param account address
    function revokeRole(
        bytes32 role,
        address account
    ) public override onlyRole(DEFAULT_ADMIN_ROLE) notAdmin(role) {
        _revokeRole(role, account);
    }

    /// @notice renounce the role of msg.sender
    /// @notice admin role cannot be renounced
    /// @param role bytes32
    function renounceRole(
        bytes32 role,
        address
    ) public virtual override notAdmin(role) {
        revert("Renounce role is disabled for safety");
    }

    /**
     * @dev See {IERC5313-owner}.
     */
    function owner() public view virtual returns (address) {
        return _currentDefaultAdmin;
    }

    /**
     * @notice no way to change admin without removing old admin first
     */
    function _grantRole(bytes32 role, address account) internal override {
        if (role == DEFAULT_ADMIN_ROLE) {
            emit AdminTransferred(_currentDefaultAdmin, account);
            _revokeRole(DEFAULT_ADMIN_ROLE, _currentDefaultAdmin);
            _currentDefaultAdmin = account;
            delete _pendingDefaultAdmin;
        }
        super._grantRole(role, account);
    }
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
IBaseStaking.sol 7 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

struct UserCooldown {
    uint104 cooldownEnd;
    uint152 underlyingAmount;
}
AccessControl.sol 248 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
IERC5313.sol 18 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5313.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface for the Light Contract Ownership Standard.
 *
 * A standardized minimal interface required to identify an account that controls a contract
 *
 * _Available since v4.9._
 */
interface IERC5313 {
    /**
     * @dev Gets the address of the owner.
     */
    function owner() external view returns (address);
}
ISingleAdminAccessControl.sol 11 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

interface ISingleAdminAccessControl {
    error InvalidAdminChange();
    error NotPendingAdmin();
    error RoleConflict();

    event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);
    event AdminTransferRequested(address indexed oldAdmin, address indexed newAdmin);
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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;
    }
}
Strings.sol 85 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
Math.sol 339 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}
SignedMath.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Read Contract

BTCD 0x57ed7ae3 → address
BTCDStaking 0x9de9dc54 → address
BTCDTakeRate 0x93684e0b → uint256
BTCDUnstakedToFISCStakersRate 0x34a18175 → uint256
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
FISC 0xaa8ee181 → address
FISCStaking 0x213e2c53 → address
FISCUnstakedToBTCDStakersRate 0xaa084af6 → uint256
YIELD_DISTRIBUTOR_ROLE 0x7c18b7c1 → bytes32
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
owner 0x8da5cb5b → address
supportsInterface 0x01ffc9a7 → bool

Write Contract 12 functions

These functions modify contract state and require a wallet transaction to execute.

acceptAdmin 0x0e18b681
No parameters
distributeYield 0xc8cc5cd8
uint256 _amountBTCD
grantRole 0x2f2ff15d
bytes32 role
address account
recoverTokens 0x61b0a56e
address _token
uint256 _amount
address _to
renounceRole 0x36568abe
bytes32 role
address
revokeRole 0xd547741f
bytes32 role
address account
setBTCDStaking 0x3f260913
address _BTCDStaking
setBTCDTakeRate 0x3319225d
uint256 _rate
setBTCDUnstakedToFISCStakersRate 0x1f899a21
uint256 _rate
setFISCStaking 0x9e70846d
address _FISCStaking
setFISCUnstakedToBTCDStakersRate 0xa2c8e8a2
uint256 _rate
transferAdmin 0x75829def
address newAdmin

Recent Transactions

No transactions found for this address