diff --git a/core/deployments/sepolia/.chainId b/core/deployments/sepolia/.chainId new file mode 100644 index 000000000..bd8d1cd44 --- /dev/null +++ b/core/deployments/sepolia/.chainId @@ -0,0 +1 @@ +11155111 \ No newline at end of file diff --git a/core/deployments/sepolia/AcreBitcoinDepositor.json b/core/deployments/sepolia/AcreBitcoinDepositor.json new file mode 100644 index 000000000..c09f41dfd --- /dev/null +++ b/core/deployments/sepolia/AcreBitcoinDepositor.json @@ -0,0 +1,1337 @@ +{ + "address": "0x37E34EbC743FFAf96b56b3f62854bb7E733a4B50", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "bridge", + "type": "address" + }, + { + "internalType": "address", + "name": "tbtcVault", + "type": "address" + }, + { + "internalType": "address", + "name": "_tbtcToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_stbtc", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "BridgingCompletionAlreadyNotified", + "type": "error" + }, + { + "inputs": [], + "name": "BridgingFinalizationAlreadyCalled", + "type": "error" + }, + { + "inputs": [], + "name": "BridgingNotCompleted", + "type": "error" + }, + { + "inputs": [], + "name": "CallerNotStaker", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositorFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bridgedAmount", + "type": "uint256" + } + ], + "name": "DepositorFeeExceedsBridgedAmount", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountToStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "currentBalance", + "type": "uint256" + } + ], + "name": "InsufficientTbtcBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "bits", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "SafeCastOverflowedUintDowncast", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [], + "name": "StakeRequestNotQueued", + "type": "error" + }, + { + "inputs": [], + "name": "StakerIsZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "StbtcZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "TbtcTokenZeroAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "enum AcreBitcoinDepositor.StakeRequestState", + "name": "currentState", + "type": "uint8" + }, + { + "internalType": "enum AcreBitcoinDepositor.StakeRequestState", + "name": "expectedState", + "type": "uint8" + } + ], + "name": "UnexpectedStakeRequestState", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint16", + "name": "referral", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bridgedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "depositorFee", + "type": "uint256" + } + ], + "name": "BridgingCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tbtcAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "finalizedAt", + "type": "uint32" + } + ], + "name": "DepositFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "initializedAt", + "type": "uint32" + } + ], + "name": "DepositInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "depositorFeeDivisor", + "type": "uint64" + } + ], + "name": "DepositorFeeDivisorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountToStake", + "type": "uint256" + } + ], + "name": "StakeRequestCancelledFromQueue", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + } + ], + "name": "StakeRequestFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + } + ], + "name": "StakeRequestFinalizedFromQueue", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "staker", + "type": "address" + } + ], + "name": "StakeRequestInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "queuedAmount", + "type": "uint256" + } + ], + "name": "StakeRequestQueued", + "type": "event" + }, + { + "inputs": [], + "name": "SATOSHI_MULTIPLIER", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "bridge", + "outputs": [ + { + "internalType": "contract IBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "cancelQueuedStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "extraData", + "type": "bytes32" + } + ], + "name": "decodeExtraData", + "outputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "uint16", + "name": "referral", + "type": "uint16" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "depositorFeeDivisor", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "uint16", + "name": "referral", + "type": "uint16" + } + ], + "name": "encodeExtraData", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "finalizeQueuedStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "finalizeStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct IBridgeTypes.BitcoinTxInfo", + "name": "fundingTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + }, + { + "internalType": "bytes8", + "name": "blindingFactor", + "type": "bytes8" + }, + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "bytes20", + "name": "refundPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "bytes4", + "name": "refundLocktime", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "internalType": "struct IBridgeTypes.DepositRevealInfo", + "name": "reveal", + "type": "tuple" + }, + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "uint16", + "name": "referral", + "type": "uint16" + } + ], + "name": "initializeStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "queueStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "stakeRequests", + "outputs": [ + { + "internalType": "enum AcreBitcoinDepositor.StakeRequestState", + "name": "state", + "type": "uint8" + }, + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "uint88", + "name": "queuedAmount", + "type": "uint88" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stbtc", + "outputs": [ + { + "internalType": "contract stBTC", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tbtcToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tbtcVault", + "outputs": [ + { + "internalType": "contract ITBTCVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "newDepositorFeeDivisor", + "type": "uint64" + } + ], + "name": "updateDepositorFeeDivisor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x6f7d1a83200314126aa36f4aaac2450d2a0c1ffd77a53327d35bf6c0331d4bec", + "receipt": { + "to": null, + "from": "0x2d154A5c7cE9939274b89bbCe9f5B069E57b09A8", + "contractAddress": "0x37E34EbC743FFAf96b56b3f62854bb7E733a4B50", + "transactionIndex": 157, + "gasUsed": "2013605", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000002000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000001000000000000000000000000000000400000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000012000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x13e2258b7e01b5bb7b0c5d438c0e623c89056660447e4bff2cd8a812392a6df5", + "transactionHash": "0x6f7d1a83200314126aa36f4aaac2450d2a0c1ffd77a53327d35bf6c0331d4bec", + "logs": [ + { + "transactionIndex": 157, + "blockNumber": 5387080, + "transactionHash": "0x6f7d1a83200314126aa36f4aaac2450d2a0c1ffd77a53327d35bf6c0331d4bec", + "address": "0x37E34EbC743FFAf96b56b3f62854bb7E733a4B50", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000002d154a5c7ce9939274b89bbce9f5b069e57b09a8" + ], + "data": "0x", + "logIndex": 237, + "blockHash": "0x13e2258b7e01b5bb7b0c5d438c0e623c89056660447e4bff2cd8a812392a6df5" + } + ], + "blockNumber": 5387080, + "cumulativeGasUsed": "27025873", + "status": 1, + "byzantium": true + }, + "args": [ + "0x9b1a7fE5a16A15F2f9475C5B231750598b113403", + "0xB5679dE944A79732A75CE556191DF11F489448d5", + "0x517f2982701695D4E52f1ECFBEf3ba31Df470161", + "0xF99139f09164B092bD9e8558984Becfb0d2eCb87" + ], + "numDeployments": 1, + "solcInputHash": "49f0432287e96a47d66ba17ae7bf5d96", + "metadata": "{\"compiler\":{\"version\":\"0.8.21+commit.d9974bed\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tbtcVault\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tbtcToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stbtc\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BridgingCompletionAlreadyNotified\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BridgingFinalizationAlreadyCalled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BridgingNotCompleted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CallerNotStaker\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositorFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bridgedAmount\",\"type\":\"uint256\"}],\"name\":\"DepositorFeeExceedsBridgedAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"}],\"name\":\"InsufficientTbtcBalance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"bits\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"SafeCastOverflowedUintDowncast\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"SafeERC20FailedOperation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeRequestNotQueued\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakerIsZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StbtcZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TbtcTokenZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum AcreBitcoinDepositor.StakeRequestState\",\"name\":\"currentState\",\"type\":\"uint8\"},{\"internalType\":\"enum AcreBitcoinDepositor.StakeRequestState\",\"name\":\"expectedState\",\"type\":\"uint8\"}],\"name\":\"UnexpectedStakeRequestState\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bridgedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"depositorFee\",\"type\":\"uint256\"}],\"name\":\"BridgingCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tbtcAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"finalizedAt\",\"type\":\"uint32\"}],\"name\":\"DepositFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"initializedAt\",\"type\":\"uint32\"}],\"name\":\"DepositInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositorFeeDivisor\",\"type\":\"uint64\"}],\"name\":\"DepositorFeeDivisorUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"}],\"name\":\"StakeRequestCancelledFromQueue\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"stakedAmount\",\"type\":\"uint256\"}],\"name\":\"StakeRequestFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"stakedAmount\",\"type\":\"uint256\"}],\"name\":\"StakeRequestFinalizedFromQueue\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"StakeRequestInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"queuedAmount\",\"type\":\"uint256\"}],\"name\":\"StakeRequestQueued\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"SATOSHI_MULTIPLIER\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contract IBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"cancelQueuedStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"extraData\",\"type\":\"bytes32\"}],\"name\":\"decodeExtraData\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositorFeeDivisor\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"name\":\"encodeExtraData\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"finalizeQueuedStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"finalizeStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"struct IBridgeTypes.BitcoinTxInfo\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"struct IBridgeTypes.DepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"name\":\"initializeStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"queueStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"stakeRequests\",\"outputs\":[{\"internalType\":\"enum AcreBitcoinDepositor.StakeRequestState\",\"name\":\"state\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint88\",\"name\":\"queuedAmount\",\"type\":\"uint88\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stbtc\",\"outputs\":[{\"internalType\":\"contract stBTC\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcVault\",\"outputs\":[{\"internalType\":\"contract ITBTCVault\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"newDepositorFeeDivisor\",\"type\":\"uint64\"}],\"name\":\"updateDepositorFeeDivisor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AddressEmptyCode(address)\":[{\"details\":\"There's no code at `target` (it is not a contract).\"}],\"AddressInsufficientBalance(address)\":[{\"details\":\"The ETH balance of the account is not enough to perform the operation.\"}],\"BridgingCompletionAlreadyNotified()\":[{\"details\":\"Attempted to notify a bridging completion, while it was already notified.\"}],\"BridgingFinalizationAlreadyCalled()\":[{\"details\":\"Attempted to call bridging finalization for a stake request for which the function was already called.\"}],\"BridgingNotCompleted()\":[{\"details\":\"Attempted to finalize a stake request, while bridging completion has not been notified yet.\"}],\"CallerNotStaker()\":[{\"details\":\"Attempted to call function by an account that is not the staker.\"}],\"DepositorFeeExceedsBridgedAmount(uint256,uint256)\":[{\"details\":\"Calculated depositor fee exceeds the amount of minted tBTC tokens.\"}],\"FailedInnerCall()\":[{\"details\":\"A call to an address target failed. The target may have reverted.\"}],\"InsufficientTbtcBalance(uint256,uint256)\":[{\"details\":\"Attempted to finalize bridging with depositor's contract tBTC balance lower than the calculated bridged tBTC amount. This error means that Governance should top-up the tBTC reserve for bridging fees approximation.\"}],\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}],\"SafeCastOverflowedUintDowncast(uint8,uint256)\":[{\"details\":\"Value doesn't fit in an uint of `bits` size.\"}],\"SafeERC20FailedOperation(address)\":[{\"details\":\"An operation with an ERC20 token failed.\"}],\"StakeRequestNotQueued()\":[{\"details\":\"Attempted to finalize or cancel a stake request that was not added to the queue, or was already finalized or cancelled.\"}],\"StakerIsZeroAddress()\":[{\"details\":\"Staker address is zero.\"}],\"UnexpectedStakeRequestState(uint8,uint8)\":[{\"details\":\"Attempted to execute function for stake request in unexpected current state.\"}]},\"events\":{\"BridgingCompleted(uint256,address,uint16,uint256,uint256)\":{\"params\":{\"bridgedAmount\":\"Amount of tBTC tokens that was bridged by the tBTC bridge.\",\"caller\":\"Address that notified about bridging completion.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"depositorFee\":\"Depositor fee amount.\",\"referral\":\"Identifier of a partner in the referral program.\"}},\"DepositorFeeDivisorUpdated(uint64)\":{\"params\":{\"depositorFeeDivisor\":\"New value of the depositor fee divisor.\"}},\"StakeRequestCancelledFromQueue(uint256,address,uint256)\":{\"params\":{\"amountToStake\":\"Amount of queued tBTC tokens that got cancelled.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"staker\":\"Address of the staker.\"}},\"StakeRequestFinalized(uint256,address,uint256)\":{\"details\":\"Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.\",\"params\":{\"caller\":\"Address that finalized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"stakedAmount\":\"Amount of staked tBTC tokens.\"}},\"StakeRequestFinalizedFromQueue(uint256,address,uint256)\":{\"details\":\"Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.\",\"params\":{\"caller\":\"Address that finalized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"stakedAmount\":\"Amount of staked tBTC tokens.\"}},\"StakeRequestInitialized(uint256,address,address)\":{\"details\":\"Deposit details can be fetched from {{ Bridge.DepositRevealed }} event emitted in the same transaction.\",\"params\":{\"caller\":\"Address that initialized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"staker\":\"The address to which the stBTC shares will be minted.\"}},\"StakeRequestQueued(uint256,address,uint256)\":{\"params\":{\"caller\":\"Address that finalized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"queuedAmount\":\"Amount of queued tBTC tokens.\"}}},\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"cancelQueuedStake(uint256)\":{\"details\":\"This function can be called only after the stake request was added to queue.Only staker provided in the extra data of the stake request can call this function.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"constructor\":{\"params\":{\"_stbtc\":\"stBTC contract instance.\",\"_tbtcToken\":\"tBTC token contract instance.\",\"bridge\":\"tBTC Bridge contract instance.\",\"tbtcVault\":\"tBTC Vault contract instance.\"}},\"decodeExtraData(bytes32)\":{\"details\":\"Unpacks the data from bytes32: 20 bytes of staker address and 2 bytes of referral, 10 bytes of trailing zeros.\",\"params\":{\"extraData\":\"Encoded extra data.\"},\"returns\":{\"referral\":\"Data used for referral program.\",\"staker\":\"The address to which the stBTC shares will be minted.\"}},\"encodeExtraData(address,uint16)\":{\"details\":\"Packs the data to bytes32: 20 bytes of staker address and 2 bytes of referral, 10 bytes of trailing zeros.\",\"params\":{\"referral\":\"Data used for referral program.\",\"staker\":\"The address to which the stBTC shares will be minted.\"},\"returns\":{\"_0\":\"Encoded extra data.\"}},\"finalizeQueuedStake(uint256)\":{\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"finalizeStake(uint256)\":{\"details\":\"In case depositing in stBTC vault fails (e.g. because of the maximum deposit limit being reached), the `queueStake` function should be called to add the stake request to the staking queue.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"initializeStake((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)\":{\"details\":\"Requirements: - The revealed vault address must match the TBTCVault address, - All requirements from {Bridge#revealDepositWithExtraData} function must be met. - `staker` must be the staker address used in the P2(W)SH BTC deposit transaction as part of the extra data. - `referral` must be the referral info used in the P2(W)SH BTC deposit transaction as part of the extra data. - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex` can be revealed only one time.\",\"params\":{\"fundingTx\":\"Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\",\"referral\":\"Data used for referral program.\",\"reveal\":\"Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\",\"staker\":\"The address to which the stBTC shares will be minted.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"queueStake(uint256)\":{\"details\":\"It queues the stake request, until the stBTC vault is ready to accept the deposit. The request must be finalized with `finalizeQueuedStake` after the limit is increased or other user withdraws their funds from the stBTC contract to make place for another deposit. The staker has a possibility to submit `cancelQueuedStake` that will withdraw the minted tBTC token and abort staking process.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"},\"updateDepositorFeeDivisor(uint64)\":{\"params\":{\"newDepositorFeeDivisor\":\"New depositor fee divisor value.\"}}},\"stateVariables\":{\"depositorFeeDivisor\":{\"details\":\"That fee is computed as follows: `depositorFee = depositedAmount / depositorFeeDivisor` for example, if the depositor fee needs to be 2% of each deposit, the `depositorFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`.\"},\"stakeRequests\":{\"details\":\"The key is a deposit key identifying the deposit.\"}},\"title\":\"Acre Bitcoin Depositor contract.\",\"version\":1},\"userdoc\":{\"errors\":{\"StbtcZeroAddress()\":[{\"notice\":\"Reverts if the stBTC address is zero.\"}],\"TbtcTokenZeroAddress()\":[{\"notice\":\"Reverts if the tBTC Token address is zero.\"}]},\"events\":{\"BridgingCompleted(uint256,address,uint16,uint256,uint256)\":{\"notice\":\"Emitted when bridging completion has been notified.\"},\"DepositorFeeDivisorUpdated(uint64)\":{\"notice\":\"Emitted when a depositor fee divisor is updated.\"},\"StakeRequestCancelledFromQueue(uint256,address,uint256)\":{\"notice\":\"Emitted when a queued stake request is cancelled.\"},\"StakeRequestFinalized(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is finalized.\"},\"StakeRequestFinalizedFromQueue(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is finalized from the queue.\"},\"StakeRequestInitialized(uint256,address,address)\":{\"notice\":\"Emitted when a stake request is initialized.\"},\"StakeRequestQueued(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is queued.\"}},\"kind\":\"user\",\"methods\":{\"SATOSHI_MULTIPLIER()\":{\"notice\":\"Multiplier to convert satoshi to TBTC token units.\"},\"bridge()\":{\"notice\":\"Bridge contract address.\"},\"cancelQueuedStake(uint256)\":{\"notice\":\"Cancel queued stake. The function can be called by the staker to recover tBTC that cannot be finalized to stake in stBTC contract due to a deposit limit being reached.\"},\"constructor\":{\"notice\":\"Acre Bitcoin Depositor contract constructor.\"},\"decodeExtraData(bytes32)\":{\"notice\":\"Decodes staker address and referral from extra data.\"},\"depositorFeeDivisor()\":{\"notice\":\"Divisor used to compute the depositor fee taken from each deposit and transferred to the treasury upon stake request finalization.\"},\"encodeExtraData(address,uint16)\":{\"notice\":\"Encodes staker address and referral as extra data.\"},\"finalizeQueuedStake(uint256)\":{\"notice\":\"This function should be called for previously queued stake request, when stBTC vault is able to accept a deposit.\"},\"finalizeStake(uint256)\":{\"notice\":\"This function should be called for previously initialized stake request, after tBTC bridging process was finalized. It stakes the tBTC from the given deposit into stBTC, emitting the stBTC shares to the staker specified in the deposit extra data and using the referral provided in the extra data.\"},\"initializeStake((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)\":{\"notice\":\"This function allows staking process initialization for a Bitcoin deposit made by an user with a P2(W)SH transaction. It uses the supplied information to reveal a deposit to the tBTC Bridge contract.\"},\"queueStake(uint256)\":{\"notice\":\"This function should be called for previously initialized stake request, after tBTC bridging process was finalized, in case the `finalizeStake` failed due to stBTC vault deposit limit being reached.\"},\"stakeRequests(uint256)\":{\"notice\":\"Mapping of stake requests.\"},\"stbtc()\":{\"notice\":\"stBTC contract.\"},\"tbtcToken()\":{\"notice\":\"tBTC Token contract.\"},\"tbtcVault()\":{\"notice\":\"TBTCVault contract address.\"},\"updateDepositorFeeDivisor(uint64)\":{\"notice\":\"Updates the depositor fee divisor.\"}},\"notice\":\"The contract integrates Acre staking with tBTC minting. User who wants to stake BTC in Acre should submit a Bitcoin transaction to the most recently created off-chain ECDSA wallets of the tBTC Bridge using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH) containing hashed information about this Depositor contract address, and staker's Ethereum address. Then, the staker initiates tBTC minting by revealing their Ethereum address along with their deposit blinding factor, refund public key hash and refund locktime on the tBTC Bridge through this Depositor contract. The off-chain ECDSA wallet and Optimistic Minting bots listen for these sorts of messages and when they get one, they check the Bitcoin network to make sure the deposit lines up. Majority of tBTC minting is finalized by the Optimistic Minting process, where Minter bot initializes minting process and if there is no veto from the Guardians, the process is finalized and tBTC minted to the Depositor address. If the revealed deposit is not handled by the Optimistic Minting process the off-chain ECDSA wallet may decide to pick the deposit transaction for sweeping, and when the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge and tBTC vault mint the tBTC token to the Depositor address. After tBTC is minted to the Depositor, on the stake finalization tBTC is staked in stBTC contract and stBTC shares are emitted to the staker.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/AcreBitcoinDepositor.sol\":\"AcreBitcoinDepositor\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to \\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\nPermission is hereby granted, free of charge, to any person obtaining\\na copy of this software and associated documentation files (the\\n\\\"Software\\\"), to deal in the Software without restriction, including\\nwithout limitation the rights to use, copy, modify, merge, publish,\\ndistribute, sublicense, and/or sell copies of the Software, and to\\npermit persons to whom the Software is furnished to do so, subject to\\nthe following conditions:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\\n*/\\n\\n\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\n\\nimport \\\"./IBridge.sol\\\";\\nimport \\\"./ITBTCVault.sol\\\";\\n\\n/// @title Abstract AbstractTBTCDepositor contract.\\n/// @notice This abstract contract is meant to facilitate integration of protocols\\n/// aiming to use tBTC as an underlying Bitcoin bridge.\\n///\\n/// Such an integrator is supposed to:\\n/// - Create a child contract inheriting from this abstract contract\\n/// - Call the `__AbstractTBTCDepositor_initialize` initializer function\\n/// - Use the `_initializeDeposit` and `_finalizeDeposit` as part of their\\n/// business logic in order to initialize and finalize deposits.\\n///\\n/// @dev Example usage:\\n/// ```\\n/// // Example upgradeable integrator contract.\\n/// contract ExampleTBTCIntegrator is AbstractTBTCDepositor, Initializable {\\n/// /// @custom:oz-upgrades-unsafe-allow constructor\\n/// constructor() {\\n/// // Prevents the contract from being initialized again.\\n/// _disableInitializers();\\n/// }\\n///\\n/// function initialize(\\n/// address _bridge,\\n/// address _tbtcVault\\n/// ) external initializer {\\n/// __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\\n/// }\\n///\\n/// function startProcess(\\n/// IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n/// IBridgeTypes.DepositRevealInfo calldata reveal\\n/// ) external {\\n/// // Embed necessary context as extra data.\\n/// bytes32 extraData = ...;\\n///\\n/// uint256 depositKey = _initializeDeposit(\\n/// fundingTx,\\n/// reveal,\\n/// extraData\\n/// );\\n///\\n/// // Use the depositKey to track the process.\\n/// }\\n///\\n/// function finalizeProcess(uint256 depositKey) external {\\n/// // Ensure the function cannot be called for the same deposit\\n/// // twice.\\n///\\n/// (\\n/// uint256 initialDepositAmount,\\n/// uint256 tbtcAmount,\\n/// bytes32 extraData\\n/// ) = _finalizeDeposit(depositKey);\\n///\\n/// // Do something with the minted TBTC using context\\n/// // embedded in the extraData.\\n/// }\\n/// }\\nabstract contract AbstractTBTCDepositor {\\n using BTCUtils for bytes;\\n\\n /// @notice Multiplier to convert satoshi to TBTC token units.\\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\\n\\n /// @notice Bridge contract address.\\n IBridge public bridge;\\n /// @notice TBTCVault contract address.\\n ITBTCVault public tbtcVault;\\n\\n // Reserved storage space that allows adding more variables without affecting\\n // the storage layout of the child contracts. The convention from OpenZeppelin\\n // suggests the storage space should add up to 50 slots. If more variables are\\n // added in the upcoming versions one need to reduce the array size accordingly.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n event DepositInitialized(uint256 indexed depositKey, uint32 initializedAt);\\n\\n event DepositFinalized(\\n uint256 indexed depositKey,\\n uint256 tbtcAmount,\\n uint32 finalizedAt\\n );\\n\\n /// @notice Initializes the contract. MUST BE CALLED from the child\\n /// contract initializer.\\n // slither-disable-next-line dead-code\\n function __AbstractTBTCDepositor_initialize(\\n address _bridge,\\n address _tbtcVault\\n ) internal {\\n require(\\n address(bridge) == address(0) && address(tbtcVault) == address(0),\\n \\\"AbstractTBTCDepositor already initialized\\\"\\n );\\n\\n require(_bridge != address(0), \\\"Bridge address cannot be zero\\\");\\n require(_tbtcVault != address(0), \\\"TBTCVault address cannot be zero\\\");\\n\\n bridge = IBridge(_bridge);\\n tbtcVault = ITBTCVault(_tbtcVault);\\n }\\n\\n /// @notice Initializes a deposit by revealing it to the Bridge.\\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo` struct.\\n /// @param extraData 32-byte deposit extra data.\\n /// @return depositKey Deposit key computed as\\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\\n /// key can be used to refer to the deposit in the Bridge and\\n /// TBTCVault contracts.\\n /// @dev Requirements:\\n /// - The revealed vault address must match the TBTCVault address,\\n /// - All requirements from {Bridge#revealDepositWithExtraData}\\n /// function must be met.\\n /// @dev This function doesn't validate if a deposit has been initialized before,\\n /// as the Bridge won't allow the same deposit to be revealed twice.\\n // slither-disable-next-line dead-code\\n function _initializeDeposit(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n bytes32 extraData\\n ) internal returns (uint256) {\\n require(reveal.vault == address(tbtcVault), \\\"Vault address mismatch\\\");\\n\\n uint256 depositKey = _calculateDepositKey(\\n _calculateBitcoinTxHash(fundingTx),\\n reveal.fundingOutputIndex\\n );\\n\\n emit DepositInitialized(\\n depositKey,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n // The Bridge does not allow to reveal the same deposit twice and\\n // revealed deposits stay there forever. The transaction will revert\\n // if the deposit has already been revealed so, there is no need to do\\n // an explicit check here.\\n bridge.revealDepositWithExtraData(fundingTx, reveal, extraData);\\n\\n return depositKey;\\n }\\n\\n /// @notice Finalizes a deposit by calculating the amount of TBTC minted\\n /// for the deposit.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @return initialDepositAmount Amount of funding transaction deposit. In\\n /// TBTC token decimals precision.\\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit. In\\n /// TBTC token decimals precision.\\n /// @return extraData 32-byte deposit extra data.\\n /// @dev Requirements:\\n /// - The deposit must be initialized but not finalized\\n /// (in the context of this contract) yet.\\n /// - The deposit must be finalized on the Bridge side. That means the\\n /// deposit must be either swept or optimistically minted.\\n /// @dev THIS FUNCTION DOESN'T VALIDATE IF A DEPOSIT HAS BEEN FINALIZED BEFORE,\\n /// IT IS A RESPONSIBILITY OF THE IMPLEMENTING CONTRACT TO ENSURE THIS\\n /// FUNCTION WON'T BE CALLED TWICE FOR THE SAME DEPOSIT.\\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function is an\\n /// approximation. See documentation of the `calculateTbtcAmount`\\n /// responsible for calculating this value for more details.\\n // slither-disable-next-line dead-code\\n function _finalizeDeposit(uint256 depositKey)\\n internal\\n returns (\\n uint256 initialDepositAmount,\\n uint256 tbtcAmount,\\n bytes32 extraData\\n )\\n {\\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\\n depositKey\\n );\\n require(deposit.revealedAt != 0, \\\"Deposit not initialized\\\");\\n\\n (, uint64 finalizedAt) = tbtcVault.optimisticMintingRequests(\\n depositKey\\n );\\n\\n require(\\n deposit.sweptAt != 0 || finalizedAt != 0,\\n \\\"Deposit not finalized by the bridge\\\"\\n );\\n\\n initialDepositAmount = deposit.amount * SATOSHI_MULTIPLIER;\\n\\n tbtcAmount = _calculateTbtcAmount(deposit.amount, deposit.treasuryFee);\\n\\n // slither-disable-next-line reentrancy-events\\n emit DepositFinalized(\\n depositKey,\\n tbtcAmount,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n extraData = deposit.extraData;\\n }\\n\\n /// @notice Calculates the amount of TBTC minted for the deposit.\\n /// @param depositAmountSat Deposit amount in satoshi (1e8 precision).\\n /// This is the actual amount deposited by the deposit creator, i.e.\\n /// the gross amount the Bridge's fees are cut from.\\n /// @param depositTreasuryFeeSat Deposit treasury fee in satoshi (1e8 precision).\\n /// This is an accurate value of the treasury fee that was actually\\n /// cut upon minting.\\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit.\\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function may\\n /// not correspond to the actual amount of TBTC minted for the deposit.\\n /// Although the treasury fee cut upon minting is known precisely,\\n /// this is not the case for the optimistic minting fee and the Bitcoin\\n /// transaction fee. To overcome that problem, this function just takes\\n /// the current maximum allowed values of both fees, at the moment of deposit\\n /// finalization. For the great majority of the deposits, such an\\n /// algorithm will return a tbtcAmount slightly lesser than the\\n /// actual amount of TBTC minted for the deposit. This will cause\\n /// some TBTC to be left in the contract and ensure there is enough\\n /// liquidity to finalize the deposit. However, in some rare cases,\\n /// where the actual values of those fees change between the deposit\\n /// minting and finalization, the tbtcAmount returned by this function\\n /// may be greater than the actual amount of TBTC minted for the deposit.\\n /// If this happens and the reserve coming from previous deposits\\n /// leftovers does not provide enough liquidity, the deposit will have\\n /// to wait for finalization until the reserve is refilled by subsequent\\n /// deposits or a manual top-up. The integrator is responsible for\\n /// handling such cases.\\n // slither-disable-next-line dead-code\\n function _calculateTbtcAmount(\\n uint64 depositAmountSat,\\n uint64 depositTreasuryFeeSat\\n ) internal view virtual returns (uint256) {\\n // Both deposit amount and treasury fee are in the 1e8 satoshi precision.\\n // We need to convert them to the 1e18 TBTC precision.\\n uint256 amountSubTreasury = (depositAmountSat - depositTreasuryFeeSat) *\\n SATOSHI_MULTIPLIER;\\n\\n uint256 omFeeDivisor = tbtcVault.optimisticMintingFeeDivisor();\\n uint256 omFee = omFeeDivisor > 0\\n ? (amountSubTreasury / omFeeDivisor)\\n : 0;\\n\\n // The deposit transaction max fee is in the 1e8 satoshi precision.\\n // We need to convert them to the 1e18 TBTC precision.\\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\\n\\n return amountSubTreasury - omFee - txMaxFee;\\n }\\n\\n /// @notice Calculates the deposit key for the given funding transaction\\n /// hash and funding output index.\\n /// @param fundingTxHash Funding transaction hash.\\n /// @param fundingOutputIndex Funding output index.\\n /// @return depositKey Deposit key computed as\\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\\n /// key can be used to refer to the deposit in the Bridge and\\n /// TBTCVault contracts.\\n // slither-disable-next-line dead-code\\n function _calculateDepositKey(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) internal pure returns (uint256) {\\n return\\n uint256(\\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\\n );\\n }\\n\\n /// @notice Calculates the Bitcoin transaction hash for the given Bitcoin\\n /// transaction data.\\n /// @param txInfo Bitcoin transaction data, see `IBridgeTypes.BitcoinTxInfo` struct.\\n /// @return txHash Bitcoin transaction hash.\\n // slither-disable-next-line dead-code\\n function _calculateBitcoinTxHash(IBridgeTypes.BitcoinTxInfo calldata txInfo)\\n internal\\n view\\n returns (bytes32)\\n {\\n return\\n abi\\n .encodePacked(\\n txInfo.version,\\n txInfo.inputVector,\\n txInfo.outputVector,\\n txInfo.locktime\\n )\\n .hash256View();\\n }\\n}\\n\",\"keccak256\":\"0x0cfd2215c106fc17c8166a31839243ad1575806401de60f80d0a4857a2a60078\",\"license\":\"GPL-3.0-only\"},\"@keep-network/tbtc-v2/contracts/integrator/IBridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\n/// @notice Namespace which groups all types relevant to the IBridge interface.\\n/// @dev This is a mirror of the real types used in the Bridge contract.\\n/// This way, the `integrator` subpackage does not need to import\\n/// anything from the `bridge` subpackage and explicitly depend on it.\\n/// This simplifies the dependency graph for integrators.\\nlibrary IBridgeTypes {\\n /// @dev See bridge/BitcoinTx.sol#Info\\n struct BitcoinTxInfo {\\n bytes4 version;\\n bytes inputVector;\\n bytes outputVector;\\n bytes4 locktime;\\n }\\n\\n /// @dev See bridge/Deposit.sol#DepositRevealInfo\\n struct DepositRevealInfo {\\n uint32 fundingOutputIndex;\\n bytes8 blindingFactor;\\n bytes20 walletPubKeyHash;\\n bytes20 refundPubKeyHash;\\n bytes4 refundLocktime;\\n address vault;\\n }\\n\\n /// @dev See bridge/Deposit.sol#DepositRequest\\n struct DepositRequest {\\n address depositor;\\n uint64 amount;\\n uint32 revealedAt;\\n address vault;\\n uint64 treasuryFee;\\n uint32 sweptAt;\\n bytes32 extraData;\\n }\\n}\\n\\n/// @notice Interface of the Bridge contract.\\n/// @dev See bridge/Bridge.sol\\ninterface IBridge {\\n /// @dev See {Bridge#revealDepositWithExtraData}\\n function revealDepositWithExtraData(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n bytes32 extraData\\n ) external;\\n\\n /// @dev See {Bridge#deposits}\\n function deposits(uint256 depositKey)\\n external\\n view\\n returns (IBridgeTypes.DepositRequest memory);\\n\\n /// @dev See {Bridge#depositParameters}\\n function depositParameters()\\n external\\n view\\n returns (\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n}\\n\",\"keccak256\":\"0x4e598d96404a19609f511f10503e80f457602ad694d081df739571f67f6e0c4e\",\"license\":\"GPL-3.0-only\"},\"@keep-network/tbtc-v2/contracts/integrator/ITBTCVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\n/// @notice Interface of the TBTCVault contract.\\n/// @dev See vault/TBTCVault.sol\\ninterface ITBTCVault {\\n /// @dev See {TBTCVault#optimisticMintingRequests}\\n function optimisticMintingRequests(uint256 depositKey)\\n external\\n returns (uint64 requestedAt, uint64 finalizedAt);\\n\\n /// @dev See {TBTCVault#optimisticMintingFeeDivisor}\\n function optimisticMintingFeeDivisor() external view returns (uint32);\\n}\\n\",\"keccak256\":\"0xf259d64c1040e2cbc3d17653491e45c5c3da17f575dac1c175c63c8a5308908e\",\"license\":\"GPL-3.0-only\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Context} from \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * The initial owner is set to the address provided by the deployer. This can\\n * later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n /**\\n * @dev The caller account is not authorized to perform an operation.\\n */\\n error OwnableUnauthorizedAccount(address account);\\n\\n /**\\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\\n */\\n error OwnableInvalidOwner(address owner);\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\\n */\\n constructor(address initialOwner) {\\n if (initialOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(initialOwner);\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n if (owner() != _msgSender()) {\\n revert OwnableUnauthorizedAccount(_msgSender());\\n }\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n if (newOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xff6d0bb2e285473e5311d9d3caacb525ae3538a80758c10649a4d61029b017bb\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Ownable} from \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * The initial owner is specified at deployment time in the constructor for `Ownable`. This\\n * can later be changed with {transferOwnership} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n if (pendingOwner() != sender) {\\n revert OwnableUnauthorizedAccount(sender);\\n }\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x5d3e5de9eadfa1f8a892eb2e95bbebd3e4b8c8ada5b76f104d383fea518fa688\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../token/ERC20/IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"../token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\n/**\\n * @dev Interface of the ERC4626 \\\"Tokenized Vault Standard\\\", as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\\n */\\ninterface IERC4626 is IERC20, IERC20Metadata {\\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed sender,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /**\\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\\n *\\n * - MUST be an ERC-20 token contract.\\n * - MUST NOT revert.\\n */\\n function asset() external view returns (address assetTokenAddress);\\n\\n /**\\n * @dev Returns the total amount of the underlying asset that is \\u201cmanaged\\u201d by Vault.\\n *\\n * - SHOULD include any compounding that occurs from yield.\\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT revert.\\n */\\n function totalAssets() external view returns (uint256 totalManagedAssets);\\n\\n /**\\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToShares(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\\n * through a deposit call.\\n *\\n * - MUST return a limited value if receiver is subject to some deposit limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\\n * - MUST NOT revert.\\n */\\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\\n * in the same transaction.\\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * deposit execution, and are accounted for during deposit.\\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\\n * - MUST return a limited value if receiver is subject to some mint limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\\n * - MUST NOT revert.\\n */\\n function maxMint(address receiver) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\\n * same transaction.\\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\\n * would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\\n */\\n function previewMint(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\\n * execution, and are accounted for during mint.\\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\\n * Vault, through a withdraw call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\\n * called\\n * in the same transaction.\\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * withdraw execution, and are accounted for during withdraw.\\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\\n * through a redeem call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxRedeem(address owner) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\\n * same transaction.\\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\\n * redemption would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\\n */\\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * redeem execution, and are accounted for during redeem.\\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\\n}\\n\",\"keccak256\":\"0x207f64371bc0fcc5be86713aa5da109a870cc3a6da50e93b64ee881e369b593d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC6093.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard ERC20 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\\n */\\ninterface IERC20Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC20InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC20InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `spender`\\u2019s `allowance`. Used in transfers.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC20InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC20InvalidSpender(address spender);\\n}\\n\\n/**\\n * @dev Standard ERC721 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\\n */\\ninterface IERC721Errors {\\n /**\\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\\n * Used in balance queries.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721InvalidOwner(address owner);\\n\\n /**\\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721NonexistentToken(uint256 tokenId);\\n\\n /**\\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param tokenId Identifier number of a token.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC721InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC721InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC721InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC721InvalidOperator(address operator);\\n}\\n\\n/**\\n * @dev Standard ERC1155 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\\n */\\ninterface IERC1155Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC1155InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC1155InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC1155MissingApprovalForAll(address operator, address owner);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC1155InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC1155InvalidOperator(address operator);\\n\\n /**\\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\\n * Used in batch transfers.\\n * @param idsLength Length of the array of token identifiers\\n * @param valuesLength Length of the array of token amounts\\n */\\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\\n}\\n\",\"keccak256\":\"0x60c65f701957fdd6faea1acb0bb45825791d473693ed9ecb34726fdfaa849dd7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"./IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"./extensions/IERC20Metadata.sol\\\";\\nimport {Context} from \\\"../../utils/Context.sol\\\";\\nimport {IERC20Errors} from \\\"../../interfaces/draft-IERC6093.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * The default value of {decimals} is 18. To change this, you should override\\n * this function so it returns a different value.\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n */\\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\\n mapping(address account => uint256) private _balances;\\n\\n mapping(address account => mapping(address spender => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the default value returned by this function, unless\\n * it's overridden.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return 18;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `value`.\\n */\\n function transfer(address to, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _approve(owner, spender, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `value`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `value`.\\n */\\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, value);\\n _transfer(from, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to`.\\n *\\n * This internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _transfer(address from, address to, uint256 value) internal {\\n if (from == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n if (to == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(from, to, value);\\n }\\n\\n /**\\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\\n * this function.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _update(address from, address to, uint256 value) internal virtual {\\n if (from == address(0)) {\\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\\n _totalSupply += value;\\n } else {\\n uint256 fromBalance = _balances[from];\\n if (fromBalance < value) {\\n revert ERC20InsufficientBalance(from, fromBalance, value);\\n }\\n unchecked {\\n // Overflow not possible: value <= fromBalance <= totalSupply.\\n _balances[from] = fromBalance - value;\\n }\\n }\\n\\n if (to == address(0)) {\\n unchecked {\\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\\n _totalSupply -= value;\\n }\\n } else {\\n unchecked {\\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\\n _balances[to] += value;\\n }\\n }\\n\\n emit Transfer(from, to, value);\\n }\\n\\n /**\\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\\n * Relies on the `_update` mechanism\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _mint(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(address(0), account, value);\\n }\\n\\n /**\\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\\n * Relies on the `_update` mechanism.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead\\n */\\n function _burn(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n _update(account, address(0), value);\\n }\\n\\n /**\\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n *\\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\\n */\\n function _approve(address owner, address spender, uint256 value) internal {\\n _approve(owner, spender, value, true);\\n }\\n\\n /**\\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\\n *\\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\\n * `Approval` event during `transferFrom` operations.\\n *\\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\\n * true using the following override:\\n * ```\\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\\n * super._approve(owner, spender, value, true);\\n * }\\n * ```\\n *\\n * Requirements are the same as {_approve}.\\n */\\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\\n if (owner == address(0)) {\\n revert ERC20InvalidApprover(address(0));\\n }\\n if (spender == address(0)) {\\n revert ERC20InvalidSpender(address(0));\\n }\\n _allowances[owner][spender] = value;\\n if (emitEvent) {\\n emit Approval(owner, spender, value);\\n }\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\\n *\\n * Does not update the allowance value in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Does not emit an {Approval} event.\\n */\\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n if (currentAllowance < value) {\\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\\n }\\n unchecked {\\n _approve(owner, spender, currentAllowance - value, false);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3e1fa9d1987f8d349dfb4d6fe93bf2ca014b52ba335cfac30bfe71e357e6f80\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the value of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the value of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\\n * caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\\n * allowance mechanism. `value` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 value) external returns (bool);\\n}\\n\",\"keccak256\":\"0xc6a8ff0ea489379b61faa647490411b80102578440ab9d84e9a957cc12164e70\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20, IERC20Metadata, ERC20} from \\\"../ERC20.sol\\\";\\nimport {SafeERC20} from \\\"../utils/SafeERC20.sol\\\";\\nimport {IERC4626} from \\\"../../../interfaces/IERC4626.sol\\\";\\nimport {Math} from \\\"../../../utils/math/Math.sol\\\";\\n\\n/**\\n * @dev Implementation of the ERC4626 \\\"Tokenized Vault Standard\\\" as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\\n *\\n * This extension allows the minting and burning of \\\"shares\\\" (represented using the ERC20 inheritance) in exchange for\\n * underlying \\\"assets\\\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\\n * the ERC20 standard. Any additional extensions included along it would affect the \\\"shares\\\" token represented by this\\n * contract and not the \\\"assets\\\" token which is an independent contract.\\n *\\n * [CAUTION]\\n * ====\\n * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning\\n * with a \\\"donation\\\" to the vault that inflates the price of a share. This is variously known as a donation or inflation\\n * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial\\n * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may\\n * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by\\n * verifying the amount received is as expected, using a wrapper that performs these checks such as\\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\\n *\\n * Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()`\\n * corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault\\n * decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself\\n * determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset\\n * (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's\\n * donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more\\n * expensive than it is profitable. More details about the underlying math can be found\\n * xref:erc4626.adoc#inflation-attack[here].\\n *\\n * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued\\n * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets\\n * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience\\n * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the\\n * `_convertToShares` and `_convertToAssets` functions.\\n *\\n * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].\\n * ====\\n */\\nabstract contract ERC4626 is ERC20, IERC4626 {\\n using Math for uint256;\\n\\n IERC20 private immutable _asset;\\n uint8 private immutable _underlyingDecimals;\\n\\n /**\\n * @dev Attempted to deposit more assets than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);\\n\\n /**\\n * @dev Attempted to mint more shares than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);\\n\\n /**\\n * @dev Attempted to withdraw more assets than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);\\n\\n /**\\n * @dev Attempted to redeem more shares than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);\\n\\n /**\\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\\n */\\n constructor(IERC20 asset_) {\\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\\n _underlyingDecimals = success ? assetDecimals : 18;\\n _asset = asset_;\\n }\\n\\n /**\\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\\n */\\n function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {\\n (bool success, bytes memory encodedDecimals) = address(asset_).staticcall(\\n abi.encodeCall(IERC20Metadata.decimals, ())\\n );\\n if (success && encodedDecimals.length >= 32) {\\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\\n if (returnedDecimals <= type(uint8).max) {\\n return (true, uint8(returnedDecimals));\\n }\\n }\\n return (false, 0);\\n }\\n\\n /**\\n * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This\\n * \\\"original\\\" value is cached during construction of the vault contract. If this read operation fails (e.g., the\\n * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.\\n *\\n * See {IERC20Metadata-decimals}.\\n */\\n function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {\\n return _underlyingDecimals + _decimalsOffset();\\n }\\n\\n /** @dev See {IERC4626-asset}. */\\n function asset() public view virtual returns (address) {\\n return address(_asset);\\n }\\n\\n /** @dev See {IERC4626-totalAssets}. */\\n function totalAssets() public view virtual returns (uint256) {\\n return _asset.balanceOf(address(this));\\n }\\n\\n /** @dev See {IERC4626-convertToShares}. */\\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-convertToAssets}. */\\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-maxDeposit}. */\\n function maxDeposit(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n /** @dev See {IERC4626-maxMint}. */\\n function maxMint(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n /** @dev See {IERC4626-maxWithdraw}. */\\n function maxWithdraw(address owner) public view virtual returns (uint256) {\\n return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-maxRedeem}. */\\n function maxRedeem(address owner) public view virtual returns (uint256) {\\n return balanceOf(owner);\\n }\\n\\n /** @dev See {IERC4626-previewDeposit}. */\\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-previewMint}. */\\n function previewMint(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Ceil);\\n }\\n\\n /** @dev See {IERC4626-previewWithdraw}. */\\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Ceil);\\n }\\n\\n /** @dev See {IERC4626-previewRedeem}. */\\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-deposit}. */\\n function deposit(uint256 assets, address receiver) public virtual returns (uint256) {\\n uint256 maxAssets = maxDeposit(receiver);\\n if (assets > maxAssets) {\\n revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);\\n }\\n\\n uint256 shares = previewDeposit(assets);\\n _deposit(_msgSender(), receiver, assets, shares);\\n\\n return shares;\\n }\\n\\n /** @dev See {IERC4626-mint}.\\n *\\n * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.\\n * In this case, the shares will be minted without requiring any assets to be deposited.\\n */\\n function mint(uint256 shares, address receiver) public virtual returns (uint256) {\\n uint256 maxShares = maxMint(receiver);\\n if (shares > maxShares) {\\n revert ERC4626ExceededMaxMint(receiver, shares, maxShares);\\n }\\n\\n uint256 assets = previewMint(shares);\\n _deposit(_msgSender(), receiver, assets, shares);\\n\\n return assets;\\n }\\n\\n /** @dev See {IERC4626-withdraw}. */\\n function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {\\n uint256 maxAssets = maxWithdraw(owner);\\n if (assets > maxAssets) {\\n revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);\\n }\\n\\n uint256 shares = previewWithdraw(assets);\\n _withdraw(_msgSender(), receiver, owner, assets, shares);\\n\\n return shares;\\n }\\n\\n /** @dev See {IERC4626-redeem}. */\\n function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {\\n uint256 maxShares = maxRedeem(owner);\\n if (shares > maxShares) {\\n revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);\\n }\\n\\n uint256 assets = previewRedeem(shares);\\n _withdraw(_msgSender(), receiver, owner, assets, shares);\\n\\n return assets;\\n }\\n\\n /**\\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\\n */\\n function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {\\n return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);\\n }\\n\\n /**\\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\\n */\\n function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {\\n return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);\\n }\\n\\n /**\\n * @dev Deposit/mint common workflow.\\n */\\n function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {\\n // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the\\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\\n // calls the vault, which is assumed not malicious.\\n //\\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\\n // assets are transferred and before the shares are minted, which is a valid state.\\n // slither-disable-next-line reentrancy-no-eth\\n SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\\n _mint(receiver, shares);\\n\\n emit Deposit(caller, receiver, assets, shares);\\n }\\n\\n /**\\n * @dev Withdraw/redeem common workflow.\\n */\\n function _withdraw(\\n address caller,\\n address receiver,\\n address owner,\\n uint256 assets,\\n uint256 shares\\n ) internal virtual {\\n if (caller != owner) {\\n _spendAllowance(owner, caller, shares);\\n }\\n\\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\\n // calls the vault, which is assumed not malicious.\\n //\\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\\n // shares are burned and after the assets are transferred, which is a valid state.\\n _burn(owner, shares);\\n SafeERC20.safeTransfer(_asset, receiver, assets);\\n\\n emit Withdraw(caller, receiver, owner, assets, shares);\\n }\\n\\n function _decimalsOffset() internal view virtual returns (uint8) {\\n return 0;\\n }\\n}\\n\",\"keccak256\":\"0x1837547e04d5fe5334eeb77a345683c22995f1e7aa033020757ddf83a80fc72d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0xaa761817f6cd7892fcf158b3c776b34551cde36f48ff9703d53898bc45a94ea2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x6008dabfe393240d73d7dd7688033f72740d570aa422254d29a7dce8568f3aff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\nimport {IERC20Permit} from \\\"../extensions/IERC20Permit.sol\\\";\\nimport {Address} from \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n /**\\n * @dev An operation with an ERC20 token failed.\\n */\\n error SafeERC20FailedOperation(address token);\\n\\n /**\\n * @dev Indicates a failed `decreaseAllowance` request.\\n */\\n error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\\n }\\n\\n /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n forceApprove(token, spender, oldAllowance + value);\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\\n * value, non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\\n unchecked {\\n uint256 currentAllowance = token.allowance(address(this), spender);\\n if (currentAllowance < requestedDecrease) {\\n revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\\n }\\n forceApprove(token, spender, currentAllowance - requestedDecrease);\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data);\\n if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\\n revert SafeERC20FailedOperation(address(token));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\\n }\\n}\\n\",\"keccak256\":\"0x37bb49513c49c87c4642a891b13b63571bc87013dde806617aa1efb54605f386\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev The ETH balance of the account is not enough to perform the operation.\\n */\\n error AddressInsufficientBalance(address account);\\n\\n /**\\n * @dev There's no code at `target` (it is not a contract).\\n */\\n error AddressEmptyCode(address target);\\n\\n /**\\n * @dev A call to an address target failed. The target may have reverted.\\n */\\n error FailedInnerCall();\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n if (address(this).balance < amount) {\\n revert AddressInsufficientBalance(address(this));\\n }\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n if (!success) {\\n revert FailedInnerCall();\\n }\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason or custom error, it is bubbled\\n * up by this function (like regular Solidity function calls). However, if\\n * the call reverted with no returned reason, this function reverts with a\\n * {FailedInnerCall} error.\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n if (address(this).balance < value) {\\n revert AddressInsufficientBalance(address(this));\\n }\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\\n * unsuccessful call.\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata\\n ) internal view returns (bytes memory) {\\n if (!success) {\\n _revert(returndata);\\n } else {\\n // only check if target is a contract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n if (returndata.length == 0 && target.code.length == 0) {\\n revert AddressEmptyCode(target);\\n }\\n return returndata;\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\\n * revert reason or with a default {FailedInnerCall} error.\\n */\\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\\n if (!success) {\\n _revert(returndata);\\n } else {\\n return returndata;\\n }\\n }\\n\\n /**\\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\\n */\\n function _revert(bytes memory returndata) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert FailedInnerCall();\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaf28a975a78550e45f65e559a3ad6a5ad43b9b8a37366999abd1b7084eb70721\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x75a4ee64c68dbd5f38bddd06e664a64c8271b4caa554fb6f0607dfd672bb4bf3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Muldiv operation overflow.\\n */\\n error MathOverflowedMulDiv();\\n\\n enum Rounding {\\n Floor, // Toward negative infinity\\n Ceil, // Toward positive infinity\\n Trunc, // Toward zero\\n Expand // Away from zero\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds towards infinity instead\\n * of rounding towards zero.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (b == 0) {\\n // Guarantee the same behavior as in a regular Solidity division.\\n return a / b;\\n }\\n\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\\n * denominator == 0.\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\\n * Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0 = x * y; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (denominator <= prod1) {\\n revert MathOverflowedMulDiv();\\n }\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\\n\\n uint256 twos = denominator & (0 - denominator);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\\n // works in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\\n * towards zero.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\\n */\\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\\n return uint8(rounding) % 2 == 1;\\n }\\n}\\n\",\"keccak256\":\"0x005ec64c6313f0555d59e278f9a7a5ab2db5bdc72a027f255a37c327af1ec02d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Value doesn't fit in an uint of `bits` size.\\n */\\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\\n\\n /**\\n * @dev An int value doesn't fit in an uint of `bits` size.\\n */\\n error SafeCastOverflowedIntToUint(int256 value);\\n\\n /**\\n * @dev Value doesn't fit in an int of `bits` size.\\n */\\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\\n\\n /**\\n * @dev An uint value doesn't fit in an int of `bits` size.\\n */\\n error SafeCastOverflowedUintToInt(uint256 value);\\n\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n if (value > type(uint248).max) {\\n revert SafeCastOverflowedUintDowncast(248, value);\\n }\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n if (value > type(uint240).max) {\\n revert SafeCastOverflowedUintDowncast(240, value);\\n }\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n if (value > type(uint232).max) {\\n revert SafeCastOverflowedUintDowncast(232, value);\\n }\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n if (value > type(uint224).max) {\\n revert SafeCastOverflowedUintDowncast(224, value);\\n }\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n if (value > type(uint216).max) {\\n revert SafeCastOverflowedUintDowncast(216, value);\\n }\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n if (value > type(uint208).max) {\\n revert SafeCastOverflowedUintDowncast(208, value);\\n }\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n if (value > type(uint200).max) {\\n revert SafeCastOverflowedUintDowncast(200, value);\\n }\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n if (value > type(uint192).max) {\\n revert SafeCastOverflowedUintDowncast(192, value);\\n }\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n if (value > type(uint184).max) {\\n revert SafeCastOverflowedUintDowncast(184, value);\\n }\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n if (value > type(uint176).max) {\\n revert SafeCastOverflowedUintDowncast(176, value);\\n }\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n if (value > type(uint168).max) {\\n revert SafeCastOverflowedUintDowncast(168, value);\\n }\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n if (value > type(uint160).max) {\\n revert SafeCastOverflowedUintDowncast(160, value);\\n }\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n if (value > type(uint152).max) {\\n revert SafeCastOverflowedUintDowncast(152, value);\\n }\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n if (value > type(uint144).max) {\\n revert SafeCastOverflowedUintDowncast(144, value);\\n }\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n if (value > type(uint136).max) {\\n revert SafeCastOverflowedUintDowncast(136, value);\\n }\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n if (value > type(uint128).max) {\\n revert SafeCastOverflowedUintDowncast(128, value);\\n }\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n if (value > type(uint120).max) {\\n revert SafeCastOverflowedUintDowncast(120, value);\\n }\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n if (value > type(uint112).max) {\\n revert SafeCastOverflowedUintDowncast(112, value);\\n }\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n if (value > type(uint104).max) {\\n revert SafeCastOverflowedUintDowncast(104, value);\\n }\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n if (value > type(uint96).max) {\\n revert SafeCastOverflowedUintDowncast(96, value);\\n }\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n if (value > type(uint88).max) {\\n revert SafeCastOverflowedUintDowncast(88, value);\\n }\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n if (value > type(uint80).max) {\\n revert SafeCastOverflowedUintDowncast(80, value);\\n }\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n if (value > type(uint72).max) {\\n revert SafeCastOverflowedUintDowncast(72, value);\\n }\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n if (value > type(uint64).max) {\\n revert SafeCastOverflowedUintDowncast(64, value);\\n }\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n if (value > type(uint56).max) {\\n revert SafeCastOverflowedUintDowncast(56, value);\\n }\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n if (value > type(uint48).max) {\\n revert SafeCastOverflowedUintDowncast(48, value);\\n }\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n if (value > type(uint40).max) {\\n revert SafeCastOverflowedUintDowncast(40, value);\\n }\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n if (value > type(uint32).max) {\\n revert SafeCastOverflowedUintDowncast(32, value);\\n }\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n if (value > type(uint24).max) {\\n revert SafeCastOverflowedUintDowncast(24, value);\\n }\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n if (value > type(uint16).max) {\\n revert SafeCastOverflowedUintDowncast(16, value);\\n }\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n if (value > type(uint8).max) {\\n revert SafeCastOverflowedUintDowncast(8, value);\\n }\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n if (value < 0) {\\n revert SafeCastOverflowedIntToUint(value);\\n }\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(248, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(240, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(232, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(224, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(216, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(208, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(200, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(192, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(184, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(176, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(168, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(160, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(152, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(144, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(136, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(128, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(120, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(112, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(104, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(96, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(88, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(80, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(72, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(64, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(56, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(48, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(40, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(32, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(24, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(16, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(8, value);\\n }\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n if (value > uint256(type(int256).max)) {\\n revert SafeCastOverflowedUintToInt(value);\\n }\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xe19a4d5f31d2861e7344e8e535e2feafb913d806d3e2b5fe7782741a2a7094fe\",\"license\":\"MIT\"},\"contracts/AcreBitcoinDepositor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\nimport {SafeERC20} from \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {SafeCast} from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\n\\nimport \\\"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\\\";\\n\\nimport {stBTC} from \\\"./stBTC.sol\\\";\\n\\n// TODO: Make Upgradable\\n// TODO: Make Pausable\\n\\n/// @title Acre Bitcoin Depositor contract.\\n/// @notice The contract integrates Acre staking with tBTC minting.\\n/// User who wants to stake BTC in Acre should submit a Bitcoin transaction\\n/// to the most recently created off-chain ECDSA wallets of the tBTC Bridge\\n/// using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH)\\n/// containing hashed information about this Depositor contract address,\\n/// and staker's Ethereum address.\\n/// Then, the staker initiates tBTC minting by revealing their Ethereum\\n/// address along with their deposit blinding factor, refund public key\\n/// hash and refund locktime on the tBTC Bridge through this Depositor\\n/// contract.\\n/// The off-chain ECDSA wallet and Optimistic Minting bots listen for these\\n/// sorts of messages and when they get one, they check the Bitcoin network\\n/// to make sure the deposit lines up. Majority of tBTC minting is finalized\\n/// by the Optimistic Minting process, where Minter bot initializes\\n/// minting process and if there is no veto from the Guardians, the\\n/// process is finalized and tBTC minted to the Depositor address. If\\n/// the revealed deposit is not handled by the Optimistic Minting process\\n/// the off-chain ECDSA wallet may decide to pick the deposit transaction\\n/// for sweeping, and when the sweep operation is confirmed on the Bitcoin\\n/// network, the tBTC Bridge and tBTC vault mint the tBTC token to the\\n/// Depositor address. After tBTC is minted to the Depositor, on the stake\\n/// finalization tBTC is staked in stBTC contract and stBTC shares are emitted\\n/// to the staker.\\ncontract AcreBitcoinDepositor is AbstractTBTCDepositor, Ownable2Step {\\n using SafeERC20 for IERC20;\\n\\n /// @notice State of the stake request.\\n enum StakeRequestState {\\n Unknown,\\n Initialized,\\n Finalized,\\n Queued,\\n FinalizedFromQueue,\\n CancelledFromQueue\\n }\\n\\n struct StakeRequest {\\n // State of the stake request.\\n StakeRequestState state;\\n // The address to which the stBTC shares will be minted. Stored only when\\n // request is queued.\\n address staker;\\n // tBTC token amount to stake after deducting tBTC minting fees and the\\n // Depositor fee. Stored only when request is queued.\\n uint88 queuedAmount;\\n }\\n\\n /// @notice Mapping of stake requests.\\n /// @dev The key is a deposit key identifying the deposit.\\n mapping(uint256 => StakeRequest) public stakeRequests;\\n\\n /// @notice tBTC Token contract.\\n // TODO: Remove slither disable when introducing upgradeability.\\n // slither-disable-next-line immutable-states\\n IERC20 public tbtcToken;\\n\\n /// @notice stBTC contract.\\n // TODO: Remove slither disable when introducing upgradeability.\\n // slither-disable-next-line immutable-states\\n stBTC public stbtc;\\n\\n /// @notice Divisor used to compute the depositor fee taken from each deposit\\n /// and transferred to the treasury upon stake request finalization.\\n /// @dev That fee is computed as follows:\\n /// `depositorFee = depositedAmount / depositorFeeDivisor`\\n /// for example, if the depositor fee needs to be 2% of each deposit,\\n /// the `depositorFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n uint64 public depositorFeeDivisor;\\n\\n /// @notice Emitted when a stake request is initialized.\\n /// @dev Deposit details can be fetched from {{ Bridge.DepositRevealed }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that initialized the stake request.\\n /// @param staker The address to which the stBTC shares will be minted.\\n event StakeRequestInitialized(\\n uint256 indexed depositKey,\\n address indexed caller,\\n address indexed staker\\n );\\n\\n /// @notice Emitted when bridging completion has been notified.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that notified about bridging completion.\\n /// @param referral Identifier of a partner in the referral program.\\n /// @param bridgedAmount Amount of tBTC tokens that was bridged by the tBTC bridge.\\n /// @param depositorFee Depositor fee amount.\\n event BridgingCompleted(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint16 indexed referral,\\n uint256 bridgedAmount,\\n uint256 depositorFee\\n );\\n\\n /// @notice Emitted when a stake request is finalized.\\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that finalized the stake request.\\n /// @param stakedAmount Amount of staked tBTC tokens.\\n event StakeRequestFinalized(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint256 stakedAmount\\n );\\n\\n /// @notice Emitted when a stake request is queued.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that finalized the stake request.\\n /// @param queuedAmount Amount of queued tBTC tokens.\\n event StakeRequestQueued(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint256 queuedAmount\\n );\\n\\n /// @notice Emitted when a stake request is finalized from the queue.\\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that finalized the stake request.\\n /// @param stakedAmount Amount of staked tBTC tokens.\\n event StakeRequestFinalizedFromQueue(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint256 stakedAmount\\n );\\n\\n /// @notice Emitted when a queued stake request is cancelled.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param staker Address of the staker.\\n /// @param amountToStake Amount of queued tBTC tokens that got cancelled.\\n event StakeRequestCancelledFromQueue(\\n uint256 indexed depositKey,\\n address indexed staker,\\n uint256 amountToStake\\n );\\n\\n /// @notice Emitted when a depositor fee divisor is updated.\\n /// @param depositorFeeDivisor New value of the depositor fee divisor.\\n event DepositorFeeDivisorUpdated(uint64 depositorFeeDivisor);\\n\\n /// Reverts if the tBTC Token address is zero.\\n error TbtcTokenZeroAddress();\\n\\n /// Reverts if the stBTC address is zero.\\n error StbtcZeroAddress();\\n\\n /// @dev Staker address is zero.\\n error StakerIsZeroAddress();\\n\\n /// @dev Attempted to execute function for stake request in unexpected current\\n /// state.\\n error UnexpectedStakeRequestState(\\n StakeRequestState currentState,\\n StakeRequestState expectedState\\n );\\n\\n /// @dev Attempted to finalize bridging with depositor's contract tBTC balance\\n /// lower than the calculated bridged tBTC amount. This error means\\n /// that Governance should top-up the tBTC reserve for bridging fees\\n /// approximation.\\n error InsufficientTbtcBalance(\\n uint256 amountToStake,\\n uint256 currentBalance\\n );\\n\\n /// @dev Attempted to notify a bridging completion, while it was already\\n /// notified.\\n error BridgingCompletionAlreadyNotified();\\n\\n /// @dev Attempted to finalize a stake request, while bridging completion has\\n /// not been notified yet.\\n error BridgingNotCompleted();\\n\\n /// @dev Calculated depositor fee exceeds the amount of minted tBTC tokens.\\n error DepositorFeeExceedsBridgedAmount(\\n uint256 depositorFee,\\n uint256 bridgedAmount\\n );\\n\\n /// @dev Attempted to call bridging finalization for a stake request for\\n /// which the function was already called.\\n error BridgingFinalizationAlreadyCalled();\\n\\n /// @dev Attempted to finalize or cancel a stake request that was not added\\n /// to the queue, or was already finalized or cancelled.\\n error StakeRequestNotQueued();\\n\\n /// @dev Attempted to call function by an account that is not the staker.\\n error CallerNotStaker();\\n\\n /// @notice Acre Bitcoin Depositor contract constructor.\\n /// @param bridge tBTC Bridge contract instance.\\n /// @param tbtcVault tBTC Vault contract instance.\\n /// @param _tbtcToken tBTC token contract instance.\\n /// @param _stbtc stBTC contract instance.\\n // TODO: Move to initializer when making the contract upgradeable.\\n constructor(\\n address bridge,\\n address tbtcVault,\\n address _tbtcToken,\\n address _stbtc\\n ) Ownable(msg.sender) {\\n __AbstractTBTCDepositor_initialize(bridge, tbtcVault);\\n\\n if (address(_tbtcToken) == address(0)) {\\n revert TbtcTokenZeroAddress();\\n }\\n if (address(_stbtc) == address(0)) {\\n revert StbtcZeroAddress();\\n }\\n\\n tbtcToken = IERC20(_tbtcToken);\\n stbtc = stBTC(_stbtc);\\n\\n depositorFeeDivisor = 1000; // 1/1000 == 10bps == 0.1% == 0.001\\n }\\n\\n /// @notice This function allows staking process initialization for a Bitcoin\\n /// deposit made by an user with a P2(W)SH transaction. It uses the\\n /// supplied information to reveal a deposit to the tBTC Bridge contract.\\n /// @dev Requirements:\\n /// - The revealed vault address must match the TBTCVault address,\\n /// - All requirements from {Bridge#revealDepositWithExtraData}\\n /// function must be met.\\n /// - `staker` must be the staker address used in the P2(W)SH BTC\\n /// deposit transaction as part of the extra data.\\n /// - `referral` must be the referral info used in the P2(W)SH BTC\\n /// deposit transaction as part of the extra data.\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\\n /// @param staker The address to which the stBTC shares will be minted.\\n /// @param referral Data used for referral program.\\n function initializeStake(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n address staker,\\n uint16 referral\\n ) external {\\n if (staker == address(0)) revert StakerIsZeroAddress();\\n\\n // We don't check if the request was already initialized, as this check\\n // is enforced in `_initializeDeposit` when calling the\\n // `Bridge.revealDepositWithExtraData` function.\\n uint256 depositKey = _initializeDeposit(\\n fundingTx,\\n reveal,\\n encodeExtraData(staker, referral)\\n );\\n\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Unknown,\\n StakeRequestState.Initialized\\n );\\n\\n emit StakeRequestInitialized(depositKey, msg.sender, staker);\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC bridging process was finalized.\\n /// It stakes the tBTC from the given deposit into stBTC, emitting the\\n /// stBTC shares to the staker specified in the deposit extra data\\n /// and using the referral provided in the extra data.\\n /// @dev In case depositing in stBTC vault fails (e.g. because of the\\n /// maximum deposit limit being reached), the `queueStake` function\\n /// should be called to add the stake request to the staking queue.\\n /// @param depositKey Deposit key identifying the deposit.\\n function finalizeStake(uint256 depositKey) external {\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Initialized,\\n StakeRequestState.Finalized\\n );\\n\\n (uint256 amountToStake, address staker) = finalizeBridging(depositKey);\\n\\n emit StakeRequestFinalized(depositKey, msg.sender, amountToStake);\\n\\n // Deposit tBTC in stBTC.\\n tbtcToken.safeIncreaseAllowance(address(stbtc), amountToStake);\\n // slither-disable-next-line unused-return\\n stbtc.deposit(amountToStake, staker);\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC bridging process was finalized, in case the\\n /// `finalizeStake` failed due to stBTC vault deposit limit\\n /// being reached.\\n /// @dev It queues the stake request, until the stBTC vault is ready to\\n /// accept the deposit. The request must be finalized with `finalizeQueuedStake`\\n /// after the limit is increased or other user withdraws their funds\\n /// from the stBTC contract to make place for another deposit.\\n /// The staker has a possibility to submit `cancelQueuedStake` that\\n /// will withdraw the minted tBTC token and abort staking process.\\n /// @param depositKey Deposit key identifying the deposit.\\n function queueStake(uint256 depositKey) external {\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Initialized,\\n StakeRequestState.Queued\\n );\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n uint256 amountToStake;\\n (amountToStake, request.staker) = finalizeBridging(depositKey);\\n\\n request.queuedAmount = SafeCast.toUint88(amountToStake);\\n\\n emit StakeRequestQueued(depositKey, msg.sender, request.queuedAmount);\\n }\\n\\n /// @notice This function should be called for previously queued stake\\n /// request, when stBTC vault is able to accept a deposit.\\n /// @param depositKey Deposit key identifying the deposit.\\n function finalizeQueuedStake(uint256 depositKey) external {\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Queued,\\n StakeRequestState.FinalizedFromQueue\\n );\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n if (request.queuedAmount == 0) revert StakeRequestNotQueued();\\n\\n uint256 amountToStake = request.queuedAmount;\\n delete (request.queuedAmount);\\n\\n emit StakeRequestFinalizedFromQueue(\\n depositKey,\\n msg.sender,\\n amountToStake\\n );\\n\\n // Deposit tBTC in stBTC.\\n tbtcToken.safeIncreaseAllowance(address(stbtc), amountToStake);\\n // slither-disable-next-line unused-return\\n stbtc.deposit(amountToStake, request.staker);\\n }\\n\\n /// @notice Cancel queued stake.\\n /// The function can be called by the staker to recover tBTC that cannot\\n /// be finalized to stake in stBTC contract due to a deposit limit being\\n /// reached.\\n /// @dev This function can be called only after the stake request was added\\n /// to queue.\\n /// @dev Only staker provided in the extra data of the stake request can\\n /// call this function.\\n /// @param depositKey Deposit key identifying the deposit.\\n function cancelQueuedStake(uint256 depositKey) external {\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Queued,\\n StakeRequestState.CancelledFromQueue\\n );\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n if (request.queuedAmount == 0) revert StakeRequestNotQueued();\\n\\n // Check if caller is the staker.\\n if (msg.sender != request.staker) revert CallerNotStaker();\\n\\n uint256 amount = request.queuedAmount;\\n delete (request.queuedAmount);\\n\\n emit StakeRequestCancelledFromQueue(depositKey, request.staker, amount);\\n\\n tbtcToken.safeTransfer(request.staker, amount);\\n }\\n\\n /// @notice Updates the depositor fee divisor.\\n /// @param newDepositorFeeDivisor New depositor fee divisor value.\\n function updateDepositorFeeDivisor(\\n uint64 newDepositorFeeDivisor\\n ) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n depositorFeeDivisor = newDepositorFeeDivisor;\\n\\n emit DepositorFeeDivisorUpdated(newDepositorFeeDivisor);\\n }\\n\\n // TODO: Handle minimum deposit amount in tBTC Bridge vs stBTC.\\n\\n /// @notice Encodes staker address and referral as extra data.\\n /// @dev Packs the data to bytes32: 20 bytes of staker address and\\n /// 2 bytes of referral, 10 bytes of trailing zeros.\\n /// @param staker The address to which the stBTC shares will be minted.\\n /// @param referral Data used for referral program.\\n /// @return Encoded extra data.\\n function encodeExtraData(\\n address staker,\\n uint16 referral\\n ) public pure returns (bytes32) {\\n return bytes32(abi.encodePacked(staker, referral));\\n }\\n\\n /// @notice Decodes staker address and referral from extra data.\\n /// @dev Unpacks the data from bytes32: 20 bytes of staker address and\\n /// 2 bytes of referral, 10 bytes of trailing zeros.\\n /// @param extraData Encoded extra data.\\n /// @return staker The address to which the stBTC shares will be minted.\\n /// @return referral Data used for referral program.\\n function decodeExtraData(\\n bytes32 extraData\\n ) public pure returns (address staker, uint16 referral) {\\n // First 20 bytes of extra data is staker address.\\n staker = address(uint160(bytes20(extraData)));\\n // Next 2 bytes of extra data is referral info.\\n referral = uint16(bytes2(extraData << (8 * 20)));\\n }\\n\\n /// @notice This function is used for state transitions. It ensures the current\\n /// stakte matches expected, and updates the stake request to a new\\n /// state.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param expectedState Expected current stake request state.\\n /// @param newState New stake request state.\\n function transitionStakeRequestState(\\n uint256 depositKey,\\n StakeRequestState expectedState,\\n StakeRequestState newState\\n ) internal {\\n // Validate current stake request state.\\n if (stakeRequests[depositKey].state != expectedState)\\n revert UnexpectedStakeRequestState(\\n stakeRequests[depositKey].state,\\n expectedState\\n );\\n\\n // Transition to a new state.\\n stakeRequests[depositKey].state = newState;\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC minting process completed, meaning tBTC was\\n /// minted to this contract.\\n /// @dev It calculates the amount to stake based on the approximate minted\\n /// tBTC amount reduced by the depositor fee.\\n /// @dev IMPORTANT NOTE: The minted tBTC amount used by this function is an\\n /// approximation. See documentation of the\\n /// {{AbstractTBTCDepositor#_calculateTbtcAmount}} responsible for calculating\\n /// this value for more details.\\n /// @dev In case balance of tBTC tokens in this contract doesn't meet the\\n /// calculated tBTC amount, the function reverts with `InsufficientTbtcBalance`\\n /// error. This case requires Governance's validation, as tBTC Bridge minting\\n /// fees might changed in the way that reserve mentioned in\\n /// {{AbstractTBTCDepositor#_calculateTbtcAmount}} needs a top-up.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @return amountToStake tBTC token amount to stake after deducting tBTC bridging\\n /// fees and the depositor fee.\\n /// @return staker The address to which the stBTC shares will be minted.\\n function finalizeBridging(\\n uint256 depositKey\\n ) internal returns (uint256, address) {\\n (\\n uint256 initialDepositAmount,\\n uint256 tbtcAmount,\\n bytes32 extraData\\n ) = _finalizeDeposit(depositKey);\\n\\n // Check if current balance is sufficient to finalize bridging of `tbtcAmount`.\\n uint256 currentBalance = tbtcToken.balanceOf(address(this));\\n if (tbtcAmount > tbtcToken.balanceOf(address(this))) {\\n revert InsufficientTbtcBalance(tbtcAmount, currentBalance);\\n }\\n\\n // Compute depositor fee. The fee is calculated based on the initial funding\\n // transaction amount, before the tBTC protocol network fees were taken.\\n uint256 depositorFee = depositorFeeDivisor > 0\\n ? (initialDepositAmount / depositorFeeDivisor)\\n : 0;\\n\\n // Ensure the depositor fee does not exceed the approximate minted tBTC\\n // amount.\\n if (depositorFee >= tbtcAmount) {\\n revert DepositorFeeExceedsBridgedAmount(depositorFee, tbtcAmount);\\n }\\n\\n uint256 amountToStake = tbtcAmount - depositorFee;\\n\\n (address staker, uint16 referral) = decodeExtraData(extraData);\\n\\n // Emit event for accounting purposes to track partner's referral ID and\\n // depositor fee taken.\\n emit BridgingCompleted(\\n depositKey,\\n msg.sender,\\n referral,\\n tbtcAmount,\\n depositorFee\\n );\\n\\n // Transfer depositor fee to the treasury wallet.\\n if (depositorFee > 0) {\\n tbtcToken.safeTransfer(stbtc.treasury(), depositorFee);\\n }\\n\\n return (amountToStake, staker);\\n }\\n}\\n\",\"keccak256\":\"0x35f811a27cfb344b8153534c7e72388516e11de67f67179c467da0ad6c711711\",\"license\":\"GPL-3.0-only\"},\"contracts/Dispatcher.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\nimport \\\"./Router.sol\\\";\\nimport \\\"./stBTC.sol\\\";\\n\\n/// @title Dispatcher\\n/// @notice Dispatcher is a contract that routes tBTC from stBTC to\\n/// yield vaults and back. Vaults supply yield strategies with tBTC that\\n/// generate yield for Bitcoin holders.\\ncontract Dispatcher is Router, Ownable2Step {\\n using SafeERC20 for IERC20;\\n\\n /// Struct holds information about a vault.\\n struct VaultInfo {\\n bool authorized;\\n }\\n\\n /// The main stBTC contract holding tBTC deposited by stakers.\\n stBTC public immutable stbtc;\\n /// tBTC token contract.\\n IERC20 public immutable tbtc;\\n /// Address of the maintainer bot.\\n address public maintainer;\\n\\n /// Authorized Yield Vaults that implement ERC4626 standard. These\\n /// vaults deposit assets to yield strategies, e.g. Uniswap V3\\n /// WBTC/TBTC pool. Vault can be a part of Acre ecosystem or can be\\n /// implemented externally. As long as it complies with ERC4626\\n /// standard and is authorized by the owner it can be plugged into\\n /// Acre.\\n address[] public vaults;\\n /// Mapping of vaults to their information.\\n mapping(address => VaultInfo) public vaultsInfo;\\n\\n /// Emitted when a vault is authorized.\\n /// @param vault Address of the vault.\\n event VaultAuthorized(address indexed vault);\\n\\n /// Emitted when a vault is deauthorized.\\n /// @param vault Address of the vault.\\n event VaultDeauthorized(address indexed vault);\\n\\n /// Emitted when tBTC is routed to a vault.\\n /// @param vault Address of the vault.\\n /// @param amount Amount of tBTC.\\n /// @param sharesOut Amount of received shares.\\n event DepositAllocated(\\n address indexed vault,\\n uint256 amount,\\n uint256 sharesOut\\n );\\n\\n /// Emitted when the maintainer address is updated.\\n /// @param maintainer Address of the new maintainer.\\n event MaintainerUpdated(address indexed maintainer);\\n\\n /// Reverts if the vault is already authorized.\\n error VaultAlreadyAuthorized();\\n\\n /// Reverts if the vault is not authorized.\\n error VaultUnauthorized();\\n\\n /// Reverts if the caller is not the maintainer.\\n error NotMaintainer();\\n\\n /// Reverts if the address is zero.\\n error ZeroAddress();\\n\\n /// Modifier that reverts if the caller is not the maintainer.\\n modifier onlyMaintainer() {\\n if (msg.sender != maintainer) {\\n revert NotMaintainer();\\n }\\n _;\\n }\\n\\n constructor(stBTC _stbtc, IERC20 _tbtc) Ownable(msg.sender) {\\n stbtc = _stbtc;\\n tbtc = _tbtc;\\n }\\n\\n /// @notice Adds a vault to the list of authorized vaults.\\n /// @param vault Address of the vault to add.\\n function authorizeVault(address vault) external onlyOwner {\\n if (isVaultAuthorized(vault)) {\\n revert VaultAlreadyAuthorized();\\n }\\n\\n vaults.push(vault);\\n vaultsInfo[vault].authorized = true;\\n\\n emit VaultAuthorized(vault);\\n }\\n\\n /// @notice Removes a vault from the list of authorized vaults.\\n /// @param vault Address of the vault to remove.\\n function deauthorizeVault(address vault) external onlyOwner {\\n if (!isVaultAuthorized(vault)) {\\n revert VaultUnauthorized();\\n }\\n\\n vaultsInfo[vault].authorized = false;\\n\\n for (uint256 i = 0; i < vaults.length; i++) {\\n if (vaults[i] == vault) {\\n vaults[i] = vaults[vaults.length - 1];\\n // slither-disable-next-line costly-loop\\n vaults.pop();\\n break;\\n }\\n }\\n\\n emit VaultDeauthorized(vault);\\n }\\n\\n /// @notice Updates the maintainer address.\\n /// @param newMaintainer Address of the new maintainer.\\n function updateMaintainer(address newMaintainer) external onlyOwner {\\n if (newMaintainer == address(0)) {\\n revert ZeroAddress();\\n }\\n\\n maintainer = newMaintainer;\\n\\n emit MaintainerUpdated(maintainer);\\n }\\n\\n /// TODO: make this function internal once the allocation distribution is\\n /// implemented\\n /// @notice Routes tBTC from stBTC to a vault. Can be called by the maintainer\\n /// only.\\n /// @param vault Address of the vault to route the assets to.\\n /// @param amount Amount of tBTC to deposit.\\n /// @param minSharesOut Minimum amount of shares to receive.\\n function depositToVault(\\n address vault,\\n uint256 amount,\\n uint256 minSharesOut\\n ) public onlyMaintainer {\\n if (!isVaultAuthorized(vault)) {\\n revert VaultUnauthorized();\\n }\\n\\n // slither-disable-next-line arbitrary-send-erc20\\n tbtc.safeTransferFrom(address(stbtc), address(this), amount);\\n tbtc.forceApprove(address(vault), amount);\\n\\n uint256 sharesOut = deposit(\\n IERC4626(vault),\\n address(stbtc),\\n amount,\\n minSharesOut\\n );\\n // slither-disable-next-line reentrancy-events\\n emit DepositAllocated(vault, amount, sharesOut);\\n }\\n\\n /// @notice Returns the list of authorized vaults.\\n function getVaults() public view returns (address[] memory) {\\n return vaults;\\n }\\n\\n /// @notice Returns true if the vault is authorized.\\n /// @param vault Address of the vault to check.\\n function isVaultAuthorized(address vault) public view returns (bool) {\\n return vaultsInfo[vault].authorized;\\n }\\n\\n /// TODO: implement redeem() / withdraw() functions\\n}\\n\",\"keccak256\":\"0x5adb54e73b82adf0befabef894d99d9bb5eb785895851764ec9f497a055ae47f\",\"license\":\"GPL-3.0-only\"},\"contracts/Router.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\n\\n/// @title Router\\n/// @notice Router is a contract that routes tBTC from stBTC to\\n/// a given vault and back. Vaults supply yield strategies with tBTC that\\n/// generate yield for Bitcoin holders.\\nabstract contract Router {\\n /// Thrown when amount of shares received is below the min set by caller.\\n /// @param vault Address of the vault.\\n /// @param sharesOut Amount of received shares.\\n /// @param minSharesOut Minimum amount of shares expected to receive.\\n error MinSharesError(\\n address vault,\\n uint256 sharesOut,\\n uint256 minSharesOut\\n );\\n\\n /// @notice Routes funds from stBTC to a vault. The amount of tBTC to\\n /// Shares of deposited tBTC are minted to the stBTC contract.\\n /// @param vault Address of the vault to route the funds to.\\n /// @param receiver Address of the receiver of the shares.\\n /// @param amount Amount of tBTC to deposit.\\n /// @param minSharesOut Minimum amount of shares to receive.\\n function deposit(\\n IERC4626 vault,\\n address receiver,\\n uint256 amount,\\n uint256 minSharesOut\\n ) internal returns (uint256 sharesOut) {\\n if ((sharesOut = vault.deposit(amount, receiver)) < minSharesOut) {\\n revert MinSharesError(address(vault), sharesOut, minSharesOut);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x520e27c613f1234755c23402524b048a81abd15222d7f318504992d490248812\",\"license\":\"GPL-3.0-only\"},\"contracts/stBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\nimport \\\"./Dispatcher.sol\\\";\\n\\n/// @title stBTC\\n/// @notice This contract implements the ERC-4626 tokenized vault standard. By\\n/// staking tBTC, users acquire a liquid staking token called stBTC,\\n/// commonly referred to as \\\"shares\\\". The staked tBTC is securely\\n/// deposited into Acre's vaults, where it generates yield over time.\\n/// Users have the flexibility to redeem stBTC, enabling them to\\n/// withdraw their staked tBTC along with the accrued yield.\\n/// @dev ERC-4626 is a standard to optimize and unify the technical parameters\\n/// of yield-bearing vaults. This contract facilitates the minting and\\n/// burning of shares (stBTC), which are represented as standard ERC20\\n/// tokens, providing a seamless exchange with tBTC tokens.\\ncontract stBTC is ERC4626, Ownable2Step {\\n using SafeERC20 for IERC20;\\n\\n /// Dispatcher contract that routes tBTC from stBTC to a given vault and back.\\n Dispatcher public dispatcher;\\n\\n /// Address of the treasury wallet, where fees should be transferred to.\\n address public treasury;\\n\\n /// Minimum amount for a single deposit operation. The value should be set\\n /// low enough so the deposits routed through Bitcoin Depositor contract won't\\n /// be rejected. It means that minimumDepositAmount should be lower than\\n /// tBTC protocol's depositDustThreshold reduced by all the minting fees taken\\n /// before depositing in the Acre contract.\\n uint256 public minimumDepositAmount;\\n\\n /// Maximum total amount of tBTC token held by Acre protocol.\\n uint256 public maximumTotalAssets;\\n\\n /// Emitted when the treasury wallet address is updated.\\n /// @param treasury New treasury wallet address.\\n event TreasuryUpdated(address treasury);\\n\\n /// Emitted when deposit parameters are updated.\\n /// @param minimumDepositAmount New value of the minimum deposit amount.\\n /// @param maximumTotalAssets New value of the maximum total assets amount.\\n event DepositParametersUpdated(\\n uint256 minimumDepositAmount,\\n uint256 maximumTotalAssets\\n );\\n\\n /// Emitted when the dispatcher contract is updated.\\n /// @param oldDispatcher Address of the old dispatcher contract.\\n /// @param newDispatcher Address of the new dispatcher contract.\\n event DispatcherUpdated(address oldDispatcher, address newDispatcher);\\n\\n /// Reverts if the amount is less than the minimum deposit amount.\\n /// @param amount Amount to check.\\n /// @param min Minimum amount to check 'amount' against.\\n error LessThanMinDeposit(uint256 amount, uint256 min);\\n\\n /// Reverts if the address is zero.\\n error ZeroAddress();\\n\\n /// Reverts if the address is disallowed.\\n error DisallowedAddress();\\n\\n constructor(\\n IERC20 _tbtc,\\n address _treasury\\n ) ERC4626(_tbtc) ERC20(\\\"Acre Staked Bitcoin\\\", \\\"stBTC\\\") Ownable(msg.sender) {\\n if (address(_treasury) == address(0)) {\\n revert ZeroAddress();\\n }\\n treasury = _treasury;\\n // TODO: Revisit the exact values closer to the launch.\\n minimumDepositAmount = 0.001 * 1e18; // 0.001 tBTC\\n maximumTotalAssets = 25 * 1e18; // 25 tBTC\\n }\\n\\n /// @notice Updates treasury wallet address.\\n /// @param newTreasury New treasury wallet address.\\n function updateTreasury(address newTreasury) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n if (newTreasury == address(0)) {\\n revert ZeroAddress();\\n }\\n if (newTreasury == address(this)) {\\n revert DisallowedAddress();\\n }\\n treasury = newTreasury;\\n\\n emit TreasuryUpdated(newTreasury);\\n }\\n\\n /// @notice Updates deposit parameters.\\n /// @dev To disable the limit for deposits, set the maximum total assets to\\n /// maximum (`type(uint256).max`).\\n /// @param _minimumDepositAmount New value of the minimum deposit amount. It\\n /// is the minimum amount for a single deposit operation.\\n /// @param _maximumTotalAssets New value of the maximum total assets amount.\\n /// It is the maximum amount of the tBTC token that the Acre protocol\\n /// can hold.\\n function updateDepositParameters(\\n uint256 _minimumDepositAmount,\\n uint256 _maximumTotalAssets\\n ) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n minimumDepositAmount = _minimumDepositAmount;\\n maximumTotalAssets = _maximumTotalAssets;\\n\\n emit DepositParametersUpdated(\\n _minimumDepositAmount,\\n _maximumTotalAssets\\n );\\n }\\n\\n // TODO: Implement a governed upgrade process that initiates an update and\\n // then finalizes it after a delay.\\n /// @notice Updates the dispatcher contract and gives it an unlimited\\n /// allowance to transfer staked tBTC.\\n /// @param newDispatcher Address of the new dispatcher contract.\\n function updateDispatcher(Dispatcher newDispatcher) external onlyOwner {\\n if (address(newDispatcher) == address(0)) {\\n revert ZeroAddress();\\n }\\n\\n address oldDispatcher = address(dispatcher);\\n\\n emit DispatcherUpdated(oldDispatcher, address(newDispatcher));\\n dispatcher = newDispatcher;\\n\\n // TODO: Once withdrawal/rebalancing is implemented, we need to revoke the\\n // approval of the vaults share tokens from the old dispatcher and approve\\n // a new dispatcher to manage the share tokens.\\n\\n if (oldDispatcher != address(0)) {\\n // Setting allowance to zero for the old dispatcher\\n IERC20(asset()).forceApprove(oldDispatcher, 0);\\n }\\n\\n // Setting allowance to max for the new dispatcher\\n IERC20(asset()).forceApprove(address(dispatcher), type(uint256).max);\\n }\\n\\n /// @notice Mints shares to receiver by depositing exactly amount of\\n /// tBTC tokens.\\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\\n /// which determines the minimum amount for a single deposit operation.\\n /// The amount of the assets has to be pre-approved in the tBTC\\n /// contract.\\n /// @param assets Approved amount of tBTC tokens to deposit.\\n /// @param receiver The address to which the shares will be minted.\\n /// @return Minted shares.\\n function deposit(\\n uint256 assets,\\n address receiver\\n ) public override returns (uint256) {\\n if (assets < minimumDepositAmount) {\\n revert LessThanMinDeposit(assets, minimumDepositAmount);\\n }\\n\\n return super.deposit(assets, receiver);\\n }\\n\\n /// @notice Mints shares to receiver by depositing tBTC tokens.\\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\\n /// which determines the minimum amount for a single deposit operation.\\n /// The amount of the assets has to be pre-approved in the tBTC\\n /// contract.\\n /// The msg.sender is required to grant approval for tBTC transfer.\\n /// To determine the total assets amount necessary for approval\\n /// corresponding to a given share amount, use the `previewMint` function.\\n /// @param shares Amount of shares to mint.\\n /// @param receiver The address to which the shares will be minted.\\n function mint(\\n uint256 shares,\\n address receiver\\n ) public override returns (uint256 assets) {\\n if ((assets = super.mint(shares, receiver)) < minimumDepositAmount) {\\n revert LessThanMinDeposit(assets, minimumDepositAmount);\\n }\\n }\\n\\n /// @notice Returns value of assets that would be exchanged for the amount of\\n /// shares owned by the `account`.\\n /// @param account Owner of shares.\\n /// @return Assets amount.\\n function assetsBalanceOf(address account) public view returns (uint256) {\\n return convertToAssets(balanceOf(account));\\n }\\n\\n /// @notice Returns the maximum amount of the tBTC token that can be\\n /// deposited into the vault for the receiver through a deposit\\n /// call. It takes into account the deposit parameter, maximum total\\n /// assets, which determines the total amount of tBTC token held by\\n /// Acre protocol.\\n /// @dev When the remaining amount of unused limit is less than the minimum\\n /// deposit amount, this function returns 0.\\n /// @return The maximum amount of tBTC token that can be deposited into\\n /// Acre protocol for the receiver.\\n function maxDeposit(address) public view override returns (uint256) {\\n if (maximumTotalAssets == type(uint256).max) {\\n return type(uint256).max;\\n }\\n\\n uint256 _totalAssets = totalAssets();\\n\\n return\\n _totalAssets >= maximumTotalAssets\\n ? 0\\n : maximumTotalAssets - _totalAssets;\\n }\\n\\n /// @notice Returns the maximum amount of the vault shares that can be\\n /// minted for the receiver, through a mint call.\\n /// @dev Since the stBTC contract limits the maximum total tBTC tokens this\\n /// function converts the maximum deposit amount to shares.\\n /// @return The maximum amount of the vault shares.\\n function maxMint(address receiver) public view override returns (uint256) {\\n uint256 _maxDeposit = maxDeposit(receiver);\\n\\n // slither-disable-next-line incorrect-equality\\n return\\n _maxDeposit == type(uint256).max\\n ? type(uint256).max\\n : convertToShares(_maxDeposit);\\n }\\n\\n /// @return Returns deposit parameters.\\n function depositParameters() public view returns (uint256, uint256) {\\n return (minimumDepositAmount, maximumTotalAssets);\\n }\\n}\\n\",\"keccak256\":\"0x6d980629590d39aa0c1acb2f38c1f100ef08e976cd67ba76c6f99b07ed43865b\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506040516200249b3803806200249b8339810160408190526200003491620002f4565b33806200005c57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000678162000106565b5062000074848462000124565b6001600160a01b0382166200009c5760405163182b2a8160e21b815260040160405180910390fd5b6001600160a01b038116620000c45760405163e4ee787760e01b815260040160405180910390fd5b603480546001600160a01b0319166001600160a01b0393841617905560358054919092166001600160e01b031990911617607d60a31b17905550620003519050565b603280546001600160a01b0319169055620001218162000285565b50565b6000546001600160a01b03161580156200014757506001546001600160a01b0316155b620001a75760405162461bcd60e51b815260206004820152602960248201527f4162737472616374544254434465706f7369746f7220616c726561647920696e6044820152681a5d1a585b1a5e995960ba1b606482015260840162000053565b6001600160a01b038216620001ff5760405162461bcd60e51b815260206004820152601d60248201527f42726964676520616464726573732063616e6e6f74206265207a65726f000000604482015260640162000053565b6001600160a01b038116620002575760405162461bcd60e51b815260206004820181905260248201527f544254435661756c7420616464726573732063616e6e6f74206265207a65726f604482015260640162000053565b600080546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b603180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516001600160a01b0381168114620002ef57600080fd5b919050565b600080600080608085870312156200030b57600080fd5b6200031685620002d7565b93506200032660208601620002d7565b92506200033660408601620002d7565b91506200034660608601620002d7565b905092959194509250565b61213a80620003616000396000f3fe608060405234801561001057600080fd5b506004361061016c5760003560e01c8063c143d675116100cd578063da9ad53c11610081578063e5d3d71411610066578063e5d3d71414610355578063e78cea9214610368578063f2fde38b1461037b57600080fd5b8063da9ad53c14610331578063e30c39781461034457600080fd5b8063c9f5a5d8116100b2578063c9f5a5d8146102b4578063d0714ad5146102c7578063d990d3ff1461031e57600080fd5b8063c143d67514610274578063c7ba0347146102a857600080fd5b8063774e2e90116101245780638da5cb5b116101095780638da5cb5b1461023d5780639bef6d521461024e578063b2e665bf1461026157600080fd5b8063774e2e90146101f257806379ba50971461023557600080fd5b80633d11a6ae116101555780633d11a6ae146101b657806369e1df8b146101d7578063715018a6146101ea57600080fd5b80630f36403a146101715780633647b205146101a1575b600080fd5b600154610184906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b46101af366004611977565b61038e565b005b6101c96101c43660046119cb565b61040c565b604051908152602001610198565b6101b46101e5366004611a00565b61047b565b6101b461055a565b610213610200366004611a00565b606081901c9160509190911c61ffff1690565b604080516001600160a01b03909316835261ffff909116602083015201610198565b6101b461056e565b6031546001600160a01b0316610184565b603554610184906001600160a01b031681565b6101b461026f366004611a00565b6105b7565b60355461028f90600160a01b900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610198565b6101c96402540be40081565b6101b46102c2366004611a00565b610714565b61030f6102d5366004611a00565b60336020526000908152604090205460ff81169061010081046001600160a01b031690600160a81b90046affffffffffffffffffffff1683565b60405161019893929190611a51565b6101b461032c366004611a89565b61084e565b6101b461033f366004611a00565b6108f2565b6032546001600160a01b0316610184565b603454610184906001600160a01b031681565b600054610184906001600160a01b031681565b6101b4610389366004611b0d565b6109a9565b610396610a27565b603580547fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b67ffffffffffffffff8416908102919091179091556040519081527f53a618edd6eab9ce346f438670ebd45da60fa3d85662375fae2b8beadf08faf39060200160405180910390a150565b6040516bffffffffffffffffffffffff19606084901b1660208201527fffff00000000000000000000000000000000000000000000000000000000000060f083901b16603482015260009060360160405160208183030381529060405261047290611b2a565b90505b92915050565b6104888160016003610a54565b6000818152603360205260408120906104a083610b0b565b83546001600160a01b03909116610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff90911617835590506104e381610dd7565b825474ffffffffffffffffffffffffffffffffffffffffff16600160a81b6affffffffffffffffffffff9283168102919091178085556040519190049091168152339084907ff412c1941036889a8a2aec22dca20565f685239ac78976dab58b52eb70f972fa9060200160405180910390a3505050565b610562610a27565b61056c6000610e2c565b565b60325433906001600160a01b031681146105ab5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b6105b481610e2c565b50565b6105c48160036004610a54565b600081815260336020526040812080549091600160a81b9091046affffffffffffffffffffff16900361060a57604051632145277d60e21b815260040160405180910390fd5b805474ffffffffffffffffffffffffffffffffffffffffff81168255604051600160a81b9091046affffffffffffffffffffff1680825290339084907ff0a477d0ba7b549d19236a4c6517edef5574c03ed185bad57c92c9323091af8f9060200160405180910390a3603554603454610690916001600160a01b03918216911683610e52565b6035548254604051636e553f6560e01b8152600481018490526001600160a01b0361010090920482166024820152911690636e553f65906044015b6020604051808303816000875af11580156106ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070e9190611b51565b50505050565b6107218160036005610a54565b600081815260336020526040812080549091600160a81b9091046affffffffffffffffffffff16900361076757604051632145277d60e21b815260040160405180910390fd5b805461010090046001600160a01b031633146107af576040517f709d46f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805474ffffffffffffffffffffffffffffffffffffffffff8116808355604051600160a81b9092046affffffffffffffffffffff16808352916101009091046001600160a01b03169084907f32aa57d54fb0ee2c9617ac9d5982ba7d88869fcbf89542a285d6c07b03dc504e9060200160405180910390a38154603454610849916001600160a01b03918216916101009091041683610ef5565b505050565b6001600160a01b03821661088e576040517ff606bf2a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006108a4858561089f868661040c565b610f69565b90506108b38160006001610a54565b6040516001600160a01b03841690339083907f8d019883471b734b0033fe25a5b76c3afefbbfa9e9b3dacdbabf505b9e4f455d90600090a45050505050565b6108ff8160016002610a54565b60008061090b83610b0b565b91509150336001600160a01b0316837f2b57d79a66895fd41ae6d27049952259b0d40a9b7c563a99b3f1844b288da08c8460405161094b91815260200190565b60405180910390a3603554603454610970916001600160a01b03918216911684610e52565b603554604051636e553f6560e01b8152600481018490526001600160a01b03838116602483015290911690636e553f65906044016106cb565b6109b1610a27565b603280546001600160a01b03831673ffffffffffffffffffffffffffffffffffffffff1990911681179091556109ef6031546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6031546001600160a01b0316331461056c5760405163118cdaa760e01b81523360048201526024016105a2565b816005811115610a6657610a66611a19565b60008481526033602052604090205460ff166005811115610a8957610a89611a19565b14610ad657600083815260336020526040908190205490517fbcbf502b0000000000000000000000000000000000000000000000000000000081526105a29160ff16908490600401611b6a565b6000838152603360205260409020805482919060ff19166001836005811115610b0157610b01611a19565b0217905550505050565b6000806000806000610b1c866110c6565b6034546040516370a0823160e01b815230600482015293965091945092506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b939190611b51565b6034546040516370a0823160e01b81523060048201529192506001600160a01b0316906370a0823190602401602060405180830381865afa158015610bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c009190611b51565b831115610c43576040517fcad48b6900000000000000000000000000000000000000000000000000000000815260048101849052602481018290526044016105a2565b603554600090600160a01b900467ffffffffffffffff16610c65576000610c83565b603554610c8390600160a01b900467ffffffffffffffff1686611b9b565b9050838110610cc8576040517f2395edf200000000000000000000000000000000000000000000000000000000815260048101829052602481018590526044016105a2565b6000610cd48286611bbd565b6040805187815260208101859052919250606086901c9161ffff605088901c1691829133918e917f6410e64d304208a5e90fc76ab4fbf4e7b8836705daeda8dde27611ae0524490a910160405180910390a48315610dc757603554604080517f61d027b30000000000000000000000000000000000000000000000000000000081529051610dc7926001600160a01b0316916361d027b39160048083019260209291908290030181865afa158015610d90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db49190611bdb565b6034546001600160a01b03169086610ef5565b5090999098509650505050505050565b60006affffffffffffffffffffff821115610e28576040517f6dfcc65000000000000000000000000000000000000000000000000000000000815260586004820152602481018390526044016105a2565b5090565b6032805473ffffffffffffffffffffffffffffffffffffffff191690556105b481611350565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edf9190611b51565b905061070e8484610ef08585611bf8565b6113af565b6040516001600160a01b0383811660248301526044820183905261084991859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611469565b6001546000906001600160a01b0316610f8860c0850160a08601611b0d565b6001600160a01b031614610fde5760405162461bcd60e51b815260206004820152601660248201527f5661756c742061646472657373206d69736d617463680000000000000000000060448201526064016105a2565b6000610ffe610fec866114e5565b610ff96020870187611c1d565b61154a565b60405163ffffffff4216815290915081907fa3ed7aef0745e1a91addae9e5daee7a8ace74852fec840b9d93da747855dd7b99060200160405180910390a26000546040517f86f014390000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906386f014399061108990889088908890600401611ce5565b600060405180830381600087803b1580156110a357600080fd5b505af11580156110b7573d6000803e3d6000fd5b509293505050505b9392505050565b600080546040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018490528291829182916001600160a01b03169063b02c43d09060240160e060405180830381865afa15801561112d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111519190611e60565b9050806040015163ffffffff166000036111ad5760405162461bcd60e51b815260206004820152601760248201527f4465706f736974206e6f7420696e697469616c697a656400000000000000000060448201526064016105a2565b6001546040517f6c626aa4000000000000000000000000000000000000000000000000000000008152600481018790526000916001600160a01b031690636c626aa49060240160408051808303816000875af1158015611211573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112359190611f1a565b9150508160a0015163ffffffff16600014158061125b575067ffffffffffffffff811615155b6112cd5760405162461bcd60e51b815260206004820152602360248201527f4465706f736974206e6f742066696e616c697a6564206279207468652062726960448201527f646765000000000000000000000000000000000000000000000000000000000060648201526084016105a2565b6402540be400826020015167ffffffffffffffff166112ec9190611f54565b945061130082602001518360800151611594565b6040805182815263ffffffff4216602082015291955087917f417b6288c9f637614f8b3f7a275fb4e44e517930fde949e463d58dfe0b97f28b910160405180910390a25060c00151929491935050565b603180546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261142e8482611717565b61070e576040516001600160a01b0384811660248301526000604483015261146391869182169063095ea7b390606401610f22565b61070e84825b600061147e6001600160a01b038416836117bf565b905080516000141580156114a35750808060200190518101906114a19190611f6b565b155b15610849576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105a2565b60006104756114f76020840184611f8d565b6115046020850185611fa8565b6115116040870187611fa8565b6115216080890160608a01611f8d565b60405160200161153696959493929190611fef565b6040516020818303038152906040526117cd565b6000828260405160200161157592919091825260e01b6001600160e01b031916602082015260240190565b60408051601f1981840301815291905280516020909101209392505050565b6000806402540be4006115a78486612031565b67ffffffffffffffff166115bb9190611f54565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166309b53f516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611612573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116369190612059565b63ffffffff169050600080821161164e576000611658565b6116588284611b9b565b905060008060009054906101000a90046001600160a01b03166001600160a01b031663c42b64d06040518163ffffffff1660e01b8152600401608060405180830381865afa1580156116ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d29190612076565b509250505060006402540be4008267ffffffffffffffff166116f49190611f54565b9050806117018487611bbd565b61170b9190611bbd565b98975050505050505050565b6000806000846001600160a01b03168460405161173491906120d5565b6000604051808303816000865af19150503d8060008114611771576040519150601f19603f3d011682016040523d82523d6000602084013e611776565b606091505b50915091508180156117a05750805115806117a05750808060200190518101906117a09190611f6b565b80156117b657506000856001600160a01b03163b115b95945050505050565b6060610472838360006117f4565b60006020600083516020850160025afa50602060006020600060025afa5050600051919050565b606081471015611832576040517fcd7860590000000000000000000000000000000000000000000000000000000081523060048201526024016105a2565b600080856001600160a01b0316848660405161184e91906120d5565b60006040518083038185875af1925050503d806000811461188b576040519150601f19603f3d011682016040523d82523d6000602084013e611890565b606091505b50915091506118a08683836118aa565b9695505050505050565b6060826118bf576118ba8261191f565b6110bf565b81511580156118d657506001600160a01b0384163b155b15611918576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016105a2565b50806110bf565b80511561192f5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff811681146105b457600080fd5b60006020828403121561198957600080fd5b81356110bf81611961565b6001600160a01b03811681146105b457600080fd5b80356119b481611994565b919050565b803561ffff811681146119b457600080fd5b600080604083850312156119de57600080fd5b82356119e981611994565b91506119f7602084016119b9565b90509250929050565b600060208284031215611a1257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60068110611a4d57634e487b7160e01b600052602160045260246000fd5b9052565b60608101611a5f8286611a2f565b6001600160a01b03841660208301526affffffffffffffffffffff83166040830152949350505050565b600080600080848603610120811215611aa157600080fd5b853567ffffffffffffffff811115611ab857600080fd5b860160808189031215611aca57600080fd5b945060c0601f1982011215611ade57600080fd5b5060208501925060e0850135611af381611994565b9150611b0261010086016119b9565b905092959194509250565b600060208284031215611b1f57600080fd5b81356110bf81611994565b80516020808301519190811015611b4b576000198160200360031b1b821691505b50919050565b600060208284031215611b6357600080fd5b5051919050565b60408101611b788285611a2f565b6110bf6020830184611a2f565b634e487b7160e01b600052601160045260246000fd5b600082611bb857634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561047557610475611b85565b80516119b481611994565b600060208284031215611bed57600080fd5b81516110bf81611994565b8082018082111561047557610475611b85565b63ffffffff811681146105b457600080fd5b600060208284031215611c2f57600080fd5b81356110bf81611c0b565b80356001600160e01b0319811681146119b457600080fd5b6000808335601e19843603018112611c6957600080fd5b830160208101925035905067ffffffffffffffff811115611c8957600080fd5b803603821315611c9857600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b80356bffffffffffffffffffffffff19811681146119b457600080fd5b60006101008083526001600160e01b031980611d0088611c3a565b1682850152611d126020880188611c52565b92506080610120860152611d2b61018086018483611c9f565b925050611d3b6040880188611c52565b85840360ff1901610140870152611d53848284611c9f565b9350505080611d6460608901611c3a565b166101608501525090508335611d7981611c0b565b63ffffffff811660208401525060208401357fffffffffffffffff0000000000000000000000000000000000000000000000008116808214611dba57600080fd5b80604085015250506bffffffffffffffffffffffff19611ddc60408601611cc8565b166060830152611dee60608501611cc8565b6bffffffffffffffffffffffff198116608084015250611e1060808501611c3a565b6001600160e01b0319811660a084015250611e2d60a085016119a9565b6001600160a01b031660c083015260e09091019190915292915050565b80516119b481611961565b80516119b481611c0b565b600060e08284031215611e7257600080fd5b60405160e0810181811067ffffffffffffffff82111715611ea357634e487b7160e01b600052604160045260246000fd5b604052611eaf83611bd0565b8152611ebd60208401611e4a565b6020820152611ece60408401611e55565b6040820152611edf60608401611bd0565b6060820152611ef060808401611e4a565b6080820152611f0160a08401611e55565b60a082015260c083015160c08201528091505092915050565b60008060408385031215611f2d57600080fd5b8251611f3881611961565b6020840151909250611f4981611961565b809150509250929050565b808202811582820484141761047557610475611b85565b600060208284031215611f7d57600080fd5b815180151581146110bf57600080fd5b600060208284031215611f9f57600080fd5b61047282611c3a565b6000808335601e19843603018112611fbf57600080fd5b83018035915067ffffffffffffffff821115611fda57600080fd5b602001915036819003821315611c9857600080fd5b60006001600160e01b03198089168352868860048501378683016004810160008152868882375093169390920160048101939093525050600801949350505050565b67ffffffffffffffff82811682821603908082111561205257612052611b85565b5092915050565b60006020828403121561206b57600080fd5b81516110bf81611c0b565b6000806000806080858703121561208c57600080fd5b845161209781611961565b60208601519094506120a881611961565b60408601519093506120b981611961565b60608601519092506120ca81611c0b565b939692955090935050565b6000825160005b818110156120f657602081860181015185830152016120dc565b50600092019182525091905056fea2646970667358221220462bf22e2a3e5c424c7897cc702ca2994745ded2b209ca480d6b59b6977ef88a64736f6c63430008150033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061016c5760003560e01c8063c143d675116100cd578063da9ad53c11610081578063e5d3d71411610066578063e5d3d71414610355578063e78cea9214610368578063f2fde38b1461037b57600080fd5b8063da9ad53c14610331578063e30c39781461034457600080fd5b8063c9f5a5d8116100b2578063c9f5a5d8146102b4578063d0714ad5146102c7578063d990d3ff1461031e57600080fd5b8063c143d67514610274578063c7ba0347146102a857600080fd5b8063774e2e90116101245780638da5cb5b116101095780638da5cb5b1461023d5780639bef6d521461024e578063b2e665bf1461026157600080fd5b8063774e2e90146101f257806379ba50971461023557600080fd5b80633d11a6ae116101555780633d11a6ae146101b657806369e1df8b146101d7578063715018a6146101ea57600080fd5b80630f36403a146101715780633647b205146101a1575b600080fd5b600154610184906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b46101af366004611977565b61038e565b005b6101c96101c43660046119cb565b61040c565b604051908152602001610198565b6101b46101e5366004611a00565b61047b565b6101b461055a565b610213610200366004611a00565b606081901c9160509190911c61ffff1690565b604080516001600160a01b03909316835261ffff909116602083015201610198565b6101b461056e565b6031546001600160a01b0316610184565b603554610184906001600160a01b031681565b6101b461026f366004611a00565b6105b7565b60355461028f90600160a01b900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610198565b6101c96402540be40081565b6101b46102c2366004611a00565b610714565b61030f6102d5366004611a00565b60336020526000908152604090205460ff81169061010081046001600160a01b031690600160a81b90046affffffffffffffffffffff1683565b60405161019893929190611a51565b6101b461032c366004611a89565b61084e565b6101b461033f366004611a00565b6108f2565b6032546001600160a01b0316610184565b603454610184906001600160a01b031681565b600054610184906001600160a01b031681565b6101b4610389366004611b0d565b6109a9565b610396610a27565b603580547fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b67ffffffffffffffff8416908102919091179091556040519081527f53a618edd6eab9ce346f438670ebd45da60fa3d85662375fae2b8beadf08faf39060200160405180910390a150565b6040516bffffffffffffffffffffffff19606084901b1660208201527fffff00000000000000000000000000000000000000000000000000000000000060f083901b16603482015260009060360160405160208183030381529060405261047290611b2a565b90505b92915050565b6104888160016003610a54565b6000818152603360205260408120906104a083610b0b565b83546001600160a01b03909116610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff90911617835590506104e381610dd7565b825474ffffffffffffffffffffffffffffffffffffffffff16600160a81b6affffffffffffffffffffff9283168102919091178085556040519190049091168152339084907ff412c1941036889a8a2aec22dca20565f685239ac78976dab58b52eb70f972fa9060200160405180910390a3505050565b610562610a27565b61056c6000610e2c565b565b60325433906001600160a01b031681146105ab5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b6105b481610e2c565b50565b6105c48160036004610a54565b600081815260336020526040812080549091600160a81b9091046affffffffffffffffffffff16900361060a57604051632145277d60e21b815260040160405180910390fd5b805474ffffffffffffffffffffffffffffffffffffffffff81168255604051600160a81b9091046affffffffffffffffffffff1680825290339084907ff0a477d0ba7b549d19236a4c6517edef5574c03ed185bad57c92c9323091af8f9060200160405180910390a3603554603454610690916001600160a01b03918216911683610e52565b6035548254604051636e553f6560e01b8152600481018490526001600160a01b0361010090920482166024820152911690636e553f65906044015b6020604051808303816000875af11580156106ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070e9190611b51565b50505050565b6107218160036005610a54565b600081815260336020526040812080549091600160a81b9091046affffffffffffffffffffff16900361076757604051632145277d60e21b815260040160405180910390fd5b805461010090046001600160a01b031633146107af576040517f709d46f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805474ffffffffffffffffffffffffffffffffffffffffff8116808355604051600160a81b9092046affffffffffffffffffffff16808352916101009091046001600160a01b03169084907f32aa57d54fb0ee2c9617ac9d5982ba7d88869fcbf89542a285d6c07b03dc504e9060200160405180910390a38154603454610849916001600160a01b03918216916101009091041683610ef5565b505050565b6001600160a01b03821661088e576040517ff606bf2a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006108a4858561089f868661040c565b610f69565b90506108b38160006001610a54565b6040516001600160a01b03841690339083907f8d019883471b734b0033fe25a5b76c3afefbbfa9e9b3dacdbabf505b9e4f455d90600090a45050505050565b6108ff8160016002610a54565b60008061090b83610b0b565b91509150336001600160a01b0316837f2b57d79a66895fd41ae6d27049952259b0d40a9b7c563a99b3f1844b288da08c8460405161094b91815260200190565b60405180910390a3603554603454610970916001600160a01b03918216911684610e52565b603554604051636e553f6560e01b8152600481018490526001600160a01b03838116602483015290911690636e553f65906044016106cb565b6109b1610a27565b603280546001600160a01b03831673ffffffffffffffffffffffffffffffffffffffff1990911681179091556109ef6031546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6031546001600160a01b0316331461056c5760405163118cdaa760e01b81523360048201526024016105a2565b816005811115610a6657610a66611a19565b60008481526033602052604090205460ff166005811115610a8957610a89611a19565b14610ad657600083815260336020526040908190205490517fbcbf502b0000000000000000000000000000000000000000000000000000000081526105a29160ff16908490600401611b6a565b6000838152603360205260409020805482919060ff19166001836005811115610b0157610b01611a19565b0217905550505050565b6000806000806000610b1c866110c6565b6034546040516370a0823160e01b815230600482015293965091945092506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b939190611b51565b6034546040516370a0823160e01b81523060048201529192506001600160a01b0316906370a0823190602401602060405180830381865afa158015610bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c009190611b51565b831115610c43576040517fcad48b6900000000000000000000000000000000000000000000000000000000815260048101849052602481018290526044016105a2565b603554600090600160a01b900467ffffffffffffffff16610c65576000610c83565b603554610c8390600160a01b900467ffffffffffffffff1686611b9b565b9050838110610cc8576040517f2395edf200000000000000000000000000000000000000000000000000000000815260048101829052602481018590526044016105a2565b6000610cd48286611bbd565b6040805187815260208101859052919250606086901c9161ffff605088901c1691829133918e917f6410e64d304208a5e90fc76ab4fbf4e7b8836705daeda8dde27611ae0524490a910160405180910390a48315610dc757603554604080517f61d027b30000000000000000000000000000000000000000000000000000000081529051610dc7926001600160a01b0316916361d027b39160048083019260209291908290030181865afa158015610d90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db49190611bdb565b6034546001600160a01b03169086610ef5565b5090999098509650505050505050565b60006affffffffffffffffffffff821115610e28576040517f6dfcc65000000000000000000000000000000000000000000000000000000000815260586004820152602481018390526044016105a2565b5090565b6032805473ffffffffffffffffffffffffffffffffffffffff191690556105b481611350565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edf9190611b51565b905061070e8484610ef08585611bf8565b6113af565b6040516001600160a01b0383811660248301526044820183905261084991859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611469565b6001546000906001600160a01b0316610f8860c0850160a08601611b0d565b6001600160a01b031614610fde5760405162461bcd60e51b815260206004820152601660248201527f5661756c742061646472657373206d69736d617463680000000000000000000060448201526064016105a2565b6000610ffe610fec866114e5565b610ff96020870187611c1d565b61154a565b60405163ffffffff4216815290915081907fa3ed7aef0745e1a91addae9e5daee7a8ace74852fec840b9d93da747855dd7b99060200160405180910390a26000546040517f86f014390000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906386f014399061108990889088908890600401611ce5565b600060405180830381600087803b1580156110a357600080fd5b505af11580156110b7573d6000803e3d6000fd5b509293505050505b9392505050565b600080546040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018490528291829182916001600160a01b03169063b02c43d09060240160e060405180830381865afa15801561112d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111519190611e60565b9050806040015163ffffffff166000036111ad5760405162461bcd60e51b815260206004820152601760248201527f4465706f736974206e6f7420696e697469616c697a656400000000000000000060448201526064016105a2565b6001546040517f6c626aa4000000000000000000000000000000000000000000000000000000008152600481018790526000916001600160a01b031690636c626aa49060240160408051808303816000875af1158015611211573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112359190611f1a565b9150508160a0015163ffffffff16600014158061125b575067ffffffffffffffff811615155b6112cd5760405162461bcd60e51b815260206004820152602360248201527f4465706f736974206e6f742066696e616c697a6564206279207468652062726960448201527f646765000000000000000000000000000000000000000000000000000000000060648201526084016105a2565b6402540be400826020015167ffffffffffffffff166112ec9190611f54565b945061130082602001518360800151611594565b6040805182815263ffffffff4216602082015291955087917f417b6288c9f637614f8b3f7a275fb4e44e517930fde949e463d58dfe0b97f28b910160405180910390a25060c00151929491935050565b603180546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261142e8482611717565b61070e576040516001600160a01b0384811660248301526000604483015261146391869182169063095ea7b390606401610f22565b61070e84825b600061147e6001600160a01b038416836117bf565b905080516000141580156114a35750808060200190518101906114a19190611f6b565b155b15610849576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105a2565b60006104756114f76020840184611f8d565b6115046020850185611fa8565b6115116040870187611fa8565b6115216080890160608a01611f8d565b60405160200161153696959493929190611fef565b6040516020818303038152906040526117cd565b6000828260405160200161157592919091825260e01b6001600160e01b031916602082015260240190565b60408051601f1981840301815291905280516020909101209392505050565b6000806402540be4006115a78486612031565b67ffffffffffffffff166115bb9190611f54565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166309b53f516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611612573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116369190612059565b63ffffffff169050600080821161164e576000611658565b6116588284611b9b565b905060008060009054906101000a90046001600160a01b03166001600160a01b031663c42b64d06040518163ffffffff1660e01b8152600401608060405180830381865afa1580156116ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d29190612076565b509250505060006402540be4008267ffffffffffffffff166116f49190611f54565b9050806117018487611bbd565b61170b9190611bbd565b98975050505050505050565b6000806000846001600160a01b03168460405161173491906120d5565b6000604051808303816000865af19150503d8060008114611771576040519150601f19603f3d011682016040523d82523d6000602084013e611776565b606091505b50915091508180156117a05750805115806117a05750808060200190518101906117a09190611f6b565b80156117b657506000856001600160a01b03163b115b95945050505050565b6060610472838360006117f4565b60006020600083516020850160025afa50602060006020600060025afa5050600051919050565b606081471015611832576040517fcd7860590000000000000000000000000000000000000000000000000000000081523060048201526024016105a2565b600080856001600160a01b0316848660405161184e91906120d5565b60006040518083038185875af1925050503d806000811461188b576040519150601f19603f3d011682016040523d82523d6000602084013e611890565b606091505b50915091506118a08683836118aa565b9695505050505050565b6060826118bf576118ba8261191f565b6110bf565b81511580156118d657506001600160a01b0384163b155b15611918576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016105a2565b50806110bf565b80511561192f5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff811681146105b457600080fd5b60006020828403121561198957600080fd5b81356110bf81611961565b6001600160a01b03811681146105b457600080fd5b80356119b481611994565b919050565b803561ffff811681146119b457600080fd5b600080604083850312156119de57600080fd5b82356119e981611994565b91506119f7602084016119b9565b90509250929050565b600060208284031215611a1257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60068110611a4d57634e487b7160e01b600052602160045260246000fd5b9052565b60608101611a5f8286611a2f565b6001600160a01b03841660208301526affffffffffffffffffffff83166040830152949350505050565b600080600080848603610120811215611aa157600080fd5b853567ffffffffffffffff811115611ab857600080fd5b860160808189031215611aca57600080fd5b945060c0601f1982011215611ade57600080fd5b5060208501925060e0850135611af381611994565b9150611b0261010086016119b9565b905092959194509250565b600060208284031215611b1f57600080fd5b81356110bf81611994565b80516020808301519190811015611b4b576000198160200360031b1b821691505b50919050565b600060208284031215611b6357600080fd5b5051919050565b60408101611b788285611a2f565b6110bf6020830184611a2f565b634e487b7160e01b600052601160045260246000fd5b600082611bb857634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561047557610475611b85565b80516119b481611994565b600060208284031215611bed57600080fd5b81516110bf81611994565b8082018082111561047557610475611b85565b63ffffffff811681146105b457600080fd5b600060208284031215611c2f57600080fd5b81356110bf81611c0b565b80356001600160e01b0319811681146119b457600080fd5b6000808335601e19843603018112611c6957600080fd5b830160208101925035905067ffffffffffffffff811115611c8957600080fd5b803603821315611c9857600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b80356bffffffffffffffffffffffff19811681146119b457600080fd5b60006101008083526001600160e01b031980611d0088611c3a565b1682850152611d126020880188611c52565b92506080610120860152611d2b61018086018483611c9f565b925050611d3b6040880188611c52565b85840360ff1901610140870152611d53848284611c9f565b9350505080611d6460608901611c3a565b166101608501525090508335611d7981611c0b565b63ffffffff811660208401525060208401357fffffffffffffffff0000000000000000000000000000000000000000000000008116808214611dba57600080fd5b80604085015250506bffffffffffffffffffffffff19611ddc60408601611cc8565b166060830152611dee60608501611cc8565b6bffffffffffffffffffffffff198116608084015250611e1060808501611c3a565b6001600160e01b0319811660a084015250611e2d60a085016119a9565b6001600160a01b031660c083015260e09091019190915292915050565b80516119b481611961565b80516119b481611c0b565b600060e08284031215611e7257600080fd5b60405160e0810181811067ffffffffffffffff82111715611ea357634e487b7160e01b600052604160045260246000fd5b604052611eaf83611bd0565b8152611ebd60208401611e4a565b6020820152611ece60408401611e55565b6040820152611edf60608401611bd0565b6060820152611ef060808401611e4a565b6080820152611f0160a08401611e55565b60a082015260c083015160c08201528091505092915050565b60008060408385031215611f2d57600080fd5b8251611f3881611961565b6020840151909250611f4981611961565b809150509250929050565b808202811582820484141761047557610475611b85565b600060208284031215611f7d57600080fd5b815180151581146110bf57600080fd5b600060208284031215611f9f57600080fd5b61047282611c3a565b6000808335601e19843603018112611fbf57600080fd5b83018035915067ffffffffffffffff821115611fda57600080fd5b602001915036819003821315611c9857600080fd5b60006001600160e01b03198089168352868860048501378683016004810160008152868882375093169390920160048101939093525050600801949350505050565b67ffffffffffffffff82811682821603908082111561205257612052611b85565b5092915050565b60006020828403121561206b57600080fd5b81516110bf81611c0b565b6000806000806080858703121561208c57600080fd5b845161209781611961565b60208601519094506120a881611961565b60408601519093506120b981611961565b60608601519092506120ca81611c0b565b939692955090935050565b6000825160005b818110156120f657602081860181015185830152016120dc565b50600092019182525091905056fea2646970667358221220462bf22e2a3e5c424c7897cc702ca2994745ded2b209ca480d6b59b6977ef88a64736f6c63430008150033", + "devdoc": { + "errors": { + "AddressEmptyCode(address)": [ + { + "details": "There's no code at `target` (it is not a contract)." + } + ], + "AddressInsufficientBalance(address)": [ + { + "details": "The ETH balance of the account is not enough to perform the operation." + } + ], + "BridgingCompletionAlreadyNotified()": [ + { + "details": "Attempted to notify a bridging completion, while it was already notified." + } + ], + "BridgingFinalizationAlreadyCalled()": [ + { + "details": "Attempted to call bridging finalization for a stake request for which the function was already called." + } + ], + "BridgingNotCompleted()": [ + { + "details": "Attempted to finalize a stake request, while bridging completion has not been notified yet." + } + ], + "CallerNotStaker()": [ + { + "details": "Attempted to call function by an account that is not the staker." + } + ], + "DepositorFeeExceedsBridgedAmount(uint256,uint256)": [ + { + "details": "Calculated depositor fee exceeds the amount of minted tBTC tokens." + } + ], + "FailedInnerCall()": [ + { + "details": "A call to an address target failed. The target may have reverted." + } + ], + "InsufficientTbtcBalance(uint256,uint256)": [ + { + "details": "Attempted to finalize bridging with depositor's contract tBTC balance lower than the calculated bridged tBTC amount. This error means that Governance should top-up the tBTC reserve for bridging fees approximation." + } + ], + "OwnableInvalidOwner(address)": [ + { + "details": "The owner is not a valid owner account. (eg. `address(0)`)" + } + ], + "OwnableUnauthorizedAccount(address)": [ + { + "details": "The caller account is not authorized to perform an operation." + } + ], + "SafeCastOverflowedUintDowncast(uint8,uint256)": [ + { + "details": "Value doesn't fit in an uint of `bits` size." + } + ], + "SafeERC20FailedOperation(address)": [ + { + "details": "An operation with an ERC20 token failed." + } + ], + "StakeRequestNotQueued()": [ + { + "details": "Attempted to finalize or cancel a stake request that was not added to the queue, or was already finalized or cancelled." + } + ], + "StakerIsZeroAddress()": [ + { + "details": "Staker address is zero." + } + ], + "UnexpectedStakeRequestState(uint8,uint8)": [ + { + "details": "Attempted to execute function for stake request in unexpected current state." + } + ] + }, + "events": { + "BridgingCompleted(uint256,address,uint16,uint256,uint256)": { + "params": { + "bridgedAmount": "Amount of tBTC tokens that was bridged by the tBTC bridge.", + "caller": "Address that notified about bridging completion.", + "depositKey": "Deposit key identifying the deposit.", + "depositorFee": "Depositor fee amount.", + "referral": "Identifier of a partner in the referral program." + } + }, + "DepositorFeeDivisorUpdated(uint64)": { + "params": { + "depositorFeeDivisor": "New value of the depositor fee divisor." + } + }, + "StakeRequestCancelledFromQueue(uint256,address,uint256)": { + "params": { + "amountToStake": "Amount of queued tBTC tokens that got cancelled.", + "depositKey": "Deposit key identifying the deposit.", + "staker": "Address of the staker." + } + }, + "StakeRequestFinalized(uint256,address,uint256)": { + "details": "Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.", + "params": { + "caller": "Address that finalized the stake request.", + "depositKey": "Deposit key identifying the deposit.", + "stakedAmount": "Amount of staked tBTC tokens." + } + }, + "StakeRequestFinalizedFromQueue(uint256,address,uint256)": { + "details": "Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.", + "params": { + "caller": "Address that finalized the stake request.", + "depositKey": "Deposit key identifying the deposit.", + "stakedAmount": "Amount of staked tBTC tokens." + } + }, + "StakeRequestInitialized(uint256,address,address)": { + "details": "Deposit details can be fetched from {{ Bridge.DepositRevealed }} event emitted in the same transaction.", + "params": { + "caller": "Address that initialized the stake request.", + "depositKey": "Deposit key identifying the deposit.", + "staker": "The address to which the stBTC shares will be minted." + } + }, + "StakeRequestQueued(uint256,address,uint256)": { + "params": { + "caller": "Address that finalized the stake request.", + "depositKey": "Deposit key identifying the deposit.", + "queuedAmount": "Amount of queued tBTC tokens." + } + } + }, + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "cancelQueuedStake(uint256)": { + "details": "This function can be called only after the stake request was added to queue.Only staker provided in the extra data of the stake request can call this function.", + "params": { + "depositKey": "Deposit key identifying the deposit." + } + }, + "constructor": { + "params": { + "_stbtc": "stBTC contract instance.", + "_tbtcToken": "tBTC token contract instance.", + "bridge": "tBTC Bridge contract instance.", + "tbtcVault": "tBTC Vault contract instance." + } + }, + "decodeExtraData(bytes32)": { + "details": "Unpacks the data from bytes32: 20 bytes of staker address and 2 bytes of referral, 10 bytes of trailing zeros.", + "params": { + "extraData": "Encoded extra data." + }, + "returns": { + "referral": "Data used for referral program.", + "staker": "The address to which the stBTC shares will be minted." + } + }, + "encodeExtraData(address,uint16)": { + "details": "Packs the data to bytes32: 20 bytes of staker address and 2 bytes of referral, 10 bytes of trailing zeros.", + "params": { + "referral": "Data used for referral program.", + "staker": "The address to which the stBTC shares will be minted." + }, + "returns": { + "_0": "Encoded extra data." + } + }, + "finalizeQueuedStake(uint256)": { + "params": { + "depositKey": "Deposit key identifying the deposit." + } + }, + "finalizeStake(uint256)": { + "details": "In case depositing in stBTC vault fails (e.g. because of the maximum deposit limit being reached), the `queueStake` function should be called to add the stake request to the staking queue.", + "params": { + "depositKey": "Deposit key identifying the deposit." + } + }, + "initializeStake((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)": { + "details": "Requirements: - The revealed vault address must match the TBTCVault address, - All requirements from {Bridge#revealDepositWithExtraData} function must be met. - `staker` must be the staker address used in the P2(W)SH BTC deposit transaction as part of the extra data. - `referral` must be the referral info used in the P2(W)SH BTC deposit transaction as part of the extra data. - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex` can be revealed only one time.", + "params": { + "fundingTx": "Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.", + "referral": "Data used for referral program.", + "reveal": "Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.", + "staker": "The address to which the stBTC shares will be minted." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "queueStake(uint256)": { + "details": "It queues the stake request, until the stBTC vault is ready to accept the deposit. The request must be finalized with `finalizeQueuedStake` after the limit is increased or other user withdraws their funds from the stBTC contract to make place for another deposit. The staker has a possibility to submit `cancelQueuedStake` that will withdraw the minted tBTC token and abort staking process.", + "params": { + "depositKey": "Deposit key identifying the deposit." + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + }, + "updateDepositorFeeDivisor(uint64)": { + "params": { + "newDepositorFeeDivisor": "New depositor fee divisor value." + } + } + }, + "stateVariables": { + "depositorFeeDivisor": { + "details": "That fee is computed as follows: `depositorFee = depositedAmount / depositorFeeDivisor` for example, if the depositor fee needs to be 2% of each deposit, the `depositorFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`." + }, + "stakeRequests": { + "details": "The key is a deposit key identifying the deposit." + } + }, + "title": "Acre Bitcoin Depositor contract.", + "version": 1 + }, + "userdoc": { + "errors": { + "StbtcZeroAddress()": [ + { + "notice": "Reverts if the stBTC address is zero." + } + ], + "TbtcTokenZeroAddress()": [ + { + "notice": "Reverts if the tBTC Token address is zero." + } + ] + }, + "events": { + "BridgingCompleted(uint256,address,uint16,uint256,uint256)": { + "notice": "Emitted when bridging completion has been notified." + }, + "DepositorFeeDivisorUpdated(uint64)": { + "notice": "Emitted when a depositor fee divisor is updated." + }, + "StakeRequestCancelledFromQueue(uint256,address,uint256)": { + "notice": "Emitted when a queued stake request is cancelled." + }, + "StakeRequestFinalized(uint256,address,uint256)": { + "notice": "Emitted when a stake request is finalized." + }, + "StakeRequestFinalizedFromQueue(uint256,address,uint256)": { + "notice": "Emitted when a stake request is finalized from the queue." + }, + "StakeRequestInitialized(uint256,address,address)": { + "notice": "Emitted when a stake request is initialized." + }, + "StakeRequestQueued(uint256,address,uint256)": { + "notice": "Emitted when a stake request is queued." + } + }, + "kind": "user", + "methods": { + "SATOSHI_MULTIPLIER()": { + "notice": "Multiplier to convert satoshi to TBTC token units." + }, + "bridge()": { + "notice": "Bridge contract address." + }, + "cancelQueuedStake(uint256)": { + "notice": "Cancel queued stake. The function can be called by the staker to recover tBTC that cannot be finalized to stake in stBTC contract due to a deposit limit being reached." + }, + "constructor": { + "notice": "Acre Bitcoin Depositor contract constructor." + }, + "decodeExtraData(bytes32)": { + "notice": "Decodes staker address and referral from extra data." + }, + "depositorFeeDivisor()": { + "notice": "Divisor used to compute the depositor fee taken from each deposit and transferred to the treasury upon stake request finalization." + }, + "encodeExtraData(address,uint16)": { + "notice": "Encodes staker address and referral as extra data." + }, + "finalizeQueuedStake(uint256)": { + "notice": "This function should be called for previously queued stake request, when stBTC vault is able to accept a deposit." + }, + "finalizeStake(uint256)": { + "notice": "This function should be called for previously initialized stake request, after tBTC bridging process was finalized. It stakes the tBTC from the given deposit into stBTC, emitting the stBTC shares to the staker specified in the deposit extra data and using the referral provided in the extra data." + }, + "initializeStake((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)": { + "notice": "This function allows staking process initialization for a Bitcoin deposit made by an user with a P2(W)SH transaction. It uses the supplied information to reveal a deposit to the tBTC Bridge contract." + }, + "queueStake(uint256)": { + "notice": "This function should be called for previously initialized stake request, after tBTC bridging process was finalized, in case the `finalizeStake` failed due to stBTC vault deposit limit being reached." + }, + "stakeRequests(uint256)": { + "notice": "Mapping of stake requests." + }, + "stbtc()": { + "notice": "stBTC contract." + }, + "tbtcToken()": { + "notice": "tBTC Token contract." + }, + "tbtcVault()": { + "notice": "TBTCVault contract address." + }, + "updateDepositorFeeDivisor(uint64)": { + "notice": "Updates the depositor fee divisor." + } + }, + "notice": "The contract integrates Acre staking with tBTC minting. User who wants to stake BTC in Acre should submit a Bitcoin transaction to the most recently created off-chain ECDSA wallets of the tBTC Bridge using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH) containing hashed information about this Depositor contract address, and staker's Ethereum address. Then, the staker initiates tBTC minting by revealing their Ethereum address along with their deposit blinding factor, refund public key hash and refund locktime on the tBTC Bridge through this Depositor contract. The off-chain ECDSA wallet and Optimistic Minting bots listen for these sorts of messages and when they get one, they check the Bitcoin network to make sure the deposit lines up. Majority of tBTC minting is finalized by the Optimistic Minting process, where Minter bot initializes minting process and if there is no veto from the Guardians, the process is finalized and tBTC minted to the Depositor address. If the revealed deposit is not handled by the Optimistic Minting process the off-chain ECDSA wallet may decide to pick the deposit transaction for sweeping, and when the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge and tBTC vault mint the tBTC token to the Depositor address. After tBTC is minted to the Depositor, on the stake finalization tBTC is staked in stBTC contract and stBTC shares are emitted to the staker.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 2683, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "bridge", + "offset": 0, + "slot": "0", + "type": "t_contract(IBridge)3087" + }, + { + "astId": 2687, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "tbtcVault", + "offset": 0, + "slot": "1", + "type": "t_contract(ITBTCVault)3107" + }, + { + "astId": 2691, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "__gap", + "offset": 0, + "slot": "2", + "type": "t_array(t_uint256)47_storage" + }, + { + "astId": 3585, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "_owner", + "offset": 0, + "slot": "49", + "type": "t_address" + }, + { + "astId": 3733, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "_pendingOwner", + "offset": 0, + "slot": "50", + "type": "t_address" + }, + { + "astId": 8874, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "stakeRequests", + "offset": 0, + "slot": "51", + "type": "t_mapping(t_uint256,t_struct(StakeRequest)8868_storage)" + }, + { + "astId": 8878, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "tbtcToken", + "offset": 0, + "slot": "52", + "type": "t_contract(IERC20)4710" + }, + { + "astId": 8882, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "stbtc", + "offset": 0, + "slot": "53", + "type": "t_contract(stBTC)10351" + }, + { + "astId": 8885, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "depositorFeeDivisor", + "offset": 20, + "slot": "53", + "type": "t_uint64" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)47_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[47]", + "numberOfBytes": "1504" + }, + "t_contract(IBridge)3087": { + "encoding": "inplace", + "label": "contract IBridge", + "numberOfBytes": "20" + }, + "t_contract(IERC20)4710": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_contract(ITBTCVault)3107": { + "encoding": "inplace", + "label": "contract ITBTCVault", + "numberOfBytes": "20" + }, + "t_contract(stBTC)10351": { + "encoding": "inplace", + "label": "contract stBTC", + "numberOfBytes": "20" + }, + "t_enum(StakeRequestState)8860": { + "encoding": "inplace", + "label": "enum AcreBitcoinDepositor.StakeRequestState", + "numberOfBytes": "1" + }, + "t_mapping(t_uint256,t_struct(StakeRequest)8868_storage)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => struct AcreBitcoinDepositor.StakeRequest)", + "numberOfBytes": "32", + "value": "t_struct(StakeRequest)8868_storage" + }, + "t_struct(StakeRequest)8868_storage": { + "encoding": "inplace", + "label": "struct AcreBitcoinDepositor.StakeRequest", + "members": [ + { + "astId": 8863, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "state", + "offset": 0, + "slot": "0", + "type": "t_enum(StakeRequestState)8860" + }, + { + "astId": 8865, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "staker", + "offset": 1, + "slot": "0", + "type": "t_address" + }, + { + "astId": 8867, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "queuedAmount", + "offset": 21, + "slot": "0", + "type": "t_uint88" + } + ], + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint64": { + "encoding": "inplace", + "label": "uint64", + "numberOfBytes": "8" + }, + "t_uint88": { + "encoding": "inplace", + "label": "uint88", + "numberOfBytes": "11" + } + } + } +} \ No newline at end of file diff --git a/core/deployments/sepolia/TbtcDepositor.json b/core/deployments/sepolia/TbtcDepositor.json deleted file mode 100644 index e832f94eb..000000000 --- a/core/deployments/sepolia/TbtcDepositor.json +++ /dev/null @@ -1,1073 +0,0 @@ -{ - "address": "0x94c99365944F122EeD3860696D3964D6B5c3c730", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_bridge", - "type": "address" - }, - { - "internalType": "address", - "name": "_tbtcVault", - "type": "address" - }, - { - "internalType": "address", - "name": "_tbtcToken", - "type": "address" - }, - { - "internalType": "address", - "name": "_stbtc", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - } - ], - "name": "AddressEmptyCode", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "AddressInsufficientBalance", - "type": "error" - }, - { - "inputs": [], - "name": "BridgingNotCompleted", - "type": "error" - }, - { - "inputs": [], - "name": "CallerNotReceiver", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "depositorFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bridgedAmount", - "type": "uint256" - } - ], - "name": "DepositorFeeExceedsBridgedAmount", - "type": "error" - }, - { - "inputs": [], - "name": "FailedInnerCall", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnableInvalidOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "OwnableUnauthorizedAccount", - "type": "error" - }, - { - "inputs": [], - "name": "ReceiverIsZeroAddress", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - } - ], - "name": "SafeERC20FailedOperation", - "type": "error" - }, - { - "inputs": [], - "name": "StakeRequestAlreadyFinalized", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint16", - "name": "referral", - "type": "uint16" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bridgedAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "depositorFee", - "type": "uint256" - } - ], - "name": "BridgingCompleted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "tbtcAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "finalizedAt", - "type": "uint32" - } - ], - "name": "DepositFinalized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "initializedAt", - "type": "uint32" - } - ], - "name": "DepositInitialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint64", - "name": "depositorFeeDivisor", - "type": "uint64" - } - ], - "name": "DepositorFeeDivisorUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountToStake", - "type": "uint256" - } - ], - "name": "StakeRequestFinalized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "receiver", - "type": "address" - } - ], - "name": "StakeRequestInitialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountToStake", - "type": "uint256" - } - ], - "name": "StakeRequestRecalled", - "type": "event" - }, - { - "inputs": [], - "name": "SATOSHI_MULTIPLIER", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "bridge", - "outputs": [ - { - "internalType": "contract IBridge", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "depositorFeeDivisor", - "outputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "uint16", - "name": "referral", - "type": "uint16" - } - ], - "name": "encodeExtraData", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - } - ], - "name": "finalizeStakeRequest", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes4", - "name": "version", - "type": "bytes4" - }, - { - "internalType": "bytes", - "name": "inputVector", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "outputVector", - "type": "bytes" - }, - { - "internalType": "bytes4", - "name": "locktime", - "type": "bytes4" - } - ], - "internalType": "struct IBridgeTypes.BitcoinTxInfo", - "name": "fundingTx", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint32", - "name": "fundingOutputIndex", - "type": "uint32" - }, - { - "internalType": "bytes8", - "name": "blindingFactor", - "type": "bytes8" - }, - { - "internalType": "bytes20", - "name": "walletPubKeyHash", - "type": "bytes20" - }, - { - "internalType": "bytes20", - "name": "refundPubKeyHash", - "type": "bytes20" - }, - { - "internalType": "bytes4", - "name": "refundLocktime", - "type": "bytes4" - }, - { - "internalType": "address", - "name": "vault", - "type": "address" - } - ], - "internalType": "struct IBridgeTypes.DepositRevealInfo", - "name": "reveal", - "type": "tuple" - }, - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "uint16", - "name": "referral", - "type": "uint16" - } - ], - "name": "initializeStakeRequest", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - } - ], - "name": "notifyBridgingCompleted", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "pendingDeposits", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - } - ], - "name": "recallStakeRequest", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "stakeRequests", - "outputs": [ - { - "internalType": "uint64", - "name": "finalizedAt", - "type": "uint64" - }, - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "uint16", - "name": "referral", - "type": "uint16" - }, - { - "internalType": "uint256", - "name": "amountToStake", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "stbtc", - "outputs": [ - { - "internalType": "contract stBTC", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "tbtcToken", - "outputs": [ - { - "internalType": "contract IERC20", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "tbtcVault", - "outputs": [ - { - "internalType": "contract ITBTCVault", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint64", - "name": "newDepositorFeeDivisor", - "type": "uint64" - } - ], - "name": "updateDepositorFeeDivisor", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0x3011d3cfe0b5c46457b742615b27e2bf14d600d0b5065d9fbecf5a4aaa156f9a", - "receipt": { - "to": null, - "from": "0x2d154A5c7cE9939274b89bbCe9f5B069E57b09A8", - "contractAddress": "0x94c99365944F122EeD3860696D3964D6B5c3c730", - "transactionIndex": 82, - "gasUsed": "1782857", - "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000400000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000c01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000012000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x400ca15fec6b03138b76dcf24adb360bae43054b70be28ee09ca072bdfe9b971", - "transactionHash": "0x3011d3cfe0b5c46457b742615b27e2bf14d600d0b5065d9fbecf5a4aaa156f9a", - "logs": [ - { - "transactionIndex": 82, - "blockNumber": 5206362, - "transactionHash": "0x3011d3cfe0b5c46457b742615b27e2bf14d600d0b5065d9fbecf5a4aaa156f9a", - "address": "0x94c99365944F122EeD3860696D3964D6B5c3c730", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000002d154a5c7ce9939274b89bbce9f5b069e57b09a8" - ], - "data": "0x", - "logIndex": 108, - "blockHash": "0x400ca15fec6b03138b76dcf24adb360bae43054b70be28ee09ca072bdfe9b971" - } - ], - "blockNumber": 5206362, - "cumulativeGasUsed": "8847472", - "status": 1, - "byzantium": true - }, - "args": [ - "0x9b1a7fE5a16A15F2f9475C5B231750598b113403", - "0xB5679dE944A79732A75CE556191DF11F489448d5", - "0x517f2982701695D4E52f1ECFBEf3ba31Df470161", - "0xF99139f09164B092bD9e8558984Becfb0d2eCb87" - ], - "numDeployments": 1, - "solcInputHash": "b22c277b248ba02f9ec5bf62d176f9ce", - "metadata": "{\"compiler\":{\"version\":\"0.8.21+commit.d9974bed\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_bridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tbtcVault\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tbtcToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stbtc\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BridgingNotCompleted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CallerNotReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositorFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bridgedAmount\",\"type\":\"uint256\"}],\"name\":\"DepositorFeeExceedsBridgedAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReceiverIsZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"SafeERC20FailedOperation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeRequestAlreadyFinalized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bridgedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"depositorFee\",\"type\":\"uint256\"}],\"name\":\"BridgingCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tbtcAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"finalizedAt\",\"type\":\"uint32\"}],\"name\":\"DepositFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"initializedAt\",\"type\":\"uint32\"}],\"name\":\"DepositInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositorFeeDivisor\",\"type\":\"uint64\"}],\"name\":\"DepositorFeeDivisorUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"}],\"name\":\"StakeRequestFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"StakeRequestInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"}],\"name\":\"StakeRequestRecalled\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"SATOSHI_MULTIPLIER\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contract IBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositorFeeDivisor\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"name\":\"encodeExtraData\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"finalizeStakeRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"struct IBridgeTypes.BitcoinTxInfo\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"struct IBridgeTypes.DepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"name\":\"initializeStakeRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"notifyBridgingCompleted\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"pendingDeposits\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"recallStakeRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"stakeRequests\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"finalizedAt\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stbtc\",\"outputs\":[{\"internalType\":\"contract stBTC\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcVault\",\"outputs\":[{\"internalType\":\"contract ITBTCVault\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"newDepositorFeeDivisor\",\"type\":\"uint64\"}],\"name\":\"updateDepositorFeeDivisor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AddressEmptyCode(address)\":[{\"details\":\"There's no code at `target` (it is not a contract).\"}],\"AddressInsufficientBalance(address)\":[{\"details\":\"The ETH balance of the account is not enough to perform the operation.\"}],\"BridgingNotCompleted()\":[{\"details\":\"Attempted to finalize a stake request, while bridging completion has not been notified yet.\"}],\"CallerNotReceiver()\":[{\"details\":\"Attempted to call function by an account that is not the receiver.\"}],\"DepositorFeeExceedsBridgedAmount(uint256,uint256)\":[{\"details\":\"Calculated depositor fee exceeds the amount of minted tBTC tokens.\"}],\"FailedInnerCall()\":[{\"details\":\"A call to an address target failed. The target may have reverted.\"}],\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}],\"ReceiverIsZeroAddress()\":[{\"details\":\"Receiver address is zero.\"}],\"SafeERC20FailedOperation(address)\":[{\"details\":\"An operation with an ERC20 token failed.\"}],\"StakeRequestAlreadyFinalized()\":[{\"details\":\"Attempted to finalize a stake request that was already finalized.\"}]},\"events\":{\"BridgingCompleted(uint256,address,uint16,uint256,uint256)\":{\"params\":{\"bridgedAmount\":\"Amount of tBTC tokens that was bridged by the tBTC bridge.\",\"caller\":\"Address that notified about bridging completion.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"depositorFee\":\"Depositor fee amount.\",\"referral\":\"Identifier of a partner in the referral program.\"}},\"DepositorFeeDivisorUpdated(uint64)\":{\"params\":{\"depositorFeeDivisor\":\"New value of the depositor fee divisor.\"}},\"StakeRequestFinalized(uint256,address,uint256)\":{\"details\":\"Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.\",\"params\":{\"amountToStake\":\"Amount of staked tBTC tokens.\",\"caller\":\"Address that finalized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\"}},\"StakeRequestInitialized(uint256,address,address)\":{\"details\":\"Deposit details can be fetched from {{ Bridge.DepositRevealed }} event emitted in the same transaction.\",\"params\":{\"caller\":\"Address that initialized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"receiver\":\"The address to which the stBTC shares will be minted.\"}},\"StakeRequestRecalled(uint256,address,uint256)\":{\"params\":{\"amountToStake\":\"Amount of recalled tBTC tokens.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"receiver\":\"Address of the receiver.\"}}},\"kind\":\"dev\",\"methods\":{\"constructor\":{\"params\":{\"_bridge\":\"tBTC Bridge contract instance.\",\"_stbtc\":\"stBTC contract instance.\",\"_tbtcVault\":\"tBTC Vault contract instance.\"}},\"encodeExtraData(address,uint16)\":{\"details\":\"Packs the data to bytes32: 20 bytes of receiver address and 2 bytes of referral, 10 bytes of trailing zeros.\",\"params\":{\"receiver\":\"The address to which the stBTC shares will be minted.\",\"referral\":\"Data used for referral program.\"},\"returns\":{\"_0\":\"Encoded extra data.\"}},\"finalizeStakeRequest(uint256)\":{\"details\":\"This function is expected to be called after `notifyBridgingCompleted`. In case depositing in stBTC vault fails (e.g. because of the maximum deposit limit being reached), the function should be retried after the limit is increased or other user withdraws their funds from the stBTC contract to make place for another deposit. The staker has a possibility to submit `recallStakeRequest` that will withdraw the minted tBTC token and abort staking process.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"initializeStakeRequest((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)\":{\"details\":\"Requirements: - The revealed vault address must match the TBTCVault address, - All requirements from {Bridge#revealDepositWithExtraData} function must be met. - `receiver` must be the receiver address used in the P2(W)SH BTC deposit transaction as part of the extra data. - `referral` must be the referral info used in the P2(W)SH BTC deposit transaction as part of the extra data. - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex` can be revealed only one time.\",\"params\":{\"fundingTx\":\"Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\",\"receiver\":\"The address to which the stBTC shares will be minted.\",\"referral\":\"Data used for referral program.\",\"reveal\":\"Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\"}},\"notifyBridgingCompleted(uint256)\":{\"details\":\"It calculates the amount to stake based on the approximate minted tBTC amount reduced by the depositor fee.IMPORTANT NOTE: The minted tBTC amount used by this function is an approximation. See documentation of the {{TBTCDepositorProxy#_calculateTbtcAmount}} responsible for calculating this value for more details.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"recallStakeRequest(uint256)\":{\"details\":\"This function can be called only after bridging in tBTC Bridge was completed. Only receiver provided in the extra data of the stake request can call this function.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"updateDepositorFeeDivisor(uint64)\":{\"params\":{\"newDepositorFeeDivisor\":\"New depositor fee divisor value.\"}}},\"stateVariables\":{\"depositorFeeDivisor\":{\"details\":\"That fee is computed as follows: `depositorFee = depositedAmount / depositorFeeDivisor` for example, if the depositor fee needs to be 2% of each deposit, the `depositorFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`.\"},\"stakeRequests\":{\"details\":\"The key is a deposit key identifying the deposit.\"}},\"title\":\"tBTC Depositor contract.\",\"version\":1},\"userdoc\":{\"events\":{\"BridgingCompleted(uint256,address,uint16,uint256,uint256)\":{\"notice\":\"Emitted when bridging completion has been notified.\"},\"DepositorFeeDivisorUpdated(uint64)\":{\"notice\":\"Emitted when a depositor fee divisor is updated.\"},\"StakeRequestFinalized(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is finalized.\"},\"StakeRequestInitialized(uint256,address,address)\":{\"notice\":\"Emitted when a stake request is initialized.\"},\"StakeRequestRecalled(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is recalled.\"}},\"kind\":\"user\",\"methods\":{\"SATOSHI_MULTIPLIER()\":{\"notice\":\"Multiplier to convert satoshi to TBTC token units.\"},\"bridge()\":{\"notice\":\"Bridge contract address.\"},\"constructor\":{\"notice\":\"Tbtc Depositor contract constructor.\"},\"depositorFeeDivisor()\":{\"notice\":\"Divisor used to compute the depositor fee taken from each deposit and transferred to the treasury upon stake request finalization.\"},\"encodeExtraData(address,uint16)\":{\"notice\":\"Encode receiver address and referral as extra data.\"},\"finalizeStakeRequest(uint256)\":{\"notice\":\"This function should be called for previously initialized stake request, after tBTC bridging process was finalized. It stakes the tBTC from the given deposit into stBTC, emitting the stBTC shares to the receiver specified in the deposit extra data and using the referral provided in the extra data.\"},\"initializeStakeRequest((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)\":{\"notice\":\"This function allows staking process initialization for a Bitcoin deposit made by an user with a P2(W)SH transaction. It uses the supplied information to reveal a deposit to the tBTC Bridge contract.\"},\"notifyBridgingCompleted(uint256)\":{\"notice\":\"This function should be called for previously initialized stake request, after tBTC minting process completed, meaning tBTC was minted to this contract.\"},\"pendingDeposits(uint256)\":{\"notice\":\"Mapping holding information about pending deposits that have been initialized but not finalized yet. If the deposit is not in this mapping it means it has already been finalized or it has not been initialized yet.\"},\"recallStakeRequest(uint256)\":{\"notice\":\"Recall bridged tBTC tokens from being requested to stake. This function can be called by the staker to recover tBTC that cannot be finalized to stake in stBTC contract due to a deposit limit being reached.\"},\"stakeRequests(uint256)\":{\"notice\":\"Mapping of stake requests.\"},\"stbtc()\":{\"notice\":\"stBTC contract.\"},\"tbtcToken()\":{\"notice\":\"tBTC Token contract.\"},\"tbtcVault()\":{\"notice\":\"TBTCVault contract address.\"},\"updateDepositorFeeDivisor(uint64)\":{\"notice\":\"Updates the depositor fee divisor.\"}},\"notice\":\"The contract integrates Acre staking with tBTC minting. User who wants to stake BTC in Acre should submit a Bitcoin transaction to the most recently created off-chain ECDSA wallets of the tBTC Bridge using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH) containing hashed information about this Depositor contract address, and staker's Ethereum address. Then, the staker initiates tBTC minting by revealing their Ethereum address along with their deposit blinding factor, refund public key hash and refund locktime on the tBTC Bridge through this Depositor contract. The off-chain ECDSA wallet listens for these sorts of messages and when it gets one, it checks the Bitcoin network to make sure the deposit lines up. If it does, the off-chain ECDSA wallet may decide to pick the deposit transaction for sweeping, and when the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge and tBTC vault mint the tBTC token to the Depositor address. After tBTC is minted to the Depositor, on the stake finalization tBTC is staked in stBTC contract and stBTC shares are emitted to the receiver pointed by the staker.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TbtcDepositor.sol\":\"TbtcDepositor\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to \\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\nPermission is hereby granted, free of charge, to any person obtaining\\na copy of this software and associated documentation files (the\\n\\\"Software\\\"), to deal in the Software without restriction, including\\nwithout limitation the rights to use, copy, modify, merge, publish,\\ndistribute, sublicense, and/or sell copies of the Software, and to\\npermit persons to whom the Software is furnished to do so, subject to\\nthe following conditions:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\\n*/\\n\\n\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\n\\nimport \\\"./IBridge.sol\\\";\\nimport \\\"./ITBTCVault.sol\\\";\\n\\n/// @title Abstract AbstractTBTCDepositor contract.\\n/// @notice This abstract contract is meant to facilitate integration of protocols\\n/// aiming to use tBTC as an underlying Bitcoin bridge.\\n///\\n/// Such an integrator is supposed to:\\n/// - Create a child contract inheriting from this abstract contract\\n/// - Call the `__AbstractTBTCDepositor_initialize` initializer function\\n/// - Use the `_initializeDeposit` and `_finalizeDeposit` as part of their\\n/// business logic in order to initialize and finalize deposits.\\n///\\n/// @dev Example usage:\\n/// ```\\n/// // Example upgradeable integrator contract.\\n/// contract ExampleTBTCIntegrator is AbstractTBTCDepositor, Initializable {\\n/// /// @custom:oz-upgrades-unsafe-allow constructor\\n/// constructor() {\\n/// // Prevents the contract from being initialized again.\\n/// _disableInitializers();\\n/// }\\n///\\n/// function initialize(\\n/// address _bridge,\\n/// address _tbtcVault\\n/// ) external initializer {\\n/// __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\\n/// }\\n///\\n/// function startProcess(\\n/// IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n/// IBridgeTypes.DepositRevealInfo calldata reveal\\n/// ) external {\\n/// // Embed necessary context as extra data.\\n/// bytes32 extraData = ...;\\n///\\n/// uint256 depositKey = _initializeDeposit(\\n/// fundingTx,\\n/// reveal,\\n/// extraData\\n/// );\\n///\\n/// // Use the depositKey to track the process.\\n/// }\\n///\\n/// function finalizeProcess(uint256 depositKey) external {\\n/// (\\n/// uint256 initialDepositAmount,\\n/// uint256 tbtcAmount,\\n/// bytes32 extraData\\n/// ) = _finalizeDeposit(depositKey);\\n///\\n/// // Do something with the minted TBTC using context\\n/// // embedded in the extraData.\\n/// }\\n/// }\\nabstract contract AbstractTBTCDepositor {\\n using BTCUtils for bytes;\\n\\n /// @notice Multiplier to convert satoshi to TBTC token units.\\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\\n\\n /// @notice Bridge contract address.\\n IBridge public bridge;\\n /// @notice TBTCVault contract address.\\n ITBTCVault public tbtcVault;\\n /// @notice Mapping holding information about pending deposits that have\\n /// been initialized but not finalized yet. If the deposit is not\\n /// in this mapping it means it has already been finalized or it\\n /// has not been initialized yet.\\n mapping(uint256 => bool) public pendingDeposits;\\n\\n // Reserved storage space that allows adding more variables without affecting\\n // the storage layout of the child contracts. The convention from OpenZeppelin\\n // suggests the storage space should add up to 50 slots. If more variables are\\n // added in the upcoming versions one need to reduce the array size accordingly.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n event DepositInitialized(uint256 indexed depositKey, uint32 initializedAt);\\n\\n event DepositFinalized(\\n uint256 indexed depositKey,\\n uint256 tbtcAmount,\\n uint32 finalizedAt\\n );\\n\\n /// @notice Initializes the contract. MUST BE CALLED from the child\\n /// contract initializer.\\n // slither-disable-next-line dead-code\\n function __AbstractTBTCDepositor_initialize(\\n address _bridge,\\n address _tbtcVault\\n ) internal {\\n require(\\n address(bridge) == address(0) && address(tbtcVault) == address(0),\\n \\\"AbstractTBTCDepositor already initialized\\\"\\n );\\n\\n require(_bridge != address(0), \\\"Bridge address cannot be zero\\\");\\n require(_tbtcVault != address(0), \\\"TBTCVault address cannot be zero\\\");\\n\\n bridge = IBridge(_bridge);\\n tbtcVault = ITBTCVault(_tbtcVault);\\n }\\n\\n /// @notice Initializes a deposit by revealing it to the Bridge.\\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo` struct.\\n /// @param extraData 32-byte deposit extra data.\\n /// @return depositKey Deposit key computed as\\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\\n /// key can be used to refer to the deposit in the Bridge and\\n /// TBTCVault contracts.\\n /// @dev Requirements:\\n /// - The revealed vault address must match the TBTCVault address,\\n /// - All requirements from {Bridge#revealDepositWithExtraData}\\n /// function must be met.\\n // slither-disable-next-line dead-code\\n function _initializeDeposit(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n bytes32 extraData\\n ) internal returns (uint256) {\\n require(reveal.vault == address(tbtcVault), \\\"Vault address mismatch\\\");\\n\\n uint256 depositKey = _calculateDepositKey(\\n _calculateBitcoinTxHash(fundingTx),\\n reveal.fundingOutputIndex\\n );\\n\\n pendingDeposits[depositKey] = true;\\n\\n emit DepositInitialized(\\n depositKey,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n // The Bridge does not allow to reveal the same deposit twice and\\n // revealed deposits stay there forever. The transaction will revert\\n // if the deposit has already been revealed so, there is no need to do\\n // an explicit check here.\\n bridge.revealDepositWithExtraData(fundingTx, reveal, extraData);\\n\\n return depositKey;\\n }\\n\\n /// @notice Finalizes a deposit by calculating the amount of TBTC minted\\n /// for the deposit\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @return initialDepositAmount Amount of funding transaction deposit. In\\n /// TBTC token decimals precision.\\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit. In\\n /// TBTC token decimals precision.\\n /// @return extraData 32-byte deposit extra data.\\n /// @dev Requirements:\\n /// - The deposit must be initialized but not finalized\\n /// (in the context of this contract) yet.\\n /// - The deposit must be finalized on the Bridge side. That means the\\n /// deposit must be either swept or optimistically minted.\\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function is an\\n /// approximation. See documentation of the `calculateTbtcAmount`\\n /// responsible for calculating this value for more details.\\n // slither-disable-next-line dead-code\\n function _finalizeDeposit(uint256 depositKey)\\n internal\\n returns (\\n uint256 initialDepositAmount,\\n uint256 tbtcAmount,\\n bytes32 extraData\\n )\\n {\\n require(pendingDeposits[depositKey], \\\"Deposit not initialized\\\");\\n\\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\\n depositKey\\n );\\n (, uint64 finalizedAt) = tbtcVault.optimisticMintingRequests(\\n depositKey\\n );\\n\\n require(\\n deposit.sweptAt != 0 || finalizedAt != 0,\\n \\\"Deposit not finalized by the bridge\\\"\\n );\\n\\n // We can safely delete the deposit from the pending deposits mapping.\\n // This deposit cannot be initialized again because the bridge does not\\n // allow to reveal the same deposit twice. Deleting the deposit from\\n // the mapping will also prevent the finalizeDeposit function from\\n // being called again for the same deposit.\\n // slither-disable-next-line reentrancy-no-eth\\n delete pendingDeposits[depositKey];\\n\\n initialDepositAmount = deposit.amount * SATOSHI_MULTIPLIER;\\n\\n tbtcAmount = _calculateTbtcAmount(deposit.amount, deposit.treasuryFee);\\n\\n // slither-disable-next-line reentrancy-events\\n emit DepositFinalized(\\n depositKey,\\n tbtcAmount,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n extraData = deposit.extraData;\\n }\\n\\n /// @notice Calculates the amount of TBTC minted for the deposit.\\n /// @param depositAmountSat Deposit amount in satoshi (1e8 precision).\\n /// This is the actual amount deposited by the deposit creator, i.e.\\n /// the gross amount the Bridge's fees are cut from.\\n /// @param depositTreasuryFeeSat Deposit treasury fee in satoshi (1e8 precision).\\n /// This is an accurate value of the treasury fee that was actually\\n /// cut upon minting.\\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit.\\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function may\\n /// not correspond to the actual amount of TBTC minted for the deposit.\\n /// Although the treasury fee cut upon minting is known precisely,\\n /// this is not the case for the optimistic minting fee and the Bitcoin\\n /// transaction fee. To overcome that problem, this function just takes\\n /// the current maximum allowed values of both fees, at the moment of deposit\\n /// finalization. For the great majority of the deposits, such an\\n /// algorithm will return a tbtcAmount slightly lesser than the\\n /// actual amount of TBTC minted for the deposit. This will cause\\n /// some TBTC to be left in the contract and ensure there is enough\\n /// liquidity to finalize the deposit. However, in some rare cases,\\n /// where the actual values of those fees change between the deposit\\n /// minting and finalization, the tbtcAmount returned by this function\\n /// may be greater than the actual amount of TBTC minted for the deposit.\\n /// If this happens and the reserve coming from previous deposits\\n /// leftovers does not provide enough liquidity, the deposit will have\\n /// to wait for finalization until the reserve is refilled by subsequent\\n /// deposits or a manual top-up. The integrator is responsible for\\n /// handling such cases.\\n // slither-disable-next-line dead-code\\n function _calculateTbtcAmount(\\n uint64 depositAmountSat,\\n uint64 depositTreasuryFeeSat\\n ) internal view virtual returns (uint256) {\\n // Both deposit amount and treasury fee are in the 1e8 satoshi precision.\\n // We need to convert them to the 1e18 TBTC precision.\\n uint256 amountSubTreasury = (depositAmountSat - depositTreasuryFeeSat) *\\n SATOSHI_MULTIPLIER;\\n\\n uint256 omFeeDivisor = tbtcVault.optimisticMintingFeeDivisor();\\n uint256 omFee = omFeeDivisor > 0\\n ? (amountSubTreasury / omFeeDivisor)\\n : 0;\\n\\n // The deposit transaction max fee is in the 1e8 satoshi precision.\\n // We need to convert them to the 1e18 TBTC precision.\\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\\n\\n return amountSubTreasury - omFee - txMaxFee;\\n }\\n\\n /// @notice Calculates the deposit key for the given funding transaction\\n /// hash and funding output index.\\n /// @param fundingTxHash Funding transaction hash.\\n /// @param fundingOutputIndex Funding output index.\\n /// @return depositKey Deposit key computed as\\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\\n /// key can be used to refer to the deposit in the Bridge and\\n /// TBTCVault contracts.\\n // slither-disable-next-line dead-code\\n function _calculateDepositKey(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) internal pure returns (uint256) {\\n return\\n uint256(\\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\\n );\\n }\\n\\n /// @notice Calculates the Bitcoin transaction hash for the given Bitcoin\\n /// transaction data.\\n /// @param txInfo Bitcoin transaction data, see `IBridgeTypes.BitcoinTxInfo` struct.\\n /// @return txHash Bitcoin transaction hash.\\n // slither-disable-next-line dead-code\\n function _calculateBitcoinTxHash(IBridgeTypes.BitcoinTxInfo calldata txInfo)\\n internal\\n view\\n returns (bytes32)\\n {\\n return\\n abi\\n .encodePacked(\\n txInfo.version,\\n txInfo.inputVector,\\n txInfo.outputVector,\\n txInfo.locktime\\n )\\n .hash256View();\\n }\\n}\\n\",\"keccak256\":\"0xb9ad6f43c942e00dfe0591c94ccda43354d5cc14e4dec41aef721d7b947a4fb8\",\"license\":\"GPL-3.0-only\"},\"@keep-network/tbtc-v2/contracts/integrator/IBridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\n/// @notice Namespace which groups all types relevant to the IBridge interface.\\n/// @dev This is a mirror of the real types used in the Bridge contract.\\n/// This way, the `integrator` subpackage does not need to import\\n/// anything from the `bridge` subpackage and explicitly depend on it.\\n/// This simplifies the dependency graph for integrators.\\nlibrary IBridgeTypes {\\n /// @dev See bridge/BitcoinTx.sol#Info\\n struct BitcoinTxInfo {\\n bytes4 version;\\n bytes inputVector;\\n bytes outputVector;\\n bytes4 locktime;\\n }\\n\\n /// @dev See bridge/Deposit.sol#DepositRevealInfo\\n struct DepositRevealInfo {\\n uint32 fundingOutputIndex;\\n bytes8 blindingFactor;\\n bytes20 walletPubKeyHash;\\n bytes20 refundPubKeyHash;\\n bytes4 refundLocktime;\\n address vault;\\n }\\n\\n /// @dev See bridge/Deposit.sol#DepositRequest\\n struct DepositRequest {\\n address depositor;\\n uint64 amount;\\n uint32 revealedAt;\\n address vault;\\n uint64 treasuryFee;\\n uint32 sweptAt;\\n bytes32 extraData;\\n }\\n}\\n\\n/// @notice Interface of the Bridge contract.\\n/// @dev See bridge/Bridge.sol\\ninterface IBridge {\\n /// @dev See {Bridge#revealDepositWithExtraData}\\n function revealDepositWithExtraData(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n bytes32 extraData\\n ) external;\\n\\n /// @dev See {Bridge#deposits}\\n function deposits(uint256 depositKey)\\n external\\n view\\n returns (IBridgeTypes.DepositRequest memory);\\n\\n /// @dev See {Bridge#depositParameters}\\n function depositParameters()\\n external\\n view\\n returns (\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n}\\n\",\"keccak256\":\"0x4e598d96404a19609f511f10503e80f457602ad694d081df739571f67f6e0c4e\",\"license\":\"GPL-3.0-only\"},\"@keep-network/tbtc-v2/contracts/integrator/ITBTCVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\n/// @notice Interface of the TBTCVault contract.\\n/// @dev See vault/TBTCVault.sol\\ninterface ITBTCVault {\\n /// @dev See {TBTCVault#optimisticMintingRequests}\\n function optimisticMintingRequests(uint256 depositKey)\\n external\\n returns (uint64 requestedAt, uint64 finalizedAt);\\n\\n /// @dev See {TBTCVault#optimisticMintingFeeDivisor}\\n function optimisticMintingFeeDivisor() external view returns (uint32);\\n}\\n\",\"keccak256\":\"0xf259d64c1040e2cbc3d17653491e45c5c3da17f575dac1c175c63c8a5308908e\",\"license\":\"GPL-3.0-only\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Context} from \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * The initial owner is set to the address provided by the deployer. This can\\n * later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n /**\\n * @dev The caller account is not authorized to perform an operation.\\n */\\n error OwnableUnauthorizedAccount(address account);\\n\\n /**\\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\\n */\\n error OwnableInvalidOwner(address owner);\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\\n */\\n constructor(address initialOwner) {\\n if (initialOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(initialOwner);\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n if (owner() != _msgSender()) {\\n revert OwnableUnauthorizedAccount(_msgSender());\\n }\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n if (newOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xff6d0bb2e285473e5311d9d3caacb525ae3538a80758c10649a4d61029b017bb\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../token/ERC20/IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"../token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\n/**\\n * @dev Interface of the ERC4626 \\\"Tokenized Vault Standard\\\", as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\\n */\\ninterface IERC4626 is IERC20, IERC20Metadata {\\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed sender,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /**\\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\\n *\\n * - MUST be an ERC-20 token contract.\\n * - MUST NOT revert.\\n */\\n function asset() external view returns (address assetTokenAddress);\\n\\n /**\\n * @dev Returns the total amount of the underlying asset that is \\u201cmanaged\\u201d by Vault.\\n *\\n * - SHOULD include any compounding that occurs from yield.\\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT revert.\\n */\\n function totalAssets() external view returns (uint256 totalManagedAssets);\\n\\n /**\\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToShares(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\\n * through a deposit call.\\n *\\n * - MUST return a limited value if receiver is subject to some deposit limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\\n * - MUST NOT revert.\\n */\\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\\n * in the same transaction.\\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * deposit execution, and are accounted for during deposit.\\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\\n * - MUST return a limited value if receiver is subject to some mint limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\\n * - MUST NOT revert.\\n */\\n function maxMint(address receiver) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\\n * same transaction.\\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\\n * would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\\n */\\n function previewMint(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\\n * execution, and are accounted for during mint.\\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\\n * Vault, through a withdraw call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\\n * called\\n * in the same transaction.\\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * withdraw execution, and are accounted for during withdraw.\\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\\n * through a redeem call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxRedeem(address owner) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\\n * same transaction.\\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\\n * redemption would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\\n */\\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * redeem execution, and are accounted for during redeem.\\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\\n}\\n\",\"keccak256\":\"0x207f64371bc0fcc5be86713aa5da109a870cc3a6da50e93b64ee881e369b593d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC6093.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard ERC20 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\\n */\\ninterface IERC20Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC20InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC20InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `spender`\\u2019s `allowance`. Used in transfers.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC20InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC20InvalidSpender(address spender);\\n}\\n\\n/**\\n * @dev Standard ERC721 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\\n */\\ninterface IERC721Errors {\\n /**\\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\\n * Used in balance queries.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721InvalidOwner(address owner);\\n\\n /**\\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721NonexistentToken(uint256 tokenId);\\n\\n /**\\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param tokenId Identifier number of a token.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC721InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC721InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC721InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC721InvalidOperator(address operator);\\n}\\n\\n/**\\n * @dev Standard ERC1155 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\\n */\\ninterface IERC1155Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC1155InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC1155InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC1155MissingApprovalForAll(address operator, address owner);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC1155InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC1155InvalidOperator(address operator);\\n\\n /**\\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\\n * Used in batch transfers.\\n * @param idsLength Length of the array of token identifiers\\n * @param valuesLength Length of the array of token amounts\\n */\\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\\n}\\n\",\"keccak256\":\"0x60c65f701957fdd6faea1acb0bb45825791d473693ed9ecb34726fdfaa849dd7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"./IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"./extensions/IERC20Metadata.sol\\\";\\nimport {Context} from \\\"../../utils/Context.sol\\\";\\nimport {IERC20Errors} from \\\"../../interfaces/draft-IERC6093.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * The default value of {decimals} is 18. To change this, you should override\\n * this function so it returns a different value.\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n */\\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\\n mapping(address account => uint256) private _balances;\\n\\n mapping(address account => mapping(address spender => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the default value returned by this function, unless\\n * it's overridden.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return 18;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `value`.\\n */\\n function transfer(address to, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _approve(owner, spender, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `value`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `value`.\\n */\\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, value);\\n _transfer(from, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to`.\\n *\\n * This internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _transfer(address from, address to, uint256 value) internal {\\n if (from == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n if (to == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(from, to, value);\\n }\\n\\n /**\\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\\n * this function.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _update(address from, address to, uint256 value) internal virtual {\\n if (from == address(0)) {\\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\\n _totalSupply += value;\\n } else {\\n uint256 fromBalance = _balances[from];\\n if (fromBalance < value) {\\n revert ERC20InsufficientBalance(from, fromBalance, value);\\n }\\n unchecked {\\n // Overflow not possible: value <= fromBalance <= totalSupply.\\n _balances[from] = fromBalance - value;\\n }\\n }\\n\\n if (to == address(0)) {\\n unchecked {\\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\\n _totalSupply -= value;\\n }\\n } else {\\n unchecked {\\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\\n _balances[to] += value;\\n }\\n }\\n\\n emit Transfer(from, to, value);\\n }\\n\\n /**\\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\\n * Relies on the `_update` mechanism\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _mint(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(address(0), account, value);\\n }\\n\\n /**\\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\\n * Relies on the `_update` mechanism.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead\\n */\\n function _burn(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n _update(account, address(0), value);\\n }\\n\\n /**\\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n *\\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\\n */\\n function _approve(address owner, address spender, uint256 value) internal {\\n _approve(owner, spender, value, true);\\n }\\n\\n /**\\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\\n *\\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\\n * `Approval` event during `transferFrom` operations.\\n *\\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\\n * true using the following override:\\n * ```\\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\\n * super._approve(owner, spender, value, true);\\n * }\\n * ```\\n *\\n * Requirements are the same as {_approve}.\\n */\\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\\n if (owner == address(0)) {\\n revert ERC20InvalidApprover(address(0));\\n }\\n if (spender == address(0)) {\\n revert ERC20InvalidSpender(address(0));\\n }\\n _allowances[owner][spender] = value;\\n if (emitEvent) {\\n emit Approval(owner, spender, value);\\n }\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\\n *\\n * Does not update the allowance value in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Does not emit an {Approval} event.\\n */\\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n if (currentAllowance < value) {\\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\\n }\\n unchecked {\\n _approve(owner, spender, currentAllowance - value, false);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3e1fa9d1987f8d349dfb4d6fe93bf2ca014b52ba335cfac30bfe71e357e6f80\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the value of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the value of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\\n * caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\\n * allowance mechanism. `value` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 value) external returns (bool);\\n}\\n\",\"keccak256\":\"0xc6a8ff0ea489379b61faa647490411b80102578440ab9d84e9a957cc12164e70\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20, IERC20Metadata, ERC20} from \\\"../ERC20.sol\\\";\\nimport {SafeERC20} from \\\"../utils/SafeERC20.sol\\\";\\nimport {IERC4626} from \\\"../../../interfaces/IERC4626.sol\\\";\\nimport {Math} from \\\"../../../utils/math/Math.sol\\\";\\n\\n/**\\n * @dev Implementation of the ERC4626 \\\"Tokenized Vault Standard\\\" as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\\n *\\n * This extension allows the minting and burning of \\\"shares\\\" (represented using the ERC20 inheritance) in exchange for\\n * underlying \\\"assets\\\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\\n * the ERC20 standard. Any additional extensions included along it would affect the \\\"shares\\\" token represented by this\\n * contract and not the \\\"assets\\\" token which is an independent contract.\\n *\\n * [CAUTION]\\n * ====\\n * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning\\n * with a \\\"donation\\\" to the vault that inflates the price of a share. This is variously known as a donation or inflation\\n * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial\\n * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may\\n * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by\\n * verifying the amount received is as expected, using a wrapper that performs these checks such as\\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\\n *\\n * Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()`\\n * corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault\\n * decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself\\n * determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset\\n * (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's\\n * donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more\\n * expensive than it is profitable. More details about the underlying math can be found\\n * xref:erc4626.adoc#inflation-attack[here].\\n *\\n * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued\\n * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets\\n * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience\\n * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the\\n * `_convertToShares` and `_convertToAssets` functions.\\n *\\n * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].\\n * ====\\n */\\nabstract contract ERC4626 is ERC20, IERC4626 {\\n using Math for uint256;\\n\\n IERC20 private immutable _asset;\\n uint8 private immutable _underlyingDecimals;\\n\\n /**\\n * @dev Attempted to deposit more assets than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);\\n\\n /**\\n * @dev Attempted to mint more shares than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);\\n\\n /**\\n * @dev Attempted to withdraw more assets than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);\\n\\n /**\\n * @dev Attempted to redeem more shares than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);\\n\\n /**\\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\\n */\\n constructor(IERC20 asset_) {\\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\\n _underlyingDecimals = success ? assetDecimals : 18;\\n _asset = asset_;\\n }\\n\\n /**\\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\\n */\\n function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {\\n (bool success, bytes memory encodedDecimals) = address(asset_).staticcall(\\n abi.encodeCall(IERC20Metadata.decimals, ())\\n );\\n if (success && encodedDecimals.length >= 32) {\\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\\n if (returnedDecimals <= type(uint8).max) {\\n return (true, uint8(returnedDecimals));\\n }\\n }\\n return (false, 0);\\n }\\n\\n /**\\n * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This\\n * \\\"original\\\" value is cached during construction of the vault contract. If this read operation fails (e.g., the\\n * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.\\n *\\n * See {IERC20Metadata-decimals}.\\n */\\n function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {\\n return _underlyingDecimals + _decimalsOffset();\\n }\\n\\n /** @dev See {IERC4626-asset}. */\\n function asset() public view virtual returns (address) {\\n return address(_asset);\\n }\\n\\n /** @dev See {IERC4626-totalAssets}. */\\n function totalAssets() public view virtual returns (uint256) {\\n return _asset.balanceOf(address(this));\\n }\\n\\n /** @dev See {IERC4626-convertToShares}. */\\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-convertToAssets}. */\\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-maxDeposit}. */\\n function maxDeposit(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n /** @dev See {IERC4626-maxMint}. */\\n function maxMint(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n /** @dev See {IERC4626-maxWithdraw}. */\\n function maxWithdraw(address owner) public view virtual returns (uint256) {\\n return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-maxRedeem}. */\\n function maxRedeem(address owner) public view virtual returns (uint256) {\\n return balanceOf(owner);\\n }\\n\\n /** @dev See {IERC4626-previewDeposit}. */\\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-previewMint}. */\\n function previewMint(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Ceil);\\n }\\n\\n /** @dev See {IERC4626-previewWithdraw}. */\\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Ceil);\\n }\\n\\n /** @dev See {IERC4626-previewRedeem}. */\\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-deposit}. */\\n function deposit(uint256 assets, address receiver) public virtual returns (uint256) {\\n uint256 maxAssets = maxDeposit(receiver);\\n if (assets > maxAssets) {\\n revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);\\n }\\n\\n uint256 shares = previewDeposit(assets);\\n _deposit(_msgSender(), receiver, assets, shares);\\n\\n return shares;\\n }\\n\\n /** @dev See {IERC4626-mint}.\\n *\\n * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.\\n * In this case, the shares will be minted without requiring any assets to be deposited.\\n */\\n function mint(uint256 shares, address receiver) public virtual returns (uint256) {\\n uint256 maxShares = maxMint(receiver);\\n if (shares > maxShares) {\\n revert ERC4626ExceededMaxMint(receiver, shares, maxShares);\\n }\\n\\n uint256 assets = previewMint(shares);\\n _deposit(_msgSender(), receiver, assets, shares);\\n\\n return assets;\\n }\\n\\n /** @dev See {IERC4626-withdraw}. */\\n function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {\\n uint256 maxAssets = maxWithdraw(owner);\\n if (assets > maxAssets) {\\n revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);\\n }\\n\\n uint256 shares = previewWithdraw(assets);\\n _withdraw(_msgSender(), receiver, owner, assets, shares);\\n\\n return shares;\\n }\\n\\n /** @dev See {IERC4626-redeem}. */\\n function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {\\n uint256 maxShares = maxRedeem(owner);\\n if (shares > maxShares) {\\n revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);\\n }\\n\\n uint256 assets = previewRedeem(shares);\\n _withdraw(_msgSender(), receiver, owner, assets, shares);\\n\\n return assets;\\n }\\n\\n /**\\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\\n */\\n function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {\\n return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);\\n }\\n\\n /**\\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\\n */\\n function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {\\n return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);\\n }\\n\\n /**\\n * @dev Deposit/mint common workflow.\\n */\\n function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {\\n // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the\\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\\n // calls the vault, which is assumed not malicious.\\n //\\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\\n // assets are transferred and before the shares are minted, which is a valid state.\\n // slither-disable-next-line reentrancy-no-eth\\n SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\\n _mint(receiver, shares);\\n\\n emit Deposit(caller, receiver, assets, shares);\\n }\\n\\n /**\\n * @dev Withdraw/redeem common workflow.\\n */\\n function _withdraw(\\n address caller,\\n address receiver,\\n address owner,\\n uint256 assets,\\n uint256 shares\\n ) internal virtual {\\n if (caller != owner) {\\n _spendAllowance(owner, caller, shares);\\n }\\n\\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\\n // calls the vault, which is assumed not malicious.\\n //\\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\\n // shares are burned and after the assets are transferred, which is a valid state.\\n _burn(owner, shares);\\n SafeERC20.safeTransfer(_asset, receiver, assets);\\n\\n emit Withdraw(caller, receiver, owner, assets, shares);\\n }\\n\\n function _decimalsOffset() internal view virtual returns (uint8) {\\n return 0;\\n }\\n}\\n\",\"keccak256\":\"0x1837547e04d5fe5334eeb77a345683c22995f1e7aa033020757ddf83a80fc72d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0xaa761817f6cd7892fcf158b3c776b34551cde36f48ff9703d53898bc45a94ea2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x6008dabfe393240d73d7dd7688033f72740d570aa422254d29a7dce8568f3aff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\nimport {IERC20Permit} from \\\"../extensions/IERC20Permit.sol\\\";\\nimport {Address} from \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n /**\\n * @dev An operation with an ERC20 token failed.\\n */\\n error SafeERC20FailedOperation(address token);\\n\\n /**\\n * @dev Indicates a failed `decreaseAllowance` request.\\n */\\n error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\\n }\\n\\n /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n forceApprove(token, spender, oldAllowance + value);\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\\n * value, non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\\n unchecked {\\n uint256 currentAllowance = token.allowance(address(this), spender);\\n if (currentAllowance < requestedDecrease) {\\n revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\\n }\\n forceApprove(token, spender, currentAllowance - requestedDecrease);\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data);\\n if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\\n revert SafeERC20FailedOperation(address(token));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\\n }\\n}\\n\",\"keccak256\":\"0x37bb49513c49c87c4642a891b13b63571bc87013dde806617aa1efb54605f386\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev The ETH balance of the account is not enough to perform the operation.\\n */\\n error AddressInsufficientBalance(address account);\\n\\n /**\\n * @dev There's no code at `target` (it is not a contract).\\n */\\n error AddressEmptyCode(address target);\\n\\n /**\\n * @dev A call to an address target failed. The target may have reverted.\\n */\\n error FailedInnerCall();\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n if (address(this).balance < amount) {\\n revert AddressInsufficientBalance(address(this));\\n }\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n if (!success) {\\n revert FailedInnerCall();\\n }\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason or custom error, it is bubbled\\n * up by this function (like regular Solidity function calls). However, if\\n * the call reverted with no returned reason, this function reverts with a\\n * {FailedInnerCall} error.\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n if (address(this).balance < value) {\\n revert AddressInsufficientBalance(address(this));\\n }\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\\n * unsuccessful call.\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata\\n ) internal view returns (bytes memory) {\\n if (!success) {\\n _revert(returndata);\\n } else {\\n // only check if target is a contract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n if (returndata.length == 0 && target.code.length == 0) {\\n revert AddressEmptyCode(target);\\n }\\n return returndata;\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\\n * revert reason or with a default {FailedInnerCall} error.\\n */\\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\\n if (!success) {\\n _revert(returndata);\\n } else {\\n return returndata;\\n }\\n }\\n\\n /**\\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\\n */\\n function _revert(bytes memory returndata) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert FailedInnerCall();\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaf28a975a78550e45f65e559a3ad6a5ad43b9b8a37366999abd1b7084eb70721\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x75a4ee64c68dbd5f38bddd06e664a64c8271b4caa554fb6f0607dfd672bb4bf3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Muldiv operation overflow.\\n */\\n error MathOverflowedMulDiv();\\n\\n enum Rounding {\\n Floor, // Toward negative infinity\\n Ceil, // Toward positive infinity\\n Trunc, // Toward zero\\n Expand // Away from zero\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds towards infinity instead\\n * of rounding towards zero.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (b == 0) {\\n // Guarantee the same behavior as in a regular Solidity division.\\n return a / b;\\n }\\n\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\\n * denominator == 0.\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\\n * Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0 = x * y; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (denominator <= prod1) {\\n revert MathOverflowedMulDiv();\\n }\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\\n\\n uint256 twos = denominator & (0 - denominator);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\\n // works in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\\n * towards zero.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\\n */\\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\\n return uint8(rounding) % 2 == 1;\\n }\\n}\\n\",\"keccak256\":\"0x005ec64c6313f0555d59e278f9a7a5ab2db5bdc72a027f255a37c327af1ec02d\",\"license\":\"MIT\"},\"contracts/Dispatcher.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\nimport \\\"./Router.sol\\\";\\nimport \\\"./stBTC.sol\\\";\\n\\n/// @title Dispatcher\\n/// @notice Dispatcher is a contract that routes tBTC from stBTC to\\n/// yield vaults and back. Vaults supply yield strategies with tBTC that\\n/// generate yield for Bitcoin holders.\\ncontract Dispatcher is Router, Ownable {\\n using SafeERC20 for IERC20;\\n\\n /// Struct holds information about a vault.\\n struct VaultInfo {\\n bool authorized;\\n }\\n\\n /// The main stBTC contract holding tBTC deposited by stakers.\\n stBTC public immutable stbtc;\\n /// tBTC token contract.\\n IERC20 public immutable tbtc;\\n /// Address of the maintainer bot.\\n address public maintainer;\\n\\n /// Authorized Yield Vaults that implement ERC4626 standard. These\\n /// vaults deposit assets to yield strategies, e.g. Uniswap V3\\n /// WBTC/TBTC pool. Vault can be a part of Acre ecosystem or can be\\n /// implemented externally. As long as it complies with ERC4626\\n /// standard and is authorized by the owner it can be plugged into\\n /// Acre.\\n address[] public vaults;\\n /// Mapping of vaults to their information.\\n mapping(address => VaultInfo) public vaultsInfo;\\n\\n /// Emitted when a vault is authorized.\\n /// @param vault Address of the vault.\\n event VaultAuthorized(address indexed vault);\\n\\n /// Emitted when a vault is deauthorized.\\n /// @param vault Address of the vault.\\n event VaultDeauthorized(address indexed vault);\\n\\n /// Emitted when tBTC is routed to a vault.\\n /// @param vault Address of the vault.\\n /// @param amount Amount of tBTC.\\n /// @param sharesOut Amount of received shares.\\n event DepositAllocated(\\n address indexed vault,\\n uint256 amount,\\n uint256 sharesOut\\n );\\n\\n /// Emitted when the maintainer address is updated.\\n /// @param maintainer Address of the new maintainer.\\n event MaintainerUpdated(address indexed maintainer);\\n\\n /// Reverts if the vault is already authorized.\\n error VaultAlreadyAuthorized();\\n\\n /// Reverts if the vault is not authorized.\\n error VaultUnauthorized();\\n\\n /// Reverts if the caller is not the maintainer.\\n error NotMaintainer();\\n\\n /// Reverts if the address is zero.\\n error ZeroAddress();\\n\\n /// Modifier that reverts if the caller is not the maintainer.\\n modifier onlyMaintainer() {\\n if (msg.sender != maintainer) {\\n revert NotMaintainer();\\n }\\n _;\\n }\\n\\n constructor(stBTC _stbtc, IERC20 _tbtc) Ownable(msg.sender) {\\n stbtc = _stbtc;\\n tbtc = _tbtc;\\n }\\n\\n /// @notice Adds a vault to the list of authorized vaults.\\n /// @param vault Address of the vault to add.\\n function authorizeVault(address vault) external onlyOwner {\\n if (isVaultAuthorized(vault)) {\\n revert VaultAlreadyAuthorized();\\n }\\n\\n vaults.push(vault);\\n vaultsInfo[vault].authorized = true;\\n\\n emit VaultAuthorized(vault);\\n }\\n\\n /// @notice Removes a vault from the list of authorized vaults.\\n /// @param vault Address of the vault to remove.\\n function deauthorizeVault(address vault) external onlyOwner {\\n if (!isVaultAuthorized(vault)) {\\n revert VaultUnauthorized();\\n }\\n\\n vaultsInfo[vault].authorized = false;\\n\\n for (uint256 i = 0; i < vaults.length; i++) {\\n if (vaults[i] == vault) {\\n vaults[i] = vaults[vaults.length - 1];\\n // slither-disable-next-line costly-loop\\n vaults.pop();\\n break;\\n }\\n }\\n\\n emit VaultDeauthorized(vault);\\n }\\n\\n /// @notice Updates the maintainer address.\\n /// @param newMaintainer Address of the new maintainer.\\n function updateMaintainer(address newMaintainer) external onlyOwner {\\n if (newMaintainer == address(0)) {\\n revert ZeroAddress();\\n }\\n\\n maintainer = newMaintainer;\\n\\n emit MaintainerUpdated(maintainer);\\n }\\n\\n /// TODO: make this function internal once the allocation distribution is\\n /// implemented\\n /// @notice Routes tBTC from stBTC to a vault. Can be called by the maintainer\\n /// only.\\n /// @param vault Address of the vault to route the assets to.\\n /// @param amount Amount of tBTC to deposit.\\n /// @param minSharesOut Minimum amount of shares to receive.\\n function depositToVault(\\n address vault,\\n uint256 amount,\\n uint256 minSharesOut\\n ) public onlyMaintainer {\\n if (!isVaultAuthorized(vault)) {\\n revert VaultUnauthorized();\\n }\\n\\n // slither-disable-next-line arbitrary-send-erc20\\n tbtc.safeTransferFrom(address(stbtc), address(this), amount);\\n tbtc.forceApprove(address(vault), amount);\\n\\n uint256 sharesOut = deposit(\\n IERC4626(vault),\\n address(stbtc),\\n amount,\\n minSharesOut\\n );\\n // slither-disable-next-line reentrancy-events\\n emit DepositAllocated(vault, amount, sharesOut);\\n }\\n\\n /// @notice Returns the list of authorized vaults.\\n function getVaults() public view returns (address[] memory) {\\n return vaults;\\n }\\n\\n /// @notice Returns true if the vault is authorized.\\n /// @param vault Address of the vault to check.\\n function isVaultAuthorized(address vault) public view returns (bool) {\\n return vaultsInfo[vault].authorized;\\n }\\n\\n /// TODO: implement redeem() / withdraw() functions\\n}\\n\",\"keccak256\":\"0x0dd77692ab8c6059afa7b4a90f26733560b53fb66192e9912a2064103c5d41fb\",\"license\":\"GPL-3.0-only\"},\"contracts/Router.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\n\\n/// @title Router\\n/// @notice Router is a contract that routes tBTC from stBTC to\\n/// a given vault and back. Vaults supply yield strategies with tBTC that\\n/// generate yield for Bitcoin holders.\\nabstract contract Router {\\n /// Thrown when amount of shares received is below the min set by caller.\\n /// @param vault Address of the vault.\\n /// @param sharesOut Amount of received shares.\\n /// @param minSharesOut Minimum amount of shares expected to receive.\\n error MinSharesError(\\n address vault,\\n uint256 sharesOut,\\n uint256 minSharesOut\\n );\\n\\n /// @notice Routes funds from stBTC to a vault. The amount of tBTC to\\n /// Shares of deposited tBTC are minted to the stBTC contract.\\n /// @param vault Address of the vault to route the funds to.\\n /// @param receiver Address of the receiver of the shares.\\n /// @param amount Amount of tBTC to deposit.\\n /// @param minSharesOut Minimum amount of shares to receive.\\n function deposit(\\n IERC4626 vault,\\n address receiver,\\n uint256 amount,\\n uint256 minSharesOut\\n ) internal returns (uint256 sharesOut) {\\n if ((sharesOut = vault.deposit(amount, receiver)) < minSharesOut) {\\n revert MinSharesError(address(vault), sharesOut, minSharesOut);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x520e27c613f1234755c23402524b048a81abd15222d7f318504992d490248812\",\"license\":\"GPL-3.0-only\"},\"contracts/TbtcDepositor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport {SafeERC20} from \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {Math} from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\n\\nimport \\\"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\\\";\\n\\nimport {stBTC} from \\\"./stBTC.sol\\\";\\n\\n// TODO: Add Missfund token protection.\\n// TODO: Make Upgradable\\n\\n/// @title tBTC Depositor contract.\\n/// @notice The contract integrates Acre staking with tBTC minting.\\n/// User who wants to stake BTC in Acre should submit a Bitcoin transaction\\n/// to the most recently created off-chain ECDSA wallets of the tBTC Bridge\\n/// using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH)\\n/// containing hashed information about this Depositor contract address,\\n/// and staker's Ethereum address.\\n/// Then, the staker initiates tBTC minting by revealing their Ethereum\\n/// address along with their deposit blinding factor, refund public key\\n/// hash and refund locktime on the tBTC Bridge through this Depositor\\n/// contract.\\n/// The off-chain ECDSA wallet listens for these sorts of\\n/// messages and when it gets one, it checks the Bitcoin network to make\\n/// sure the deposit lines up. If it does, the off-chain ECDSA wallet\\n/// may decide to pick the deposit transaction for sweeping, and when\\n/// the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge\\n/// and tBTC vault mint the tBTC token to the Depositor address.\\n/// After tBTC is minted to the Depositor, on the stake finalization\\n/// tBTC is staked in stBTC contract and stBTC shares are emitted to the\\n/// receiver pointed by the staker.\\ncontract TbtcDepositor is AbstractTBTCDepositor, Ownable {\\n using BTCUtils for bytes;\\n using SafeERC20 for IERC20;\\n\\n struct StakeRequest {\\n // Timestamp at which the deposit request was initialized is not stored\\n // in this structure, as it is available under `Bridge.DepositRequest.revealedAt`.\\n\\n // UNIX timestamp at which the deposit request was finalized.\\n // 0 if not yet finalized.\\n uint64 finalizedAt;\\n // The address to which the stBTC shares will be minted.\\n address receiver;\\n // Identifier of a partner in the referral program.\\n uint16 referral;\\n // tBTC token amount to stake after deducting tBTC minting fees and the\\n // Depositor fee.\\n uint256 amountToStake;\\n }\\n\\n /// @notice tBTC Token contract.\\n IERC20 public immutable tbtcToken;\\n /// @notice stBTC contract.\\n stBTC public immutable stbtc;\\n\\n /// @notice Mapping of stake requests.\\n /// @dev The key is a deposit key identifying the deposit.\\n mapping(uint256 => StakeRequest) public stakeRequests;\\n\\n /// @notice Divisor used to compute the depositor fee taken from each deposit\\n /// and transferred to the treasury upon stake request finalization.\\n /// @dev That fee is computed as follows:\\n /// `depositorFee = depositedAmount / depositorFeeDivisor`\\n /// for example, if the depositor fee needs to be 2% of each deposit,\\n /// the `depositorFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n uint64 public depositorFeeDivisor;\\n\\n /// @notice Emitted when a stake request is initialized.\\n /// @dev Deposit details can be fetched from {{ Bridge.DepositRevealed }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that initialized the stake request.\\n /// @param receiver The address to which the stBTC shares will be minted.\\n event StakeRequestInitialized(\\n uint256 indexed depositKey,\\n address indexed caller,\\n address indexed receiver\\n );\\n\\n /// @notice Emitted when bridging completion has been notified.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that notified about bridging completion.\\n /// @param referral Identifier of a partner in the referral program.\\n /// @param bridgedAmount Amount of tBTC tokens that was bridged by the tBTC bridge.\\n /// @param depositorFee Depositor fee amount.\\n event BridgingCompleted(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint16 indexed referral,\\n uint256 bridgedAmount,\\n uint256 depositorFee\\n );\\n\\n /// @notice Emitted when a stake request is finalized.\\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that finalized the stake request.\\n /// @param amountToStake Amount of staked tBTC tokens.\\n event StakeRequestFinalized(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint256 amountToStake\\n );\\n\\n /// @notice Emitted when a stake request is recalled.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param receiver Address of the receiver.\\n /// @param amountToStake Amount of recalled tBTC tokens.\\n event StakeRequestRecalled(\\n uint256 indexed depositKey,\\n address indexed receiver,\\n uint256 amountToStake\\n );\\n\\n /// @notice Emitted when a depositor fee divisor is updated.\\n /// @param depositorFeeDivisor New value of the depositor fee divisor.\\n event DepositorFeeDivisorUpdated(uint64 depositorFeeDivisor);\\n\\n /// @dev Receiver address is zero.\\n error ReceiverIsZeroAddress();\\n\\n /// @dev Attempted to finalize a stake request, while bridging completion has\\n /// not been notified yet.\\n error BridgingNotCompleted();\\n\\n /// @dev Calculated depositor fee exceeds the amount of minted tBTC tokens.\\n error DepositorFeeExceedsBridgedAmount(\\n uint256 depositorFee,\\n uint256 bridgedAmount\\n );\\n\\n /// @dev Attempted to finalize a stake request that was already finalized.\\n error StakeRequestAlreadyFinalized();\\n\\n /// @dev Attempted to call function by an account that is not the receiver.\\n error CallerNotReceiver();\\n\\n /// @notice Tbtc Depositor contract constructor.\\n /// @param _bridge tBTC Bridge contract instance.\\n /// @param _tbtcVault tBTC Vault contract instance.\\n /// @param _stbtc stBTC contract instance.\\n // TODO: Move to initializer when making the contract upgradeable.\\n constructor(\\n address _bridge,\\n address _tbtcVault,\\n address _tbtcToken,\\n address _stbtc\\n ) Ownable(msg.sender) {\\n __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\\n\\n require(_tbtcToken != address(0), \\\"TBTCToken address cannot be zero\\\");\\n require(_stbtc != address(0), \\\"stBTC address cannot be zero\\\");\\n\\n tbtcToken = IERC20(_tbtcToken);\\n stbtc = stBTC(_stbtc);\\n\\n depositorFeeDivisor = 1000; // 1/1000 == 10bps == 0.1% == 0.001\\n }\\n\\n /// @notice This function allows staking process initialization for a Bitcoin\\n /// deposit made by an user with a P2(W)SH transaction. It uses the\\n /// supplied information to reveal a deposit to the tBTC Bridge contract.\\n /// @dev Requirements:\\n /// - The revealed vault address must match the TBTCVault address,\\n /// - All requirements from {Bridge#revealDepositWithExtraData}\\n /// function must be met.\\n /// - `receiver` must be the receiver address used in the P2(W)SH BTC\\n /// deposit transaction as part of the extra data.\\n /// - `referral` must be the referral info used in the P2(W)SH BTC\\n /// deposit transaction as part of the extra data.\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\\n /// @param receiver The address to which the stBTC shares will be minted.\\n /// @param referral Data used for referral program.\\n function initializeStakeRequest(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n address receiver,\\n uint16 referral\\n ) external {\\n if (receiver == address(0)) revert ReceiverIsZeroAddress();\\n\\n // We don't check if the request was already initialized, as this check\\n // is enforced in `_initializeDeposit` when calling the\\n // `Bridge.revealDepositWithExtraData` function.\\n\\n uint256 depositKey = _initializeDeposit(\\n fundingTx,\\n reveal,\\n encodeExtraData(receiver, referral)\\n );\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n request.receiver = receiver;\\n request.referral = referral;\\n\\n emit StakeRequestInitialized(depositKey, msg.sender, receiver);\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC minting process completed, meaning tBTC was\\n /// minted to this contract.\\n /// @dev It calculates the amount to stake based on the approximate minted\\n /// tBTC amount reduced by the depositor fee.\\n /// @dev IMPORTANT NOTE: The minted tBTC amount used by this function is an\\n /// approximation. See documentation of the\\n /// {{TBTCDepositorProxy#_calculateTbtcAmount}} responsible for calculating\\n /// this value for more details.\\n /// @param depositKey Deposit key identifying the deposit.\\n function notifyBridgingCompleted(uint256 depositKey) external {\\n (\\n uint256 depositAmount,\\n uint256 depositSubBridgingFeesAmount,\\n\\n ) = _finalizeDeposit(depositKey);\\n\\n // Compute depositor fee. The fee is calculated based on the initial funding\\n // transaction amount, before the tBTC protocol network fees were taken.\\n uint256 depositorFee = depositorFeeDivisor > 0\\n ? (depositAmount / depositorFeeDivisor)\\n : 0;\\n\\n // Ensure the depositor fee does not exceed the approximate minted tBTC\\n // amount.\\n if (depositorFee >= depositSubBridgingFeesAmount) {\\n revert DepositorFeeExceedsBridgedAmount(\\n depositorFee,\\n depositSubBridgingFeesAmount\\n );\\n }\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n request.amountToStake = depositSubBridgingFeesAmount - depositorFee;\\n\\n emit BridgingCompleted(\\n depositKey,\\n msg.sender,\\n request.referral,\\n depositSubBridgingFeesAmount,\\n depositorFee\\n );\\n\\n // Transfer depositor fee to the treasury wallet.\\n if (depositorFee > 0) {\\n tbtcToken.safeTransfer(stbtc.treasury(), depositorFee);\\n }\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC bridging process was finalized.\\n /// It stakes the tBTC from the given deposit into stBTC, emitting the\\n /// stBTC shares to the receiver specified in the deposit extra data\\n /// and using the referral provided in the extra data.\\n /// @dev This function is expected to be called after `notifyBridgingCompleted`.\\n /// In case depositing in stBTC vault fails (e.g. because of the\\n /// maximum deposit limit being reached), the function should be retried\\n /// after the limit is increased or other user withdraws their funds\\n /// from the stBTC contract to make place for another deposit.\\n /// The staker has a possibility to submit `recallStakeRequest` that\\n /// will withdraw the minted tBTC token and abort staking process.\\n /// @param depositKey Deposit key identifying the deposit.\\n function finalizeStakeRequest(uint256 depositKey) external {\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n if (request.amountToStake == 0) revert BridgingNotCompleted();\\n if (request.finalizedAt > 0) revert StakeRequestAlreadyFinalized();\\n\\n // solhint-disable-next-line not-rely-on-time\\n request.finalizedAt = uint64(block.timestamp);\\n\\n emit StakeRequestFinalized(\\n depositKey,\\n msg.sender,\\n request.amountToStake\\n );\\n\\n // Deposit tBTC in stBTC.\\n tbtcToken.safeIncreaseAllowance(address(stbtc), request.amountToStake);\\n // slither-disable-next-line unused-return\\n stbtc.deposit(request.amountToStake, request.receiver);\\n }\\n\\n /// @notice Recall bridged tBTC tokens from being requested to stake. This\\n /// function can be called by the staker to recover tBTC that cannot\\n /// be finalized to stake in stBTC contract due to a deposit limit being\\n /// reached.\\n /// @dev This function can be called only after bridging in tBTC Bridge was\\n /// completed. Only receiver provided in the extra data of the stake\\n /// request can call this function.\\n /// @param depositKey Deposit key identifying the deposit.\\n function recallStakeRequest(uint256 depositKey) external {\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n if (request.amountToStake == 0) revert BridgingNotCompleted();\\n if (request.finalizedAt > 0) revert StakeRequestAlreadyFinalized();\\n\\n // Check if caller is the receiver.\\n if (msg.sender != request.receiver) revert CallerNotReceiver();\\n\\n // solhint-disable-next-line not-rely-on-time\\n request.finalizedAt = uint64(block.timestamp);\\n\\n emit StakeRequestRecalled(\\n depositKey,\\n request.receiver,\\n request.amountToStake\\n );\\n\\n tbtcToken.safeTransfer(request.receiver, request.amountToStake);\\n }\\n\\n /// @notice Updates the depositor fee divisor.\\n /// @param newDepositorFeeDivisor New depositor fee divisor value.\\n function updateDepositorFeeDivisor(\\n uint64 newDepositorFeeDivisor\\n ) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n depositorFeeDivisor = newDepositorFeeDivisor;\\n\\n emit DepositorFeeDivisorUpdated(newDepositorFeeDivisor);\\n }\\n\\n // TODO: Handle minimum deposit amount in tBTC Bridge vs stBTC.\\n\\n /// @notice Encode receiver address and referral as extra data.\\n /// @dev Packs the data to bytes32: 20 bytes of receiver address and\\n /// 2 bytes of referral, 10 bytes of trailing zeros.\\n /// @param receiver The address to which the stBTC shares will be minted.\\n /// @param referral Data used for referral program.\\n /// @return Encoded extra data.\\n function encodeExtraData(\\n address receiver,\\n uint16 referral\\n ) public pure returns (bytes32) {\\n return bytes32(abi.encodePacked(receiver, referral));\\n }\\n}\\n\",\"keccak256\":\"0x1dc56bb3b4e6212341be7899343ae55fac01910dbeed6bef0088f722ad67a017\",\"license\":\"GPL-3.0-only\"},\"contracts/lib/ERC4626Fees.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// Inspired by https://docs.openzeppelin.com/contracts/5.x/erc4626#fees\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {ERC4626} from \\\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\\\";\\nimport {SafeERC20} from \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport {Math} from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\n\\n/// @dev ERC4626 vault with entry/exit fees expressed in https://en.wikipedia.org/wiki/Basis_point[basis point (bp)].\\nabstract contract ERC4626Fees is ERC4626 {\\n using Math for uint256;\\n\\n uint256 private constant _BASIS_POINT_SCALE = 1e4;\\n\\n // === Overrides ===\\n\\n /// @dev Preview taking an entry fee on deposit. See {IERC4626-previewDeposit}.\\n function previewDeposit(\\n uint256 assets\\n ) public view virtual override returns (uint256) {\\n uint256 fee = _feeOnTotal(assets, _entryFeeBasisPoints());\\n return super.previewDeposit(assets - fee);\\n }\\n\\n /// @dev Preview adding an entry fee on mint. See {IERC4626-previewMint}.\\n function previewMint(\\n uint256 shares\\n ) public view virtual override returns (uint256) {\\n uint256 assets = super.previewMint(shares);\\n return assets + _feeOnRaw(assets, _entryFeeBasisPoints());\\n }\\n\\n // TODO: add previewWithraw\\n\\n // TODO: add previewRedeem\\n\\n /// @dev Send entry fee to {_feeRecipient}. See {IERC4626-_deposit}.\\n function _deposit(\\n address caller,\\n address receiver,\\n uint256 assets,\\n uint256 shares\\n ) internal virtual override {\\n uint256 fee = _feeOnTotal(assets, _entryFeeBasisPoints());\\n address recipient = _feeRecipient();\\n\\n super._deposit(caller, receiver, assets, shares);\\n\\n if (fee > 0 && recipient != address(this)) {\\n SafeERC20.safeTransfer(IERC20(asset()), recipient, fee);\\n }\\n }\\n\\n // TODO: add withdraw\\n\\n // === Fee configuration ===\\n\\n // slither-disable-next-line dead-code\\n function _entryFeeBasisPoints() internal view virtual returns (uint256);\\n\\n // TODO: add exitFeeBasisPoints\\n\\n // slither-disable-next-line dead-code\\n function _feeRecipient() internal view virtual returns (address);\\n\\n // === Fee operations ===\\n\\n /// @dev Calculates the fees that should be added to an amount `assets`\\n /// that does not already include fees.\\n /// Used in {IERC4626-mint} and {IERC4626-withdraw} operations.\\n function _feeOnRaw(\\n uint256 assets,\\n uint256 feeBasisPoints\\n ) private pure returns (uint256) {\\n return\\n assets.mulDiv(\\n feeBasisPoints,\\n _BASIS_POINT_SCALE,\\n Math.Rounding.Ceil\\n );\\n }\\n\\n /// @dev Calculates the fee part of an amount `assets` that already includes fees.\\n /// Used in {IERC4626-deposit} and {IERC4626-redeem} operations.\\n function _feeOnTotal(\\n uint256 assets,\\n uint256 feeBasisPoints\\n ) private pure returns (uint256) {\\n return\\n assets.mulDiv(\\n feeBasisPoints,\\n feeBasisPoints + _BASIS_POINT_SCALE,\\n Math.Rounding.Ceil\\n );\\n }\\n}\\n\",\"keccak256\":\"0xccfc01be23cbc979745a6e7f3421c4d050dc2ad7ddb6d9e1543c8e681e91d596\",\"license\":\"MIT\"},\"contracts/stBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"./Dispatcher.sol\\\";\\nimport \\\"./lib/ERC4626Fees.sol\\\";\\n\\n/// @title stBTC\\n/// @notice This contract implements the ERC-4626 tokenized vault standard. By\\n/// staking tBTC, users acquire a liquid staking token called stBTC,\\n/// commonly referred to as \\\"shares\\\". The staked tBTC is securely\\n/// deposited into Acre's vaults, where it generates yield over time.\\n/// Users have the flexibility to redeem stBTC, enabling them to\\n/// withdraw their staked tBTC along with the accrued yield.\\n/// @dev ERC-4626 is a standard to optimize and unify the technical parameters\\n/// of yield-bearing vaults. This contract facilitates the minting and\\n/// burning of shares (stBTC), which are represented as standard ERC20\\n/// tokens, providing a seamless exchange with tBTC tokens.\\ncontract stBTC is ERC4626Fees, Ownable {\\n using SafeERC20 for IERC20;\\n\\n /// Dispatcher contract that routes tBTC from stBTC to a given vault and back.\\n Dispatcher public dispatcher;\\n\\n /// Address of the treasury wallet, where fees should be transferred to.\\n address public treasury;\\n\\n /// Entry fee basis points applied to entry fee calculation.\\n uint256 public entryFeeBasisPoints;\\n\\n /// Minimum amount for a single deposit operation. The value should be set\\n /// low enough so the deposits routed through TbtcDepositor contract won't\\n /// be rejected. It means that minimumDepositAmount should be lower than\\n /// tBTC protocol's depositDustThreshold reduced by all the minting fees taken\\n /// before depositing in the Acre contract.\\n uint256 public minimumDepositAmount;\\n\\n /// Maximum total amount of tBTC token held by Acre protocol.\\n uint256 public maximumTotalAssets;\\n\\n /// Emitted when a referral is used.\\n /// @param referral Used for referral program.\\n /// @param assets Amount of tBTC tokens staked.\\n event StakeReferral(uint16 indexed referral, uint256 assets);\\n\\n /// Emitted when the treasury wallet address is updated.\\n /// @param treasury New treasury wallet address.\\n event TreasuryUpdated(address treasury);\\n\\n /// Emitted when deposit parameters are updated.\\n /// @param minimumDepositAmount New value of the minimum deposit amount.\\n /// @param maximumTotalAssets New value of the maximum total assets amount.\\n event DepositParametersUpdated(\\n uint256 minimumDepositAmount,\\n uint256 maximumTotalAssets\\n );\\n\\n /// Emitted when the dispatcher contract is updated.\\n /// @param oldDispatcher Address of the old dispatcher contract.\\n /// @param newDispatcher Address of the new dispatcher contract.\\n event DispatcherUpdated(address oldDispatcher, address newDispatcher);\\n\\n /// Emitted when the entry fee basis points are updated.\\n /// @param entryFeeBasisPoints New value of the fee basis points.\\n event EntryFeeBasisPointsUpdated(uint256 entryFeeBasisPoints);\\n\\n /// Reverts if the amount is less than the minimum deposit amount.\\n /// @param amount Amount to check.\\n /// @param min Minimum amount to check 'amount' against.\\n error LessThanMinDeposit(uint256 amount, uint256 min);\\n\\n /// Reverts if the address is zero.\\n error ZeroAddress();\\n\\n /// Reverts if the address is disallowed.\\n error DisallowedAddress();\\n\\n constructor(\\n IERC20 _tbtc,\\n address _treasury\\n ) ERC4626(_tbtc) ERC20(\\\"Acre Staked Bitcoin\\\", \\\"stBTC\\\") Ownable(msg.sender) {\\n if (address(_treasury) == address(0)) {\\n revert ZeroAddress();\\n }\\n treasury = _treasury;\\n // TODO: Revisit the exact values closer to the launch.\\n minimumDepositAmount = 0.001 * 1e18; // 0.001 tBTC\\n maximumTotalAssets = 25 * 1e18; // 25 tBTC\\n entryFeeBasisPoints = 5; // 5bps == 0.05% == 0.0005\\n }\\n\\n /// @notice Updates treasury wallet address.\\n /// @param newTreasury New treasury wallet address.\\n function updateTreasury(address newTreasury) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n if (newTreasury == address(0)) {\\n revert ZeroAddress();\\n }\\n if (newTreasury == address(this)) {\\n revert DisallowedAddress();\\n }\\n treasury = newTreasury;\\n\\n emit TreasuryUpdated(newTreasury);\\n }\\n\\n /// @notice Updates deposit parameters.\\n /// @dev To disable the limit for deposits, set the maximum total assets to\\n /// maximum (`type(uint256).max`).\\n /// @param _minimumDepositAmount New value of the minimum deposit amount. It\\n /// is the minimum amount for a single deposit operation.\\n /// @param _maximumTotalAssets New value of the maximum total assets amount.\\n /// It is the maximum amount of the tBTC token that the Acre protocol\\n /// can hold.\\n function updateDepositParameters(\\n uint256 _minimumDepositAmount,\\n uint256 _maximumTotalAssets\\n ) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n minimumDepositAmount = _minimumDepositAmount;\\n maximumTotalAssets = _maximumTotalAssets;\\n\\n emit DepositParametersUpdated(\\n _minimumDepositAmount,\\n _maximumTotalAssets\\n );\\n }\\n\\n // TODO: Implement a governed upgrade process that initiates an update and\\n // then finalizes it after a delay.\\n /// @notice Updates the dispatcher contract and gives it an unlimited\\n /// allowance to transfer staked tBTC.\\n /// @param newDispatcher Address of the new dispatcher contract.\\n function updateDispatcher(Dispatcher newDispatcher) external onlyOwner {\\n if (address(newDispatcher) == address(0)) {\\n revert ZeroAddress();\\n }\\n\\n address oldDispatcher = address(dispatcher);\\n\\n emit DispatcherUpdated(oldDispatcher, address(newDispatcher));\\n dispatcher = newDispatcher;\\n\\n // TODO: Once withdrawal/rebalancing is implemented, we need to revoke the\\n // approval of the vaults share tokens from the old dispatcher and approve\\n // a new dispatcher to manage the share tokens.\\n\\n if (oldDispatcher != address(0)) {\\n // Setting allowance to zero for the old dispatcher\\n IERC20(asset()).forceApprove(oldDispatcher, 0);\\n }\\n\\n // Setting allowance to max for the new dispatcher\\n IERC20(asset()).forceApprove(address(dispatcher), type(uint256).max);\\n }\\n\\n // TODO: Implement a governed upgrade process that initiates an update and\\n // then finalizes it after a delay.\\n /// @notice Update the entry fee basis points.\\n /// @param newEntryFeeBasisPoints New value of the fee basis points.\\n function updateEntryFeeBasisPoints(\\n uint256 newEntryFeeBasisPoints\\n ) external onlyOwner {\\n entryFeeBasisPoints = newEntryFeeBasisPoints;\\n\\n emit EntryFeeBasisPointsUpdated(newEntryFeeBasisPoints);\\n }\\n\\n /// @notice Mints shares to receiver by depositing exactly amount of\\n /// tBTC tokens.\\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\\n /// which determines the minimum amount for a single deposit operation.\\n /// The amount of the assets has to be pre-approved in the tBTC\\n /// contract.\\n /// @param assets Approved amount of tBTC tokens to deposit. This includes\\n /// treasury fees for staking tBTC.\\n /// @param receiver The address to which the shares will be minted.\\n /// @return Minted shares adjusted for the fees taken by the treasury.\\n function deposit(\\n uint256 assets,\\n address receiver\\n ) public override returns (uint256) {\\n if (assets < minimumDepositAmount) {\\n revert LessThanMinDeposit(assets, minimumDepositAmount);\\n }\\n\\n return super.deposit(assets, receiver);\\n }\\n\\n /// @notice Mints shares to receiver by depositing tBTC tokens.\\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\\n /// which determines the minimum amount for a single deposit operation.\\n /// The amount of the assets has to be pre-approved in the tBTC\\n /// contract.\\n /// The msg.sender is required to grant approval for the transfer of a\\n /// certain amount of tBTC, and in addition, approval for the associated\\n /// fee. Specifically, the total amount to be approved (amountToApprove)\\n /// should be equal to the sum of the deposited amount and the fee.\\n /// To determine the total assets amount necessary for approval\\n /// corresponding to a given share amount, use the `previewMint` function.\\n /// @param shares Amount of shares to mint.\\n /// @param receiver The address to which the shares will be minted.\\n function mint(\\n uint256 shares,\\n address receiver\\n ) public override returns (uint256 assets) {\\n if ((assets = super.mint(shares, receiver)) < minimumDepositAmount) {\\n revert LessThanMinDeposit(assets, minimumDepositAmount);\\n }\\n }\\n\\n /// @notice Stakes a given amount of tBTC token and mints shares to a\\n /// receiver.\\n /// @dev This function calls `deposit` function from `ERC4626` contract. The\\n /// amount of the assets has to be pre-approved in the tBTC contract.\\n /// @param assets Approved amount for the transfer and stake.\\n /// @param receiver The address to which the shares will be minted.\\n /// @param referral Data used for referral program.\\n /// @return shares Minted shares.\\n function stake(\\n uint256 assets,\\n address receiver,\\n uint16 referral\\n ) public returns (uint256) {\\n // TODO: revisit the type of referral.\\n uint256 shares = deposit(assets, receiver);\\n\\n if (referral > 0) {\\n emit StakeReferral(referral, assets);\\n }\\n\\n return shares;\\n }\\n\\n /// @notice Returns the maximum amount of the tBTC token that can be\\n /// deposited into the vault for the receiver through a deposit\\n /// call. It takes into account the deposit parameter, maximum total\\n /// assets, which determines the total amount of tBTC token held by\\n /// Acre. This function always returns available limit for deposits,\\n /// but the fee is not taken into account. As a result of this, there\\n /// always will be some dust left. If the dust is lower than the\\n /// minimum deposit amount, this function will return 0.\\n /// @return The maximum amount of tBTC token that can be deposited into\\n /// Acre protocol for the receiver.\\n function maxDeposit(address) public view override returns (uint256) {\\n if (maximumTotalAssets == type(uint256).max) {\\n return type(uint256).max;\\n }\\n\\n uint256 currentTotalAssets = totalAssets();\\n if (currentTotalAssets >= maximumTotalAssets) return 0;\\n\\n // Max amount left for next deposits. If it is lower than the minimum\\n // deposit amount, return 0.\\n uint256 unusedLimit = maximumTotalAssets - currentTotalAssets;\\n\\n return minimumDepositAmount > unusedLimit ? 0 : unusedLimit;\\n }\\n\\n /// @notice Returns the maximum amount of the vault shares that can be\\n /// minted for the receiver, through a mint call.\\n /// @dev Since the stBTC contract limits the maximum total tBTC tokens this\\n /// function converts the maximum deposit amount to shares.\\n /// @return The maximum amount of the vault shares.\\n function maxMint(address receiver) public view override returns (uint256) {\\n uint256 _maxDeposit = maxDeposit(receiver);\\n\\n // slither-disable-next-line incorrect-equality\\n return\\n _maxDeposit == type(uint256).max\\n ? type(uint256).max\\n : convertToShares(_maxDeposit);\\n }\\n\\n /// @return Returns deposit parameters.\\n function depositParameters() public view returns (uint256, uint256) {\\n return (minimumDepositAmount, maximumTotalAssets);\\n }\\n\\n /// @notice Redeems shares for tBTC tokens.\\n function _entryFeeBasisPoints() internal view override returns (uint256) {\\n return entryFeeBasisPoints;\\n }\\n\\n /// @notice Returns the address of the treasury wallet, where fees should be\\n /// transferred to.\\n function _feeRecipient() internal view override returns (address) {\\n return treasury;\\n }\\n}\\n\",\"keccak256\":\"0x5e622d3cef791a39b7089c64cacd5c62f14c13af316e2e8a3141244f7f69324e\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", - "bytecode": "0x60c06040523480156200001157600080fd5b506040516200215538038062002155833981016040819052620000349162000322565b33806200005c57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000678162000152565b50620000748484620001a4565b6001600160a01b038216620000cc5760405162461bcd60e51b815260206004820181905260248201527f54425443546f6b656e20616464726573732063616e6e6f74206265207a65726f604482015260640162000053565b6001600160a01b038116620001245760405162461bcd60e51b815260206004820152601c60248201527f737442544320616464726573732063616e6e6f74206265207a65726f00000000604482015260640162000053565b6001600160a01b039182166080521660a0525050603480546001600160401b0319166103e81790556200037f565b603280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000546001600160a01b0316158015620001c757506001546001600160a01b0316155b620002275760405162461bcd60e51b815260206004820152602960248201527f4162737472616374544254434465706f7369746f7220616c726561647920696e6044820152681a5d1a585b1a5e995960ba1b606482015260840162000053565b6001600160a01b0382166200027f5760405162461bcd60e51b815260206004820152601d60248201527f42726964676520616464726573732063616e6e6f74206265207a65726f000000604482015260640162000053565b6001600160a01b038116620002d75760405162461bcd60e51b815260206004820181905260248201527f544254435661756c7420616464726573732063616e6e6f74206265207a65726f604482015260640162000053565b600080546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b80516001600160a01b03811681146200031d57600080fd5b919050565b600080600080608085870312156200033957600080fd5b620003448562000305565b9350620003546020860162000305565b9250620003646040860162000305565b9150620003746060860162000305565b905092959194509250565b60805160a051611d86620003cf600039600081816101dd01528181610447015281816104bf015261063301526000818161031501528181610424015281816106bd01526108fa0152611d866000f3fe608060405234801561001057600080fd5b506004361061011b5760003560e01c80639bef6d52116100b2578063d0714ad511610081578063e5d3d71411610066578063e5d3d71414610310578063e78cea9214610337578063f2fde38b1461034a57600080fd5b8063d0714ad51461026b578063d7820273146102fd57600080fd5b80639bef6d52146101d8578063a7932794146101ff578063c143d67514610232578063c7ba03471461025f57600080fd5b80633d11a6ae116100ee5780633d11a6ae1461018b578063715018a6146101ac5780637cea8689146101b45780638da5cb5b146101c757600080fd5b80630e8491c5146101205780630f36403a146101355780631dc2004d146101655780633647b20514610178575b600080fd5b61013361012e366004611638565b61035d565b005b600154610148906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610133610173366004611638565b610531565b610133610186366004611667565b6106eb565b61019e6101993660046116bb565b610749565b60405190815260200161015c565b6101336107b8565b6101336101c2366004611638565b6107cc565b6032546001600160a01b0316610148565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b61022261020d366004611638565b60026020526000908152604090205460ff1681565b604051901515815260200161015c565b6034546102469067ffffffffffffffff1681565b60405167ffffffffffffffff909116815260200161015c565b61019e6402540be40081565b6102c1610279366004611638565b6033602052600090815260409020805460019091015467ffffffffffffffff8216916801000000000000000081046001600160a01b031691600160e01b90910461ffff169084565b6040805167ffffffffffffffff90951685526001600160a01b03909316602085015261ffff90911691830191909152606082015260800161015c565b61013361030b3660046116f0565b610934565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b600054610148906001600160a01b031681565b610133610358366004611774565b610a3f565b6000818152603360205260408120600181015490910361039057604051632f3d137560e11b815260040160405180910390fd5b805467ffffffffffffffff16156103ba57604051631960824560e01b815260040160405180910390fd5b805467ffffffffffffffff19164267ffffffffffffffff161781556001810154604051908152339083907f2b57d79a66895fd41ae6d27049952259b0d40a9b7c563a99b3f1844b288da08c9060200160405180910390a3600181015461046c906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016907f000000000000000000000000000000000000000000000000000000000000000090610a96565b600181015481546040517f6e553f6500000000000000000000000000000000000000000000000000000000815260048101929092526801000000000000000090046001600160a01b0390811660248301527f00000000000000000000000000000000000000000000000000000000000000001690636e553f65906044016020604051808303816000875af1158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c9190611791565b505050565b60008061053d83610b3f565b50603454919350915060009067ffffffffffffffff1661055e576000610575565b6034546105759067ffffffffffffffff16846117c0565b90508181106105bf576040517f2395edf200000000000000000000000000000000000000000000000000000000815260048101829052602481018390526044015b60405180910390fd5b60008481526033602052604090206105d782846117e2565b600182015580546040805185815260208101859052600160e01b90920461ffff1691339188917f6410e64d304208a5e90fc76ab4fbf4e7b8836705daeda8dde27611ae0524490a910160405180910390a481156106e4576106e47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b39190611800565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169084610de7565b5050505050565b6106f3610e5b565b6034805467ffffffffffffffff191667ffffffffffffffff83169081179091556040519081527f53a618edd6eab9ce346f438670ebd45da60fa3d85662375fae2b8beadf08faf39060200160405180910390a150565b6040516bffffffffffffffffffffffff19606084901b1660208201527fffff00000000000000000000000000000000000000000000000000000000000060f083901b1660348201526000906036016040516020818303038152906040526107af9061181d565b90505b92915050565b6107c0610e5b565b6107ca6000610ea1565b565b600081815260336020526040812060018101549091036107ff57604051632f3d137560e11b815260040160405180910390fd5b805467ffffffffffffffff161561082957604051631960824560e01b815260040160405180910390fd5b80546801000000000000000090046001600160a01b03163314610878576040517f93f2d2aa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805467ffffffffffffffff19164267ffffffffffffffff16178082556001820154604051908152680100000000000000009091046001600160a01b03169083907f27cfa5af2e7eaf7c58bf2ba2ee252e69260b83b8efc6fb2c1f4563e4d4b70f769060200160405180910390a380546001820154610930916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811692680100000000000000009092041690610de7565b5050565b6001600160a01b038216610974576040517f80f67d2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061098a85856109858686610749565b610f0b565b60008181526033602052604080822080547fffff00000000000000000000000000000000000000000000ffffffffffffffff16680100000000000000006001600160a01b0389169081027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691909117600160e01b61ffff8916021782559151939450929091339185917f8d019883471b734b0033fe25a5b76c3afefbbfa9e9b3dacdbabf505b9e4f455d91a4505050505050565b610a47610e5b565b6001600160a01b038116610a8a576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016105b6565b610a9381610ea1565b50565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b239190611791565b9050610b398484610b348585611844565b611082565b50505050565b6000818152600260205260408120548190819060ff16610ba15760405162461bcd60e51b815260206004820152601760248201527f4465706f736974206e6f7420696e697469616c697a656400000000000000000060448201526064016105b6565b600080546040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b039091169063b02c43d09060240160e060405180830381865afa158015610c04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c28919061187f565b6001546040517f6c626aa4000000000000000000000000000000000000000000000000000000008152600481018890529192506000916001600160a01b0390911690636c626aa49060240160408051808303816000875af1158015610c91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb59190611939565b9150508160a0015163ffffffff166000141580610cdb575067ffffffffffffffff811615155b610d4d5760405162461bcd60e51b815260206004820152602360248201527f4465706f736974206e6f742066696e616c697a6564206279207468652062726960448201527f646765000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6000868152600260209081526040909120805460ff19169055820151610d83906402540be4009067ffffffffffffffff16611973565b9450610d9782602001518360800151611140565b6040805182815263ffffffff4216602082015291955087917f417b6288c9f637614f8b3f7a275fb4e44e517930fde949e463d58dfe0b97f28b910160405180910390a25060c00151929491935050565b6040516001600160a01b0383811660248301526044820183905261052c91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506112c3565b6032546001600160a01b031633146107ca576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016105b6565b603280546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001546000906001600160a01b0316610f2a60c0850160a08601611774565b6001600160a01b031614610f805760405162461bcd60e51b815260206004820152601660248201527f5661756c742061646472657373206d69736d617463680000000000000000000060448201526064016105b6565b6000610fa0610f8e8661133f565b610f9b602087018761198a565b6113a4565b600081815260026020908152604091829020805460ff1916600117905590514263ffffffff16815291925082917fa3ed7aef0745e1a91addae9e5daee7a8ace74852fec840b9d93da747855dd7b9910160405180910390a26000546040517f86f014390000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906386f014399061104590889088908890600401611a52565b600060405180830381600087803b15801561105f57600080fd5b505af1158015611073573d6000803e3d6000fd5b509293505050505b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261110184826113ee565b610b39576040516001600160a01b0384811660248301526000604483015261113691869182169063095ea7b390606401610e14565b610b3984826112c3565b6000806402540be4006111538486611bb7565b67ffffffffffffffff166111679190611973565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166309b53f516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e29190611bdf565b63ffffffff16905060008082116111fa576000611204565b61120482846117c0565b905060008060009054906101000a90046001600160a01b03166001600160a01b031663c42b64d06040518163ffffffff1660e01b8152600401608060405180830381865afa15801561125a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127e9190611bfc565b509250505060006402540be4008267ffffffffffffffff166112a09190611973565b9050806112ad84876117e2565b6112b791906117e2565b98975050505050505050565b60006112d86001600160a01b03841683611496565b905080516000141580156112fd5750808060200190518101906112fb9190611c5b565b155b1561052c576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105b6565b60006107b26113516020840184611c7d565b61135e6020850185611c98565b61136b6040870187611c98565b61137b6080890160608a01611c7d565b60405160200161139096959493929190611cdf565b6040516020818303038152906040526114a4565b600082826040516020016113cf92919091825260e01b6001600160e01b031916602082015260240190565b60408051601f1981840301815291905280516020909101209392505050565b6000806000846001600160a01b03168460405161140b9190611d21565b6000604051808303816000865af19150503d8060008114611448576040519150601f19603f3d011682016040523d82523d6000602084013e61144d565b606091505b50915091508180156114775750805115806114775750808060200190518101906114779190611c5b565b801561148d57506000856001600160a01b03163b115b95945050505050565b60606107af838360006114cb565b60006020600083516020850160025afa50602060006020600060025afa5050600051919050565b606081471015611509576040517fcd7860590000000000000000000000000000000000000000000000000000000081523060048201526024016105b6565b600080856001600160a01b031684866040516115259190611d21565b60006040518083038185875af1925050503d8060008114611562576040519150601f19603f3d011682016040523d82523d6000602084013e611567565b606091505b5091509150611577868383611581565b9695505050505050565b60608261159657611591826115f6565b61107b565b81511580156115ad57506001600160a01b0384163b155b156115ef576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016105b6565b508061107b565b8051156116065780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006020828403121561164a57600080fd5b5035919050565b67ffffffffffffffff81168114610a9357600080fd5b60006020828403121561167957600080fd5b813561107b81611651565b6001600160a01b0381168114610a9357600080fd5b80356116a481611684565b919050565b803561ffff811681146116a457600080fd5b600080604083850312156116ce57600080fd5b82356116d981611684565b91506116e7602084016116a9565b90509250929050565b60008060008084860361012081121561170857600080fd5b853567ffffffffffffffff81111561171f57600080fd5b86016080818903121561173157600080fd5b945060c0601f198201121561174557600080fd5b5060208501925060e085013561175a81611684565b915061176961010086016116a9565b905092959194509250565b60006020828403121561178657600080fd5b813561107b81611684565b6000602082840312156117a357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000826117dd57634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156107b2576107b26117aa565b80516116a481611684565b60006020828403121561181257600080fd5b815161107b81611684565b8051602080830151919081101561183e576000198160200360031b1b821691505b50919050565b808201808211156107b2576107b26117aa565b80516116a481611651565b63ffffffff81168114610a9357600080fd5b80516116a481611862565b600060e0828403121561189157600080fd5b60405160e0810181811067ffffffffffffffff821117156118c257634e487b7160e01b600052604160045260246000fd5b6040526118ce836117f5565b81526118dc60208401611857565b60208201526118ed60408401611874565b60408201526118fe606084016117f5565b606082015261190f60808401611857565b608082015261192060a08401611874565b60a082015260c083015160c08201528091505092915050565b6000806040838503121561194c57600080fd5b825161195781611651565b602084015190925061196881611651565b809150509250929050565b80820281158282048414176107b2576107b26117aa565b60006020828403121561199c57600080fd5b813561107b81611862565b80356001600160e01b0319811681146116a457600080fd5b6000808335601e198436030181126119d657600080fd5b830160208101925035905067ffffffffffffffff8111156119f657600080fd5b803603821315611a0557600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b80356bffffffffffffffffffffffff19811681146116a457600080fd5b60006101008083526001600160e01b031980611a6d886119a7565b1682850152611a7f60208801886119bf565b92506080610120860152611a9861018086018483611a0c565b925050611aa860408801886119bf565b85840360ff1901610140870152611ac0848284611a0c565b9350505080611ad1606089016119a7565b166101608501525090508335611ae681611862565b63ffffffff811660208401525060208401357fffffffffffffffff0000000000000000000000000000000000000000000000008116808214611b2757600080fd5b80604085015250506bffffffffffffffffffffffff19611b4960408601611a35565b166060830152611b5b60608501611a35565b6bffffffffffffffffffffffff198116608084015250611b7d608085016119a7565b6001600160e01b0319811660a084015250611b9a60a08501611699565b6001600160a01b031660c083015260e09091019190915292915050565b67ffffffffffffffff828116828216039080821115611bd857611bd86117aa565b5092915050565b600060208284031215611bf157600080fd5b815161107b81611862565b60008060008060808587031215611c1257600080fd5b8451611c1d81611651565b6020860151909450611c2e81611651565b6040860151909350611c3f81611651565b6060860151909250611c5081611862565b939692955090935050565b600060208284031215611c6d57600080fd5b8151801515811461107b57600080fd5b600060208284031215611c8f57600080fd5b6107af826119a7565b6000808335601e19843603018112611caf57600080fd5b83018035915067ffffffffffffffff821115611cca57600080fd5b602001915036819003821315611a0557600080fd5b60006001600160e01b03198089168352868860048501378683016004810160008152868882375093169390920160048101939093525050600801949350505050565b6000825160005b81811015611d425760208186018101518583015201611d28565b50600092019182525091905056fea2646970667358221220d7e96a88169fbbb6355b500c970d1027a84d03bce2cf68304d33d263b06d67d964736f6c63430008150033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061011b5760003560e01c80639bef6d52116100b2578063d0714ad511610081578063e5d3d71411610066578063e5d3d71414610310578063e78cea9214610337578063f2fde38b1461034a57600080fd5b8063d0714ad51461026b578063d7820273146102fd57600080fd5b80639bef6d52146101d8578063a7932794146101ff578063c143d67514610232578063c7ba03471461025f57600080fd5b80633d11a6ae116100ee5780633d11a6ae1461018b578063715018a6146101ac5780637cea8689146101b45780638da5cb5b146101c757600080fd5b80630e8491c5146101205780630f36403a146101355780631dc2004d146101655780633647b20514610178575b600080fd5b61013361012e366004611638565b61035d565b005b600154610148906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610133610173366004611638565b610531565b610133610186366004611667565b6106eb565b61019e6101993660046116bb565b610749565b60405190815260200161015c565b6101336107b8565b6101336101c2366004611638565b6107cc565b6032546001600160a01b0316610148565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b61022261020d366004611638565b60026020526000908152604090205460ff1681565b604051901515815260200161015c565b6034546102469067ffffffffffffffff1681565b60405167ffffffffffffffff909116815260200161015c565b61019e6402540be40081565b6102c1610279366004611638565b6033602052600090815260409020805460019091015467ffffffffffffffff8216916801000000000000000081046001600160a01b031691600160e01b90910461ffff169084565b6040805167ffffffffffffffff90951685526001600160a01b03909316602085015261ffff90911691830191909152606082015260800161015c565b61013361030b3660046116f0565b610934565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b600054610148906001600160a01b031681565b610133610358366004611774565b610a3f565b6000818152603360205260408120600181015490910361039057604051632f3d137560e11b815260040160405180910390fd5b805467ffffffffffffffff16156103ba57604051631960824560e01b815260040160405180910390fd5b805467ffffffffffffffff19164267ffffffffffffffff161781556001810154604051908152339083907f2b57d79a66895fd41ae6d27049952259b0d40a9b7c563a99b3f1844b288da08c9060200160405180910390a3600181015461046c906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016907f000000000000000000000000000000000000000000000000000000000000000090610a96565b600181015481546040517f6e553f6500000000000000000000000000000000000000000000000000000000815260048101929092526801000000000000000090046001600160a01b0390811660248301527f00000000000000000000000000000000000000000000000000000000000000001690636e553f65906044016020604051808303816000875af1158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c9190611791565b505050565b60008061053d83610b3f565b50603454919350915060009067ffffffffffffffff1661055e576000610575565b6034546105759067ffffffffffffffff16846117c0565b90508181106105bf576040517f2395edf200000000000000000000000000000000000000000000000000000000815260048101829052602481018390526044015b60405180910390fd5b60008481526033602052604090206105d782846117e2565b600182015580546040805185815260208101859052600160e01b90920461ffff1691339188917f6410e64d304208a5e90fc76ab4fbf4e7b8836705daeda8dde27611ae0524490a910160405180910390a481156106e4576106e47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b39190611800565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169084610de7565b5050505050565b6106f3610e5b565b6034805467ffffffffffffffff191667ffffffffffffffff83169081179091556040519081527f53a618edd6eab9ce346f438670ebd45da60fa3d85662375fae2b8beadf08faf39060200160405180910390a150565b6040516bffffffffffffffffffffffff19606084901b1660208201527fffff00000000000000000000000000000000000000000000000000000000000060f083901b1660348201526000906036016040516020818303038152906040526107af9061181d565b90505b92915050565b6107c0610e5b565b6107ca6000610ea1565b565b600081815260336020526040812060018101549091036107ff57604051632f3d137560e11b815260040160405180910390fd5b805467ffffffffffffffff161561082957604051631960824560e01b815260040160405180910390fd5b80546801000000000000000090046001600160a01b03163314610878576040517f93f2d2aa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805467ffffffffffffffff19164267ffffffffffffffff16178082556001820154604051908152680100000000000000009091046001600160a01b03169083907f27cfa5af2e7eaf7c58bf2ba2ee252e69260b83b8efc6fb2c1f4563e4d4b70f769060200160405180910390a380546001820154610930916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811692680100000000000000009092041690610de7565b5050565b6001600160a01b038216610974576040517f80f67d2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061098a85856109858686610749565b610f0b565b60008181526033602052604080822080547fffff00000000000000000000000000000000000000000000ffffffffffffffff16680100000000000000006001600160a01b0389169081027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691909117600160e01b61ffff8916021782559151939450929091339185917f8d019883471b734b0033fe25a5b76c3afefbbfa9e9b3dacdbabf505b9e4f455d91a4505050505050565b610a47610e5b565b6001600160a01b038116610a8a576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016105b6565b610a9381610ea1565b50565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b239190611791565b9050610b398484610b348585611844565b611082565b50505050565b6000818152600260205260408120548190819060ff16610ba15760405162461bcd60e51b815260206004820152601760248201527f4465706f736974206e6f7420696e697469616c697a656400000000000000000060448201526064016105b6565b600080546040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b039091169063b02c43d09060240160e060405180830381865afa158015610c04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c28919061187f565b6001546040517f6c626aa4000000000000000000000000000000000000000000000000000000008152600481018890529192506000916001600160a01b0390911690636c626aa49060240160408051808303816000875af1158015610c91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb59190611939565b9150508160a0015163ffffffff166000141580610cdb575067ffffffffffffffff811615155b610d4d5760405162461bcd60e51b815260206004820152602360248201527f4465706f736974206e6f742066696e616c697a6564206279207468652062726960448201527f646765000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6000868152600260209081526040909120805460ff19169055820151610d83906402540be4009067ffffffffffffffff16611973565b9450610d9782602001518360800151611140565b6040805182815263ffffffff4216602082015291955087917f417b6288c9f637614f8b3f7a275fb4e44e517930fde949e463d58dfe0b97f28b910160405180910390a25060c00151929491935050565b6040516001600160a01b0383811660248301526044820183905261052c91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506112c3565b6032546001600160a01b031633146107ca576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016105b6565b603280546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001546000906001600160a01b0316610f2a60c0850160a08601611774565b6001600160a01b031614610f805760405162461bcd60e51b815260206004820152601660248201527f5661756c742061646472657373206d69736d617463680000000000000000000060448201526064016105b6565b6000610fa0610f8e8661133f565b610f9b602087018761198a565b6113a4565b600081815260026020908152604091829020805460ff1916600117905590514263ffffffff16815291925082917fa3ed7aef0745e1a91addae9e5daee7a8ace74852fec840b9d93da747855dd7b9910160405180910390a26000546040517f86f014390000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906386f014399061104590889088908890600401611a52565b600060405180830381600087803b15801561105f57600080fd5b505af1158015611073573d6000803e3d6000fd5b509293505050505b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261110184826113ee565b610b39576040516001600160a01b0384811660248301526000604483015261113691869182169063095ea7b390606401610e14565b610b3984826112c3565b6000806402540be4006111538486611bb7565b67ffffffffffffffff166111679190611973565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166309b53f516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e29190611bdf565b63ffffffff16905060008082116111fa576000611204565b61120482846117c0565b905060008060009054906101000a90046001600160a01b03166001600160a01b031663c42b64d06040518163ffffffff1660e01b8152600401608060405180830381865afa15801561125a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127e9190611bfc565b509250505060006402540be4008267ffffffffffffffff166112a09190611973565b9050806112ad84876117e2565b6112b791906117e2565b98975050505050505050565b60006112d86001600160a01b03841683611496565b905080516000141580156112fd5750808060200190518101906112fb9190611c5b565b155b1561052c576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105b6565b60006107b26113516020840184611c7d565b61135e6020850185611c98565b61136b6040870187611c98565b61137b6080890160608a01611c7d565b60405160200161139096959493929190611cdf565b6040516020818303038152906040526114a4565b600082826040516020016113cf92919091825260e01b6001600160e01b031916602082015260240190565b60408051601f1981840301815291905280516020909101209392505050565b6000806000846001600160a01b03168460405161140b9190611d21565b6000604051808303816000865af19150503d8060008114611448576040519150601f19603f3d011682016040523d82523d6000602084013e61144d565b606091505b50915091508180156114775750805115806114775750808060200190518101906114779190611c5b565b801561148d57506000856001600160a01b03163b115b95945050505050565b60606107af838360006114cb565b60006020600083516020850160025afa50602060006020600060025afa5050600051919050565b606081471015611509576040517fcd7860590000000000000000000000000000000000000000000000000000000081523060048201526024016105b6565b600080856001600160a01b031684866040516115259190611d21565b60006040518083038185875af1925050503d8060008114611562576040519150601f19603f3d011682016040523d82523d6000602084013e611567565b606091505b5091509150611577868383611581565b9695505050505050565b60608261159657611591826115f6565b61107b565b81511580156115ad57506001600160a01b0384163b155b156115ef576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016105b6565b508061107b565b8051156116065780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006020828403121561164a57600080fd5b5035919050565b67ffffffffffffffff81168114610a9357600080fd5b60006020828403121561167957600080fd5b813561107b81611651565b6001600160a01b0381168114610a9357600080fd5b80356116a481611684565b919050565b803561ffff811681146116a457600080fd5b600080604083850312156116ce57600080fd5b82356116d981611684565b91506116e7602084016116a9565b90509250929050565b60008060008084860361012081121561170857600080fd5b853567ffffffffffffffff81111561171f57600080fd5b86016080818903121561173157600080fd5b945060c0601f198201121561174557600080fd5b5060208501925060e085013561175a81611684565b915061176961010086016116a9565b905092959194509250565b60006020828403121561178657600080fd5b813561107b81611684565b6000602082840312156117a357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000826117dd57634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156107b2576107b26117aa565b80516116a481611684565b60006020828403121561181257600080fd5b815161107b81611684565b8051602080830151919081101561183e576000198160200360031b1b821691505b50919050565b808201808211156107b2576107b26117aa565b80516116a481611651565b63ffffffff81168114610a9357600080fd5b80516116a481611862565b600060e0828403121561189157600080fd5b60405160e0810181811067ffffffffffffffff821117156118c257634e487b7160e01b600052604160045260246000fd5b6040526118ce836117f5565b81526118dc60208401611857565b60208201526118ed60408401611874565b60408201526118fe606084016117f5565b606082015261190f60808401611857565b608082015261192060a08401611874565b60a082015260c083015160c08201528091505092915050565b6000806040838503121561194c57600080fd5b825161195781611651565b602084015190925061196881611651565b809150509250929050565b80820281158282048414176107b2576107b26117aa565b60006020828403121561199c57600080fd5b813561107b81611862565b80356001600160e01b0319811681146116a457600080fd5b6000808335601e198436030181126119d657600080fd5b830160208101925035905067ffffffffffffffff8111156119f657600080fd5b803603821315611a0557600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b80356bffffffffffffffffffffffff19811681146116a457600080fd5b60006101008083526001600160e01b031980611a6d886119a7565b1682850152611a7f60208801886119bf565b92506080610120860152611a9861018086018483611a0c565b925050611aa860408801886119bf565b85840360ff1901610140870152611ac0848284611a0c565b9350505080611ad1606089016119a7565b166101608501525090508335611ae681611862565b63ffffffff811660208401525060208401357fffffffffffffffff0000000000000000000000000000000000000000000000008116808214611b2757600080fd5b80604085015250506bffffffffffffffffffffffff19611b4960408601611a35565b166060830152611b5b60608501611a35565b6bffffffffffffffffffffffff198116608084015250611b7d608085016119a7565b6001600160e01b0319811660a084015250611b9a60a08501611699565b6001600160a01b031660c083015260e09091019190915292915050565b67ffffffffffffffff828116828216039080821115611bd857611bd86117aa565b5092915050565b600060208284031215611bf157600080fd5b815161107b81611862565b60008060008060808587031215611c1257600080fd5b8451611c1d81611651565b6020860151909450611c2e81611651565b6040860151909350611c3f81611651565b6060860151909250611c5081611862565b939692955090935050565b600060208284031215611c6d57600080fd5b8151801515811461107b57600080fd5b600060208284031215611c8f57600080fd5b6107af826119a7565b6000808335601e19843603018112611caf57600080fd5b83018035915067ffffffffffffffff821115611cca57600080fd5b602001915036819003821315611a0557600080fd5b60006001600160e01b03198089168352868860048501378683016004810160008152868882375093169390920160048101939093525050600801949350505050565b6000825160005b81811015611d425760208186018101518583015201611d28565b50600092019182525091905056fea2646970667358221220d7e96a88169fbbb6355b500c970d1027a84d03bce2cf68304d33d263b06d67d964736f6c63430008150033", - "devdoc": { - "errors": { - "AddressEmptyCode(address)": [ - { - "details": "There's no code at `target` (it is not a contract)." - } - ], - "AddressInsufficientBalance(address)": [ - { - "details": "The ETH balance of the account is not enough to perform the operation." - } - ], - "BridgingNotCompleted()": [ - { - "details": "Attempted to finalize a stake request, while bridging completion has not been notified yet." - } - ], - "CallerNotReceiver()": [ - { - "details": "Attempted to call function by an account that is not the receiver." - } - ], - "DepositorFeeExceedsBridgedAmount(uint256,uint256)": [ - { - "details": "Calculated depositor fee exceeds the amount of minted tBTC tokens." - } - ], - "FailedInnerCall()": [ - { - "details": "A call to an address target failed. The target may have reverted." - } - ], - "OwnableInvalidOwner(address)": [ - { - "details": "The owner is not a valid owner account. (eg. `address(0)`)" - } - ], - "OwnableUnauthorizedAccount(address)": [ - { - "details": "The caller account is not authorized to perform an operation." - } - ], - "ReceiverIsZeroAddress()": [ - { - "details": "Receiver address is zero." - } - ], - "SafeERC20FailedOperation(address)": [ - { - "details": "An operation with an ERC20 token failed." - } - ], - "StakeRequestAlreadyFinalized()": [ - { - "details": "Attempted to finalize a stake request that was already finalized." - } - ] - }, - "events": { - "BridgingCompleted(uint256,address,uint16,uint256,uint256)": { - "params": { - "bridgedAmount": "Amount of tBTC tokens that was bridged by the tBTC bridge.", - "caller": "Address that notified about bridging completion.", - "depositKey": "Deposit key identifying the deposit.", - "depositorFee": "Depositor fee amount.", - "referral": "Identifier of a partner in the referral program." - } - }, - "DepositorFeeDivisorUpdated(uint64)": { - "params": { - "depositorFeeDivisor": "New value of the depositor fee divisor." - } - }, - "StakeRequestFinalized(uint256,address,uint256)": { - "details": "Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.", - "params": { - "amountToStake": "Amount of staked tBTC tokens.", - "caller": "Address that finalized the stake request.", - "depositKey": "Deposit key identifying the deposit." - } - }, - "StakeRequestInitialized(uint256,address,address)": { - "details": "Deposit details can be fetched from {{ Bridge.DepositRevealed }} event emitted in the same transaction.", - "params": { - "caller": "Address that initialized the stake request.", - "depositKey": "Deposit key identifying the deposit.", - "receiver": "The address to which the stBTC shares will be minted." - } - }, - "StakeRequestRecalled(uint256,address,uint256)": { - "params": { - "amountToStake": "Amount of recalled tBTC tokens.", - "depositKey": "Deposit key identifying the deposit.", - "receiver": "Address of the receiver." - } - } - }, - "kind": "dev", - "methods": { - "constructor": { - "params": { - "_bridge": "tBTC Bridge contract instance.", - "_stbtc": "stBTC contract instance.", - "_tbtcVault": "tBTC Vault contract instance." - } - }, - "encodeExtraData(address,uint16)": { - "details": "Packs the data to bytes32: 20 bytes of receiver address and 2 bytes of referral, 10 bytes of trailing zeros.", - "params": { - "receiver": "The address to which the stBTC shares will be minted.", - "referral": "Data used for referral program." - }, - "returns": { - "_0": "Encoded extra data." - } - }, - "finalizeStakeRequest(uint256)": { - "details": "This function is expected to be called after `notifyBridgingCompleted`. In case depositing in stBTC vault fails (e.g. because of the maximum deposit limit being reached), the function should be retried after the limit is increased or other user withdraws their funds from the stBTC contract to make place for another deposit. The staker has a possibility to submit `recallStakeRequest` that will withdraw the minted tBTC token and abort staking process.", - "params": { - "depositKey": "Deposit key identifying the deposit." - } - }, - "initializeStakeRequest((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)": { - "details": "Requirements: - The revealed vault address must match the TBTCVault address, - All requirements from {Bridge#revealDepositWithExtraData} function must be met. - `receiver` must be the receiver address used in the P2(W)SH BTC deposit transaction as part of the extra data. - `referral` must be the referral info used in the P2(W)SH BTC deposit transaction as part of the extra data. - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex` can be revealed only one time.", - "params": { - "fundingTx": "Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.", - "receiver": "The address to which the stBTC shares will be minted.", - "referral": "Data used for referral program.", - "reveal": "Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`." - } - }, - "notifyBridgingCompleted(uint256)": { - "details": "It calculates the amount to stake based on the approximate minted tBTC amount reduced by the depositor fee.IMPORTANT NOTE: The minted tBTC amount used by this function is an approximation. See documentation of the {{TBTCDepositorProxy#_calculateTbtcAmount}} responsible for calculating this value for more details.", - "params": { - "depositKey": "Deposit key identifying the deposit." - } - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "recallStakeRequest(uint256)": { - "details": "This function can be called only after bridging in tBTC Bridge was completed. Only receiver provided in the extra data of the stake request can call this function.", - "params": { - "depositKey": "Deposit key identifying the deposit." - } - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." - }, - "transferOwnership(address)": { - "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." - }, - "updateDepositorFeeDivisor(uint64)": { - "params": { - "newDepositorFeeDivisor": "New depositor fee divisor value." - } - } - }, - "stateVariables": { - "depositorFeeDivisor": { - "details": "That fee is computed as follows: `depositorFee = depositedAmount / depositorFeeDivisor` for example, if the depositor fee needs to be 2% of each deposit, the `depositorFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`." - }, - "stakeRequests": { - "details": "The key is a deposit key identifying the deposit." - } - }, - "title": "tBTC Depositor contract.", - "version": 1 - }, - "userdoc": { - "events": { - "BridgingCompleted(uint256,address,uint16,uint256,uint256)": { - "notice": "Emitted when bridging completion has been notified." - }, - "DepositorFeeDivisorUpdated(uint64)": { - "notice": "Emitted when a depositor fee divisor is updated." - }, - "StakeRequestFinalized(uint256,address,uint256)": { - "notice": "Emitted when a stake request is finalized." - }, - "StakeRequestInitialized(uint256,address,address)": { - "notice": "Emitted when a stake request is initialized." - }, - "StakeRequestRecalled(uint256,address,uint256)": { - "notice": "Emitted when a stake request is recalled." - } - }, - "kind": "user", - "methods": { - "SATOSHI_MULTIPLIER()": { - "notice": "Multiplier to convert satoshi to TBTC token units." - }, - "bridge()": { - "notice": "Bridge contract address." - }, - "constructor": { - "notice": "Tbtc Depositor contract constructor." - }, - "depositorFeeDivisor()": { - "notice": "Divisor used to compute the depositor fee taken from each deposit and transferred to the treasury upon stake request finalization." - }, - "encodeExtraData(address,uint16)": { - "notice": "Encode receiver address and referral as extra data." - }, - "finalizeStakeRequest(uint256)": { - "notice": "This function should be called for previously initialized stake request, after tBTC bridging process was finalized. It stakes the tBTC from the given deposit into stBTC, emitting the stBTC shares to the receiver specified in the deposit extra data and using the referral provided in the extra data." - }, - "initializeStakeRequest((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)": { - "notice": "This function allows staking process initialization for a Bitcoin deposit made by an user with a P2(W)SH transaction. It uses the supplied information to reveal a deposit to the tBTC Bridge contract." - }, - "notifyBridgingCompleted(uint256)": { - "notice": "This function should be called for previously initialized stake request, after tBTC minting process completed, meaning tBTC was minted to this contract." - }, - "pendingDeposits(uint256)": { - "notice": "Mapping holding information about pending deposits that have been initialized but not finalized yet. If the deposit is not in this mapping it means it has already been finalized or it has not been initialized yet." - }, - "recallStakeRequest(uint256)": { - "notice": "Recall bridged tBTC tokens from being requested to stake. This function can be called by the staker to recover tBTC that cannot be finalized to stake in stBTC contract due to a deposit limit being reached." - }, - "stakeRequests(uint256)": { - "notice": "Mapping of stake requests." - }, - "stbtc()": { - "notice": "stBTC contract." - }, - "tbtcToken()": { - "notice": "tBTC Token contract." - }, - "tbtcVault()": { - "notice": "TBTCVault contract address." - }, - "updateDepositorFeeDivisor(uint64)": { - "notice": "Updates the depositor fee divisor." - } - }, - "notice": "The contract integrates Acre staking with tBTC minting. User who wants to stake BTC in Acre should submit a Bitcoin transaction to the most recently created off-chain ECDSA wallets of the tBTC Bridge using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH) containing hashed information about this Depositor contract address, and staker's Ethereum address. Then, the staker initiates tBTC minting by revealing their Ethereum address along with their deposit blinding factor, refund public key hash and refund locktime on the tBTC Bridge through this Depositor contract. The off-chain ECDSA wallet listens for these sorts of messages and when it gets one, it checks the Bitcoin network to make sure the deposit lines up. If it does, the off-chain ECDSA wallet may decide to pick the deposit transaction for sweeping, and when the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge and tBTC vault mint the tBTC token to the Depositor address. After tBTC is minted to the Depositor, on the stake finalization tBTC is staked in stBTC contract and stBTC shares are emitted to the receiver pointed by the staker.", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 2683, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "bridge", - "offset": 0, - "slot": "0", - "type": "t_contract(IBridge)3102" - }, - { - "astId": 2687, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "tbtcVault", - "offset": 0, - "slot": "1", - "type": "t_contract(ITBTCVault)3122" - }, - { - "astId": 2692, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "pendingDeposits", - "offset": 0, - "slot": "2", - "type": "t_mapping(t_uint256,t_bool)" - }, - { - "astId": 2696, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "__gap", - "offset": 0, - "slot": "3", - "type": "t_array(t_uint256)47_storage" - }, - { - "astId": 3597, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "_owner", - "offset": 0, - "slot": "50", - "type": "t_address" - }, - { - "astId": 7435, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "stakeRequests", - "offset": 0, - "slot": "51", - "type": "t_mapping(t_uint256,t_struct(StakeRequest)7421_storage)" - }, - { - "astId": 7438, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "depositorFeeDivisor", - "offset": 0, - "slot": "52", - "type": "t_uint64" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_uint256)47_storage": { - "base": "t_uint256", - "encoding": "inplace", - "label": "uint256[47]", - "numberOfBytes": "1504" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_contract(IBridge)3102": { - "encoding": "inplace", - "label": "contract IBridge", - "numberOfBytes": "20" - }, - "t_contract(ITBTCVault)3122": { - "encoding": "inplace", - "label": "contract ITBTCVault", - "numberOfBytes": "20" - }, - "t_mapping(t_uint256,t_bool)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => bool)", - "numberOfBytes": "32", - "value": "t_bool" - }, - "t_mapping(t_uint256,t_struct(StakeRequest)7421_storage)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => struct TbtcDepositor.StakeRequest)", - "numberOfBytes": "32", - "value": "t_struct(StakeRequest)7421_storage" - }, - "t_struct(StakeRequest)7421_storage": { - "encoding": "inplace", - "label": "struct TbtcDepositor.StakeRequest", - "members": [ - { - "astId": 7414, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "finalizedAt", - "offset": 0, - "slot": "0", - "type": "t_uint64" - }, - { - "astId": 7416, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "receiver", - "offset": 8, - "slot": "0", - "type": "t_address" - }, - { - "astId": 7418, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "referral", - "offset": 28, - "slot": "0", - "type": "t_uint16" - }, - { - "astId": 7420, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "amountToStake", - "offset": 0, - "slot": "1", - "type": "t_uint256" - } - ], - "numberOfBytes": "64" - }, - "t_uint16": { - "encoding": "inplace", - "label": "uint16", - "numberOfBytes": "2" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - }, - "t_uint64": { - "encoding": "inplace", - "label": "uint64", - "numberOfBytes": "8" - } - } - } -} \ No newline at end of file diff --git a/core/deployments/sepolia/solcInputs/49f0432287e96a47d66ba17ae7bf5d96.json b/core/deployments/sepolia/solcInputs/49f0432287e96a47d66ba17ae7bf5d96.json new file mode 100644 index 000000000..dcd762398 --- /dev/null +++ b/core/deployments/sepolia/solcInputs/49f0432287e96a47d66ba17ae7bf5d96.json @@ -0,0 +1,117 @@ +{ + "language": "Solidity", + "sources": { + "@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol": { + "content": "pragma solidity ^0.8.4;\n\n/** @title BitcoinSPV */\n/** @author Summa (https://summa.one) */\n\nimport {BytesLib} from \"./BytesLib.sol\";\nimport {SafeMath} from \"./SafeMath.sol\";\n\nlibrary BTCUtils {\n using BytesLib for bytes;\n using SafeMath for uint256;\n\n // The target at minimum Difficulty. Also the target of the genesis block\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\n\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\n\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\n\n /* ***** */\n /* UTILS */\n /* ***** */\n\n /// @notice Determines the length of a VarInt in bytes\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\n /// @param _flag The first byte of a VarInt\n /// @return The number of non-flag bytes in the VarInt\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\n return determineVarIntDataLengthAt(_flag, 0);\n }\n\n /// @notice Determines the length of a VarInt in bytes\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\n /// @param _b The byte array containing a VarInt\n /// @param _at The position of the VarInt in the array\n /// @return The number of non-flag bytes in the VarInt\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\n if (uint8(_b[_at]) == 0xff) {\n return 8; // one-byte flag, 8 bytes data\n }\n if (uint8(_b[_at]) == 0xfe) {\n return 4; // one-byte flag, 4 bytes data\n }\n if (uint8(_b[_at]) == 0xfd) {\n return 2; // one-byte flag, 2 bytes data\n }\n\n return 0; // flag is data\n }\n\n /// @notice Parse a VarInt into its data length and the number it represents\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\n /// Caller SHOULD explicitly handle this case (or bubble it up)\n /// @param _b A byte-string starting with a VarInt\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\n return parseVarIntAt(_b, 0);\n }\n\n /// @notice Parse a VarInt into its data length and the number it represents\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\n /// Caller SHOULD explicitly handle this case (or bubble it up)\n /// @param _b A byte-string containing a VarInt\n /// @param _at The position of the VarInt\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\n\n if (_dataLen == 0) {\n return (0, uint8(_b[_at]));\n }\n if (_b.length < 1 + _dataLen + _at) {\n return (ERR_BAD_ARG, 0);\n }\n uint256 _number;\n if (_dataLen == 2) {\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\n } else if (_dataLen == 4) {\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\n } else if (_dataLen == 8) {\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\n }\n return (_dataLen, _number);\n }\n\n /// @notice Changes the endianness of a byte array\n /// @dev Returns a new, backwards, bytes\n /// @param _b The bytes to reverse\n /// @return The reversed bytes\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\n bytes memory _newValue = new bytes(_b.length);\n\n for (uint i = 0; i < _b.length; i++) {\n _newValue[_b.length - i - 1] = _b[i];\n }\n\n return _newValue;\n }\n\n /// @notice Changes the endianness of a uint256\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\n v = _b;\n\n // swap bytes\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\n // swap 2-byte long pairs\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\n // swap 4-byte long pairs\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\n // swap 8-byte long pairs\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\n // swap 16-byte long pairs\n v = (v >> 128) | (v << 128);\n }\n\n /// @notice Changes the endianness of a uint64\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\n v = _b;\n\n // swap bytes\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\n ((v & 0x00FF00FF00FF00FF) << 8);\n // swap 2-byte long pairs\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\n ((v & 0x0000FFFF0000FFFF) << 16);\n // swap 4-byte long pairs\n v = (v >> 32) | (v << 32);\n }\n\n /// @notice Changes the endianness of a uint32\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\n v = _b;\n\n // swap bytes\n v = ((v >> 8) & 0x00FF00FF) |\n ((v & 0x00FF00FF) << 8);\n // swap 2-byte long pairs\n v = (v >> 16) | (v << 16);\n }\n\n /// @notice Changes the endianness of a uint24\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\n }\n\n /// @notice Changes the endianness of a uint16\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\n v = (_b << 8) | (_b >> 8);\n }\n\n\n /// @notice Converts big-endian bytes to a uint\n /// @dev Traverses the byte array and sums the bytes\n /// @param _b The big-endian bytes-encoded integer\n /// @return The integer representation\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\n uint256 _number;\n\n for (uint i = 0; i < _b.length; i++) {\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\n }\n\n return _number;\n }\n\n /// @notice Get the last _num bytes from a byte array\n /// @param _b The byte array to slice\n /// @param _num The number of bytes to extract from the end\n /// @return The last _num bytes of _b\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\n uint256 _start = _b.length.sub(_num);\n\n return _b.slice(_start, _num);\n }\n\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\n /// @param _b The pre-image\n /// @return The digest\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\n }\n\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\n /// @param _b The pre-image\n /// @return res The digest\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\n // read from position 12 = 0c\n res := mload(0x0c)\n }\n }\n\n /// @notice Implements bitcoin's hash256 (double sha2)\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\n /// @param _b The pre-image\n /// @return The digest\n function hash256(bytes memory _b) internal pure returns (bytes32) {\n return sha256(abi.encodePacked(sha256(_b)));\n }\n\n /// @notice Implements bitcoin's hash256 (double sha2)\n /// @dev sha2 is precompiled smart contract located at address(2)\n /// @param _b The pre-image\n /// @return res The digest\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\n res := mload(0x00)\n }\n }\n\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\n /// @dev sha2 is precompiled smart contract located at address(2)\n /// @param _a The first bytes32 of the pre-image\n /// @param _b The second bytes32 of the pre-image\n /// @return res The digest\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n mstore(0x00, _a)\n mstore(0x20, _b)\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\n res := mload(0x00)\n }\n }\n\n /// @notice Implements bitcoin's hash256 (double sha2)\n /// @dev sha2 is precompiled smart contract located at address(2)\n /// @param _b The array containing the pre-image\n /// @param at The start of the pre-image\n /// @param len The length of the pre-image\n /// @return res The digest\n function hash256Slice(\n bytes memory _b,\n uint256 at,\n uint256 len\n ) internal view returns (bytes32 res) {\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\n res := mload(0x00)\n }\n }\n\n /* ************ */\n /* Legacy Input */\n /* ************ */\n\n /// @notice Extracts the nth input from the vin (0-indexed)\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\n /// @param _vin The vin as a tightly-packed byte array\n /// @param _index The 0-indexed location of the input to extract\n /// @return The input as a byte array\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\n uint256 _varIntDataLen;\n uint256 _nIns;\n\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\n require(_varIntDataLen != ERR_BAD_ARG, \"Read overrun during VarInt parsing\");\n require(_index < _nIns, \"Vin read overrun\");\n\n uint256 _len = 0;\n uint256 _offset = 1 + _varIntDataLen;\n\n for (uint256 _i = 0; _i < _index; _i ++) {\n _len = determineInputLengthAt(_vin, _offset);\n require(_len != ERR_BAD_ARG, \"Bad VarInt in scriptSig\");\n _offset = _offset + _len;\n }\n\n _len = determineInputLengthAt(_vin, _offset);\n require(_len != ERR_BAD_ARG, \"Bad VarInt in scriptSig\");\n return _vin.slice(_offset, _len);\n }\n\n /// @notice Determines whether an input is legacy\n /// @dev False if no scriptSig, otherwise True\n /// @param _input The input\n /// @return True for legacy, False for witness\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\n return _input[36] != hex\"00\";\n }\n\n /// @notice Determines the length of a scriptSig in an input\n /// @dev Will return 0 if passed a witness input.\n /// @param _input The LEGACY input\n /// @return The length of the script sig\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\n return extractScriptSigLenAt(_input, 0);\n }\n\n /// @notice Determines the length of a scriptSig in an input\n /// starting at the specified position\n /// @dev Will return 0 if passed a witness input.\n /// @param _input The byte array containing the LEGACY input\n /// @param _at The position of the input in the array\n /// @return The length of the script sig\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\n if (_input.length < 37 + _at) {\n return (ERR_BAD_ARG, 0);\n }\n\n uint256 _varIntDataLen;\n uint256 _scriptSigLen;\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\n\n return (_varIntDataLen, _scriptSigLen);\n }\n\n /// @notice Determines the length of an input from its scriptSig\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\n /// @param _input The input\n /// @return The length of the input in bytes\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\n return determineInputLengthAt(_input, 0);\n }\n\n /// @notice Determines the length of an input from its scriptSig,\n /// starting at the specified position\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\n /// @param _input The byte array containing the input\n /// @param _at The position of the input in the array\n /// @return The length of the input in bytes\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\n uint256 _varIntDataLen;\n uint256 _scriptSigLen;\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\n if (_varIntDataLen == ERR_BAD_ARG) {\n return ERR_BAD_ARG;\n }\n\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\n }\n\n /// @notice Extracts the LE sequence bytes from an input\n /// @dev Sequence is used for relative time locks\n /// @param _input The LEGACY input\n /// @return The sequence bytes (LE uint)\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\n uint256 _varIntDataLen;\n uint256 _scriptSigLen;\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\n require(_varIntDataLen != ERR_BAD_ARG, \"Bad VarInt in scriptSig\");\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\n }\n\n /// @notice Extracts the sequence from the input\n /// @dev Sequence is a 4-byte little-endian number\n /// @param _input The LEGACY input\n /// @return The sequence number (big-endian uint)\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\n uint32 _beSequence = reverseUint32(_leSeqence);\n return _beSequence;\n }\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\n /// @dev Will return hex\"00\" if passed a witness input\n /// @param _input The LEGACY input\n /// @return The length-prepended scriptSig\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\n uint256 _varIntDataLen;\n uint256 _scriptSigLen;\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\n require(_varIntDataLen != ERR_BAD_ARG, \"Bad VarInt in scriptSig\");\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\n }\n\n\n /* ************* */\n /* Witness Input */\n /* ************* */\n\n /// @notice Extracts the LE sequence bytes from an input\n /// @dev Sequence is used for relative time locks\n /// @param _input The WITNESS input\n /// @return The sequence bytes (LE uint)\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\n return _input.slice4(37);\n }\n\n /// @notice Extracts the sequence from the input in a tx\n /// @dev Sequence is a 4-byte little-endian number\n /// @param _input The WITNESS input\n /// @return The sequence number (big-endian uint)\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\n uint32 _inputeSequence = reverseUint32(_leSeqence);\n return _inputeSequence;\n }\n\n /// @notice Extracts the outpoint from the input in a tx\n /// @dev 32-byte tx id with 4-byte index\n /// @param _input The input\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\n return _input.slice(0, 36);\n }\n\n /// @notice Extracts the outpoint tx id from an input\n /// @dev 32-byte tx id\n /// @param _input The input\n /// @return The tx id (little-endian bytes)\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\n return _input.slice32(0);\n }\n\n /// @notice Extracts the outpoint tx id from an input\n /// starting at the specified position\n /// @dev 32-byte tx id\n /// @param _input The byte array containing the input\n /// @param _at The position of the input\n /// @return The tx id (little-endian bytes)\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\n return _input.slice32(_at);\n }\n\n /// @notice Extracts the LE tx input index from the input in a tx\n /// @dev 4-byte tx index\n /// @param _input The input\n /// @return The tx index (little-endian bytes)\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\n return _input.slice4(32);\n }\n\n /// @notice Extracts the LE tx input index from the input in a tx\n /// starting at the specified position\n /// @dev 4-byte tx index\n /// @param _input The byte array containing the input\n /// @param _at The position of the input\n /// @return The tx index (little-endian bytes)\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\n return _input.slice4(32 + _at);\n }\n\n /* ****** */\n /* Output */\n /* ****** */\n\n /// @notice Determines the length of an output\n /// @dev Works with any properly formatted output\n /// @param _output The output\n /// @return The length indicated by the prefix, error if invalid length\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\n return determineOutputLengthAt(_output, 0);\n }\n\n /// @notice Determines the length of an output\n /// starting at the specified position\n /// @dev Works with any properly formatted output\n /// @param _output The byte array containing the output\n /// @param _at The position of the output\n /// @return The length indicated by the prefix, error if invalid length\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\n if (_output.length < 9 + _at) {\n return ERR_BAD_ARG;\n }\n uint256 _varIntDataLen;\n uint256 _scriptPubkeyLength;\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\n\n if (_varIntDataLen == ERR_BAD_ARG) {\n return ERR_BAD_ARG;\n }\n\n // 8-byte value, 1-byte for tag itself\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\n }\n\n /// @notice Extracts the output at a given index in the TxOuts vector\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\n /// @param _vout The _vout to extract from\n /// @param _index The 0-indexed location of the output to extract\n /// @return The specified output\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\n uint256 _varIntDataLen;\n uint256 _nOuts;\n\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\n require(_varIntDataLen != ERR_BAD_ARG, \"Read overrun during VarInt parsing\");\n require(_index < _nOuts, \"Vout read overrun\");\n\n uint256 _len = 0;\n uint256 _offset = 1 + _varIntDataLen;\n\n for (uint256 _i = 0; _i < _index; _i ++) {\n _len = determineOutputLengthAt(_vout, _offset);\n require(_len != ERR_BAD_ARG, \"Bad VarInt in scriptPubkey\");\n _offset += _len;\n }\n\n _len = determineOutputLengthAt(_vout, _offset);\n require(_len != ERR_BAD_ARG, \"Bad VarInt in scriptPubkey\");\n return _vout.slice(_offset, _len);\n }\n\n /// @notice Extracts the value bytes from the output in a tx\n /// @dev Value is an 8-byte little-endian number\n /// @param _output The output\n /// @return The output value as LE bytes\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\n return _output.slice8(0);\n }\n\n /// @notice Extracts the value from the output in a tx\n /// @dev Value is an 8-byte little-endian number\n /// @param _output The output\n /// @return The output value\n function extractValue(bytes memory _output) internal pure returns (uint64) {\n uint64 _leValue = uint64(extractValueLE(_output));\n uint64 _beValue = reverseUint64(_leValue);\n return _beValue;\n }\n\n /// @notice Extracts the value from the output in a tx\n /// @dev Value is an 8-byte little-endian number\n /// @param _output The byte array containing the output\n /// @param _at The starting index of the output in the array\n /// @return The output value\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\n uint64 _leValue = uint64(_output.slice8(_at));\n uint64 _beValue = reverseUint64(_leValue);\n return _beValue;\n }\n\n /// @notice Extracts the data from an op return output\n /// @dev Returns hex\"\" if no data or not an op return\n /// @param _output The output\n /// @return Any data contained in the opreturn output, null if not an op return\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\n if (_output[9] != hex\"6a\") {\n return hex\"\";\n }\n bytes1 _dataLen = _output[10];\n return _output.slice(11, uint256(uint8(_dataLen)));\n }\n\n /// @notice Extracts the hash from the output script\n /// @dev Determines type by the length prefix and validates format\n /// @param _output The output\n /// @return The hash committed to by the pk_script, or null for errors\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\n return extractHashAt(_output, 8, _output.length - 8);\n }\n\n /// @notice Extracts the hash from the output script\n /// @dev Determines type by the length prefix and validates format\n /// @param _output The byte array containing the output\n /// @param _at The starting index of the output script in the array\n /// (output start + 8)\n /// @param _len The length of the output script\n /// (output length - 8)\n /// @return The hash committed to by the pk_script, or null for errors\n function extractHashAt(\n bytes memory _output,\n uint256 _at,\n uint256 _len\n ) internal pure returns (bytes memory) {\n uint8 _scriptLen = uint8(_output[_at]);\n\n // don't have to worry about overflow here.\n // if _scriptLen + 1 overflows, then output length would have to be < 1\n // for this check to pass. if it's < 1, then we errored when assigning\n // _scriptLen\n if (_scriptLen + 1 != _len) {\n return hex\"\";\n }\n\n if (uint8(_output[_at + 1]) == 0) {\n if (_scriptLen < 2) {\n return hex\"\";\n }\n uint256 _payloadLen = uint8(_output[_at + 2]);\n // Check for maliciously formatted witness outputs.\n // No need to worry about underflow as long b/c of the `< 2` check\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\n return hex\"\";\n }\n return _output.slice(_at + 3, _payloadLen);\n } else {\n bytes3 _tag = _output.slice3(_at);\n // p2pkh\n if (_tag == hex\"1976a9\") {\n // Check for maliciously formatted p2pkh\n // No need to worry about underflow, b/c of _scriptLen check\n if (uint8(_output[_at + 3]) != 0x14 ||\n _output.slice2(_at + _len - 2) != hex\"88ac\") {\n return hex\"\";\n }\n return _output.slice(_at + 4, 20);\n //p2sh\n } else if (_tag == hex\"17a914\") {\n // Check for maliciously formatted p2sh\n // No need to worry about underflow, b/c of _scriptLen check\n if (uint8(_output[_at + _len - 1]) != 0x87) {\n return hex\"\";\n }\n return _output.slice(_at + 3, 20);\n }\n }\n return hex\"\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\n }\n\n /* ********** */\n /* Witness TX */\n /* ********** */\n\n\n /// @notice Checks that the vin passed up is properly formatted\n /// @dev Consider a vin with a valid vout in its scriptsig\n /// @param _vin Raw bytes length-prefixed input vector\n /// @return True if it represents a validly formatted vin\n function validateVin(bytes memory _vin) internal pure returns (bool) {\n uint256 _varIntDataLen;\n uint256 _nIns;\n\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\n\n // Not valid if it says there are too many or no inputs\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\n return false;\n }\n\n uint256 _offset = 1 + _varIntDataLen;\n\n for (uint256 i = 0; i < _nIns; i++) {\n // If we're at the end, but still expect more\n if (_offset >= _vin.length) {\n return false;\n }\n\n // Grab the next input and determine its length.\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\n if (_nextLen == ERR_BAD_ARG) {\n return false;\n }\n\n // Increase the offset by that much\n _offset += _nextLen;\n }\n\n // Returns false if we're not exactly at the end\n return _offset == _vin.length;\n }\n\n /// @notice Checks that the vout passed up is properly formatted\n /// @dev Consider a vout with a valid scriptpubkey\n /// @param _vout Raw bytes length-prefixed output vector\n /// @return True if it represents a validly formatted vout\n function validateVout(bytes memory _vout) internal pure returns (bool) {\n uint256 _varIntDataLen;\n uint256 _nOuts;\n\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\n\n // Not valid if it says there are too many or no outputs\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\n return false;\n }\n\n uint256 _offset = 1 + _varIntDataLen;\n\n for (uint256 i = 0; i < _nOuts; i++) {\n // If we're at the end, but still expect more\n if (_offset >= _vout.length) {\n return false;\n }\n\n // Grab the next output and determine its length.\n // Increase the offset by that much\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\n if (_nextLen == ERR_BAD_ARG) {\n return false;\n }\n\n _offset += _nextLen;\n }\n\n // Returns false if we're not exactly at the end\n return _offset == _vout.length;\n }\n\n\n\n /* ************ */\n /* Block Header */\n /* ************ */\n\n /// @notice Extracts the transaction merkle root from a block header\n /// @dev Use verifyHash256Merkle to verify proofs with this root\n /// @param _header The header\n /// @return The merkle root (little-endian)\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\n return _header.slice32(36);\n }\n\n /// @notice Extracts the target from a block header\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\n /// @param _header The header\n /// @return The target threshold\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\n return extractTargetAt(_header, 0);\n }\n\n /// @notice Extracts the target from a block header\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\n /// @param _header The array containing the header\n /// @param at The start of the header\n /// @return The target threshold\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\n uint24 _m = uint24(_header.slice3(72 + at));\n uint8 _e = uint8(_header[75 + at]);\n uint256 _mantissa = uint256(reverseUint24(_m));\n uint _exponent = _e - 3;\n\n return _mantissa * (256 ** _exponent);\n }\n\n /// @notice Calculate difficulty from the difficulty 1 target and current target\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\n /// @param _target The current target\n /// @return The block difficulty (bdiff)\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\n // Difficulty 1 calculated from 0x1d00ffff\n return DIFF1_TARGET.div(_target);\n }\n\n /// @notice Extracts the previous block's hash from a block header\n /// @dev Block headers do NOT include block number :(\n /// @param _header The header\n /// @return The previous block's hash (little-endian)\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\n return _header.slice32(4);\n }\n\n /// @notice Extracts the previous block's hash from a block header\n /// @dev Block headers do NOT include block number :(\n /// @param _header The array containing the header\n /// @param at The start of the header\n /// @return The previous block's hash (little-endian)\n function extractPrevBlockLEAt(\n bytes memory _header,\n uint256 at\n ) internal pure returns (bytes32) {\n return _header.slice32(4 + at);\n }\n\n /// @notice Extracts the timestamp from a block header\n /// @dev Time is not 100% reliable\n /// @param _header The header\n /// @return The timestamp (little-endian bytes)\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\n return _header.slice4(68);\n }\n\n /// @notice Extracts the timestamp from a block header\n /// @dev Time is not 100% reliable\n /// @param _header The header\n /// @return The timestamp (uint)\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\n return reverseUint32(uint32(extractTimestampLE(_header)));\n }\n\n /// @notice Extracts the expected difficulty from a block header\n /// @dev Does NOT verify the work\n /// @param _header The header\n /// @return The difficulty as an integer\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\n return calculateDifficulty(extractTarget(_header));\n }\n\n /// @notice Concatenates and hashes two inputs for merkle proving\n /// @param _a The first hash\n /// @param _b The second hash\n /// @return The double-sha256 of the concatenated hashes\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\n return hash256View(abi.encodePacked(_a, _b));\n }\n\n /// @notice Concatenates and hashes two inputs for merkle proving\n /// @param _a The first hash\n /// @param _b The second hash\n /// @return The double-sha256 of the concatenated hashes\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\n return hash256Pair(_a, _b);\n }\n\n\n /// @notice Verifies a Bitcoin-style merkle tree\n /// @dev Leaves are 0-indexed. Inefficient version.\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\n /// @param _index The index of the leaf\n /// @return true if the proof is valid, else false\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\n // Not an even number of hashes\n if (_proof.length % 32 != 0) {\n return false;\n }\n\n // Special case for coinbase-only blocks\n if (_proof.length == 32) {\n return true;\n }\n\n // Should never occur\n if (_proof.length == 64) {\n return false;\n }\n\n bytes32 _root = _proof.slice32(_proof.length - 32);\n bytes32 _current = _proof.slice32(0);\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\n\n return verifyHash256Merkle(_current, _tree, _root, _index);\n }\n\n /// @notice Verifies a Bitcoin-style merkle tree\n /// @dev Leaves are 0-indexed. Efficient version.\n /// @param _leaf The leaf of the proof. LE sha256 hash.\n /// @param _tree The intermediate nodes in the proof.\n /// Tightly packed LE sha256 hashes.\n /// @param _root The root of the proof. LE sha256 hash.\n /// @param _index The index of the leaf\n /// @return true if the proof is valid, else false\n function verifyHash256Merkle(\n bytes32 _leaf,\n bytes memory _tree,\n bytes32 _root,\n uint _index\n ) internal view returns (bool) {\n // Not an even number of hashes\n if (_tree.length % 32 != 0) {\n return false;\n }\n\n // Should never occur\n if (_tree.length == 0) {\n return false;\n }\n\n uint _idx = _index;\n bytes32 _current = _leaf;\n\n // i moves in increments of 32\n for (uint i = 0; i < _tree.length; i += 32) {\n if (_idx % 2 == 1) {\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\n } else {\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\n }\n _idx = _idx >> 1;\n }\n return _current == _root;\n }\n\n /*\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\n NB: We get a full-bitlength target from this. For comparison with\n header-encoded targets we need to mask it with the header target\n e.g. (full & truncated) == truncated\n */\n /// @notice performs the bitcoin difficulty retarget\n /// @dev implements the Bitcoin algorithm precisely\n /// @param _previousTarget the target of the previous period\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\n /// @return the new period's target threshold\n function retargetAlgorithm(\n uint256 _previousTarget,\n uint256 _firstTimestamp,\n uint256 _secondTimestamp\n ) internal pure returns (uint256) {\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\n\n // Normalize ratio to factor of 4 if very long or very short\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\n _elapsedTime = RETARGET_PERIOD.div(4);\n }\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\n _elapsedTime = RETARGET_PERIOD.mul(4);\n }\n\n /*\n NB: high targets e.g. ffff0020 can cause overflows here\n so we divide it by 256**2, then multiply by 256**2 later\n we know the target is evenly divisible by 256**2, so this isn't an issue\n */\n\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\n }\n}\n" + }, + "@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol": { + "content": "pragma solidity ^0.8.4;\n\n/*\n\nhttps://github.com/GNSPS/solidity-bytes-utils/\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \n*/\n\n\n/** @title BytesLib **/\n/** @author https://github.com/GNSPS **/\n\nlibrary BytesLib {\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\n bytes memory tempBytes;\n\n assembly {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // Store the length of the first bytes array at the beginning of\n // the memory for tempBytes.\n let length := mload(_preBytes)\n mstore(tempBytes, length)\n\n // Maintain a memory counter for the current write location in the\n // temp bytes array by adding the 32 bytes for the array length to\n // the starting location.\n let mc := add(tempBytes, 0x20)\n // Stop copying when the memory counter reaches the length of the\n // first bytes array.\n let end := add(mc, length)\n\n for {\n // Initialize a copy counter to the start of the _preBytes data,\n // 32 bytes into its memory.\n let cc := add(_preBytes, 0x20)\n } lt(mc, end) {\n // Increase both counters by 32 bytes each iteration.\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // Write the _preBytes data into the tempBytes memory 32 bytes\n // at a time.\n mstore(mc, mload(cc))\n }\n\n // Add the length of _postBytes to the current length of tempBytes\n // and store it as the new length in the first 32 bytes of the\n // tempBytes memory.\n length := mload(_postBytes)\n mstore(tempBytes, add(length, mload(tempBytes)))\n\n // Move the memory counter back from a multiple of 0x20 to the\n // actual end of the _preBytes data.\n mc := end\n // Stop copying when the memory counter reaches the new combined\n // length of the arrays.\n end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n // Update the free-memory pointer by padding our last write location\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\n // next 32 byte block, then round down to the nearest multiple of\n // 32. If the sum of the length of the two arrays is zero then add\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\n mstore(0x40, and(\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\n not(31) // Round down to the nearest 32 bytes.\n ))\n }\n\n return tempBytes;\n }\n\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\n assembly {\n // Read the first 32 bytes of _preBytes storage, which is the length\n // of the array. (We don't need to use the offset into the slot\n // because arrays use the entire slot.)\n let fslot := sload(_preBytes.slot)\n // Arrays of 31 bytes or less have an even value in their slot,\n // while longer arrays have an odd value. The actual length is\n // the slot divided by two for odd values, and the lowest order\n // byte divided by two for even values.\n // If the slot is even, bitwise and the slot with 255 and divide by\n // two to get the length. If the slot is odd, bitwise and the slot\n // with -1 and divide by two.\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\n let mlength := mload(_postBytes)\n let newlength := add(slength, mlength)\n // slength can contain both the length and contents of the array\n // if length < 32 bytes so let's prepare for that\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\n switch add(lt(slength, 32), lt(newlength, 32))\n case 2 {\n // Since the new array still fits in the slot, we just need to\n // update the contents of the slot.\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\n sstore(\n _preBytes.slot,\n // all the modifications to the slot are inside this\n // next block\n add(\n // we can just add to the slot contents because the\n // bytes we want to change are the LSBs\n fslot,\n add(\n mul(\n div(\n // load the bytes from memory\n mload(add(_postBytes, 0x20)),\n // zero all bytes to the right\n exp(0x100, sub(32, mlength))\n ),\n // and now shift left the number of bytes to\n // leave space for the length in the slot\n exp(0x100, sub(32, newlength))\n ),\n // increase length by the double of the memory\n // bytes length\n mul(mlength, 2)\n )\n )\n )\n }\n case 1 {\n // The stored value fits in the slot, but the combined value\n // will exceed it.\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\n\n // save new length\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\n\n // The contents of the _postBytes array start 32 bytes into\n // the structure. Our first read should obtain the `submod`\n // bytes that can fit into the unused space in the last word\n // of the stored array. To get this, we read 32 bytes starting\n // from `submod`, so the data we read overlaps with the array\n // contents by `submod` bytes. Masking the lowest-order\n // `submod` bytes allows us to add that value directly to the\n // stored value.\n\n let submod := sub(32, slength)\n let mc := add(_postBytes, submod)\n let end := add(_postBytes, mlength)\n let mask := sub(exp(0x100, submod), 1)\n\n sstore(\n sc,\n add(\n and(\n fslot,\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\n ),\n and(mload(mc), mask)\n )\n )\n\n for {\n mc := add(mc, 0x20)\n sc := add(sc, 1)\n } lt(mc, end) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n sstore(sc, mload(mc))\n }\n\n mask := exp(0x100, sub(mc, end))\n\n sstore(sc, mul(div(mload(mc), mask), mask))\n }\n default {\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n // Start copying to the last used word of the stored array.\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\n\n // save new length\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\n\n // Copy over the first `submod` bytes of the new data as in\n // case 1 above.\n let slengthmod := mod(slength, 32)\n let mlengthmod := mod(mlength, 32)\n let submod := sub(32, slengthmod)\n let mc := add(_postBytes, submod)\n let end := add(_postBytes, mlength)\n let mask := sub(exp(0x100, submod), 1)\n\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\n\n for {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } lt(mc, end) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n sstore(sc, mload(mc))\n }\n\n mask := exp(0x100, sub(mc, end))\n\n sstore(sc, mul(div(mload(mc), mask), mask))\n }\n }\n }\n\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\n if (_length == 0) {\n return hex\"\";\n }\n uint _end = _start + _length;\n require(_end > _start && _bytes.length >= _end, \"Slice out of bounds\");\n\n assembly {\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\n res := mload(0x40)\n mstore(0x40, add(add(res, 64), _length))\n mstore(res, _length)\n\n // Compute distance between source and destination pointers\n let diff := sub(res, add(_bytes, _start))\n\n for {\n let src := add(add(_bytes, 32), _start)\n let end := add(src, _length)\n } lt(src, end) {\n src := add(src, 32)\n } {\n mstore(add(src, diff), mload(src))\n }\n }\n }\n\n /// @notice Take a slice of the byte array, overwriting the destination.\n /// The length of the slice will equal the length of the destination array.\n /// @dev Make sure the destination array has afterspace if required.\n /// @param _bytes The source array\n /// @param _dest The destination array.\n /// @param _start The location to start in the source array.\n function sliceInPlace(\n bytes memory _bytes,\n bytes memory _dest,\n uint _start\n ) internal pure {\n uint _length = _dest.length;\n uint _end = _start + _length;\n require(_end > _start && _bytes.length >= _end, \"Slice out of bounds\");\n\n assembly {\n for {\n let src := add(add(_bytes, 32), _start)\n let res := add(_dest, 32)\n let end := add(src, _length)\n } lt(src, end) {\n src := add(src, 32)\n res := add(res, 32)\n } {\n mstore(res, mload(src))\n }\n }\n }\n\n // Static slice functions, no bounds checking\n /// @notice take a 32-byte slice from the specified position\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\n assembly {\n res := mload(add(add(_bytes, 32), _start))\n }\n }\n\n /// @notice take a 20-byte slice from the specified position\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\n return bytes20(slice32(_bytes, _start));\n }\n\n /// @notice take a 8-byte slice from the specified position\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\n return bytes8(slice32(_bytes, _start));\n }\n\n /// @notice take a 4-byte slice from the specified position\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\n return bytes4(slice32(_bytes, _start));\n }\n\n /// @notice take a 3-byte slice from the specified position\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\n return bytes3(slice32(_bytes, _start));\n }\n\n /// @notice take a 2-byte slice from the specified position\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\n return bytes2(slice32(_bytes, _start));\n }\n\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\n uint _totalLen = _start + 20;\n require(_totalLen > _start && _bytes.length >= _totalLen, \"Address conversion out of bounds.\");\n address tempAddress;\n\n assembly {\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\n }\n\n return tempAddress;\n }\n\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\n uint _totalLen = _start + 32;\n require(_totalLen > _start && _bytes.length >= _totalLen, \"Uint conversion out of bounds.\");\n uint256 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x20), _start))\n }\n\n return tempUint;\n }\n\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\n bool success = true;\n\n assembly {\n let length := mload(_preBytes)\n\n // if lengths don't match the arrays are not equal\n switch eq(length, mload(_postBytes))\n case 1 {\n // cb is a circuit breaker in the for loop since there's\n // no said feature for inline assembly loops\n // cb = 1 - don't breaker\n // cb = 0 - break\n let cb := 1\n\n let mc := add(_preBytes, 0x20)\n let end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n // the next line is the loop condition:\n // while(uint(mc < end) + cb == 2)\n } eq(add(lt(mc, end), cb), 2) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // if any of these checks fails then arrays are not equal\n if iszero(eq(mload(mc), mload(cc))) {\n // unsuccess:\n success := 0\n cb := 0\n }\n }\n }\n default {\n // unsuccess:\n success := 0\n }\n }\n\n return success;\n }\n\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\n bool success = true;\n\n assembly {\n // we know _preBytes_offset is 0\n let fslot := sload(_preBytes.slot)\n // Decode the length of the stored array like in concatStorage().\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\n let mlength := mload(_postBytes)\n\n // if lengths don't match the arrays are not equal\n switch eq(slength, mlength)\n case 1 {\n // slength can contain both the length and contents of the array\n // if length < 32 bytes so let's prepare for that\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\n if iszero(iszero(slength)) {\n switch lt(slength, 32)\n case 1 {\n // blank the last byte which is the length\n fslot := mul(div(fslot, 0x100), 0x100)\n\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\n // unsuccess:\n success := 0\n }\n }\n default {\n // cb is a circuit breaker in the for loop since there's\n // no said feature for inline assembly loops\n // cb = 1 - don't breaker\n // cb = 0 - break\n let cb := 1\n\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n let sc := keccak256(0x0, 0x20)\n\n let mc := add(_postBytes, 0x20)\n let end := add(mc, mlength)\n\n // the next line is the loop condition:\n // while(uint(mc < end) + cb == 2)\n for {} eq(add(lt(mc, end), cb), 2) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n if iszero(eq(sload(sc), mload(mc))) {\n // unsuccess:\n success := 0\n cb := 0\n }\n }\n }\n }\n }\n default {\n // unsuccess:\n success := 0\n }\n }\n\n return success;\n }\n\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\n if (_source.length == 0) {\n return 0x0;\n }\n\n assembly {\n result := mload(add(_source, 32))\n }\n }\n\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\n uint _end = _start + _length;\n require(_end > _start && _bytes.length >= _end, \"Slice out of bounds\");\n\n assembly {\n result := keccak256(add(add(_bytes, 32), _start), _length)\n }\n }\n}\n" + }, + "@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol": { + "content": "pragma solidity ^0.8.4;\n\n/*\nThe MIT License (MIT)\n\nCopyright (c) 2016 Smart Contract Solutions, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n\n/**\n * @title SafeMath\n * @dev Math operations with safety checks that throw on error\n */\nlibrary SafeMath {\n\n /**\n * @dev Multiplies two numbers, throws on overflow.\n */\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (_a == 0) {\n return 0;\n }\n\n c = _a * _b;\n require(c / _a == _b, \"Overflow during multiplication.\");\n return c;\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\n // uint256 c = _a / _b;\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\n return _a / _b;\n }\n\n /**\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\n require(_b <= _a, \"Underflow during subtraction.\");\n return _a - _b;\n }\n\n /**\n * @dev Adds two numbers, throws on overflow.\n */\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\n c = _a + _b;\n require(c >= _a, \"Overflow during addition.\");\n return c;\n }\n}\n" + }, + "@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\nimport {BTCUtils} from \"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\";\n\nimport \"./IBridge.sol\";\nimport \"./ITBTCVault.sol\";\n\n/// @title Abstract AbstractTBTCDepositor contract.\n/// @notice This abstract contract is meant to facilitate integration of protocols\n/// aiming to use tBTC as an underlying Bitcoin bridge.\n///\n/// Such an integrator is supposed to:\n/// - Create a child contract inheriting from this abstract contract\n/// - Call the `__AbstractTBTCDepositor_initialize` initializer function\n/// - Use the `_initializeDeposit` and `_finalizeDeposit` as part of their\n/// business logic in order to initialize and finalize deposits.\n///\n/// @dev Example usage:\n/// ```\n/// // Example upgradeable integrator contract.\n/// contract ExampleTBTCIntegrator is AbstractTBTCDepositor, Initializable {\n/// /// @custom:oz-upgrades-unsafe-allow constructor\n/// constructor() {\n/// // Prevents the contract from being initialized again.\n/// _disableInitializers();\n/// }\n///\n/// function initialize(\n/// address _bridge,\n/// address _tbtcVault\n/// ) external initializer {\n/// __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\n/// }\n///\n/// function startProcess(\n/// IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n/// IBridgeTypes.DepositRevealInfo calldata reveal\n/// ) external {\n/// // Embed necessary context as extra data.\n/// bytes32 extraData = ...;\n///\n/// uint256 depositKey = _initializeDeposit(\n/// fundingTx,\n/// reveal,\n/// extraData\n/// );\n///\n/// // Use the depositKey to track the process.\n/// }\n///\n/// function finalizeProcess(uint256 depositKey) external {\n/// // Ensure the function cannot be called for the same deposit\n/// // twice.\n///\n/// (\n/// uint256 initialDepositAmount,\n/// uint256 tbtcAmount,\n/// bytes32 extraData\n/// ) = _finalizeDeposit(depositKey);\n///\n/// // Do something with the minted TBTC using context\n/// // embedded in the extraData.\n/// }\n/// }\nabstract contract AbstractTBTCDepositor {\n using BTCUtils for bytes;\n\n /// @notice Multiplier to convert satoshi to TBTC token units.\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\n\n /// @notice Bridge contract address.\n IBridge public bridge;\n /// @notice TBTCVault contract address.\n ITBTCVault public tbtcVault;\n\n // Reserved storage space that allows adding more variables without affecting\n // the storage layout of the child contracts. The convention from OpenZeppelin\n // suggests the storage space should add up to 50 slots. If more variables are\n // added in the upcoming versions one need to reduce the array size accordingly.\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // slither-disable-next-line unused-state\n uint256[47] private __gap;\n\n event DepositInitialized(uint256 indexed depositKey, uint32 initializedAt);\n\n event DepositFinalized(\n uint256 indexed depositKey,\n uint256 tbtcAmount,\n uint32 finalizedAt\n );\n\n /// @notice Initializes the contract. MUST BE CALLED from the child\n /// contract initializer.\n // slither-disable-next-line dead-code\n function __AbstractTBTCDepositor_initialize(\n address _bridge,\n address _tbtcVault\n ) internal {\n require(\n address(bridge) == address(0) && address(tbtcVault) == address(0),\n \"AbstractTBTCDepositor already initialized\"\n );\n\n require(_bridge != address(0), \"Bridge address cannot be zero\");\n require(_tbtcVault != address(0), \"TBTCVault address cannot be zero\");\n\n bridge = IBridge(_bridge);\n tbtcVault = ITBTCVault(_tbtcVault);\n }\n\n /// @notice Initializes a deposit by revealing it to the Bridge.\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo` struct.\n /// @param extraData 32-byte deposit extra data.\n /// @return depositKey Deposit key computed as\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\n /// key can be used to refer to the deposit in the Bridge and\n /// TBTCVault contracts.\n /// @dev Requirements:\n /// - The revealed vault address must match the TBTCVault address,\n /// - All requirements from {Bridge#revealDepositWithExtraData}\n /// function must be met.\n /// @dev This function doesn't validate if a deposit has been initialized before,\n /// as the Bridge won't allow the same deposit to be revealed twice.\n // slither-disable-next-line dead-code\n function _initializeDeposit(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) internal returns (uint256) {\n require(reveal.vault == address(tbtcVault), \"Vault address mismatch\");\n\n uint256 depositKey = _calculateDepositKey(\n _calculateBitcoinTxHash(fundingTx),\n reveal.fundingOutputIndex\n );\n\n emit DepositInitialized(\n depositKey,\n /* solhint-disable-next-line not-rely-on-time */\n uint32(block.timestamp)\n );\n\n // The Bridge does not allow to reveal the same deposit twice and\n // revealed deposits stay there forever. The transaction will revert\n // if the deposit has already been revealed so, there is no need to do\n // an explicit check here.\n bridge.revealDepositWithExtraData(fundingTx, reveal, extraData);\n\n return depositKey;\n }\n\n /// @notice Finalizes a deposit by calculating the amount of TBTC minted\n /// for the deposit.\n /// @param depositKey Deposit key identifying the deposit.\n /// @return initialDepositAmount Amount of funding transaction deposit. In\n /// TBTC token decimals precision.\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit. In\n /// TBTC token decimals precision.\n /// @return extraData 32-byte deposit extra data.\n /// @dev Requirements:\n /// - The deposit must be initialized but not finalized\n /// (in the context of this contract) yet.\n /// - The deposit must be finalized on the Bridge side. That means the\n /// deposit must be either swept or optimistically minted.\n /// @dev THIS FUNCTION DOESN'T VALIDATE IF A DEPOSIT HAS BEEN FINALIZED BEFORE,\n /// IT IS A RESPONSIBILITY OF THE IMPLEMENTING CONTRACT TO ENSURE THIS\n /// FUNCTION WON'T BE CALLED TWICE FOR THE SAME DEPOSIT.\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function is an\n /// approximation. See documentation of the `calculateTbtcAmount`\n /// responsible for calculating this value for more details.\n // slither-disable-next-line dead-code\n function _finalizeDeposit(uint256 depositKey)\n internal\n returns (\n uint256 initialDepositAmount,\n uint256 tbtcAmount,\n bytes32 extraData\n )\n {\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\n depositKey\n );\n require(deposit.revealedAt != 0, \"Deposit not initialized\");\n\n (, uint64 finalizedAt) = tbtcVault.optimisticMintingRequests(\n depositKey\n );\n\n require(\n deposit.sweptAt != 0 || finalizedAt != 0,\n \"Deposit not finalized by the bridge\"\n );\n\n initialDepositAmount = deposit.amount * SATOSHI_MULTIPLIER;\n\n tbtcAmount = _calculateTbtcAmount(deposit.amount, deposit.treasuryFee);\n\n // slither-disable-next-line reentrancy-events\n emit DepositFinalized(\n depositKey,\n tbtcAmount,\n /* solhint-disable-next-line not-rely-on-time */\n uint32(block.timestamp)\n );\n\n extraData = deposit.extraData;\n }\n\n /// @notice Calculates the amount of TBTC minted for the deposit.\n /// @param depositAmountSat Deposit amount in satoshi (1e8 precision).\n /// This is the actual amount deposited by the deposit creator, i.e.\n /// the gross amount the Bridge's fees are cut from.\n /// @param depositTreasuryFeeSat Deposit treasury fee in satoshi (1e8 precision).\n /// This is an accurate value of the treasury fee that was actually\n /// cut upon minting.\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit.\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function may\n /// not correspond to the actual amount of TBTC minted for the deposit.\n /// Although the treasury fee cut upon minting is known precisely,\n /// this is not the case for the optimistic minting fee and the Bitcoin\n /// transaction fee. To overcome that problem, this function just takes\n /// the current maximum allowed values of both fees, at the moment of deposit\n /// finalization. For the great majority of the deposits, such an\n /// algorithm will return a tbtcAmount slightly lesser than the\n /// actual amount of TBTC minted for the deposit. This will cause\n /// some TBTC to be left in the contract and ensure there is enough\n /// liquidity to finalize the deposit. However, in some rare cases,\n /// where the actual values of those fees change between the deposit\n /// minting and finalization, the tbtcAmount returned by this function\n /// may be greater than the actual amount of TBTC minted for the deposit.\n /// If this happens and the reserve coming from previous deposits\n /// leftovers does not provide enough liquidity, the deposit will have\n /// to wait for finalization until the reserve is refilled by subsequent\n /// deposits or a manual top-up. The integrator is responsible for\n /// handling such cases.\n // slither-disable-next-line dead-code\n function _calculateTbtcAmount(\n uint64 depositAmountSat,\n uint64 depositTreasuryFeeSat\n ) internal view virtual returns (uint256) {\n // Both deposit amount and treasury fee are in the 1e8 satoshi precision.\n // We need to convert them to the 1e18 TBTC precision.\n uint256 amountSubTreasury = (depositAmountSat - depositTreasuryFeeSat) *\n SATOSHI_MULTIPLIER;\n\n uint256 omFeeDivisor = tbtcVault.optimisticMintingFeeDivisor();\n uint256 omFee = omFeeDivisor > 0\n ? (amountSubTreasury / omFeeDivisor)\n : 0;\n\n // The deposit transaction max fee is in the 1e8 satoshi precision.\n // We need to convert them to the 1e18 TBTC precision.\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\n\n return amountSubTreasury - omFee - txMaxFee;\n }\n\n /// @notice Calculates the deposit key for the given funding transaction\n /// hash and funding output index.\n /// @param fundingTxHash Funding transaction hash.\n /// @param fundingOutputIndex Funding output index.\n /// @return depositKey Deposit key computed as\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\n /// key can be used to refer to the deposit in the Bridge and\n /// TBTCVault contracts.\n // slither-disable-next-line dead-code\n function _calculateDepositKey(\n bytes32 fundingTxHash,\n uint32 fundingOutputIndex\n ) internal pure returns (uint256) {\n return\n uint256(\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\n );\n }\n\n /// @notice Calculates the Bitcoin transaction hash for the given Bitcoin\n /// transaction data.\n /// @param txInfo Bitcoin transaction data, see `IBridgeTypes.BitcoinTxInfo` struct.\n /// @return txHash Bitcoin transaction hash.\n // slither-disable-next-line dead-code\n function _calculateBitcoinTxHash(IBridgeTypes.BitcoinTxInfo calldata txInfo)\n internal\n view\n returns (bytes32)\n {\n return\n abi\n .encodePacked(\n txInfo.version,\n txInfo.inputVector,\n txInfo.outputVector,\n txInfo.locktime\n )\n .hash256View();\n }\n}\n" + }, + "@keep-network/tbtc-v2/contracts/integrator/IBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\n/// @notice Namespace which groups all types relevant to the IBridge interface.\n/// @dev This is a mirror of the real types used in the Bridge contract.\n/// This way, the `integrator` subpackage does not need to import\n/// anything from the `bridge` subpackage and explicitly depend on it.\n/// This simplifies the dependency graph for integrators.\nlibrary IBridgeTypes {\n /// @dev See bridge/BitcoinTx.sol#Info\n struct BitcoinTxInfo {\n bytes4 version;\n bytes inputVector;\n bytes outputVector;\n bytes4 locktime;\n }\n\n /// @dev See bridge/Deposit.sol#DepositRevealInfo\n struct DepositRevealInfo {\n uint32 fundingOutputIndex;\n bytes8 blindingFactor;\n bytes20 walletPubKeyHash;\n bytes20 refundPubKeyHash;\n bytes4 refundLocktime;\n address vault;\n }\n\n /// @dev See bridge/Deposit.sol#DepositRequest\n struct DepositRequest {\n address depositor;\n uint64 amount;\n uint32 revealedAt;\n address vault;\n uint64 treasuryFee;\n uint32 sweptAt;\n bytes32 extraData;\n }\n}\n\n/// @notice Interface of the Bridge contract.\n/// @dev See bridge/Bridge.sol\ninterface IBridge {\n /// @dev See {Bridge#revealDepositWithExtraData}\n function revealDepositWithExtraData(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external;\n\n /// @dev See {Bridge#deposits}\n function deposits(uint256 depositKey)\n external\n view\n returns (IBridgeTypes.DepositRequest memory);\n\n /// @dev See {Bridge#depositParameters}\n function depositParameters()\n external\n view\n returns (\n uint64 depositDustThreshold,\n uint64 depositTreasuryFeeDivisor,\n uint64 depositTxMaxFee,\n uint32 depositRevealAheadPeriod\n );\n}\n" + }, + "@keep-network/tbtc-v2/contracts/integrator/ITBTCVault.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\n/// @notice Interface of the TBTCVault contract.\n/// @dev See vault/TBTCVault.sol\ninterface ITBTCVault {\n /// @dev See {TBTCVault#optimisticMintingRequests}\n function optimisticMintingRequests(uint256 depositKey)\n external\n returns (uint64 requestedAt, uint64 finalizedAt);\n\n /// @dev See {TBTCVault#optimisticMintingFeeDivisor}\n function optimisticMintingFeeDivisor() external view returns (uint32);\n}\n" + }, + "@keep-network/tbtc-v2/contracts/test/TestTBTCDepositor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.0;\n\nimport {BTCUtils} from \"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\";\n\nimport \"../integrator/AbstractTBTCDepositor.sol\";\nimport \"../integrator/IBridge.sol\";\nimport \"../integrator/ITBTCVault.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ncontract TestTBTCDepositor is AbstractTBTCDepositor {\n event InitializeDepositReturned(uint256 depositKey);\n\n event FinalizeDepositReturned(\n uint256 initialDepositAmount,\n uint256 tbtcAmount,\n bytes32 extraData\n );\n\n function initialize(address _bridge, address _tbtcVault) external {\n __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\n }\n\n function initializeDepositPublic(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external {\n uint256 depositKey = _initializeDeposit(fundingTx, reveal, extraData);\n emit InitializeDepositReturned(depositKey);\n }\n\n function finalizeDepositPublic(uint256 depositKey) external {\n (\n uint256 initialDepositAmount,\n uint256 tbtcAmount,\n bytes32 extraData\n ) = _finalizeDeposit(depositKey);\n emit FinalizeDepositReturned(\n initialDepositAmount,\n tbtcAmount,\n extraData\n );\n }\n\n function calculateTbtcAmountPublic(\n uint64 depositAmountSat,\n uint64 depositTreasuryFeeSat\n ) external view returns (uint256) {\n return _calculateTbtcAmount(depositAmountSat, depositTreasuryFeeSat);\n }\n}\n\ncontract MockBridge is IBridge {\n using BTCUtils for bytes;\n\n mapping(uint256 => IBridgeTypes.DepositRequest) internal _deposits;\n\n uint64 internal _depositTreasuryFeeDivisor = 50; // 1/50 == 100 bps == 2% == 0.02\n uint64 internal _depositTxMaxFee = 1000; // 1000 satoshi = 0.00001 BTC\n\n event DepositRevealed(uint256 depositKey);\n\n function revealDepositWithExtraData(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external {\n bytes32 fundingTxHash = abi\n .encodePacked(\n fundingTx.version,\n fundingTx.inputVector,\n fundingTx.outputVector,\n fundingTx.locktime\n )\n .hash256View();\n\n uint256 depositKey = uint256(\n keccak256(\n abi.encodePacked(fundingTxHash, reveal.fundingOutputIndex)\n )\n );\n\n require(\n _deposits[depositKey].revealedAt == 0,\n \"Deposit already revealed\"\n );\n\n bytes memory fundingOutput = fundingTx\n .outputVector\n .extractOutputAtIndex(reveal.fundingOutputIndex);\n\n uint64 fundingOutputAmount = fundingOutput.extractValue();\n\n IBridgeTypes.DepositRequest memory request;\n\n request.depositor = msg.sender;\n request.amount = fundingOutputAmount;\n /* solhint-disable-next-line not-rely-on-time */\n request.revealedAt = uint32(block.timestamp);\n request.vault = reveal.vault;\n request.treasuryFee = _depositTreasuryFeeDivisor > 0\n ? fundingOutputAmount / _depositTreasuryFeeDivisor\n : 0;\n request.sweptAt = 0;\n request.extraData = extraData;\n\n _deposits[depositKey] = request;\n\n emit DepositRevealed(depositKey);\n }\n\n function sweepDeposit(uint256 depositKey) public {\n require(_deposits[depositKey].revealedAt != 0, \"Deposit not revealed\");\n require(_deposits[depositKey].sweptAt == 0, \"Deposit already swept\");\n /* solhint-disable-next-line not-rely-on-time */\n _deposits[depositKey].sweptAt = uint32(block.timestamp);\n }\n\n function deposits(uint256 depositKey)\n external\n view\n returns (IBridgeTypes.DepositRequest memory)\n {\n return _deposits[depositKey];\n }\n\n function depositParameters()\n external\n view\n returns (\n uint64 depositDustThreshold,\n uint64 depositTreasuryFeeDivisor,\n uint64 depositTxMaxFee,\n uint32 depositRevealAheadPeriod\n )\n {\n depositDustThreshold = 0;\n depositTreasuryFeeDivisor = 0;\n depositTxMaxFee = _depositTxMaxFee;\n depositRevealAheadPeriod = 0;\n }\n\n function setDepositTreasuryFeeDivisor(uint64 value) external {\n _depositTreasuryFeeDivisor = value;\n }\n\n function setDepositTxMaxFee(uint64 value) external {\n _depositTxMaxFee = value;\n }\n}\n\ncontract MockTBTCVault is ITBTCVault {\n struct Request {\n uint64 requestedAt;\n uint64 finalizedAt;\n }\n\n mapping(uint256 => Request) internal _requests;\n\n uint32 public optimisticMintingFeeDivisor = 100; // 1%\n\n function optimisticMintingRequests(uint256 depositKey)\n external\n returns (uint64 requestedAt, uint64 finalizedAt)\n {\n Request memory request = _requests[depositKey];\n return (request.requestedAt, request.finalizedAt);\n }\n\n /// @dev The function is virtual to allow other projects using this mock\n /// for AbtractTBTCDepositor-based contract tests to add any custom\n /// logic needed.\n function createOptimisticMintingRequest(uint256 depositKey) public virtual {\n require(\n _requests[depositKey].requestedAt == 0,\n \"Request already exists\"\n );\n /* solhint-disable-next-line not-rely-on-time */\n _requests[depositKey].requestedAt = uint64(block.timestamp);\n }\n\n /// @dev The function is virtual to allow other projects using this mock\n /// for AbtractTBTCDepositor-based contract tests to add any custom\n /// logic needed.\n function finalizeOptimisticMintingRequest(uint256 depositKey)\n public\n virtual\n {\n require(\n _requests[depositKey].requestedAt != 0,\n \"Request does not exist\"\n );\n require(\n _requests[depositKey].finalizedAt == 0,\n \"Request already finalized\"\n );\n /* solhint-disable-next-line not-rely-on-time */\n _requests[depositKey].finalizedAt = uint64(block.timestamp);\n }\n\n function setOptimisticMintingFeeDivisor(uint32 value) external {\n optimisticMintingFeeDivisor = value;\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable2Step.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)\n\npragma solidity ^0.8.20;\n\nimport {Ownable} from \"./Ownable.sol\";\n\n/**\n * @dev Contract module which provides access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is specified at deployment time in the constructor for `Ownable`. This\n * can later be changed with {transferOwnership} and {acceptOwnership}.\n *\n * This module is used through inheritance. It will make available all functions\n * from parent (Ownable).\n */\nabstract contract Ownable2Step is Ownable {\n address private _pendingOwner;\n\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Returns the address of the pending owner.\n */\n function pendingOwner() public view virtual returns (address) {\n return _pendingOwner;\n }\n\n /**\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual override onlyOwner {\n _pendingOwner = newOwner;\n emit OwnershipTransferStarted(owner(), newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual override {\n delete _pendingOwner;\n super._transferOwnership(newOwner);\n }\n\n /**\n * @dev The new owner accepts the ownership transfer.\n */\n function acceptOwnership() public virtual {\n address sender = _msgSender();\n if (pendingOwner() != sender) {\n revert OwnableUnauthorizedAccount(sender);\n }\n _transferOwnership(sender);\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../token/ERC20/IERC20.sol\";\nimport {IERC20Metadata} from \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed sender,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20, IERC20Metadata, ERC20} from \"../ERC20.sol\";\nimport {SafeERC20} from \"../utils/SafeERC20.sol\";\nimport {IERC4626} from \"../../../interfaces/IERC4626.sol\";\nimport {Math} from \"../../../utils/math/Math.sol\";\n\n/**\n * @dev Implementation of the ERC4626 \"Tokenized Vault Standard\" as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\n *\n * This extension allows the minting and burning of \"shares\" (represented using the ERC20 inheritance) in exchange for\n * underlying \"assets\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\n * the ERC20 standard. Any additional extensions included along it would affect the \"shares\" token represented by this\n * contract and not the \"assets\" token which is an independent contract.\n *\n * [CAUTION]\n * ====\n * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning\n * with a \"donation\" to the vault that inflates the price of a share. This is variously known as a donation or inflation\n * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial\n * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may\n * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by\n * verifying the amount received is as expected, using a wrapper that performs these checks such as\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\n *\n * Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()`\n * corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault\n * decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself\n * determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset\n * (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's\n * donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more\n * expensive than it is profitable. More details about the underlying math can be found\n * xref:erc4626.adoc#inflation-attack[here].\n *\n * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued\n * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets\n * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience\n * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the\n * `_convertToShares` and `_convertToAssets` functions.\n *\n * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].\n * ====\n */\nabstract contract ERC4626 is ERC20, IERC4626 {\n using Math for uint256;\n\n IERC20 private immutable _asset;\n uint8 private immutable _underlyingDecimals;\n\n /**\n * @dev Attempted to deposit more assets than the max amount for `receiver`.\n */\n error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);\n\n /**\n * @dev Attempted to mint more shares than the max amount for `receiver`.\n */\n error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);\n\n /**\n * @dev Attempted to withdraw more assets than the max amount for `receiver`.\n */\n error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);\n\n /**\n * @dev Attempted to redeem more shares than the max amount for `receiver`.\n */\n error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);\n\n /**\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\n */\n constructor(IERC20 asset_) {\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\n _underlyingDecimals = success ? assetDecimals : 18;\n _asset = asset_;\n }\n\n /**\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\n */\n function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {\n (bool success, bytes memory encodedDecimals) = address(asset_).staticcall(\n abi.encodeCall(IERC20Metadata.decimals, ())\n );\n if (success && encodedDecimals.length >= 32) {\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\n if (returnedDecimals <= type(uint8).max) {\n return (true, uint8(returnedDecimals));\n }\n }\n return (false, 0);\n }\n\n /**\n * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This\n * \"original\" value is cached during construction of the vault contract. If this read operation fails (e.g., the\n * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.\n *\n * See {IERC20Metadata-decimals}.\n */\n function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {\n return _underlyingDecimals + _decimalsOffset();\n }\n\n /** @dev See {IERC4626-asset}. */\n function asset() public view virtual returns (address) {\n return address(_asset);\n }\n\n /** @dev See {IERC4626-totalAssets}. */\n function totalAssets() public view virtual returns (uint256) {\n return _asset.balanceOf(address(this));\n }\n\n /** @dev See {IERC4626-convertToShares}. */\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-convertToAssets}. */\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-maxDeposit}. */\n function maxDeposit(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4626-maxMint}. */\n function maxMint(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4626-maxWithdraw}. */\n function maxWithdraw(address owner) public view virtual returns (uint256) {\n return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-maxRedeem}. */\n function maxRedeem(address owner) public view virtual returns (uint256) {\n return balanceOf(owner);\n }\n\n /** @dev See {IERC4626-previewDeposit}. */\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-previewMint}. */\n function previewMint(uint256 shares) public view virtual returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Ceil);\n }\n\n /** @dev See {IERC4626-previewWithdraw}. */\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Ceil);\n }\n\n /** @dev See {IERC4626-previewRedeem}. */\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-deposit}. */\n function deposit(uint256 assets, address receiver) public virtual returns (uint256) {\n uint256 maxAssets = maxDeposit(receiver);\n if (assets > maxAssets) {\n revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);\n }\n\n uint256 shares = previewDeposit(assets);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-mint}.\n *\n * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.\n * In this case, the shares will be minted without requiring any assets to be deposited.\n */\n function mint(uint256 shares, address receiver) public virtual returns (uint256) {\n uint256 maxShares = maxMint(receiver);\n if (shares > maxShares) {\n revert ERC4626ExceededMaxMint(receiver, shares, maxShares);\n }\n\n uint256 assets = previewMint(shares);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return assets;\n }\n\n /** @dev See {IERC4626-withdraw}. */\n function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {\n uint256 maxAssets = maxWithdraw(owner);\n if (assets > maxAssets) {\n revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);\n }\n\n uint256 shares = previewWithdraw(assets);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-redeem}. */\n function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {\n uint256 maxShares = maxRedeem(owner);\n if (shares > maxShares) {\n revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);\n }\n\n uint256 assets = previewRedeem(shares);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\n */\n function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {\n return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\n */\n function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {\n return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);\n }\n\n /**\n * @dev Deposit/mint common workflow.\n */\n function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {\n // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\n // assets are transferred and before the shares are minted, which is a valid state.\n // slither-disable-next-line reentrancy-no-eth\n SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\n _mint(receiver, shares);\n\n emit Deposit(caller, receiver, assets, shares);\n }\n\n /**\n * @dev Withdraw/redeem common workflow.\n */\n function _withdraw(\n address caller,\n address receiver,\n address owner,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n if (caller != owner) {\n _spendAllowance(owner, caller, shares);\n }\n\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\n // shares are burned and after the assets are transferred, which is a valid state.\n _burn(owner, shares);\n SafeERC20.safeTransfer(_asset, receiver, assets);\n\n emit Withdraw(caller, receiver, owner, assets, shares);\n }\n\n function _decimalsOffset() internal view virtual returns (uint8) {\n return 0;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\nimport {IERC20Permit} from \"../extensions/IERC20Permit.sol\";\nimport {Address} from \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n /**\n * @dev An operation with an ERC20 token failed.\n */\n error SafeERC20FailedOperation(address token);\n\n /**\n * @dev Indicates a failed `decreaseAllowance` request.\n */\n error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n forceApprove(token, spender, oldAllowance + value);\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\n * value, non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\n unchecked {\n uint256 currentAllowance = token.allowance(address(this), spender);\n if (currentAllowance < requestedDecrease) {\n revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\n }\n forceApprove(token, spender, currentAllowance - requestedDecrease);\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data);\n if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance < amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance < value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 && target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SafeCast.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\n * checks.\n *\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\n * easily result in undesired exploitation or bugs, since developers usually\n * assume that overflows raise errors. `SafeCast` restores this intuition by\n * reverting the transaction when such an operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeCast {\n /**\n * @dev Value doesn't fit in an uint of `bits` size.\n */\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\n\n /**\n * @dev An int value doesn't fit in an uint of `bits` size.\n */\n error SafeCastOverflowedIntToUint(int256 value);\n\n /**\n * @dev Value doesn't fit in an int of `bits` size.\n */\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\n\n /**\n * @dev An uint value doesn't fit in an int of `bits` size.\n */\n error SafeCastOverflowedUintToInt(uint256 value);\n\n /**\n * @dev Returns the downcasted uint248 from uint256, reverting on\n * overflow (when the input is greater than largest uint248).\n *\n * Counterpart to Solidity's `uint248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n */\n function toUint248(uint256 value) internal pure returns (uint248) {\n if (value > type(uint248).max) {\n revert SafeCastOverflowedUintDowncast(248, value);\n }\n return uint248(value);\n }\n\n /**\n * @dev Returns the downcasted uint240 from uint256, reverting on\n * overflow (when the input is greater than largest uint240).\n *\n * Counterpart to Solidity's `uint240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n */\n function toUint240(uint256 value) internal pure returns (uint240) {\n if (value > type(uint240).max) {\n revert SafeCastOverflowedUintDowncast(240, value);\n }\n return uint240(value);\n }\n\n /**\n * @dev Returns the downcasted uint232 from uint256, reverting on\n * overflow (when the input is greater than largest uint232).\n *\n * Counterpart to Solidity's `uint232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n */\n function toUint232(uint256 value) internal pure returns (uint232) {\n if (value > type(uint232).max) {\n revert SafeCastOverflowedUintDowncast(232, value);\n }\n return uint232(value);\n }\n\n /**\n * @dev Returns the downcasted uint224 from uint256, reverting on\n * overflow (when the input is greater than largest uint224).\n *\n * Counterpart to Solidity's `uint224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toUint224(uint256 value) internal pure returns (uint224) {\n if (value > type(uint224).max) {\n revert SafeCastOverflowedUintDowncast(224, value);\n }\n return uint224(value);\n }\n\n /**\n * @dev Returns the downcasted uint216 from uint256, reverting on\n * overflow (when the input is greater than largest uint216).\n *\n * Counterpart to Solidity's `uint216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n */\n function toUint216(uint256 value) internal pure returns (uint216) {\n if (value > type(uint216).max) {\n revert SafeCastOverflowedUintDowncast(216, value);\n }\n return uint216(value);\n }\n\n /**\n * @dev Returns the downcasted uint208 from uint256, reverting on\n * overflow (when the input is greater than largest uint208).\n *\n * Counterpart to Solidity's `uint208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n */\n function toUint208(uint256 value) internal pure returns (uint208) {\n if (value > type(uint208).max) {\n revert SafeCastOverflowedUintDowncast(208, value);\n }\n return uint208(value);\n }\n\n /**\n * @dev Returns the downcasted uint200 from uint256, reverting on\n * overflow (when the input is greater than largest uint200).\n *\n * Counterpart to Solidity's `uint200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n */\n function toUint200(uint256 value) internal pure returns (uint200) {\n if (value > type(uint200).max) {\n revert SafeCastOverflowedUintDowncast(200, value);\n }\n return uint200(value);\n }\n\n /**\n * @dev Returns the downcasted uint192 from uint256, reverting on\n * overflow (when the input is greater than largest uint192).\n *\n * Counterpart to Solidity's `uint192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n */\n function toUint192(uint256 value) internal pure returns (uint192) {\n if (value > type(uint192).max) {\n revert SafeCastOverflowedUintDowncast(192, value);\n }\n return uint192(value);\n }\n\n /**\n * @dev Returns the downcasted uint184 from uint256, reverting on\n * overflow (when the input is greater than largest uint184).\n *\n * Counterpart to Solidity's `uint184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n */\n function toUint184(uint256 value) internal pure returns (uint184) {\n if (value > type(uint184).max) {\n revert SafeCastOverflowedUintDowncast(184, value);\n }\n return uint184(value);\n }\n\n /**\n * @dev Returns the downcasted uint176 from uint256, reverting on\n * overflow (when the input is greater than largest uint176).\n *\n * Counterpart to Solidity's `uint176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n */\n function toUint176(uint256 value) internal pure returns (uint176) {\n if (value > type(uint176).max) {\n revert SafeCastOverflowedUintDowncast(176, value);\n }\n return uint176(value);\n }\n\n /**\n * @dev Returns the downcasted uint168 from uint256, reverting on\n * overflow (when the input is greater than largest uint168).\n *\n * Counterpart to Solidity's `uint168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n */\n function toUint168(uint256 value) internal pure returns (uint168) {\n if (value > type(uint168).max) {\n revert SafeCastOverflowedUintDowncast(168, value);\n }\n return uint168(value);\n }\n\n /**\n * @dev Returns the downcasted uint160 from uint256, reverting on\n * overflow (when the input is greater than largest uint160).\n *\n * Counterpart to Solidity's `uint160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n */\n function toUint160(uint256 value) internal pure returns (uint160) {\n if (value > type(uint160).max) {\n revert SafeCastOverflowedUintDowncast(160, value);\n }\n return uint160(value);\n }\n\n /**\n * @dev Returns the downcasted uint152 from uint256, reverting on\n * overflow (when the input is greater than largest uint152).\n *\n * Counterpart to Solidity's `uint152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n */\n function toUint152(uint256 value) internal pure returns (uint152) {\n if (value > type(uint152).max) {\n revert SafeCastOverflowedUintDowncast(152, value);\n }\n return uint152(value);\n }\n\n /**\n * @dev Returns the downcasted uint144 from uint256, reverting on\n * overflow (when the input is greater than largest uint144).\n *\n * Counterpart to Solidity's `uint144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n */\n function toUint144(uint256 value) internal pure returns (uint144) {\n if (value > type(uint144).max) {\n revert SafeCastOverflowedUintDowncast(144, value);\n }\n return uint144(value);\n }\n\n /**\n * @dev Returns the downcasted uint136 from uint256, reverting on\n * overflow (when the input is greater than largest uint136).\n *\n * Counterpart to Solidity's `uint136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n */\n function toUint136(uint256 value) internal pure returns (uint136) {\n if (value > type(uint136).max) {\n revert SafeCastOverflowedUintDowncast(136, value);\n }\n return uint136(value);\n }\n\n /**\n * @dev Returns the downcasted uint128 from uint256, reverting on\n * overflow (when the input is greater than largest uint128).\n *\n * Counterpart to Solidity's `uint128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toUint128(uint256 value) internal pure returns (uint128) {\n if (value > type(uint128).max) {\n revert SafeCastOverflowedUintDowncast(128, value);\n }\n return uint128(value);\n }\n\n /**\n * @dev Returns the downcasted uint120 from uint256, reverting on\n * overflow (when the input is greater than largest uint120).\n *\n * Counterpart to Solidity's `uint120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n */\n function toUint120(uint256 value) internal pure returns (uint120) {\n if (value > type(uint120).max) {\n revert SafeCastOverflowedUintDowncast(120, value);\n }\n return uint120(value);\n }\n\n /**\n * @dev Returns the downcasted uint112 from uint256, reverting on\n * overflow (when the input is greater than largest uint112).\n *\n * Counterpart to Solidity's `uint112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n */\n function toUint112(uint256 value) internal pure returns (uint112) {\n if (value > type(uint112).max) {\n revert SafeCastOverflowedUintDowncast(112, value);\n }\n return uint112(value);\n }\n\n /**\n * @dev Returns the downcasted uint104 from uint256, reverting on\n * overflow (when the input is greater than largest uint104).\n *\n * Counterpart to Solidity's `uint104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n */\n function toUint104(uint256 value) internal pure returns (uint104) {\n if (value > type(uint104).max) {\n revert SafeCastOverflowedUintDowncast(104, value);\n }\n return uint104(value);\n }\n\n /**\n * @dev Returns the downcasted uint96 from uint256, reverting on\n * overflow (when the input is greater than largest uint96).\n *\n * Counterpart to Solidity's `uint96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toUint96(uint256 value) internal pure returns (uint96) {\n if (value > type(uint96).max) {\n revert SafeCastOverflowedUintDowncast(96, value);\n }\n return uint96(value);\n }\n\n /**\n * @dev Returns the downcasted uint88 from uint256, reverting on\n * overflow (when the input is greater than largest uint88).\n *\n * Counterpart to Solidity's `uint88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n */\n function toUint88(uint256 value) internal pure returns (uint88) {\n if (value > type(uint88).max) {\n revert SafeCastOverflowedUintDowncast(88, value);\n }\n return uint88(value);\n }\n\n /**\n * @dev Returns the downcasted uint80 from uint256, reverting on\n * overflow (when the input is greater than largest uint80).\n *\n * Counterpart to Solidity's `uint80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n */\n function toUint80(uint256 value) internal pure returns (uint80) {\n if (value > type(uint80).max) {\n revert SafeCastOverflowedUintDowncast(80, value);\n }\n return uint80(value);\n }\n\n /**\n * @dev Returns the downcasted uint72 from uint256, reverting on\n * overflow (when the input is greater than largest uint72).\n *\n * Counterpart to Solidity's `uint72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n */\n function toUint72(uint256 value) internal pure returns (uint72) {\n if (value > type(uint72).max) {\n revert SafeCastOverflowedUintDowncast(72, value);\n }\n return uint72(value);\n }\n\n /**\n * @dev Returns the downcasted uint64 from uint256, reverting on\n * overflow (when the input is greater than largest uint64).\n *\n * Counterpart to Solidity's `uint64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toUint64(uint256 value) internal pure returns (uint64) {\n if (value > type(uint64).max) {\n revert SafeCastOverflowedUintDowncast(64, value);\n }\n return uint64(value);\n }\n\n /**\n * @dev Returns the downcasted uint56 from uint256, reverting on\n * overflow (when the input is greater than largest uint56).\n *\n * Counterpart to Solidity's `uint56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n */\n function toUint56(uint256 value) internal pure returns (uint56) {\n if (value > type(uint56).max) {\n revert SafeCastOverflowedUintDowncast(56, value);\n }\n return uint56(value);\n }\n\n /**\n * @dev Returns the downcasted uint48 from uint256, reverting on\n * overflow (when the input is greater than largest uint48).\n *\n * Counterpart to Solidity's `uint48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n */\n function toUint48(uint256 value) internal pure returns (uint48) {\n if (value > type(uint48).max) {\n revert SafeCastOverflowedUintDowncast(48, value);\n }\n return uint48(value);\n }\n\n /**\n * @dev Returns the downcasted uint40 from uint256, reverting on\n * overflow (when the input is greater than largest uint40).\n *\n * Counterpart to Solidity's `uint40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n */\n function toUint40(uint256 value) internal pure returns (uint40) {\n if (value > type(uint40).max) {\n revert SafeCastOverflowedUintDowncast(40, value);\n }\n return uint40(value);\n }\n\n /**\n * @dev Returns the downcasted uint32 from uint256, reverting on\n * overflow (when the input is greater than largest uint32).\n *\n * Counterpart to Solidity's `uint32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toUint32(uint256 value) internal pure returns (uint32) {\n if (value > type(uint32).max) {\n revert SafeCastOverflowedUintDowncast(32, value);\n }\n return uint32(value);\n }\n\n /**\n * @dev Returns the downcasted uint24 from uint256, reverting on\n * overflow (when the input is greater than largest uint24).\n *\n * Counterpart to Solidity's `uint24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n */\n function toUint24(uint256 value) internal pure returns (uint24) {\n if (value > type(uint24).max) {\n revert SafeCastOverflowedUintDowncast(24, value);\n }\n return uint24(value);\n }\n\n /**\n * @dev Returns the downcasted uint16 from uint256, reverting on\n * overflow (when the input is greater than largest uint16).\n *\n * Counterpart to Solidity's `uint16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toUint16(uint256 value) internal pure returns (uint16) {\n if (value > type(uint16).max) {\n revert SafeCastOverflowedUintDowncast(16, value);\n }\n return uint16(value);\n }\n\n /**\n * @dev Returns the downcasted uint8 from uint256, reverting on\n * overflow (when the input is greater than largest uint8).\n *\n * Counterpart to Solidity's `uint8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n */\n function toUint8(uint256 value) internal pure returns (uint8) {\n if (value > type(uint8).max) {\n revert SafeCastOverflowedUintDowncast(8, value);\n }\n return uint8(value);\n }\n\n /**\n * @dev Converts a signed int256 into an unsigned uint256.\n *\n * Requirements:\n *\n * - input must be greater than or equal to 0.\n */\n function toUint256(int256 value) internal pure returns (uint256) {\n if (value < 0) {\n revert SafeCastOverflowedIntToUint(value);\n }\n return uint256(value);\n }\n\n /**\n * @dev Returns the downcasted int248 from int256, reverting on\n * overflow (when the input is less than smallest int248 or\n * greater than largest int248).\n *\n * Counterpart to Solidity's `int248` operator.\n *\n * Requirements:\n *\n * - input must fit into 248 bits\n */\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\n downcasted = int248(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(248, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int240 from int256, reverting on\n * overflow (when the input is less than smallest int240 or\n * greater than largest int240).\n *\n * Counterpart to Solidity's `int240` operator.\n *\n * Requirements:\n *\n * - input must fit into 240 bits\n */\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\n downcasted = int240(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(240, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int232 from int256, reverting on\n * overflow (when the input is less than smallest int232 or\n * greater than largest int232).\n *\n * Counterpart to Solidity's `int232` operator.\n *\n * Requirements:\n *\n * - input must fit into 232 bits\n */\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\n downcasted = int232(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(232, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int224 from int256, reverting on\n * overflow (when the input is less than smallest int224 or\n * greater than largest int224).\n *\n * Counterpart to Solidity's `int224` operator.\n *\n * Requirements:\n *\n * - input must fit into 224 bits\n */\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\n downcasted = int224(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(224, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int216 from int256, reverting on\n * overflow (when the input is less than smallest int216 or\n * greater than largest int216).\n *\n * Counterpart to Solidity's `int216` operator.\n *\n * Requirements:\n *\n * - input must fit into 216 bits\n */\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\n downcasted = int216(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(216, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int208 from int256, reverting on\n * overflow (when the input is less than smallest int208 or\n * greater than largest int208).\n *\n * Counterpart to Solidity's `int208` operator.\n *\n * Requirements:\n *\n * - input must fit into 208 bits\n */\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\n downcasted = int208(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(208, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int200 from int256, reverting on\n * overflow (when the input is less than smallest int200 or\n * greater than largest int200).\n *\n * Counterpart to Solidity's `int200` operator.\n *\n * Requirements:\n *\n * - input must fit into 200 bits\n */\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\n downcasted = int200(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(200, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int192 from int256, reverting on\n * overflow (when the input is less than smallest int192 or\n * greater than largest int192).\n *\n * Counterpart to Solidity's `int192` operator.\n *\n * Requirements:\n *\n * - input must fit into 192 bits\n */\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\n downcasted = int192(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(192, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int184 from int256, reverting on\n * overflow (when the input is less than smallest int184 or\n * greater than largest int184).\n *\n * Counterpart to Solidity's `int184` operator.\n *\n * Requirements:\n *\n * - input must fit into 184 bits\n */\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\n downcasted = int184(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(184, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int176 from int256, reverting on\n * overflow (when the input is less than smallest int176 or\n * greater than largest int176).\n *\n * Counterpart to Solidity's `int176` operator.\n *\n * Requirements:\n *\n * - input must fit into 176 bits\n */\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\n downcasted = int176(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(176, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int168 from int256, reverting on\n * overflow (when the input is less than smallest int168 or\n * greater than largest int168).\n *\n * Counterpart to Solidity's `int168` operator.\n *\n * Requirements:\n *\n * - input must fit into 168 bits\n */\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\n downcasted = int168(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(168, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int160 from int256, reverting on\n * overflow (when the input is less than smallest int160 or\n * greater than largest int160).\n *\n * Counterpart to Solidity's `int160` operator.\n *\n * Requirements:\n *\n * - input must fit into 160 bits\n */\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\n downcasted = int160(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(160, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int152 from int256, reverting on\n * overflow (when the input is less than smallest int152 or\n * greater than largest int152).\n *\n * Counterpart to Solidity's `int152` operator.\n *\n * Requirements:\n *\n * - input must fit into 152 bits\n */\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\n downcasted = int152(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(152, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int144 from int256, reverting on\n * overflow (when the input is less than smallest int144 or\n * greater than largest int144).\n *\n * Counterpart to Solidity's `int144` operator.\n *\n * Requirements:\n *\n * - input must fit into 144 bits\n */\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\n downcasted = int144(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(144, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int136 from int256, reverting on\n * overflow (when the input is less than smallest int136 or\n * greater than largest int136).\n *\n * Counterpart to Solidity's `int136` operator.\n *\n * Requirements:\n *\n * - input must fit into 136 bits\n */\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\n downcasted = int136(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(136, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int128 from int256, reverting on\n * overflow (when the input is less than smallest int128 or\n * greater than largest int128).\n *\n * Counterpart to Solidity's `int128` operator.\n *\n * Requirements:\n *\n * - input must fit into 128 bits\n */\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\n downcasted = int128(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(128, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int120 from int256, reverting on\n * overflow (when the input is less than smallest int120 or\n * greater than largest int120).\n *\n * Counterpart to Solidity's `int120` operator.\n *\n * Requirements:\n *\n * - input must fit into 120 bits\n */\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\n downcasted = int120(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(120, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int112 from int256, reverting on\n * overflow (when the input is less than smallest int112 or\n * greater than largest int112).\n *\n * Counterpart to Solidity's `int112` operator.\n *\n * Requirements:\n *\n * - input must fit into 112 bits\n */\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\n downcasted = int112(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(112, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int104 from int256, reverting on\n * overflow (when the input is less than smallest int104 or\n * greater than largest int104).\n *\n * Counterpart to Solidity's `int104` operator.\n *\n * Requirements:\n *\n * - input must fit into 104 bits\n */\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\n downcasted = int104(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(104, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int96 from int256, reverting on\n * overflow (when the input is less than smallest int96 or\n * greater than largest int96).\n *\n * Counterpart to Solidity's `int96` operator.\n *\n * Requirements:\n *\n * - input must fit into 96 bits\n */\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\n downcasted = int96(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(96, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int88 from int256, reverting on\n * overflow (when the input is less than smallest int88 or\n * greater than largest int88).\n *\n * Counterpart to Solidity's `int88` operator.\n *\n * Requirements:\n *\n * - input must fit into 88 bits\n */\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\n downcasted = int88(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(88, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int80 from int256, reverting on\n * overflow (when the input is less than smallest int80 or\n * greater than largest int80).\n *\n * Counterpart to Solidity's `int80` operator.\n *\n * Requirements:\n *\n * - input must fit into 80 bits\n */\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\n downcasted = int80(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(80, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int72 from int256, reverting on\n * overflow (when the input is less than smallest int72 or\n * greater than largest int72).\n *\n * Counterpart to Solidity's `int72` operator.\n *\n * Requirements:\n *\n * - input must fit into 72 bits\n */\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\n downcasted = int72(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(72, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int64 from int256, reverting on\n * overflow (when the input is less than smallest int64 or\n * greater than largest int64).\n *\n * Counterpart to Solidity's `int64` operator.\n *\n * Requirements:\n *\n * - input must fit into 64 bits\n */\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\n downcasted = int64(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(64, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int56 from int256, reverting on\n * overflow (when the input is less than smallest int56 or\n * greater than largest int56).\n *\n * Counterpart to Solidity's `int56` operator.\n *\n * Requirements:\n *\n * - input must fit into 56 bits\n */\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\n downcasted = int56(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(56, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int48 from int256, reverting on\n * overflow (when the input is less than smallest int48 or\n * greater than largest int48).\n *\n * Counterpart to Solidity's `int48` operator.\n *\n * Requirements:\n *\n * - input must fit into 48 bits\n */\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\n downcasted = int48(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(48, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int40 from int256, reverting on\n * overflow (when the input is less than smallest int40 or\n * greater than largest int40).\n *\n * Counterpart to Solidity's `int40` operator.\n *\n * Requirements:\n *\n * - input must fit into 40 bits\n */\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\n downcasted = int40(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(40, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int32 from int256, reverting on\n * overflow (when the input is less than smallest int32 or\n * greater than largest int32).\n *\n * Counterpart to Solidity's `int32` operator.\n *\n * Requirements:\n *\n * - input must fit into 32 bits\n */\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\n downcasted = int32(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(32, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int24 from int256, reverting on\n * overflow (when the input is less than smallest int24 or\n * greater than largest int24).\n *\n * Counterpart to Solidity's `int24` operator.\n *\n * Requirements:\n *\n * - input must fit into 24 bits\n */\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\n downcasted = int24(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(24, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int16 from int256, reverting on\n * overflow (when the input is less than smallest int16 or\n * greater than largest int16).\n *\n * Counterpart to Solidity's `int16` operator.\n *\n * Requirements:\n *\n * - input must fit into 16 bits\n */\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\n downcasted = int16(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(16, value);\n }\n }\n\n /**\n * @dev Returns the downcasted int8 from int256, reverting on\n * overflow (when the input is less than smallest int8 or\n * greater than largest int8).\n *\n * Counterpart to Solidity's `int8` operator.\n *\n * Requirements:\n *\n * - input must fit into 8 bits\n */\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\n downcasted = int8(value);\n if (downcasted != value) {\n revert SafeCastOverflowedIntDowncast(8, value);\n }\n }\n\n /**\n * @dev Converts an unsigned uint256 into a signed int256.\n *\n * Requirements:\n *\n * - input must be less than or equal to maxInt256.\n */\n function toInt256(uint256 value) internal pure returns (int256) {\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\n if (value > uint256(type(int256).max)) {\n revert SafeCastOverflowedUintToInt(value);\n }\n return int256(value);\n }\n}\n" + }, + "contracts/AcreBitcoinDepositor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeCast} from \"@openzeppelin/contracts/utils/math/SafeCast.sol\";\n\nimport \"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\";\n\nimport {stBTC} from \"./stBTC.sol\";\n\n// TODO: Make Upgradable\n// TODO: Make Pausable\n\n/// @title Acre Bitcoin Depositor contract.\n/// @notice The contract integrates Acre staking with tBTC minting.\n/// User who wants to stake BTC in Acre should submit a Bitcoin transaction\n/// to the most recently created off-chain ECDSA wallets of the tBTC Bridge\n/// using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH)\n/// containing hashed information about this Depositor contract address,\n/// and staker's Ethereum address.\n/// Then, the staker initiates tBTC minting by revealing their Ethereum\n/// address along with their deposit blinding factor, refund public key\n/// hash and refund locktime on the tBTC Bridge through this Depositor\n/// contract.\n/// The off-chain ECDSA wallet and Optimistic Minting bots listen for these\n/// sorts of messages and when they get one, they check the Bitcoin network\n/// to make sure the deposit lines up. Majority of tBTC minting is finalized\n/// by the Optimistic Minting process, where Minter bot initializes\n/// minting process and if there is no veto from the Guardians, the\n/// process is finalized and tBTC minted to the Depositor address. If\n/// the revealed deposit is not handled by the Optimistic Minting process\n/// the off-chain ECDSA wallet may decide to pick the deposit transaction\n/// for sweeping, and when the sweep operation is confirmed on the Bitcoin\n/// network, the tBTC Bridge and tBTC vault mint the tBTC token to the\n/// Depositor address. After tBTC is minted to the Depositor, on the stake\n/// finalization tBTC is staked in stBTC contract and stBTC shares are emitted\n/// to the staker.\ncontract AcreBitcoinDepositor is AbstractTBTCDepositor, Ownable2Step {\n using SafeERC20 for IERC20;\n\n /// @notice State of the stake request.\n enum StakeRequestState {\n Unknown,\n Initialized,\n Finalized,\n Queued,\n FinalizedFromQueue,\n CancelledFromQueue\n }\n\n struct StakeRequest {\n // State of the stake request.\n StakeRequestState state;\n // The address to which the stBTC shares will be minted. Stored only when\n // request is queued.\n address staker;\n // tBTC token amount to stake after deducting tBTC minting fees and the\n // Depositor fee. Stored only when request is queued.\n uint88 queuedAmount;\n }\n\n /// @notice Mapping of stake requests.\n /// @dev The key is a deposit key identifying the deposit.\n mapping(uint256 => StakeRequest) public stakeRequests;\n\n /// @notice tBTC Token contract.\n // TODO: Remove slither disable when introducing upgradeability.\n // slither-disable-next-line immutable-states\n IERC20 public tbtcToken;\n\n /// @notice stBTC contract.\n // TODO: Remove slither disable when introducing upgradeability.\n // slither-disable-next-line immutable-states\n stBTC public stbtc;\n\n /// @notice Divisor used to compute the depositor fee taken from each deposit\n /// and transferred to the treasury upon stake request finalization.\n /// @dev That fee is computed as follows:\n /// `depositorFee = depositedAmount / depositorFeeDivisor`\n /// for example, if the depositor fee needs to be 2% of each deposit,\n /// the `depositorFeeDivisor` should be set to `50` because\n /// `1/50 = 0.02 = 2%`.\n uint64 public depositorFeeDivisor;\n\n /// @notice Emitted when a stake request is initialized.\n /// @dev Deposit details can be fetched from {{ Bridge.DepositRevealed }}\n /// event emitted in the same transaction.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param caller Address that initialized the stake request.\n /// @param staker The address to which the stBTC shares will be minted.\n event StakeRequestInitialized(\n uint256 indexed depositKey,\n address indexed caller,\n address indexed staker\n );\n\n /// @notice Emitted when bridging completion has been notified.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param caller Address that notified about bridging completion.\n /// @param referral Identifier of a partner in the referral program.\n /// @param bridgedAmount Amount of tBTC tokens that was bridged by the tBTC bridge.\n /// @param depositorFee Depositor fee amount.\n event BridgingCompleted(\n uint256 indexed depositKey,\n address indexed caller,\n uint16 indexed referral,\n uint256 bridgedAmount,\n uint256 depositorFee\n );\n\n /// @notice Emitted when a stake request is finalized.\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\n /// event emitted in the same transaction.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param caller Address that finalized the stake request.\n /// @param stakedAmount Amount of staked tBTC tokens.\n event StakeRequestFinalized(\n uint256 indexed depositKey,\n address indexed caller,\n uint256 stakedAmount\n );\n\n /// @notice Emitted when a stake request is queued.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param caller Address that finalized the stake request.\n /// @param queuedAmount Amount of queued tBTC tokens.\n event StakeRequestQueued(\n uint256 indexed depositKey,\n address indexed caller,\n uint256 queuedAmount\n );\n\n /// @notice Emitted when a stake request is finalized from the queue.\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\n /// event emitted in the same transaction.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param caller Address that finalized the stake request.\n /// @param stakedAmount Amount of staked tBTC tokens.\n event StakeRequestFinalizedFromQueue(\n uint256 indexed depositKey,\n address indexed caller,\n uint256 stakedAmount\n );\n\n /// @notice Emitted when a queued stake request is cancelled.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param staker Address of the staker.\n /// @param amountToStake Amount of queued tBTC tokens that got cancelled.\n event StakeRequestCancelledFromQueue(\n uint256 indexed depositKey,\n address indexed staker,\n uint256 amountToStake\n );\n\n /// @notice Emitted when a depositor fee divisor is updated.\n /// @param depositorFeeDivisor New value of the depositor fee divisor.\n event DepositorFeeDivisorUpdated(uint64 depositorFeeDivisor);\n\n /// Reverts if the tBTC Token address is zero.\n error TbtcTokenZeroAddress();\n\n /// Reverts if the stBTC address is zero.\n error StbtcZeroAddress();\n\n /// @dev Staker address is zero.\n error StakerIsZeroAddress();\n\n /// @dev Attempted to execute function for stake request in unexpected current\n /// state.\n error UnexpectedStakeRequestState(\n StakeRequestState currentState,\n StakeRequestState expectedState\n );\n\n /// @dev Attempted to finalize bridging with depositor's contract tBTC balance\n /// lower than the calculated bridged tBTC amount. This error means\n /// that Governance should top-up the tBTC reserve for bridging fees\n /// approximation.\n error InsufficientTbtcBalance(\n uint256 amountToStake,\n uint256 currentBalance\n );\n\n /// @dev Attempted to notify a bridging completion, while it was already\n /// notified.\n error BridgingCompletionAlreadyNotified();\n\n /// @dev Attempted to finalize a stake request, while bridging completion has\n /// not been notified yet.\n error BridgingNotCompleted();\n\n /// @dev Calculated depositor fee exceeds the amount of minted tBTC tokens.\n error DepositorFeeExceedsBridgedAmount(\n uint256 depositorFee,\n uint256 bridgedAmount\n );\n\n /// @dev Attempted to call bridging finalization for a stake request for\n /// which the function was already called.\n error BridgingFinalizationAlreadyCalled();\n\n /// @dev Attempted to finalize or cancel a stake request that was not added\n /// to the queue, or was already finalized or cancelled.\n error StakeRequestNotQueued();\n\n /// @dev Attempted to call function by an account that is not the staker.\n error CallerNotStaker();\n\n /// @notice Acre Bitcoin Depositor contract constructor.\n /// @param bridge tBTC Bridge contract instance.\n /// @param tbtcVault tBTC Vault contract instance.\n /// @param _tbtcToken tBTC token contract instance.\n /// @param _stbtc stBTC contract instance.\n // TODO: Move to initializer when making the contract upgradeable.\n constructor(\n address bridge,\n address tbtcVault,\n address _tbtcToken,\n address _stbtc\n ) Ownable(msg.sender) {\n __AbstractTBTCDepositor_initialize(bridge, tbtcVault);\n\n if (address(_tbtcToken) == address(0)) {\n revert TbtcTokenZeroAddress();\n }\n if (address(_stbtc) == address(0)) {\n revert StbtcZeroAddress();\n }\n\n tbtcToken = IERC20(_tbtcToken);\n stbtc = stBTC(_stbtc);\n\n depositorFeeDivisor = 1000; // 1/1000 == 10bps == 0.1% == 0.001\n }\n\n /// @notice This function allows staking process initialization for a Bitcoin\n /// deposit made by an user with a P2(W)SH transaction. It uses the\n /// supplied information to reveal a deposit to the tBTC Bridge contract.\n /// @dev Requirements:\n /// - The revealed vault address must match the TBTCVault address,\n /// - All requirements from {Bridge#revealDepositWithExtraData}\n /// function must be met.\n /// - `staker` must be the staker address used in the P2(W)SH BTC\n /// deposit transaction as part of the extra data.\n /// - `referral` must be the referral info used in the P2(W)SH BTC\n /// deposit transaction as part of the extra data.\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\n /// can be revealed only one time.\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\n /// @param staker The address to which the stBTC shares will be minted.\n /// @param referral Data used for referral program.\n function initializeStake(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n address staker,\n uint16 referral\n ) external {\n if (staker == address(0)) revert StakerIsZeroAddress();\n\n // We don't check if the request was already initialized, as this check\n // is enforced in `_initializeDeposit` when calling the\n // `Bridge.revealDepositWithExtraData` function.\n uint256 depositKey = _initializeDeposit(\n fundingTx,\n reveal,\n encodeExtraData(staker, referral)\n );\n\n transitionStakeRequestState(\n depositKey,\n StakeRequestState.Unknown,\n StakeRequestState.Initialized\n );\n\n emit StakeRequestInitialized(depositKey, msg.sender, staker);\n }\n\n /// @notice This function should be called for previously initialized stake\n /// request, after tBTC bridging process was finalized.\n /// It stakes the tBTC from the given deposit into stBTC, emitting the\n /// stBTC shares to the staker specified in the deposit extra data\n /// and using the referral provided in the extra data.\n /// @dev In case depositing in stBTC vault fails (e.g. because of the\n /// maximum deposit limit being reached), the `queueStake` function\n /// should be called to add the stake request to the staking queue.\n /// @param depositKey Deposit key identifying the deposit.\n function finalizeStake(uint256 depositKey) external {\n transitionStakeRequestState(\n depositKey,\n StakeRequestState.Initialized,\n StakeRequestState.Finalized\n );\n\n (uint256 amountToStake, address staker) = finalizeBridging(depositKey);\n\n emit StakeRequestFinalized(depositKey, msg.sender, amountToStake);\n\n // Deposit tBTC in stBTC.\n tbtcToken.safeIncreaseAllowance(address(stbtc), amountToStake);\n // slither-disable-next-line unused-return\n stbtc.deposit(amountToStake, staker);\n }\n\n /// @notice This function should be called for previously initialized stake\n /// request, after tBTC bridging process was finalized, in case the\n /// `finalizeStake` failed due to stBTC vault deposit limit\n /// being reached.\n /// @dev It queues the stake request, until the stBTC vault is ready to\n /// accept the deposit. The request must be finalized with `finalizeQueuedStake`\n /// after the limit is increased or other user withdraws their funds\n /// from the stBTC contract to make place for another deposit.\n /// The staker has a possibility to submit `cancelQueuedStake` that\n /// will withdraw the minted tBTC token and abort staking process.\n /// @param depositKey Deposit key identifying the deposit.\n function queueStake(uint256 depositKey) external {\n transitionStakeRequestState(\n depositKey,\n StakeRequestState.Initialized,\n StakeRequestState.Queued\n );\n\n StakeRequest storage request = stakeRequests[depositKey];\n\n uint256 amountToStake;\n (amountToStake, request.staker) = finalizeBridging(depositKey);\n\n request.queuedAmount = SafeCast.toUint88(amountToStake);\n\n emit StakeRequestQueued(depositKey, msg.sender, request.queuedAmount);\n }\n\n /// @notice This function should be called for previously queued stake\n /// request, when stBTC vault is able to accept a deposit.\n /// @param depositKey Deposit key identifying the deposit.\n function finalizeQueuedStake(uint256 depositKey) external {\n transitionStakeRequestState(\n depositKey,\n StakeRequestState.Queued,\n StakeRequestState.FinalizedFromQueue\n );\n\n StakeRequest storage request = stakeRequests[depositKey];\n\n if (request.queuedAmount == 0) revert StakeRequestNotQueued();\n\n uint256 amountToStake = request.queuedAmount;\n delete (request.queuedAmount);\n\n emit StakeRequestFinalizedFromQueue(\n depositKey,\n msg.sender,\n amountToStake\n );\n\n // Deposit tBTC in stBTC.\n tbtcToken.safeIncreaseAllowance(address(stbtc), amountToStake);\n // slither-disable-next-line unused-return\n stbtc.deposit(amountToStake, request.staker);\n }\n\n /// @notice Cancel queued stake.\n /// The function can be called by the staker to recover tBTC that cannot\n /// be finalized to stake in stBTC contract due to a deposit limit being\n /// reached.\n /// @dev This function can be called only after the stake request was added\n /// to queue.\n /// @dev Only staker provided in the extra data of the stake request can\n /// call this function.\n /// @param depositKey Deposit key identifying the deposit.\n function cancelQueuedStake(uint256 depositKey) external {\n transitionStakeRequestState(\n depositKey,\n StakeRequestState.Queued,\n StakeRequestState.CancelledFromQueue\n );\n\n StakeRequest storage request = stakeRequests[depositKey];\n\n if (request.queuedAmount == 0) revert StakeRequestNotQueued();\n\n // Check if caller is the staker.\n if (msg.sender != request.staker) revert CallerNotStaker();\n\n uint256 amount = request.queuedAmount;\n delete (request.queuedAmount);\n\n emit StakeRequestCancelledFromQueue(depositKey, request.staker, amount);\n\n tbtcToken.safeTransfer(request.staker, amount);\n }\n\n /// @notice Updates the depositor fee divisor.\n /// @param newDepositorFeeDivisor New depositor fee divisor value.\n function updateDepositorFeeDivisor(\n uint64 newDepositorFeeDivisor\n ) external onlyOwner {\n // TODO: Introduce a parameters update process.\n depositorFeeDivisor = newDepositorFeeDivisor;\n\n emit DepositorFeeDivisorUpdated(newDepositorFeeDivisor);\n }\n\n // TODO: Handle minimum deposit amount in tBTC Bridge vs stBTC.\n\n /// @notice Encodes staker address and referral as extra data.\n /// @dev Packs the data to bytes32: 20 bytes of staker address and\n /// 2 bytes of referral, 10 bytes of trailing zeros.\n /// @param staker The address to which the stBTC shares will be minted.\n /// @param referral Data used for referral program.\n /// @return Encoded extra data.\n function encodeExtraData(\n address staker,\n uint16 referral\n ) public pure returns (bytes32) {\n return bytes32(abi.encodePacked(staker, referral));\n }\n\n /// @notice Decodes staker address and referral from extra data.\n /// @dev Unpacks the data from bytes32: 20 bytes of staker address and\n /// 2 bytes of referral, 10 bytes of trailing zeros.\n /// @param extraData Encoded extra data.\n /// @return staker The address to which the stBTC shares will be minted.\n /// @return referral Data used for referral program.\n function decodeExtraData(\n bytes32 extraData\n ) public pure returns (address staker, uint16 referral) {\n // First 20 bytes of extra data is staker address.\n staker = address(uint160(bytes20(extraData)));\n // Next 2 bytes of extra data is referral info.\n referral = uint16(bytes2(extraData << (8 * 20)));\n }\n\n /// @notice This function is used for state transitions. It ensures the current\n /// stakte matches expected, and updates the stake request to a new\n /// state.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param expectedState Expected current stake request state.\n /// @param newState New stake request state.\n function transitionStakeRequestState(\n uint256 depositKey,\n StakeRequestState expectedState,\n StakeRequestState newState\n ) internal {\n // Validate current stake request state.\n if (stakeRequests[depositKey].state != expectedState)\n revert UnexpectedStakeRequestState(\n stakeRequests[depositKey].state,\n expectedState\n );\n\n // Transition to a new state.\n stakeRequests[depositKey].state = newState;\n }\n\n /// @notice This function should be called for previously initialized stake\n /// request, after tBTC minting process completed, meaning tBTC was\n /// minted to this contract.\n /// @dev It calculates the amount to stake based on the approximate minted\n /// tBTC amount reduced by the depositor fee.\n /// @dev IMPORTANT NOTE: The minted tBTC amount used by this function is an\n /// approximation. See documentation of the\n /// {{AbstractTBTCDepositor#_calculateTbtcAmount}} responsible for calculating\n /// this value for more details.\n /// @dev In case balance of tBTC tokens in this contract doesn't meet the\n /// calculated tBTC amount, the function reverts with `InsufficientTbtcBalance`\n /// error. This case requires Governance's validation, as tBTC Bridge minting\n /// fees might changed in the way that reserve mentioned in\n /// {{AbstractTBTCDepositor#_calculateTbtcAmount}} needs a top-up.\n /// @param depositKey Deposit key identifying the deposit.\n /// @return amountToStake tBTC token amount to stake after deducting tBTC bridging\n /// fees and the depositor fee.\n /// @return staker The address to which the stBTC shares will be minted.\n function finalizeBridging(\n uint256 depositKey\n ) internal returns (uint256, address) {\n (\n uint256 initialDepositAmount,\n uint256 tbtcAmount,\n bytes32 extraData\n ) = _finalizeDeposit(depositKey);\n\n // Check if current balance is sufficient to finalize bridging of `tbtcAmount`.\n uint256 currentBalance = tbtcToken.balanceOf(address(this));\n if (tbtcAmount > tbtcToken.balanceOf(address(this))) {\n revert InsufficientTbtcBalance(tbtcAmount, currentBalance);\n }\n\n // Compute depositor fee. The fee is calculated based on the initial funding\n // transaction amount, before the tBTC protocol network fees were taken.\n uint256 depositorFee = depositorFeeDivisor > 0\n ? (initialDepositAmount / depositorFeeDivisor)\n : 0;\n\n // Ensure the depositor fee does not exceed the approximate minted tBTC\n // amount.\n if (depositorFee >= tbtcAmount) {\n revert DepositorFeeExceedsBridgedAmount(depositorFee, tbtcAmount);\n }\n\n uint256 amountToStake = tbtcAmount - depositorFee;\n\n (address staker, uint16 referral) = decodeExtraData(extraData);\n\n // Emit event for accounting purposes to track partner's referral ID and\n // depositor fee taken.\n emit BridgingCompleted(\n depositKey,\n msg.sender,\n referral,\n tbtcAmount,\n depositorFee\n );\n\n // Transfer depositor fee to the treasury wallet.\n if (depositorFee > 0) {\n tbtcToken.safeTransfer(stbtc.treasury(), depositorFee);\n }\n\n return (amountToStake, staker);\n }\n}\n" + }, + "contracts/Dispatcher.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\nimport \"./Router.sol\";\nimport \"./stBTC.sol\";\n\n/// @title Dispatcher\n/// @notice Dispatcher is a contract that routes tBTC from stBTC to\n/// yield vaults and back. Vaults supply yield strategies with tBTC that\n/// generate yield for Bitcoin holders.\ncontract Dispatcher is Router, Ownable2Step {\n using SafeERC20 for IERC20;\n\n /// Struct holds information about a vault.\n struct VaultInfo {\n bool authorized;\n }\n\n /// The main stBTC contract holding tBTC deposited by stakers.\n stBTC public immutable stbtc;\n /// tBTC token contract.\n IERC20 public immutable tbtc;\n /// Address of the maintainer bot.\n address public maintainer;\n\n /// Authorized Yield Vaults that implement ERC4626 standard. These\n /// vaults deposit assets to yield strategies, e.g. Uniswap V3\n /// WBTC/TBTC pool. Vault can be a part of Acre ecosystem or can be\n /// implemented externally. As long as it complies with ERC4626\n /// standard and is authorized by the owner it can be plugged into\n /// Acre.\n address[] public vaults;\n /// Mapping of vaults to their information.\n mapping(address => VaultInfo) public vaultsInfo;\n\n /// Emitted when a vault is authorized.\n /// @param vault Address of the vault.\n event VaultAuthorized(address indexed vault);\n\n /// Emitted when a vault is deauthorized.\n /// @param vault Address of the vault.\n event VaultDeauthorized(address indexed vault);\n\n /// Emitted when tBTC is routed to a vault.\n /// @param vault Address of the vault.\n /// @param amount Amount of tBTC.\n /// @param sharesOut Amount of received shares.\n event DepositAllocated(\n address indexed vault,\n uint256 amount,\n uint256 sharesOut\n );\n\n /// Emitted when the maintainer address is updated.\n /// @param maintainer Address of the new maintainer.\n event MaintainerUpdated(address indexed maintainer);\n\n /// Reverts if the vault is already authorized.\n error VaultAlreadyAuthorized();\n\n /// Reverts if the vault is not authorized.\n error VaultUnauthorized();\n\n /// Reverts if the caller is not the maintainer.\n error NotMaintainer();\n\n /// Reverts if the address is zero.\n error ZeroAddress();\n\n /// Modifier that reverts if the caller is not the maintainer.\n modifier onlyMaintainer() {\n if (msg.sender != maintainer) {\n revert NotMaintainer();\n }\n _;\n }\n\n constructor(stBTC _stbtc, IERC20 _tbtc) Ownable(msg.sender) {\n stbtc = _stbtc;\n tbtc = _tbtc;\n }\n\n /// @notice Adds a vault to the list of authorized vaults.\n /// @param vault Address of the vault to add.\n function authorizeVault(address vault) external onlyOwner {\n if (isVaultAuthorized(vault)) {\n revert VaultAlreadyAuthorized();\n }\n\n vaults.push(vault);\n vaultsInfo[vault].authorized = true;\n\n emit VaultAuthorized(vault);\n }\n\n /// @notice Removes a vault from the list of authorized vaults.\n /// @param vault Address of the vault to remove.\n function deauthorizeVault(address vault) external onlyOwner {\n if (!isVaultAuthorized(vault)) {\n revert VaultUnauthorized();\n }\n\n vaultsInfo[vault].authorized = false;\n\n for (uint256 i = 0; i < vaults.length; i++) {\n if (vaults[i] == vault) {\n vaults[i] = vaults[vaults.length - 1];\n // slither-disable-next-line costly-loop\n vaults.pop();\n break;\n }\n }\n\n emit VaultDeauthorized(vault);\n }\n\n /// @notice Updates the maintainer address.\n /// @param newMaintainer Address of the new maintainer.\n function updateMaintainer(address newMaintainer) external onlyOwner {\n if (newMaintainer == address(0)) {\n revert ZeroAddress();\n }\n\n maintainer = newMaintainer;\n\n emit MaintainerUpdated(maintainer);\n }\n\n /// TODO: make this function internal once the allocation distribution is\n /// implemented\n /// @notice Routes tBTC from stBTC to a vault. Can be called by the maintainer\n /// only.\n /// @param vault Address of the vault to route the assets to.\n /// @param amount Amount of tBTC to deposit.\n /// @param minSharesOut Minimum amount of shares to receive.\n function depositToVault(\n address vault,\n uint256 amount,\n uint256 minSharesOut\n ) public onlyMaintainer {\n if (!isVaultAuthorized(vault)) {\n revert VaultUnauthorized();\n }\n\n // slither-disable-next-line arbitrary-send-erc20\n tbtc.safeTransferFrom(address(stbtc), address(this), amount);\n tbtc.forceApprove(address(vault), amount);\n\n uint256 sharesOut = deposit(\n IERC4626(vault),\n address(stbtc),\n amount,\n minSharesOut\n );\n // slither-disable-next-line reentrancy-events\n emit DepositAllocated(vault, amount, sharesOut);\n }\n\n /// @notice Returns the list of authorized vaults.\n function getVaults() public view returns (address[] memory) {\n return vaults;\n }\n\n /// @notice Returns true if the vault is authorized.\n /// @param vault Address of the vault to check.\n function isVaultAuthorized(address vault) public view returns (bool) {\n return vaultsInfo[vault].authorized;\n }\n\n /// TODO: implement redeem() / withdraw() functions\n}\n" + }, + "contracts/Router.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\n\n/// @title Router\n/// @notice Router is a contract that routes tBTC from stBTC to\n/// a given vault and back. Vaults supply yield strategies with tBTC that\n/// generate yield for Bitcoin holders.\nabstract contract Router {\n /// Thrown when amount of shares received is below the min set by caller.\n /// @param vault Address of the vault.\n /// @param sharesOut Amount of received shares.\n /// @param minSharesOut Minimum amount of shares expected to receive.\n error MinSharesError(\n address vault,\n uint256 sharesOut,\n uint256 minSharesOut\n );\n\n /// @notice Routes funds from stBTC to a vault. The amount of tBTC to\n /// Shares of deposited tBTC are minted to the stBTC contract.\n /// @param vault Address of the vault to route the funds to.\n /// @param receiver Address of the receiver of the shares.\n /// @param amount Amount of tBTC to deposit.\n /// @param minSharesOut Minimum amount of shares to receive.\n function deposit(\n IERC4626 vault,\n address receiver,\n uint256 amount,\n uint256 minSharesOut\n ) internal returns (uint256 sharesOut) {\n if ((sharesOut = vault.deposit(amount, receiver)) < minSharesOut) {\n revert MinSharesError(address(vault), sharesOut, minSharesOut);\n }\n }\n}\n" + }, + "contracts/stBTC.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable2Step.sol\";\nimport \"./Dispatcher.sol\";\n\n/// @title stBTC\n/// @notice This contract implements the ERC-4626 tokenized vault standard. By\n/// staking tBTC, users acquire a liquid staking token called stBTC,\n/// commonly referred to as \"shares\". The staked tBTC is securely\n/// deposited into Acre's vaults, where it generates yield over time.\n/// Users have the flexibility to redeem stBTC, enabling them to\n/// withdraw their staked tBTC along with the accrued yield.\n/// @dev ERC-4626 is a standard to optimize and unify the technical parameters\n/// of yield-bearing vaults. This contract facilitates the minting and\n/// burning of shares (stBTC), which are represented as standard ERC20\n/// tokens, providing a seamless exchange with tBTC tokens.\ncontract stBTC is ERC4626, Ownable2Step {\n using SafeERC20 for IERC20;\n\n /// Dispatcher contract that routes tBTC from stBTC to a given vault and back.\n Dispatcher public dispatcher;\n\n /// Address of the treasury wallet, where fees should be transferred to.\n address public treasury;\n\n /// Minimum amount for a single deposit operation. The value should be set\n /// low enough so the deposits routed through Bitcoin Depositor contract won't\n /// be rejected. It means that minimumDepositAmount should be lower than\n /// tBTC protocol's depositDustThreshold reduced by all the minting fees taken\n /// before depositing in the Acre contract.\n uint256 public minimumDepositAmount;\n\n /// Maximum total amount of tBTC token held by Acre protocol.\n uint256 public maximumTotalAssets;\n\n /// Emitted when the treasury wallet address is updated.\n /// @param treasury New treasury wallet address.\n event TreasuryUpdated(address treasury);\n\n /// Emitted when deposit parameters are updated.\n /// @param minimumDepositAmount New value of the minimum deposit amount.\n /// @param maximumTotalAssets New value of the maximum total assets amount.\n event DepositParametersUpdated(\n uint256 minimumDepositAmount,\n uint256 maximumTotalAssets\n );\n\n /// Emitted when the dispatcher contract is updated.\n /// @param oldDispatcher Address of the old dispatcher contract.\n /// @param newDispatcher Address of the new dispatcher contract.\n event DispatcherUpdated(address oldDispatcher, address newDispatcher);\n\n /// Reverts if the amount is less than the minimum deposit amount.\n /// @param amount Amount to check.\n /// @param min Minimum amount to check 'amount' against.\n error LessThanMinDeposit(uint256 amount, uint256 min);\n\n /// Reverts if the address is zero.\n error ZeroAddress();\n\n /// Reverts if the address is disallowed.\n error DisallowedAddress();\n\n constructor(\n IERC20 _tbtc,\n address _treasury\n ) ERC4626(_tbtc) ERC20(\"Acre Staked Bitcoin\", \"stBTC\") Ownable(msg.sender) {\n if (address(_treasury) == address(0)) {\n revert ZeroAddress();\n }\n treasury = _treasury;\n // TODO: Revisit the exact values closer to the launch.\n minimumDepositAmount = 0.001 * 1e18; // 0.001 tBTC\n maximumTotalAssets = 25 * 1e18; // 25 tBTC\n }\n\n /// @notice Updates treasury wallet address.\n /// @param newTreasury New treasury wallet address.\n function updateTreasury(address newTreasury) external onlyOwner {\n // TODO: Introduce a parameters update process.\n if (newTreasury == address(0)) {\n revert ZeroAddress();\n }\n if (newTreasury == address(this)) {\n revert DisallowedAddress();\n }\n treasury = newTreasury;\n\n emit TreasuryUpdated(newTreasury);\n }\n\n /// @notice Updates deposit parameters.\n /// @dev To disable the limit for deposits, set the maximum total assets to\n /// maximum (`type(uint256).max`).\n /// @param _minimumDepositAmount New value of the minimum deposit amount. It\n /// is the minimum amount for a single deposit operation.\n /// @param _maximumTotalAssets New value of the maximum total assets amount.\n /// It is the maximum amount of the tBTC token that the Acre protocol\n /// can hold.\n function updateDepositParameters(\n uint256 _minimumDepositAmount,\n uint256 _maximumTotalAssets\n ) external onlyOwner {\n // TODO: Introduce a parameters update process.\n minimumDepositAmount = _minimumDepositAmount;\n maximumTotalAssets = _maximumTotalAssets;\n\n emit DepositParametersUpdated(\n _minimumDepositAmount,\n _maximumTotalAssets\n );\n }\n\n // TODO: Implement a governed upgrade process that initiates an update and\n // then finalizes it after a delay.\n /// @notice Updates the dispatcher contract and gives it an unlimited\n /// allowance to transfer staked tBTC.\n /// @param newDispatcher Address of the new dispatcher contract.\n function updateDispatcher(Dispatcher newDispatcher) external onlyOwner {\n if (address(newDispatcher) == address(0)) {\n revert ZeroAddress();\n }\n\n address oldDispatcher = address(dispatcher);\n\n emit DispatcherUpdated(oldDispatcher, address(newDispatcher));\n dispatcher = newDispatcher;\n\n // TODO: Once withdrawal/rebalancing is implemented, we need to revoke the\n // approval of the vaults share tokens from the old dispatcher and approve\n // a new dispatcher to manage the share tokens.\n\n if (oldDispatcher != address(0)) {\n // Setting allowance to zero for the old dispatcher\n IERC20(asset()).forceApprove(oldDispatcher, 0);\n }\n\n // Setting allowance to max for the new dispatcher\n IERC20(asset()).forceApprove(address(dispatcher), type(uint256).max);\n }\n\n /// @notice Mints shares to receiver by depositing exactly amount of\n /// tBTC tokens.\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\n /// which determines the minimum amount for a single deposit operation.\n /// The amount of the assets has to be pre-approved in the tBTC\n /// contract.\n /// @param assets Approved amount of tBTC tokens to deposit.\n /// @param receiver The address to which the shares will be minted.\n /// @return Minted shares.\n function deposit(\n uint256 assets,\n address receiver\n ) public override returns (uint256) {\n if (assets < minimumDepositAmount) {\n revert LessThanMinDeposit(assets, minimumDepositAmount);\n }\n\n return super.deposit(assets, receiver);\n }\n\n /// @notice Mints shares to receiver by depositing tBTC tokens.\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\n /// which determines the minimum amount for a single deposit operation.\n /// The amount of the assets has to be pre-approved in the tBTC\n /// contract.\n /// The msg.sender is required to grant approval for tBTC transfer.\n /// To determine the total assets amount necessary for approval\n /// corresponding to a given share amount, use the `previewMint` function.\n /// @param shares Amount of shares to mint.\n /// @param receiver The address to which the shares will be minted.\n function mint(\n uint256 shares,\n address receiver\n ) public override returns (uint256 assets) {\n if ((assets = super.mint(shares, receiver)) < minimumDepositAmount) {\n revert LessThanMinDeposit(assets, minimumDepositAmount);\n }\n }\n\n /// @notice Returns value of assets that would be exchanged for the amount of\n /// shares owned by the `account`.\n /// @param account Owner of shares.\n /// @return Assets amount.\n function assetsBalanceOf(address account) public view returns (uint256) {\n return convertToAssets(balanceOf(account));\n }\n\n /// @notice Returns the maximum amount of the tBTC token that can be\n /// deposited into the vault for the receiver through a deposit\n /// call. It takes into account the deposit parameter, maximum total\n /// assets, which determines the total amount of tBTC token held by\n /// Acre protocol.\n /// @dev When the remaining amount of unused limit is less than the minimum\n /// deposit amount, this function returns 0.\n /// @return The maximum amount of tBTC token that can be deposited into\n /// Acre protocol for the receiver.\n function maxDeposit(address) public view override returns (uint256) {\n if (maximumTotalAssets == type(uint256).max) {\n return type(uint256).max;\n }\n\n uint256 _totalAssets = totalAssets();\n\n return\n _totalAssets >= maximumTotalAssets\n ? 0\n : maximumTotalAssets - _totalAssets;\n }\n\n /// @notice Returns the maximum amount of the vault shares that can be\n /// minted for the receiver, through a mint call.\n /// @dev Since the stBTC contract limits the maximum total tBTC tokens this\n /// function converts the maximum deposit amount to shares.\n /// @return The maximum amount of the vault shares.\n function maxMint(address receiver) public view override returns (uint256) {\n uint256 _maxDeposit = maxDeposit(receiver);\n\n // slither-disable-next-line incorrect-equality\n return\n _maxDeposit == type(uint256).max\n ? type(uint256).max\n : convertToShares(_maxDeposit);\n }\n\n /// @return Returns deposit parameters.\n function depositParameters() public view returns (uint256, uint256) {\n return (minimumDepositAmount, maximumTotalAssets);\n }\n}\n" + }, + "contracts/test/AcreBitcoinDepositor.t.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport {AcreBitcoinDepositor} from \"../AcreBitcoinDepositor.sol\";\n\n/// @dev A test contract to expose internal function from AcreBitcoinDepositor contract.\n/// This solution follows Foundry recommendation:\n/// https://book.getfoundry.sh/tutorials/best-practices#internal-functions\ncontract AcreBitcoinDepositorHarness is AcreBitcoinDepositor {\n constructor(\n address bridge,\n address tbtcVault,\n address tbtcToken,\n address stbtc\n ) AcreBitcoinDepositor(bridge, tbtcVault, tbtcToken, stbtc) {}\n\n function exposed_finalizeBridging(\n uint256 depositKey\n ) external returns (uint256 amountToStake, address staker) {\n return finalizeBridging(depositKey);\n }\n}\n" + }, + "contracts/test/MockTbtcBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport {MockBridge, MockTBTCVault} from \"@keep-network/tbtc-v2/contracts/test/TestTBTCDepositor.sol\";\nimport {IBridge} from \"@keep-network/tbtc-v2/contracts/integrator/IBridge.sol\";\nimport {IBridgeTypes} from \"@keep-network/tbtc-v2/contracts/integrator/IBridge.sol\";\n\nimport {TestERC20} from \"./TestERC20.sol\";\n\ncontract BridgeStub is MockBridge {}\n\ncontract TBTCVaultStub is MockTBTCVault {\n TestERC20 public immutable tbtc;\n IBridge public immutable bridge;\n\n /// @notice Multiplier to convert satoshi to TBTC token units.\n uint256 public constant SATOSHI_MULTIPLIER = 10 ** 10;\n\n constructor(TestERC20 _tbtc, IBridge _bridge) {\n tbtc = _tbtc;\n bridge = _bridge;\n }\n\n function finalizeOptimisticMintingRequest(\n uint256 depositKey\n ) public override {\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\n depositKey\n );\n\n uint256 amountSubTreasury = (deposit.amount - deposit.treasuryFee) *\n SATOSHI_MULTIPLIER;\n\n uint256 omFee = optimisticMintingFeeDivisor > 0\n ? (amountSubTreasury / optimisticMintingFeeDivisor)\n : 0;\n\n // The deposit transaction max fee is in the 1e8 satoshi precision.\n // We need to convert them to the 1e18 TBTC precision.\n // slither-disable-next-line unused-return\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\n\n uint256 amountToMint = amountSubTreasury - omFee - txMaxFee;\n\n finalizeOptimisticMintingRequestWithAmount(depositKey, amountToMint);\n }\n\n function finalizeOptimisticMintingRequestWithAmount(\n uint256 depositKey,\n uint256 amountToMint\n ) public {\n MockTBTCVault.finalizeOptimisticMintingRequest(depositKey);\n\n tbtc.mint(bridge.deposits(depositKey).depositor, amountToMint);\n }\n}\n" + }, + "contracts/test/TestERC20.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract TestERC20 is ERC20 {\n constructor(string memory name, string memory symbol) ERC20(name, symbol) {}\n\n function mint(address account, uint256 value) external {\n _mint(account, value);\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/core/deployments/sepolia/solcInputs/b22c277b248ba02f9ec5bf62d176f9ce.json b/core/deployments/sepolia/solcInputs/b22c277b248ba02f9ec5bf62d176f9ce.json new file mode 100644 index 000000000..0ee23a5b9 --- /dev/null +++ b/core/deployments/sepolia/solcInputs/b22c277b248ba02f9ec5bf62d176f9ce.json @@ -0,0 +1,114 @@ +{ + "language": "Solidity", + "sources": { + "@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol": { + "content": "pragma solidity ^0.8.4;\n\n/** @title BitcoinSPV */\n/** @author Summa (https://summa.one) */\n\nimport {BytesLib} from \"./BytesLib.sol\";\nimport {SafeMath} from \"./SafeMath.sol\";\n\nlibrary BTCUtils {\n using BytesLib for bytes;\n using SafeMath for uint256;\n\n // The target at minimum Difficulty. Also the target of the genesis block\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\n\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\n\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\n\n /* ***** */\n /* UTILS */\n /* ***** */\n\n /// @notice Determines the length of a VarInt in bytes\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\n /// @param _flag The first byte of a VarInt\n /// @return The number of non-flag bytes in the VarInt\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\n return determineVarIntDataLengthAt(_flag, 0);\n }\n\n /// @notice Determines the length of a VarInt in bytes\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\n /// @param _b The byte array containing a VarInt\n /// @param _at The position of the VarInt in the array\n /// @return The number of non-flag bytes in the VarInt\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\n if (uint8(_b[_at]) == 0xff) {\n return 8; // one-byte flag, 8 bytes data\n }\n if (uint8(_b[_at]) == 0xfe) {\n return 4; // one-byte flag, 4 bytes data\n }\n if (uint8(_b[_at]) == 0xfd) {\n return 2; // one-byte flag, 2 bytes data\n }\n\n return 0; // flag is data\n }\n\n /// @notice Parse a VarInt into its data length and the number it represents\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\n /// Caller SHOULD explicitly handle this case (or bubble it up)\n /// @param _b A byte-string starting with a VarInt\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\n return parseVarIntAt(_b, 0);\n }\n\n /// @notice Parse a VarInt into its data length and the number it represents\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\n /// Caller SHOULD explicitly handle this case (or bubble it up)\n /// @param _b A byte-string containing a VarInt\n /// @param _at The position of the VarInt\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\n\n if (_dataLen == 0) {\n return (0, uint8(_b[_at]));\n }\n if (_b.length < 1 + _dataLen + _at) {\n return (ERR_BAD_ARG, 0);\n }\n uint256 _number;\n if (_dataLen == 2) {\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\n } else if (_dataLen == 4) {\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\n } else if (_dataLen == 8) {\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\n }\n return (_dataLen, _number);\n }\n\n /// @notice Changes the endianness of a byte array\n /// @dev Returns a new, backwards, bytes\n /// @param _b The bytes to reverse\n /// @return The reversed bytes\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\n bytes memory _newValue = new bytes(_b.length);\n\n for (uint i = 0; i < _b.length; i++) {\n _newValue[_b.length - i - 1] = _b[i];\n }\n\n return _newValue;\n }\n\n /// @notice Changes the endianness of a uint256\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\n v = _b;\n\n // swap bytes\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\n // swap 2-byte long pairs\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\n // swap 4-byte long pairs\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\n // swap 8-byte long pairs\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\n // swap 16-byte long pairs\n v = (v >> 128) | (v << 128);\n }\n\n /// @notice Changes the endianness of a uint64\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\n v = _b;\n\n // swap bytes\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\n ((v & 0x00FF00FF00FF00FF) << 8);\n // swap 2-byte long pairs\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\n ((v & 0x0000FFFF0000FFFF) << 16);\n // swap 4-byte long pairs\n v = (v >> 32) | (v << 32);\n }\n\n /// @notice Changes the endianness of a uint32\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\n v = _b;\n\n // swap bytes\n v = ((v >> 8) & 0x00FF00FF) |\n ((v & 0x00FF00FF) << 8);\n // swap 2-byte long pairs\n v = (v >> 16) | (v << 16);\n }\n\n /// @notice Changes the endianness of a uint24\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\n }\n\n /// @notice Changes the endianness of a uint16\n /// @param _b The unsigned integer to reverse\n /// @return v The reversed value\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\n v = (_b << 8) | (_b >> 8);\n }\n\n\n /// @notice Converts big-endian bytes to a uint\n /// @dev Traverses the byte array and sums the bytes\n /// @param _b The big-endian bytes-encoded integer\n /// @return The integer representation\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\n uint256 _number;\n\n for (uint i = 0; i < _b.length; i++) {\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\n }\n\n return _number;\n }\n\n /// @notice Get the last _num bytes from a byte array\n /// @param _b The byte array to slice\n /// @param _num The number of bytes to extract from the end\n /// @return The last _num bytes of _b\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\n uint256 _start = _b.length.sub(_num);\n\n return _b.slice(_start, _num);\n }\n\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\n /// @param _b The pre-image\n /// @return The digest\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\n }\n\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\n /// @param _b The pre-image\n /// @return res The digest\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\n // read from position 12 = 0c\n res := mload(0x0c)\n }\n }\n\n /// @notice Implements bitcoin's hash256 (double sha2)\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\n /// @param _b The pre-image\n /// @return The digest\n function hash256(bytes memory _b) internal pure returns (bytes32) {\n return sha256(abi.encodePacked(sha256(_b)));\n }\n\n /// @notice Implements bitcoin's hash256 (double sha2)\n /// @dev sha2 is precompiled smart contract located at address(2)\n /// @param _b The pre-image\n /// @return res The digest\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\n res := mload(0x00)\n }\n }\n\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\n /// @dev sha2 is precompiled smart contract located at address(2)\n /// @param _a The first bytes32 of the pre-image\n /// @param _b The second bytes32 of the pre-image\n /// @return res The digest\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n mstore(0x00, _a)\n mstore(0x20, _b)\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\n res := mload(0x00)\n }\n }\n\n /// @notice Implements bitcoin's hash256 (double sha2)\n /// @dev sha2 is precompiled smart contract located at address(2)\n /// @param _b The array containing the pre-image\n /// @param at The start of the pre-image\n /// @param len The length of the pre-image\n /// @return res The digest\n function hash256Slice(\n bytes memory _b,\n uint256 at,\n uint256 len\n ) internal view returns (bytes32 res) {\n // solium-disable-next-line security/no-inline-assembly\n assembly {\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\n res := mload(0x00)\n }\n }\n\n /* ************ */\n /* Legacy Input */\n /* ************ */\n\n /// @notice Extracts the nth input from the vin (0-indexed)\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\n /// @param _vin The vin as a tightly-packed byte array\n /// @param _index The 0-indexed location of the input to extract\n /// @return The input as a byte array\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\n uint256 _varIntDataLen;\n uint256 _nIns;\n\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\n require(_varIntDataLen != ERR_BAD_ARG, \"Read overrun during VarInt parsing\");\n require(_index < _nIns, \"Vin read overrun\");\n\n uint256 _len = 0;\n uint256 _offset = 1 + _varIntDataLen;\n\n for (uint256 _i = 0; _i < _index; _i ++) {\n _len = determineInputLengthAt(_vin, _offset);\n require(_len != ERR_BAD_ARG, \"Bad VarInt in scriptSig\");\n _offset = _offset + _len;\n }\n\n _len = determineInputLengthAt(_vin, _offset);\n require(_len != ERR_BAD_ARG, \"Bad VarInt in scriptSig\");\n return _vin.slice(_offset, _len);\n }\n\n /// @notice Determines whether an input is legacy\n /// @dev False if no scriptSig, otherwise True\n /// @param _input The input\n /// @return True for legacy, False for witness\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\n return _input[36] != hex\"00\";\n }\n\n /// @notice Determines the length of a scriptSig in an input\n /// @dev Will return 0 if passed a witness input.\n /// @param _input The LEGACY input\n /// @return The length of the script sig\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\n return extractScriptSigLenAt(_input, 0);\n }\n\n /// @notice Determines the length of a scriptSig in an input\n /// starting at the specified position\n /// @dev Will return 0 if passed a witness input.\n /// @param _input The byte array containing the LEGACY input\n /// @param _at The position of the input in the array\n /// @return The length of the script sig\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\n if (_input.length < 37 + _at) {\n return (ERR_BAD_ARG, 0);\n }\n\n uint256 _varIntDataLen;\n uint256 _scriptSigLen;\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\n\n return (_varIntDataLen, _scriptSigLen);\n }\n\n /// @notice Determines the length of an input from its scriptSig\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\n /// @param _input The input\n /// @return The length of the input in bytes\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\n return determineInputLengthAt(_input, 0);\n }\n\n /// @notice Determines the length of an input from its scriptSig,\n /// starting at the specified position\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\n /// @param _input The byte array containing the input\n /// @param _at The position of the input in the array\n /// @return The length of the input in bytes\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\n uint256 _varIntDataLen;\n uint256 _scriptSigLen;\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\n if (_varIntDataLen == ERR_BAD_ARG) {\n return ERR_BAD_ARG;\n }\n\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\n }\n\n /// @notice Extracts the LE sequence bytes from an input\n /// @dev Sequence is used for relative time locks\n /// @param _input The LEGACY input\n /// @return The sequence bytes (LE uint)\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\n uint256 _varIntDataLen;\n uint256 _scriptSigLen;\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\n require(_varIntDataLen != ERR_BAD_ARG, \"Bad VarInt in scriptSig\");\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\n }\n\n /// @notice Extracts the sequence from the input\n /// @dev Sequence is a 4-byte little-endian number\n /// @param _input The LEGACY input\n /// @return The sequence number (big-endian uint)\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\n uint32 _beSequence = reverseUint32(_leSeqence);\n return _beSequence;\n }\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\n /// @dev Will return hex\"00\" if passed a witness input\n /// @param _input The LEGACY input\n /// @return The length-prepended scriptSig\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\n uint256 _varIntDataLen;\n uint256 _scriptSigLen;\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\n require(_varIntDataLen != ERR_BAD_ARG, \"Bad VarInt in scriptSig\");\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\n }\n\n\n /* ************* */\n /* Witness Input */\n /* ************* */\n\n /// @notice Extracts the LE sequence bytes from an input\n /// @dev Sequence is used for relative time locks\n /// @param _input The WITNESS input\n /// @return The sequence bytes (LE uint)\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\n return _input.slice4(37);\n }\n\n /// @notice Extracts the sequence from the input in a tx\n /// @dev Sequence is a 4-byte little-endian number\n /// @param _input The WITNESS input\n /// @return The sequence number (big-endian uint)\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\n uint32 _inputeSequence = reverseUint32(_leSeqence);\n return _inputeSequence;\n }\n\n /// @notice Extracts the outpoint from the input in a tx\n /// @dev 32-byte tx id with 4-byte index\n /// @param _input The input\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\n return _input.slice(0, 36);\n }\n\n /// @notice Extracts the outpoint tx id from an input\n /// @dev 32-byte tx id\n /// @param _input The input\n /// @return The tx id (little-endian bytes)\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\n return _input.slice32(0);\n }\n\n /// @notice Extracts the outpoint tx id from an input\n /// starting at the specified position\n /// @dev 32-byte tx id\n /// @param _input The byte array containing the input\n /// @param _at The position of the input\n /// @return The tx id (little-endian bytes)\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\n return _input.slice32(_at);\n }\n\n /// @notice Extracts the LE tx input index from the input in a tx\n /// @dev 4-byte tx index\n /// @param _input The input\n /// @return The tx index (little-endian bytes)\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\n return _input.slice4(32);\n }\n\n /// @notice Extracts the LE tx input index from the input in a tx\n /// starting at the specified position\n /// @dev 4-byte tx index\n /// @param _input The byte array containing the input\n /// @param _at The position of the input\n /// @return The tx index (little-endian bytes)\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\n return _input.slice4(32 + _at);\n }\n\n /* ****** */\n /* Output */\n /* ****** */\n\n /// @notice Determines the length of an output\n /// @dev Works with any properly formatted output\n /// @param _output The output\n /// @return The length indicated by the prefix, error if invalid length\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\n return determineOutputLengthAt(_output, 0);\n }\n\n /// @notice Determines the length of an output\n /// starting at the specified position\n /// @dev Works with any properly formatted output\n /// @param _output The byte array containing the output\n /// @param _at The position of the output\n /// @return The length indicated by the prefix, error if invalid length\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\n if (_output.length < 9 + _at) {\n return ERR_BAD_ARG;\n }\n uint256 _varIntDataLen;\n uint256 _scriptPubkeyLength;\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\n\n if (_varIntDataLen == ERR_BAD_ARG) {\n return ERR_BAD_ARG;\n }\n\n // 8-byte value, 1-byte for tag itself\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\n }\n\n /// @notice Extracts the output at a given index in the TxOuts vector\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\n /// @param _vout The _vout to extract from\n /// @param _index The 0-indexed location of the output to extract\n /// @return The specified output\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\n uint256 _varIntDataLen;\n uint256 _nOuts;\n\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\n require(_varIntDataLen != ERR_BAD_ARG, \"Read overrun during VarInt parsing\");\n require(_index < _nOuts, \"Vout read overrun\");\n\n uint256 _len = 0;\n uint256 _offset = 1 + _varIntDataLen;\n\n for (uint256 _i = 0; _i < _index; _i ++) {\n _len = determineOutputLengthAt(_vout, _offset);\n require(_len != ERR_BAD_ARG, \"Bad VarInt in scriptPubkey\");\n _offset += _len;\n }\n\n _len = determineOutputLengthAt(_vout, _offset);\n require(_len != ERR_BAD_ARG, \"Bad VarInt in scriptPubkey\");\n return _vout.slice(_offset, _len);\n }\n\n /// @notice Extracts the value bytes from the output in a tx\n /// @dev Value is an 8-byte little-endian number\n /// @param _output The output\n /// @return The output value as LE bytes\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\n return _output.slice8(0);\n }\n\n /// @notice Extracts the value from the output in a tx\n /// @dev Value is an 8-byte little-endian number\n /// @param _output The output\n /// @return The output value\n function extractValue(bytes memory _output) internal pure returns (uint64) {\n uint64 _leValue = uint64(extractValueLE(_output));\n uint64 _beValue = reverseUint64(_leValue);\n return _beValue;\n }\n\n /// @notice Extracts the value from the output in a tx\n /// @dev Value is an 8-byte little-endian number\n /// @param _output The byte array containing the output\n /// @param _at The starting index of the output in the array\n /// @return The output value\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\n uint64 _leValue = uint64(_output.slice8(_at));\n uint64 _beValue = reverseUint64(_leValue);\n return _beValue;\n }\n\n /// @notice Extracts the data from an op return output\n /// @dev Returns hex\"\" if no data or not an op return\n /// @param _output The output\n /// @return Any data contained in the opreturn output, null if not an op return\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\n if (_output[9] != hex\"6a\") {\n return hex\"\";\n }\n bytes1 _dataLen = _output[10];\n return _output.slice(11, uint256(uint8(_dataLen)));\n }\n\n /// @notice Extracts the hash from the output script\n /// @dev Determines type by the length prefix and validates format\n /// @param _output The output\n /// @return The hash committed to by the pk_script, or null for errors\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\n return extractHashAt(_output, 8, _output.length - 8);\n }\n\n /// @notice Extracts the hash from the output script\n /// @dev Determines type by the length prefix and validates format\n /// @param _output The byte array containing the output\n /// @param _at The starting index of the output script in the array\n /// (output start + 8)\n /// @param _len The length of the output script\n /// (output length - 8)\n /// @return The hash committed to by the pk_script, or null for errors\n function extractHashAt(\n bytes memory _output,\n uint256 _at,\n uint256 _len\n ) internal pure returns (bytes memory) {\n uint8 _scriptLen = uint8(_output[_at]);\n\n // don't have to worry about overflow here.\n // if _scriptLen + 1 overflows, then output length would have to be < 1\n // for this check to pass. if it's < 1, then we errored when assigning\n // _scriptLen\n if (_scriptLen + 1 != _len) {\n return hex\"\";\n }\n\n if (uint8(_output[_at + 1]) == 0) {\n if (_scriptLen < 2) {\n return hex\"\";\n }\n uint256 _payloadLen = uint8(_output[_at + 2]);\n // Check for maliciously formatted witness outputs.\n // No need to worry about underflow as long b/c of the `< 2` check\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\n return hex\"\";\n }\n return _output.slice(_at + 3, _payloadLen);\n } else {\n bytes3 _tag = _output.slice3(_at);\n // p2pkh\n if (_tag == hex\"1976a9\") {\n // Check for maliciously formatted p2pkh\n // No need to worry about underflow, b/c of _scriptLen check\n if (uint8(_output[_at + 3]) != 0x14 ||\n _output.slice2(_at + _len - 2) != hex\"88ac\") {\n return hex\"\";\n }\n return _output.slice(_at + 4, 20);\n //p2sh\n } else if (_tag == hex\"17a914\") {\n // Check for maliciously formatted p2sh\n // No need to worry about underflow, b/c of _scriptLen check\n if (uint8(_output[_at + _len - 1]) != 0x87) {\n return hex\"\";\n }\n return _output.slice(_at + 3, 20);\n }\n }\n return hex\"\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\n }\n\n /* ********** */\n /* Witness TX */\n /* ********** */\n\n\n /// @notice Checks that the vin passed up is properly formatted\n /// @dev Consider a vin with a valid vout in its scriptsig\n /// @param _vin Raw bytes length-prefixed input vector\n /// @return True if it represents a validly formatted vin\n function validateVin(bytes memory _vin) internal pure returns (bool) {\n uint256 _varIntDataLen;\n uint256 _nIns;\n\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\n\n // Not valid if it says there are too many or no inputs\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\n return false;\n }\n\n uint256 _offset = 1 + _varIntDataLen;\n\n for (uint256 i = 0; i < _nIns; i++) {\n // If we're at the end, but still expect more\n if (_offset >= _vin.length) {\n return false;\n }\n\n // Grab the next input and determine its length.\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\n if (_nextLen == ERR_BAD_ARG) {\n return false;\n }\n\n // Increase the offset by that much\n _offset += _nextLen;\n }\n\n // Returns false if we're not exactly at the end\n return _offset == _vin.length;\n }\n\n /// @notice Checks that the vout passed up is properly formatted\n /// @dev Consider a vout with a valid scriptpubkey\n /// @param _vout Raw bytes length-prefixed output vector\n /// @return True if it represents a validly formatted vout\n function validateVout(bytes memory _vout) internal pure returns (bool) {\n uint256 _varIntDataLen;\n uint256 _nOuts;\n\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\n\n // Not valid if it says there are too many or no outputs\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\n return false;\n }\n\n uint256 _offset = 1 + _varIntDataLen;\n\n for (uint256 i = 0; i < _nOuts; i++) {\n // If we're at the end, but still expect more\n if (_offset >= _vout.length) {\n return false;\n }\n\n // Grab the next output and determine its length.\n // Increase the offset by that much\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\n if (_nextLen == ERR_BAD_ARG) {\n return false;\n }\n\n _offset += _nextLen;\n }\n\n // Returns false if we're not exactly at the end\n return _offset == _vout.length;\n }\n\n\n\n /* ************ */\n /* Block Header */\n /* ************ */\n\n /// @notice Extracts the transaction merkle root from a block header\n /// @dev Use verifyHash256Merkle to verify proofs with this root\n /// @param _header The header\n /// @return The merkle root (little-endian)\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\n return _header.slice32(36);\n }\n\n /// @notice Extracts the target from a block header\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\n /// @param _header The header\n /// @return The target threshold\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\n return extractTargetAt(_header, 0);\n }\n\n /// @notice Extracts the target from a block header\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\n /// @param _header The array containing the header\n /// @param at The start of the header\n /// @return The target threshold\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\n uint24 _m = uint24(_header.slice3(72 + at));\n uint8 _e = uint8(_header[75 + at]);\n uint256 _mantissa = uint256(reverseUint24(_m));\n uint _exponent = _e - 3;\n\n return _mantissa * (256 ** _exponent);\n }\n\n /// @notice Calculate difficulty from the difficulty 1 target and current target\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\n /// @param _target The current target\n /// @return The block difficulty (bdiff)\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\n // Difficulty 1 calculated from 0x1d00ffff\n return DIFF1_TARGET.div(_target);\n }\n\n /// @notice Extracts the previous block's hash from a block header\n /// @dev Block headers do NOT include block number :(\n /// @param _header The header\n /// @return The previous block's hash (little-endian)\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\n return _header.slice32(4);\n }\n\n /// @notice Extracts the previous block's hash from a block header\n /// @dev Block headers do NOT include block number :(\n /// @param _header The array containing the header\n /// @param at The start of the header\n /// @return The previous block's hash (little-endian)\n function extractPrevBlockLEAt(\n bytes memory _header,\n uint256 at\n ) internal pure returns (bytes32) {\n return _header.slice32(4 + at);\n }\n\n /// @notice Extracts the timestamp from a block header\n /// @dev Time is not 100% reliable\n /// @param _header The header\n /// @return The timestamp (little-endian bytes)\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\n return _header.slice4(68);\n }\n\n /// @notice Extracts the timestamp from a block header\n /// @dev Time is not 100% reliable\n /// @param _header The header\n /// @return The timestamp (uint)\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\n return reverseUint32(uint32(extractTimestampLE(_header)));\n }\n\n /// @notice Extracts the expected difficulty from a block header\n /// @dev Does NOT verify the work\n /// @param _header The header\n /// @return The difficulty as an integer\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\n return calculateDifficulty(extractTarget(_header));\n }\n\n /// @notice Concatenates and hashes two inputs for merkle proving\n /// @param _a The first hash\n /// @param _b The second hash\n /// @return The double-sha256 of the concatenated hashes\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\n return hash256View(abi.encodePacked(_a, _b));\n }\n\n /// @notice Concatenates and hashes two inputs for merkle proving\n /// @param _a The first hash\n /// @param _b The second hash\n /// @return The double-sha256 of the concatenated hashes\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\n return hash256Pair(_a, _b);\n }\n\n\n /// @notice Verifies a Bitcoin-style merkle tree\n /// @dev Leaves are 0-indexed. Inefficient version.\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\n /// @param _index The index of the leaf\n /// @return true if the proof is valid, else false\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\n // Not an even number of hashes\n if (_proof.length % 32 != 0) {\n return false;\n }\n\n // Special case for coinbase-only blocks\n if (_proof.length == 32) {\n return true;\n }\n\n // Should never occur\n if (_proof.length == 64) {\n return false;\n }\n\n bytes32 _root = _proof.slice32(_proof.length - 32);\n bytes32 _current = _proof.slice32(0);\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\n\n return verifyHash256Merkle(_current, _tree, _root, _index);\n }\n\n /// @notice Verifies a Bitcoin-style merkle tree\n /// @dev Leaves are 0-indexed. Efficient version.\n /// @param _leaf The leaf of the proof. LE sha256 hash.\n /// @param _tree The intermediate nodes in the proof.\n /// Tightly packed LE sha256 hashes.\n /// @param _root The root of the proof. LE sha256 hash.\n /// @param _index The index of the leaf\n /// @return true if the proof is valid, else false\n function verifyHash256Merkle(\n bytes32 _leaf,\n bytes memory _tree,\n bytes32 _root,\n uint _index\n ) internal view returns (bool) {\n // Not an even number of hashes\n if (_tree.length % 32 != 0) {\n return false;\n }\n\n // Should never occur\n if (_tree.length == 0) {\n return false;\n }\n\n uint _idx = _index;\n bytes32 _current = _leaf;\n\n // i moves in increments of 32\n for (uint i = 0; i < _tree.length; i += 32) {\n if (_idx % 2 == 1) {\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\n } else {\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\n }\n _idx = _idx >> 1;\n }\n return _current == _root;\n }\n\n /*\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\n NB: We get a full-bitlength target from this. For comparison with\n header-encoded targets we need to mask it with the header target\n e.g. (full & truncated) == truncated\n */\n /// @notice performs the bitcoin difficulty retarget\n /// @dev implements the Bitcoin algorithm precisely\n /// @param _previousTarget the target of the previous period\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\n /// @return the new period's target threshold\n function retargetAlgorithm(\n uint256 _previousTarget,\n uint256 _firstTimestamp,\n uint256 _secondTimestamp\n ) internal pure returns (uint256) {\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\n\n // Normalize ratio to factor of 4 if very long or very short\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\n _elapsedTime = RETARGET_PERIOD.div(4);\n }\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\n _elapsedTime = RETARGET_PERIOD.mul(4);\n }\n\n /*\n NB: high targets e.g. ffff0020 can cause overflows here\n so we divide it by 256**2, then multiply by 256**2 later\n we know the target is evenly divisible by 256**2, so this isn't an issue\n */\n\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\n }\n}\n" + }, + "@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol": { + "content": "pragma solidity ^0.8.4;\n\n/*\n\nhttps://github.com/GNSPS/solidity-bytes-utils/\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to \n*/\n\n\n/** @title BytesLib **/\n/** @author https://github.com/GNSPS **/\n\nlibrary BytesLib {\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\n bytes memory tempBytes;\n\n assembly {\n // Get a location of some free memory and store it in tempBytes as\n // Solidity does for memory variables.\n tempBytes := mload(0x40)\n\n // Store the length of the first bytes array at the beginning of\n // the memory for tempBytes.\n let length := mload(_preBytes)\n mstore(tempBytes, length)\n\n // Maintain a memory counter for the current write location in the\n // temp bytes array by adding the 32 bytes for the array length to\n // the starting location.\n let mc := add(tempBytes, 0x20)\n // Stop copying when the memory counter reaches the length of the\n // first bytes array.\n let end := add(mc, length)\n\n for {\n // Initialize a copy counter to the start of the _preBytes data,\n // 32 bytes into its memory.\n let cc := add(_preBytes, 0x20)\n } lt(mc, end) {\n // Increase both counters by 32 bytes each iteration.\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // Write the _preBytes data into the tempBytes memory 32 bytes\n // at a time.\n mstore(mc, mload(cc))\n }\n\n // Add the length of _postBytes to the current length of tempBytes\n // and store it as the new length in the first 32 bytes of the\n // tempBytes memory.\n length := mload(_postBytes)\n mstore(tempBytes, add(length, mload(tempBytes)))\n\n // Move the memory counter back from a multiple of 0x20 to the\n // actual end of the _preBytes data.\n mc := end\n // Stop copying when the memory counter reaches the new combined\n // length of the arrays.\n end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n } lt(mc, end) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n mstore(mc, mload(cc))\n }\n\n // Update the free-memory pointer by padding our last write location\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\n // next 32 byte block, then round down to the nearest multiple of\n // 32. If the sum of the length of the two arrays is zero then add\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\n mstore(0x40, and(\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\n not(31) // Round down to the nearest 32 bytes.\n ))\n }\n\n return tempBytes;\n }\n\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\n assembly {\n // Read the first 32 bytes of _preBytes storage, which is the length\n // of the array. (We don't need to use the offset into the slot\n // because arrays use the entire slot.)\n let fslot := sload(_preBytes.slot)\n // Arrays of 31 bytes or less have an even value in their slot,\n // while longer arrays have an odd value. The actual length is\n // the slot divided by two for odd values, and the lowest order\n // byte divided by two for even values.\n // If the slot is even, bitwise and the slot with 255 and divide by\n // two to get the length. If the slot is odd, bitwise and the slot\n // with -1 and divide by two.\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\n let mlength := mload(_postBytes)\n let newlength := add(slength, mlength)\n // slength can contain both the length and contents of the array\n // if length < 32 bytes so let's prepare for that\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\n switch add(lt(slength, 32), lt(newlength, 32))\n case 2 {\n // Since the new array still fits in the slot, we just need to\n // update the contents of the slot.\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\n sstore(\n _preBytes.slot,\n // all the modifications to the slot are inside this\n // next block\n add(\n // we can just add to the slot contents because the\n // bytes we want to change are the LSBs\n fslot,\n add(\n mul(\n div(\n // load the bytes from memory\n mload(add(_postBytes, 0x20)),\n // zero all bytes to the right\n exp(0x100, sub(32, mlength))\n ),\n // and now shift left the number of bytes to\n // leave space for the length in the slot\n exp(0x100, sub(32, newlength))\n ),\n // increase length by the double of the memory\n // bytes length\n mul(mlength, 2)\n )\n )\n )\n }\n case 1 {\n // The stored value fits in the slot, but the combined value\n // will exceed it.\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\n\n // save new length\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\n\n // The contents of the _postBytes array start 32 bytes into\n // the structure. Our first read should obtain the `submod`\n // bytes that can fit into the unused space in the last word\n // of the stored array. To get this, we read 32 bytes starting\n // from `submod`, so the data we read overlaps with the array\n // contents by `submod` bytes. Masking the lowest-order\n // `submod` bytes allows us to add that value directly to the\n // stored value.\n\n let submod := sub(32, slength)\n let mc := add(_postBytes, submod)\n let end := add(_postBytes, mlength)\n let mask := sub(exp(0x100, submod), 1)\n\n sstore(\n sc,\n add(\n and(\n fslot,\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\n ),\n and(mload(mc), mask)\n )\n )\n\n for {\n mc := add(mc, 0x20)\n sc := add(sc, 1)\n } lt(mc, end) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n sstore(sc, mload(mc))\n }\n\n mask := exp(0x100, sub(mc, end))\n\n sstore(sc, mul(div(mload(mc), mask), mask))\n }\n default {\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n // Start copying to the last used word of the stored array.\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\n\n // save new length\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\n\n // Copy over the first `submod` bytes of the new data as in\n // case 1 above.\n let slengthmod := mod(slength, 32)\n let mlengthmod := mod(mlength, 32)\n let submod := sub(32, slengthmod)\n let mc := add(_postBytes, submod)\n let end := add(_postBytes, mlength)\n let mask := sub(exp(0x100, submod), 1)\n\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\n\n for {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } lt(mc, end) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n sstore(sc, mload(mc))\n }\n\n mask := exp(0x100, sub(mc, end))\n\n sstore(sc, mul(div(mload(mc), mask), mask))\n }\n }\n }\n\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\n if (_length == 0) {\n return hex\"\";\n }\n uint _end = _start + _length;\n require(_end > _start && _bytes.length >= _end, \"Slice out of bounds\");\n\n assembly {\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\n res := mload(0x40)\n mstore(0x40, add(add(res, 64), _length))\n mstore(res, _length)\n\n // Compute distance between source and destination pointers\n let diff := sub(res, add(_bytes, _start))\n\n for {\n let src := add(add(_bytes, 32), _start)\n let end := add(src, _length)\n } lt(src, end) {\n src := add(src, 32)\n } {\n mstore(add(src, diff), mload(src))\n }\n }\n }\n\n /// @notice Take a slice of the byte array, overwriting the destination.\n /// The length of the slice will equal the length of the destination array.\n /// @dev Make sure the destination array has afterspace if required.\n /// @param _bytes The source array\n /// @param _dest The destination array.\n /// @param _start The location to start in the source array.\n function sliceInPlace(\n bytes memory _bytes,\n bytes memory _dest,\n uint _start\n ) internal pure {\n uint _length = _dest.length;\n uint _end = _start + _length;\n require(_end > _start && _bytes.length >= _end, \"Slice out of bounds\");\n\n assembly {\n for {\n let src := add(add(_bytes, 32), _start)\n let res := add(_dest, 32)\n let end := add(src, _length)\n } lt(src, end) {\n src := add(src, 32)\n res := add(res, 32)\n } {\n mstore(res, mload(src))\n }\n }\n }\n\n // Static slice functions, no bounds checking\n /// @notice take a 32-byte slice from the specified position\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\n assembly {\n res := mload(add(add(_bytes, 32), _start))\n }\n }\n\n /// @notice take a 20-byte slice from the specified position\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\n return bytes20(slice32(_bytes, _start));\n }\n\n /// @notice take a 8-byte slice from the specified position\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\n return bytes8(slice32(_bytes, _start));\n }\n\n /// @notice take a 4-byte slice from the specified position\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\n return bytes4(slice32(_bytes, _start));\n }\n\n /// @notice take a 3-byte slice from the specified position\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\n return bytes3(slice32(_bytes, _start));\n }\n\n /// @notice take a 2-byte slice from the specified position\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\n return bytes2(slice32(_bytes, _start));\n }\n\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\n uint _totalLen = _start + 20;\n require(_totalLen > _start && _bytes.length >= _totalLen, \"Address conversion out of bounds.\");\n address tempAddress;\n\n assembly {\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\n }\n\n return tempAddress;\n }\n\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\n uint _totalLen = _start + 32;\n require(_totalLen > _start && _bytes.length >= _totalLen, \"Uint conversion out of bounds.\");\n uint256 tempUint;\n\n assembly {\n tempUint := mload(add(add(_bytes, 0x20), _start))\n }\n\n return tempUint;\n }\n\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\n bool success = true;\n\n assembly {\n let length := mload(_preBytes)\n\n // if lengths don't match the arrays are not equal\n switch eq(length, mload(_postBytes))\n case 1 {\n // cb is a circuit breaker in the for loop since there's\n // no said feature for inline assembly loops\n // cb = 1 - don't breaker\n // cb = 0 - break\n let cb := 1\n\n let mc := add(_preBytes, 0x20)\n let end := add(mc, length)\n\n for {\n let cc := add(_postBytes, 0x20)\n // the next line is the loop condition:\n // while(uint(mc < end) + cb == 2)\n } eq(add(lt(mc, end), cb), 2) {\n mc := add(mc, 0x20)\n cc := add(cc, 0x20)\n } {\n // if any of these checks fails then arrays are not equal\n if iszero(eq(mload(mc), mload(cc))) {\n // unsuccess:\n success := 0\n cb := 0\n }\n }\n }\n default {\n // unsuccess:\n success := 0\n }\n }\n\n return success;\n }\n\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\n bool success = true;\n\n assembly {\n // we know _preBytes_offset is 0\n let fslot := sload(_preBytes.slot)\n // Decode the length of the stored array like in concatStorage().\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\n let mlength := mload(_postBytes)\n\n // if lengths don't match the arrays are not equal\n switch eq(slength, mlength)\n case 1 {\n // slength can contain both the length and contents of the array\n // if length < 32 bytes so let's prepare for that\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\n if iszero(iszero(slength)) {\n switch lt(slength, 32)\n case 1 {\n // blank the last byte which is the length\n fslot := mul(div(fslot, 0x100), 0x100)\n\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\n // unsuccess:\n success := 0\n }\n }\n default {\n // cb is a circuit breaker in the for loop since there's\n // no said feature for inline assembly loops\n // cb = 1 - don't breaker\n // cb = 0 - break\n let cb := 1\n\n // get the keccak hash to get the contents of the array\n mstore(0x0, _preBytes.slot)\n let sc := keccak256(0x0, 0x20)\n\n let mc := add(_postBytes, 0x20)\n let end := add(mc, mlength)\n\n // the next line is the loop condition:\n // while(uint(mc < end) + cb == 2)\n for {} eq(add(lt(mc, end), cb), 2) {\n sc := add(sc, 1)\n mc := add(mc, 0x20)\n } {\n if iszero(eq(sload(sc), mload(mc))) {\n // unsuccess:\n success := 0\n cb := 0\n }\n }\n }\n }\n }\n default {\n // unsuccess:\n success := 0\n }\n }\n\n return success;\n }\n\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\n if (_source.length == 0) {\n return 0x0;\n }\n\n assembly {\n result := mload(add(_source, 32))\n }\n }\n\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\n uint _end = _start + _length;\n require(_end > _start && _bytes.length >= _end, \"Slice out of bounds\");\n\n assembly {\n result := keccak256(add(add(_bytes, 32), _start), _length)\n }\n }\n}\n" + }, + "@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol": { + "content": "pragma solidity ^0.8.4;\n\n/*\nThe MIT License (MIT)\n\nCopyright (c) 2016 Smart Contract Solutions, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n\n/**\n * @title SafeMath\n * @dev Math operations with safety checks that throw on error\n */\nlibrary SafeMath {\n\n /**\n * @dev Multiplies two numbers, throws on overflow.\n */\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (_a == 0) {\n return 0;\n }\n\n c = _a * _b;\n require(c / _a == _b, \"Overflow during multiplication.\");\n return c;\n }\n\n /**\n * @dev Integer division of two numbers, truncating the quotient.\n */\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\n // uint256 c = _a / _b;\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\n return _a / _b;\n }\n\n /**\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\n require(_b <= _a, \"Underflow during subtraction.\");\n return _a - _b;\n }\n\n /**\n * @dev Adds two numbers, throws on overflow.\n */\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\n c = _a + _b;\n require(c >= _a, \"Overflow during addition.\");\n return c;\n }\n}\n" + }, + "@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\nimport {BTCUtils} from \"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\";\n\nimport \"./IBridge.sol\";\nimport \"./ITBTCVault.sol\";\n\n/// @title Abstract AbstractTBTCDepositor contract.\n/// @notice This abstract contract is meant to facilitate integration of protocols\n/// aiming to use tBTC as an underlying Bitcoin bridge.\n///\n/// Such an integrator is supposed to:\n/// - Create a child contract inheriting from this abstract contract\n/// - Call the `__AbstractTBTCDepositor_initialize` initializer function\n/// - Use the `_initializeDeposit` and `_finalizeDeposit` as part of their\n/// business logic in order to initialize and finalize deposits.\n///\n/// @dev Example usage:\n/// ```\n/// // Example upgradeable integrator contract.\n/// contract ExampleTBTCIntegrator is AbstractTBTCDepositor, Initializable {\n/// /// @custom:oz-upgrades-unsafe-allow constructor\n/// constructor() {\n/// // Prevents the contract from being initialized again.\n/// _disableInitializers();\n/// }\n///\n/// function initialize(\n/// address _bridge,\n/// address _tbtcVault\n/// ) external initializer {\n/// __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\n/// }\n///\n/// function startProcess(\n/// IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n/// IBridgeTypes.DepositRevealInfo calldata reveal\n/// ) external {\n/// // Embed necessary context as extra data.\n/// bytes32 extraData = ...;\n///\n/// uint256 depositKey = _initializeDeposit(\n/// fundingTx,\n/// reveal,\n/// extraData\n/// );\n///\n/// // Use the depositKey to track the process.\n/// }\n///\n/// function finalizeProcess(uint256 depositKey) external {\n/// (\n/// uint256 initialDepositAmount,\n/// uint256 tbtcAmount,\n/// bytes32 extraData\n/// ) = _finalizeDeposit(depositKey);\n///\n/// // Do something with the minted TBTC using context\n/// // embedded in the extraData.\n/// }\n/// }\nabstract contract AbstractTBTCDepositor {\n using BTCUtils for bytes;\n\n /// @notice Multiplier to convert satoshi to TBTC token units.\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\n\n /// @notice Bridge contract address.\n IBridge public bridge;\n /// @notice TBTCVault contract address.\n ITBTCVault public tbtcVault;\n /// @notice Mapping holding information about pending deposits that have\n /// been initialized but not finalized yet. If the deposit is not\n /// in this mapping it means it has already been finalized or it\n /// has not been initialized yet.\n mapping(uint256 => bool) public pendingDeposits;\n\n // Reserved storage space that allows adding more variables without affecting\n // the storage layout of the child contracts. The convention from OpenZeppelin\n // suggests the storage space should add up to 50 slots. If more variables are\n // added in the upcoming versions one need to reduce the array size accordingly.\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // slither-disable-next-line unused-state\n uint256[47] private __gap;\n\n event DepositInitialized(uint256 indexed depositKey, uint32 initializedAt);\n\n event DepositFinalized(\n uint256 indexed depositKey,\n uint256 tbtcAmount,\n uint32 finalizedAt\n );\n\n /// @notice Initializes the contract. MUST BE CALLED from the child\n /// contract initializer.\n // slither-disable-next-line dead-code\n function __AbstractTBTCDepositor_initialize(\n address _bridge,\n address _tbtcVault\n ) internal {\n require(\n address(bridge) == address(0) && address(tbtcVault) == address(0),\n \"AbstractTBTCDepositor already initialized\"\n );\n\n require(_bridge != address(0), \"Bridge address cannot be zero\");\n require(_tbtcVault != address(0), \"TBTCVault address cannot be zero\");\n\n bridge = IBridge(_bridge);\n tbtcVault = ITBTCVault(_tbtcVault);\n }\n\n /// @notice Initializes a deposit by revealing it to the Bridge.\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo` struct.\n /// @param extraData 32-byte deposit extra data.\n /// @return depositKey Deposit key computed as\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\n /// key can be used to refer to the deposit in the Bridge and\n /// TBTCVault contracts.\n /// @dev Requirements:\n /// - The revealed vault address must match the TBTCVault address,\n /// - All requirements from {Bridge#revealDepositWithExtraData}\n /// function must be met.\n // slither-disable-next-line dead-code\n function _initializeDeposit(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) internal returns (uint256) {\n require(reveal.vault == address(tbtcVault), \"Vault address mismatch\");\n\n uint256 depositKey = _calculateDepositKey(\n _calculateBitcoinTxHash(fundingTx),\n reveal.fundingOutputIndex\n );\n\n pendingDeposits[depositKey] = true;\n\n emit DepositInitialized(\n depositKey,\n /* solhint-disable-next-line not-rely-on-time */\n uint32(block.timestamp)\n );\n\n // The Bridge does not allow to reveal the same deposit twice and\n // revealed deposits stay there forever. The transaction will revert\n // if the deposit has already been revealed so, there is no need to do\n // an explicit check here.\n bridge.revealDepositWithExtraData(fundingTx, reveal, extraData);\n\n return depositKey;\n }\n\n /// @notice Finalizes a deposit by calculating the amount of TBTC minted\n /// for the deposit\n /// @param depositKey Deposit key identifying the deposit.\n /// @return initialDepositAmount Amount of funding transaction deposit. In\n /// TBTC token decimals precision.\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit. In\n /// TBTC token decimals precision.\n /// @return extraData 32-byte deposit extra data.\n /// @dev Requirements:\n /// - The deposit must be initialized but not finalized\n /// (in the context of this contract) yet.\n /// - The deposit must be finalized on the Bridge side. That means the\n /// deposit must be either swept or optimistically minted.\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function is an\n /// approximation. See documentation of the `calculateTbtcAmount`\n /// responsible for calculating this value for more details.\n // slither-disable-next-line dead-code\n function _finalizeDeposit(uint256 depositKey)\n internal\n returns (\n uint256 initialDepositAmount,\n uint256 tbtcAmount,\n bytes32 extraData\n )\n {\n require(pendingDeposits[depositKey], \"Deposit not initialized\");\n\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\n depositKey\n );\n (, uint64 finalizedAt) = tbtcVault.optimisticMintingRequests(\n depositKey\n );\n\n require(\n deposit.sweptAt != 0 || finalizedAt != 0,\n \"Deposit not finalized by the bridge\"\n );\n\n // We can safely delete the deposit from the pending deposits mapping.\n // This deposit cannot be initialized again because the bridge does not\n // allow to reveal the same deposit twice. Deleting the deposit from\n // the mapping will also prevent the finalizeDeposit function from\n // being called again for the same deposit.\n // slither-disable-next-line reentrancy-no-eth\n delete pendingDeposits[depositKey];\n\n initialDepositAmount = deposit.amount * SATOSHI_MULTIPLIER;\n\n tbtcAmount = _calculateTbtcAmount(deposit.amount, deposit.treasuryFee);\n\n // slither-disable-next-line reentrancy-events\n emit DepositFinalized(\n depositKey,\n tbtcAmount,\n /* solhint-disable-next-line not-rely-on-time */\n uint32(block.timestamp)\n );\n\n extraData = deposit.extraData;\n }\n\n /// @notice Calculates the amount of TBTC minted for the deposit.\n /// @param depositAmountSat Deposit amount in satoshi (1e8 precision).\n /// This is the actual amount deposited by the deposit creator, i.e.\n /// the gross amount the Bridge's fees are cut from.\n /// @param depositTreasuryFeeSat Deposit treasury fee in satoshi (1e8 precision).\n /// This is an accurate value of the treasury fee that was actually\n /// cut upon minting.\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit.\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function may\n /// not correspond to the actual amount of TBTC minted for the deposit.\n /// Although the treasury fee cut upon minting is known precisely,\n /// this is not the case for the optimistic minting fee and the Bitcoin\n /// transaction fee. To overcome that problem, this function just takes\n /// the current maximum allowed values of both fees, at the moment of deposit\n /// finalization. For the great majority of the deposits, such an\n /// algorithm will return a tbtcAmount slightly lesser than the\n /// actual amount of TBTC minted for the deposit. This will cause\n /// some TBTC to be left in the contract and ensure there is enough\n /// liquidity to finalize the deposit. However, in some rare cases,\n /// where the actual values of those fees change between the deposit\n /// minting and finalization, the tbtcAmount returned by this function\n /// may be greater than the actual amount of TBTC minted for the deposit.\n /// If this happens and the reserve coming from previous deposits\n /// leftovers does not provide enough liquidity, the deposit will have\n /// to wait for finalization until the reserve is refilled by subsequent\n /// deposits or a manual top-up. The integrator is responsible for\n /// handling such cases.\n // slither-disable-next-line dead-code\n function _calculateTbtcAmount(\n uint64 depositAmountSat,\n uint64 depositTreasuryFeeSat\n ) internal view virtual returns (uint256) {\n // Both deposit amount and treasury fee are in the 1e8 satoshi precision.\n // We need to convert them to the 1e18 TBTC precision.\n uint256 amountSubTreasury = (depositAmountSat - depositTreasuryFeeSat) *\n SATOSHI_MULTIPLIER;\n\n uint256 omFeeDivisor = tbtcVault.optimisticMintingFeeDivisor();\n uint256 omFee = omFeeDivisor > 0\n ? (amountSubTreasury / omFeeDivisor)\n : 0;\n\n // The deposit transaction max fee is in the 1e8 satoshi precision.\n // We need to convert them to the 1e18 TBTC precision.\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\n\n return amountSubTreasury - omFee - txMaxFee;\n }\n\n /// @notice Calculates the deposit key for the given funding transaction\n /// hash and funding output index.\n /// @param fundingTxHash Funding transaction hash.\n /// @param fundingOutputIndex Funding output index.\n /// @return depositKey Deposit key computed as\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\n /// key can be used to refer to the deposit in the Bridge and\n /// TBTCVault contracts.\n // slither-disable-next-line dead-code\n function _calculateDepositKey(\n bytes32 fundingTxHash,\n uint32 fundingOutputIndex\n ) internal pure returns (uint256) {\n return\n uint256(\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\n );\n }\n\n /// @notice Calculates the Bitcoin transaction hash for the given Bitcoin\n /// transaction data.\n /// @param txInfo Bitcoin transaction data, see `IBridgeTypes.BitcoinTxInfo` struct.\n /// @return txHash Bitcoin transaction hash.\n // slither-disable-next-line dead-code\n function _calculateBitcoinTxHash(IBridgeTypes.BitcoinTxInfo calldata txInfo)\n internal\n view\n returns (bytes32)\n {\n return\n abi\n .encodePacked(\n txInfo.version,\n txInfo.inputVector,\n txInfo.outputVector,\n txInfo.locktime\n )\n .hash256View();\n }\n}\n" + }, + "@keep-network/tbtc-v2/contracts/integrator/IBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\n/// @notice Namespace which groups all types relevant to the IBridge interface.\n/// @dev This is a mirror of the real types used in the Bridge contract.\n/// This way, the `integrator` subpackage does not need to import\n/// anything from the `bridge` subpackage and explicitly depend on it.\n/// This simplifies the dependency graph for integrators.\nlibrary IBridgeTypes {\n /// @dev See bridge/BitcoinTx.sol#Info\n struct BitcoinTxInfo {\n bytes4 version;\n bytes inputVector;\n bytes outputVector;\n bytes4 locktime;\n }\n\n /// @dev See bridge/Deposit.sol#DepositRevealInfo\n struct DepositRevealInfo {\n uint32 fundingOutputIndex;\n bytes8 blindingFactor;\n bytes20 walletPubKeyHash;\n bytes20 refundPubKeyHash;\n bytes4 refundLocktime;\n address vault;\n }\n\n /// @dev See bridge/Deposit.sol#DepositRequest\n struct DepositRequest {\n address depositor;\n uint64 amount;\n uint32 revealedAt;\n address vault;\n uint64 treasuryFee;\n uint32 sweptAt;\n bytes32 extraData;\n }\n}\n\n/// @notice Interface of the Bridge contract.\n/// @dev See bridge/Bridge.sol\ninterface IBridge {\n /// @dev See {Bridge#revealDepositWithExtraData}\n function revealDepositWithExtraData(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external;\n\n /// @dev See {Bridge#deposits}\n function deposits(uint256 depositKey)\n external\n view\n returns (IBridgeTypes.DepositRequest memory);\n\n /// @dev See {Bridge#depositParameters}\n function depositParameters()\n external\n view\n returns (\n uint64 depositDustThreshold,\n uint64 depositTreasuryFeeDivisor,\n uint64 depositTxMaxFee,\n uint32 depositRevealAheadPeriod\n );\n}\n" + }, + "@keep-network/tbtc-v2/contracts/integrator/ITBTCVault.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.0;\n\n/// @notice Interface of the TBTCVault contract.\n/// @dev See vault/TBTCVault.sol\ninterface ITBTCVault {\n /// @dev See {TBTCVault#optimisticMintingRequests}\n function optimisticMintingRequests(uint256 depositKey)\n external\n returns (uint64 requestedAt, uint64 finalizedAt);\n\n /// @dev See {TBTCVault#optimisticMintingFeeDivisor}\n function optimisticMintingFeeDivisor() external view returns (uint32);\n}\n" + }, + "@keep-network/tbtc-v2/contracts/test/TestTBTCDepositor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.0;\n\nimport {BTCUtils} from \"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\";\n\nimport \"../integrator/AbstractTBTCDepositor.sol\";\nimport \"../integrator/IBridge.sol\";\nimport \"../integrator/ITBTCVault.sol\";\n\ncontract TestTBTCDepositor is AbstractTBTCDepositor {\n event InitializeDepositReturned(uint256 depositKey);\n\n event FinalizeDepositReturned(\n uint256 initialDepositAmount,\n uint256 tbtcAmount,\n bytes32 extraData\n );\n\n function initialize(address _bridge, address _tbtcVault) external {\n __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\n }\n\n function initializeDepositPublic(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external {\n uint256 depositKey = _initializeDeposit(fundingTx, reveal, extraData);\n emit InitializeDepositReturned(depositKey);\n }\n\n function finalizeDepositPublic(uint256 depositKey) external {\n (\n uint256 initialDepositAmount,\n uint256 tbtcAmount,\n bytes32 extraData\n ) = _finalizeDeposit(depositKey);\n emit FinalizeDepositReturned(\n initialDepositAmount,\n tbtcAmount,\n extraData\n );\n }\n\n function calculateTbtcAmountPublic(\n uint64 depositAmountSat,\n uint64 depositTreasuryFeeSat\n ) external view returns (uint256) {\n return _calculateTbtcAmount(depositAmountSat, depositTreasuryFeeSat);\n }\n}\n\ncontract MockBridge is IBridge {\n using BTCUtils for bytes;\n\n mapping(uint256 => IBridgeTypes.DepositRequest) internal _deposits;\n\n uint64 internal _depositTreasuryFeeDivisor = 50; // 1/50 == 100 bps == 2% == 0.02\n uint64 internal _depositTxMaxFee = 1000; // 1000 satoshi = 0.00001 BTC\n\n event DepositRevealed(uint256 depositKey);\n\n function revealDepositWithExtraData(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n bytes32 extraData\n ) external {\n bytes32 fundingTxHash = abi\n .encodePacked(\n fundingTx.version,\n fundingTx.inputVector,\n fundingTx.outputVector,\n fundingTx.locktime\n )\n .hash256View();\n\n uint256 depositKey = uint256(\n keccak256(\n abi.encodePacked(fundingTxHash, reveal.fundingOutputIndex)\n )\n );\n\n require(\n _deposits[depositKey].revealedAt == 0,\n \"Deposit already revealed\"\n );\n\n bytes memory fundingOutput = fundingTx\n .outputVector\n .extractOutputAtIndex(reveal.fundingOutputIndex);\n\n uint64 fundingOutputAmount = fundingOutput.extractValue();\n\n IBridgeTypes.DepositRequest memory request;\n\n request.depositor = msg.sender;\n request.amount = fundingOutputAmount;\n /* solhint-disable-next-line not-rely-on-time */\n request.revealedAt = uint32(block.timestamp);\n request.vault = reveal.vault;\n request.treasuryFee = _depositTreasuryFeeDivisor > 0\n ? fundingOutputAmount / _depositTreasuryFeeDivisor\n : 0;\n request.sweptAt = 0;\n request.extraData = extraData;\n\n _deposits[depositKey] = request;\n\n emit DepositRevealed(depositKey);\n }\n\n function sweepDeposit(uint256 depositKey) public {\n require(_deposits[depositKey].revealedAt != 0, \"Deposit not revealed\");\n require(_deposits[depositKey].sweptAt == 0, \"Deposit already swept\");\n /* solhint-disable-next-line not-rely-on-time */\n _deposits[depositKey].sweptAt = uint32(block.timestamp);\n }\n\n function deposits(uint256 depositKey)\n external\n view\n returns (IBridgeTypes.DepositRequest memory)\n {\n return _deposits[depositKey];\n }\n\n function depositParameters()\n external\n view\n returns (\n uint64 depositDustThreshold,\n uint64 depositTreasuryFeeDivisor,\n uint64 depositTxMaxFee,\n uint32 depositRevealAheadPeriod\n )\n {\n depositDustThreshold = 0;\n depositTreasuryFeeDivisor = 0;\n depositTxMaxFee = _depositTxMaxFee;\n depositRevealAheadPeriod = 0;\n }\n\n function setDepositTreasuryFeeDivisor(uint64 value) external {\n _depositTreasuryFeeDivisor = value;\n }\n\n function setDepositTxMaxFee(uint64 value) external {\n _depositTxMaxFee = value;\n }\n}\n\ncontract MockTBTCVault is ITBTCVault {\n struct Request {\n uint64 requestedAt;\n uint64 finalizedAt;\n }\n\n mapping(uint256 => Request) internal _requests;\n\n uint32 public optimisticMintingFeeDivisor = 100; // 1%\n\n function optimisticMintingRequests(uint256 depositKey)\n external\n returns (uint64 requestedAt, uint64 finalizedAt)\n {\n Request memory request = _requests[depositKey];\n return (request.requestedAt, request.finalizedAt);\n }\n\n function createOptimisticMintingRequest(uint256 depositKey) external {\n require(\n _requests[depositKey].requestedAt == 0,\n \"Request already exists\"\n );\n /* solhint-disable-next-line not-rely-on-time */\n _requests[depositKey].requestedAt = uint64(block.timestamp);\n }\n\n function finalizeOptimisticMintingRequest(uint256 depositKey) public {\n require(\n _requests[depositKey].requestedAt != 0,\n \"Request does not exist\"\n );\n require(\n _requests[depositKey].finalizedAt == 0,\n \"Request already finalized\"\n );\n /* solhint-disable-next-line not-rely-on-time */\n _requests[depositKey].finalizedAt = uint64(block.timestamp);\n }\n\n function setOptimisticMintingFeeDivisor(uint32 value) external {\n optimisticMintingFeeDivisor = value;\n }\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC6093.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n" + }, + "@openzeppelin/contracts/interfaces/IERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../token/ERC20/IERC20.sol\";\nimport {IERC20Metadata} from \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\n\n event Withdraw(\n address indexed sender,\n address indexed receiver,\n address indexed owner,\n uint256 assets,\n uint256 shares\n );\n\n /**\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n *\n * - MUST be an ERC-20 token contract.\n * - MUST NOT revert.\n */\n function asset() external view returns (address assetTokenAddress);\n\n /**\n * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n *\n * - SHOULD include any compounding that occurs from yield.\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT revert.\n */\n function totalAssets() external view returns (uint256 totalManagedAssets);\n\n /**\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n * scenario where all the conditions are met.\n *\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n * - MUST NOT show any variations depending on the caller.\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n * - MUST NOT revert.\n *\n * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n * from.\n */\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n * through a deposit call.\n *\n * - MUST return a limited value if receiver is subject to some deposit limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n * - MUST NOT revert.\n */\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n * in the same transaction.\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * deposit execution, and are accounted for during deposit.\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n * - MUST return a limited value if receiver is subject to some mint limit.\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n * - MUST NOT revert.\n */\n function maxMint(address receiver) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n * current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n * same transaction.\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n * would be accepted, regardless if the user has enough tokens approved, etc.\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\n */\n function previewMint(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n *\n * - MUST emit the Deposit event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n * execution, and are accounted for during mint.\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n * approving enough underlying tokens to the Vault contract, etc).\n *\n * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n */\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n /**\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n * Vault, through a withdraw call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n * called\n * in the same transaction.\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n */\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n /**\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * withdraw execution, and are accounted for during withdraw.\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\n\n /**\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n * through a redeem call.\n *\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n * - MUST NOT revert.\n */\n function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n /**\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n * given current on-chain conditions.\n *\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n * same transaction.\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n * redemption would be accepted, regardless if the user has enough shares, etc.\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n * - MUST NOT revert.\n *\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n */\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n /**\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n *\n * - MUST emit the Withdraw event.\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n * redeem execution, and are accounted for during redeem.\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n * not having enough shares, etc).\n *\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n * Those methods should be performed separately.\n */\n function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20, IERC20Metadata, ERC20} from \"../ERC20.sol\";\nimport {SafeERC20} from \"../utils/SafeERC20.sol\";\nimport {IERC4626} from \"../../../interfaces/IERC4626.sol\";\nimport {Math} from \"../../../utils/math/Math.sol\";\n\n/**\n * @dev Implementation of the ERC4626 \"Tokenized Vault Standard\" as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\n *\n * This extension allows the minting and burning of \"shares\" (represented using the ERC20 inheritance) in exchange for\n * underlying \"assets\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\n * the ERC20 standard. Any additional extensions included along it would affect the \"shares\" token represented by this\n * contract and not the \"assets\" token which is an independent contract.\n *\n * [CAUTION]\n * ====\n * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning\n * with a \"donation\" to the vault that inflates the price of a share. This is variously known as a donation or inflation\n * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial\n * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may\n * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by\n * verifying the amount received is as expected, using a wrapper that performs these checks such as\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\n *\n * Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()`\n * corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault\n * decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself\n * determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset\n * (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's\n * donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more\n * expensive than it is profitable. More details about the underlying math can be found\n * xref:erc4626.adoc#inflation-attack[here].\n *\n * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued\n * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets\n * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience\n * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the\n * `_convertToShares` and `_convertToAssets` functions.\n *\n * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].\n * ====\n */\nabstract contract ERC4626 is ERC20, IERC4626 {\n using Math for uint256;\n\n IERC20 private immutable _asset;\n uint8 private immutable _underlyingDecimals;\n\n /**\n * @dev Attempted to deposit more assets than the max amount for `receiver`.\n */\n error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);\n\n /**\n * @dev Attempted to mint more shares than the max amount for `receiver`.\n */\n error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);\n\n /**\n * @dev Attempted to withdraw more assets than the max amount for `receiver`.\n */\n error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);\n\n /**\n * @dev Attempted to redeem more shares than the max amount for `receiver`.\n */\n error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);\n\n /**\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\n */\n constructor(IERC20 asset_) {\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\n _underlyingDecimals = success ? assetDecimals : 18;\n _asset = asset_;\n }\n\n /**\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\n */\n function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {\n (bool success, bytes memory encodedDecimals) = address(asset_).staticcall(\n abi.encodeCall(IERC20Metadata.decimals, ())\n );\n if (success && encodedDecimals.length >= 32) {\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\n if (returnedDecimals <= type(uint8).max) {\n return (true, uint8(returnedDecimals));\n }\n }\n return (false, 0);\n }\n\n /**\n * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This\n * \"original\" value is cached during construction of the vault contract. If this read operation fails (e.g., the\n * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.\n *\n * See {IERC20Metadata-decimals}.\n */\n function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {\n return _underlyingDecimals + _decimalsOffset();\n }\n\n /** @dev See {IERC4626-asset}. */\n function asset() public view virtual returns (address) {\n return address(_asset);\n }\n\n /** @dev See {IERC4626-totalAssets}. */\n function totalAssets() public view virtual returns (uint256) {\n return _asset.balanceOf(address(this));\n }\n\n /** @dev See {IERC4626-convertToShares}. */\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-convertToAssets}. */\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-maxDeposit}. */\n function maxDeposit(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4626-maxMint}. */\n function maxMint(address) public view virtual returns (uint256) {\n return type(uint256).max;\n }\n\n /** @dev See {IERC4626-maxWithdraw}. */\n function maxWithdraw(address owner) public view virtual returns (uint256) {\n return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-maxRedeem}. */\n function maxRedeem(address owner) public view virtual returns (uint256) {\n return balanceOf(owner);\n }\n\n /** @dev See {IERC4626-previewDeposit}. */\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-previewMint}. */\n function previewMint(uint256 shares) public view virtual returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Ceil);\n }\n\n /** @dev See {IERC4626-previewWithdraw}. */\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\n return _convertToShares(assets, Math.Rounding.Ceil);\n }\n\n /** @dev See {IERC4626-previewRedeem}. */\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\n return _convertToAssets(shares, Math.Rounding.Floor);\n }\n\n /** @dev See {IERC4626-deposit}. */\n function deposit(uint256 assets, address receiver) public virtual returns (uint256) {\n uint256 maxAssets = maxDeposit(receiver);\n if (assets > maxAssets) {\n revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);\n }\n\n uint256 shares = previewDeposit(assets);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-mint}.\n *\n * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.\n * In this case, the shares will be minted without requiring any assets to be deposited.\n */\n function mint(uint256 shares, address receiver) public virtual returns (uint256) {\n uint256 maxShares = maxMint(receiver);\n if (shares > maxShares) {\n revert ERC4626ExceededMaxMint(receiver, shares, maxShares);\n }\n\n uint256 assets = previewMint(shares);\n _deposit(_msgSender(), receiver, assets, shares);\n\n return assets;\n }\n\n /** @dev See {IERC4626-withdraw}. */\n function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {\n uint256 maxAssets = maxWithdraw(owner);\n if (assets > maxAssets) {\n revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);\n }\n\n uint256 shares = previewWithdraw(assets);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return shares;\n }\n\n /** @dev See {IERC4626-redeem}. */\n function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {\n uint256 maxShares = maxRedeem(owner);\n if (shares > maxShares) {\n revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);\n }\n\n uint256 assets = previewRedeem(shares);\n _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n return assets;\n }\n\n /**\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\n */\n function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {\n return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);\n }\n\n /**\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\n */\n function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {\n return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);\n }\n\n /**\n * @dev Deposit/mint common workflow.\n */\n function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {\n // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\n // assets are transferred and before the shares are minted, which is a valid state.\n // slither-disable-next-line reentrancy-no-eth\n SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\n _mint(receiver, shares);\n\n emit Deposit(caller, receiver, assets, shares);\n }\n\n /**\n * @dev Withdraw/redeem common workflow.\n */\n function _withdraw(\n address caller,\n address receiver,\n address owner,\n uint256 assets,\n uint256 shares\n ) internal virtual {\n if (caller != owner) {\n _spendAllowance(owner, caller, shares);\n }\n\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\n // calls the vault, which is assumed not malicious.\n //\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\n // shares are burned and after the assets are transferred, which is a valid state.\n _burn(owner, shares);\n SafeERC20.safeTransfer(_asset, receiver, assets);\n\n emit Withdraw(caller, receiver, owner, assets, shares);\n }\n\n function _decimalsOffset() internal view virtual returns (uint8) {\n return 0;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\nimport {IERC20Permit} from \"../extensions/IERC20Permit.sol\";\nimport {Address} from \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n /**\n * @dev An operation with an ERC20 token failed.\n */\n error SafeERC20FailedOperation(address token);\n\n /**\n * @dev Indicates a failed `decreaseAllowance` request.\n */\n error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n forceApprove(token, spender, oldAllowance + value);\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\n * value, non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\n unchecked {\n uint256 currentAllowance = token.allowance(address(this), spender);\n if (currentAllowance < requestedDecrease) {\n revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\n }\n forceApprove(token, spender, currentAllowance - requestedDecrease);\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data);\n if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\n revert SafeERC20FailedOperation(address(token));\n }\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance < amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance < value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 && target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" + }, + "contracts/Dispatcher.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\nimport \"./Router.sol\";\nimport \"./stBTC.sol\";\n\n/// @title Dispatcher\n/// @notice Dispatcher is a contract that routes tBTC from stBTC to\n/// yield vaults and back. Vaults supply yield strategies with tBTC that\n/// generate yield for Bitcoin holders.\ncontract Dispatcher is Router, Ownable {\n using SafeERC20 for IERC20;\n\n /// Struct holds information about a vault.\n struct VaultInfo {\n bool authorized;\n }\n\n /// The main stBTC contract holding tBTC deposited by stakers.\n stBTC public immutable stbtc;\n /// tBTC token contract.\n IERC20 public immutable tbtc;\n /// Address of the maintainer bot.\n address public maintainer;\n\n /// Authorized Yield Vaults that implement ERC4626 standard. These\n /// vaults deposit assets to yield strategies, e.g. Uniswap V3\n /// WBTC/TBTC pool. Vault can be a part of Acre ecosystem or can be\n /// implemented externally. As long as it complies with ERC4626\n /// standard and is authorized by the owner it can be plugged into\n /// Acre.\n address[] public vaults;\n /// Mapping of vaults to their information.\n mapping(address => VaultInfo) public vaultsInfo;\n\n /// Emitted when a vault is authorized.\n /// @param vault Address of the vault.\n event VaultAuthorized(address indexed vault);\n\n /// Emitted when a vault is deauthorized.\n /// @param vault Address of the vault.\n event VaultDeauthorized(address indexed vault);\n\n /// Emitted when tBTC is routed to a vault.\n /// @param vault Address of the vault.\n /// @param amount Amount of tBTC.\n /// @param sharesOut Amount of received shares.\n event DepositAllocated(\n address indexed vault,\n uint256 amount,\n uint256 sharesOut\n );\n\n /// Emitted when the maintainer address is updated.\n /// @param maintainer Address of the new maintainer.\n event MaintainerUpdated(address indexed maintainer);\n\n /// Reverts if the vault is already authorized.\n error VaultAlreadyAuthorized();\n\n /// Reverts if the vault is not authorized.\n error VaultUnauthorized();\n\n /// Reverts if the caller is not the maintainer.\n error NotMaintainer();\n\n /// Reverts if the address is zero.\n error ZeroAddress();\n\n /// Modifier that reverts if the caller is not the maintainer.\n modifier onlyMaintainer() {\n if (msg.sender != maintainer) {\n revert NotMaintainer();\n }\n _;\n }\n\n constructor(stBTC _stbtc, IERC20 _tbtc) Ownable(msg.sender) {\n stbtc = _stbtc;\n tbtc = _tbtc;\n }\n\n /// @notice Adds a vault to the list of authorized vaults.\n /// @param vault Address of the vault to add.\n function authorizeVault(address vault) external onlyOwner {\n if (isVaultAuthorized(vault)) {\n revert VaultAlreadyAuthorized();\n }\n\n vaults.push(vault);\n vaultsInfo[vault].authorized = true;\n\n emit VaultAuthorized(vault);\n }\n\n /// @notice Removes a vault from the list of authorized vaults.\n /// @param vault Address of the vault to remove.\n function deauthorizeVault(address vault) external onlyOwner {\n if (!isVaultAuthorized(vault)) {\n revert VaultUnauthorized();\n }\n\n vaultsInfo[vault].authorized = false;\n\n for (uint256 i = 0; i < vaults.length; i++) {\n if (vaults[i] == vault) {\n vaults[i] = vaults[vaults.length - 1];\n // slither-disable-next-line costly-loop\n vaults.pop();\n break;\n }\n }\n\n emit VaultDeauthorized(vault);\n }\n\n /// @notice Updates the maintainer address.\n /// @param newMaintainer Address of the new maintainer.\n function updateMaintainer(address newMaintainer) external onlyOwner {\n if (newMaintainer == address(0)) {\n revert ZeroAddress();\n }\n\n maintainer = newMaintainer;\n\n emit MaintainerUpdated(maintainer);\n }\n\n /// TODO: make this function internal once the allocation distribution is\n /// implemented\n /// @notice Routes tBTC from stBTC to a vault. Can be called by the maintainer\n /// only.\n /// @param vault Address of the vault to route the assets to.\n /// @param amount Amount of tBTC to deposit.\n /// @param minSharesOut Minimum amount of shares to receive.\n function depositToVault(\n address vault,\n uint256 amount,\n uint256 minSharesOut\n ) public onlyMaintainer {\n if (!isVaultAuthorized(vault)) {\n revert VaultUnauthorized();\n }\n\n // slither-disable-next-line arbitrary-send-erc20\n tbtc.safeTransferFrom(address(stbtc), address(this), amount);\n tbtc.forceApprove(address(vault), amount);\n\n uint256 sharesOut = deposit(\n IERC4626(vault),\n address(stbtc),\n amount,\n minSharesOut\n );\n // slither-disable-next-line reentrancy-events\n emit DepositAllocated(vault, amount, sharesOut);\n }\n\n /// @notice Returns the list of authorized vaults.\n function getVaults() public view returns (address[] memory) {\n return vaults;\n }\n\n /// @notice Returns true if the vault is authorized.\n /// @param vault Address of the vault to check.\n function isVaultAuthorized(address vault) public view returns (bool) {\n return vaultsInfo[vault].authorized;\n }\n\n /// TODO: implement redeem() / withdraw() functions\n}\n" + }, + "contracts/lib/ERC4626Fees.sol": { + "content": "// SPDX-License-Identifier: MIT\n\n// Inspired by https://docs.openzeppelin.com/contracts/5.x/erc4626#fees\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {ERC4626} from \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\n\n/// @dev ERC4626 vault with entry/exit fees expressed in https://en.wikipedia.org/wiki/Basis_point[basis point (bp)].\nabstract contract ERC4626Fees is ERC4626 {\n using Math for uint256;\n\n uint256 private constant _BASIS_POINT_SCALE = 1e4;\n\n // === Overrides ===\n\n /// @dev Preview taking an entry fee on deposit. See {IERC4626-previewDeposit}.\n function previewDeposit(\n uint256 assets\n ) public view virtual override returns (uint256) {\n uint256 fee = _feeOnTotal(assets, _entryFeeBasisPoints());\n return super.previewDeposit(assets - fee);\n }\n\n /// @dev Preview adding an entry fee on mint. See {IERC4626-previewMint}.\n function previewMint(\n uint256 shares\n ) public view virtual override returns (uint256) {\n uint256 assets = super.previewMint(shares);\n return assets + _feeOnRaw(assets, _entryFeeBasisPoints());\n }\n\n // TODO: add previewWithraw\n\n // TODO: add previewRedeem\n\n /// @dev Send entry fee to {_feeRecipient}. See {IERC4626-_deposit}.\n function _deposit(\n address caller,\n address receiver,\n uint256 assets,\n uint256 shares\n ) internal virtual override {\n uint256 fee = _feeOnTotal(assets, _entryFeeBasisPoints());\n address recipient = _feeRecipient();\n\n super._deposit(caller, receiver, assets, shares);\n\n if (fee > 0 && recipient != address(this)) {\n SafeERC20.safeTransfer(IERC20(asset()), recipient, fee);\n }\n }\n\n // TODO: add withdraw\n\n // === Fee configuration ===\n\n // slither-disable-next-line dead-code\n function _entryFeeBasisPoints() internal view virtual returns (uint256);\n\n // TODO: add exitFeeBasisPoints\n\n // slither-disable-next-line dead-code\n function _feeRecipient() internal view virtual returns (address);\n\n // === Fee operations ===\n\n /// @dev Calculates the fees that should be added to an amount `assets`\n /// that does not already include fees.\n /// Used in {IERC4626-mint} and {IERC4626-withdraw} operations.\n function _feeOnRaw(\n uint256 assets,\n uint256 feeBasisPoints\n ) private pure returns (uint256) {\n return\n assets.mulDiv(\n feeBasisPoints,\n _BASIS_POINT_SCALE,\n Math.Rounding.Ceil\n );\n }\n\n /// @dev Calculates the fee part of an amount `assets` that already includes fees.\n /// Used in {IERC4626-deposit} and {IERC4626-redeem} operations.\n function _feeOnTotal(\n uint256 assets,\n uint256 feeBasisPoints\n ) private pure returns (uint256) {\n return\n assets.mulDiv(\n feeBasisPoints,\n feeBasisPoints + _BASIS_POINT_SCALE,\n Math.Rounding.Ceil\n );\n }\n}\n" + }, + "contracts/Router.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/interfaces/IERC4626.sol\";\n\n/// @title Router\n/// @notice Router is a contract that routes tBTC from stBTC to\n/// a given vault and back. Vaults supply yield strategies with tBTC that\n/// generate yield for Bitcoin holders.\nabstract contract Router {\n /// Thrown when amount of shares received is below the min set by caller.\n /// @param vault Address of the vault.\n /// @param sharesOut Amount of received shares.\n /// @param minSharesOut Minimum amount of shares expected to receive.\n error MinSharesError(\n address vault,\n uint256 sharesOut,\n uint256 minSharesOut\n );\n\n /// @notice Routes funds from stBTC to a vault. The amount of tBTC to\n /// Shares of deposited tBTC are minted to the stBTC contract.\n /// @param vault Address of the vault to route the funds to.\n /// @param receiver Address of the receiver of the shares.\n /// @param amount Amount of tBTC to deposit.\n /// @param minSharesOut Minimum amount of shares to receive.\n function deposit(\n IERC4626 vault,\n address receiver,\n uint256 amount,\n uint256 minSharesOut\n ) internal returns (uint256 sharesOut) {\n if ((sharesOut = vault.deposit(amount, receiver)) < minSharesOut) {\n revert MinSharesError(address(vault), sharesOut, minSharesOut);\n }\n }\n}\n" + }, + "contracts/stBTC.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"./Dispatcher.sol\";\nimport \"./lib/ERC4626Fees.sol\";\n\n/// @title stBTC\n/// @notice This contract implements the ERC-4626 tokenized vault standard. By\n/// staking tBTC, users acquire a liquid staking token called stBTC,\n/// commonly referred to as \"shares\". The staked tBTC is securely\n/// deposited into Acre's vaults, where it generates yield over time.\n/// Users have the flexibility to redeem stBTC, enabling them to\n/// withdraw their staked tBTC along with the accrued yield.\n/// @dev ERC-4626 is a standard to optimize and unify the technical parameters\n/// of yield-bearing vaults. This contract facilitates the minting and\n/// burning of shares (stBTC), which are represented as standard ERC20\n/// tokens, providing a seamless exchange with tBTC tokens.\ncontract stBTC is ERC4626Fees, Ownable {\n using SafeERC20 for IERC20;\n\n /// Dispatcher contract that routes tBTC from stBTC to a given vault and back.\n Dispatcher public dispatcher;\n\n /// Address of the treasury wallet, where fees should be transferred to.\n address public treasury;\n\n /// Entry fee basis points applied to entry fee calculation.\n uint256 public entryFeeBasisPoints;\n\n /// Minimum amount for a single deposit operation. The value should be set\n /// low enough so the deposits routed through TbtcDepositor contract won't\n /// be rejected. It means that minimumDepositAmount should be lower than\n /// tBTC protocol's depositDustThreshold reduced by all the minting fees taken\n /// before depositing in the Acre contract.\n uint256 public minimumDepositAmount;\n\n /// Maximum total amount of tBTC token held by Acre protocol.\n uint256 public maximumTotalAssets;\n\n /// Emitted when a referral is used.\n /// @param referral Used for referral program.\n /// @param assets Amount of tBTC tokens staked.\n event StakeReferral(uint16 indexed referral, uint256 assets);\n\n /// Emitted when the treasury wallet address is updated.\n /// @param treasury New treasury wallet address.\n event TreasuryUpdated(address treasury);\n\n /// Emitted when deposit parameters are updated.\n /// @param minimumDepositAmount New value of the minimum deposit amount.\n /// @param maximumTotalAssets New value of the maximum total assets amount.\n event DepositParametersUpdated(\n uint256 minimumDepositAmount,\n uint256 maximumTotalAssets\n );\n\n /// Emitted when the dispatcher contract is updated.\n /// @param oldDispatcher Address of the old dispatcher contract.\n /// @param newDispatcher Address of the new dispatcher contract.\n event DispatcherUpdated(address oldDispatcher, address newDispatcher);\n\n /// Emitted when the entry fee basis points are updated.\n /// @param entryFeeBasisPoints New value of the fee basis points.\n event EntryFeeBasisPointsUpdated(uint256 entryFeeBasisPoints);\n\n /// Reverts if the amount is less than the minimum deposit amount.\n /// @param amount Amount to check.\n /// @param min Minimum amount to check 'amount' against.\n error LessThanMinDeposit(uint256 amount, uint256 min);\n\n /// Reverts if the address is zero.\n error ZeroAddress();\n\n /// Reverts if the address is disallowed.\n error DisallowedAddress();\n\n constructor(\n IERC20 _tbtc,\n address _treasury\n ) ERC4626(_tbtc) ERC20(\"Acre Staked Bitcoin\", \"stBTC\") Ownable(msg.sender) {\n if (address(_treasury) == address(0)) {\n revert ZeroAddress();\n }\n treasury = _treasury;\n // TODO: Revisit the exact values closer to the launch.\n minimumDepositAmount = 0.001 * 1e18; // 0.001 tBTC\n maximumTotalAssets = 25 * 1e18; // 25 tBTC\n entryFeeBasisPoints = 5; // 5bps == 0.05% == 0.0005\n }\n\n /// @notice Updates treasury wallet address.\n /// @param newTreasury New treasury wallet address.\n function updateTreasury(address newTreasury) external onlyOwner {\n // TODO: Introduce a parameters update process.\n if (newTreasury == address(0)) {\n revert ZeroAddress();\n }\n if (newTreasury == address(this)) {\n revert DisallowedAddress();\n }\n treasury = newTreasury;\n\n emit TreasuryUpdated(newTreasury);\n }\n\n /// @notice Updates deposit parameters.\n /// @dev To disable the limit for deposits, set the maximum total assets to\n /// maximum (`type(uint256).max`).\n /// @param _minimumDepositAmount New value of the minimum deposit amount. It\n /// is the minimum amount for a single deposit operation.\n /// @param _maximumTotalAssets New value of the maximum total assets amount.\n /// It is the maximum amount of the tBTC token that the Acre protocol\n /// can hold.\n function updateDepositParameters(\n uint256 _minimumDepositAmount,\n uint256 _maximumTotalAssets\n ) external onlyOwner {\n // TODO: Introduce a parameters update process.\n minimumDepositAmount = _minimumDepositAmount;\n maximumTotalAssets = _maximumTotalAssets;\n\n emit DepositParametersUpdated(\n _minimumDepositAmount,\n _maximumTotalAssets\n );\n }\n\n // TODO: Implement a governed upgrade process that initiates an update and\n // then finalizes it after a delay.\n /// @notice Updates the dispatcher contract and gives it an unlimited\n /// allowance to transfer staked tBTC.\n /// @param newDispatcher Address of the new dispatcher contract.\n function updateDispatcher(Dispatcher newDispatcher) external onlyOwner {\n if (address(newDispatcher) == address(0)) {\n revert ZeroAddress();\n }\n\n address oldDispatcher = address(dispatcher);\n\n emit DispatcherUpdated(oldDispatcher, address(newDispatcher));\n dispatcher = newDispatcher;\n\n // TODO: Once withdrawal/rebalancing is implemented, we need to revoke the\n // approval of the vaults share tokens from the old dispatcher and approve\n // a new dispatcher to manage the share tokens.\n\n if (oldDispatcher != address(0)) {\n // Setting allowance to zero for the old dispatcher\n IERC20(asset()).forceApprove(oldDispatcher, 0);\n }\n\n // Setting allowance to max for the new dispatcher\n IERC20(asset()).forceApprove(address(dispatcher), type(uint256).max);\n }\n\n // TODO: Implement a governed upgrade process that initiates an update and\n // then finalizes it after a delay.\n /// @notice Update the entry fee basis points.\n /// @param newEntryFeeBasisPoints New value of the fee basis points.\n function updateEntryFeeBasisPoints(\n uint256 newEntryFeeBasisPoints\n ) external onlyOwner {\n entryFeeBasisPoints = newEntryFeeBasisPoints;\n\n emit EntryFeeBasisPointsUpdated(newEntryFeeBasisPoints);\n }\n\n /// @notice Mints shares to receiver by depositing exactly amount of\n /// tBTC tokens.\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\n /// which determines the minimum amount for a single deposit operation.\n /// The amount of the assets has to be pre-approved in the tBTC\n /// contract.\n /// @param assets Approved amount of tBTC tokens to deposit. This includes\n /// treasury fees for staking tBTC.\n /// @param receiver The address to which the shares will be minted.\n /// @return Minted shares adjusted for the fees taken by the treasury.\n function deposit(\n uint256 assets,\n address receiver\n ) public override returns (uint256) {\n if (assets < minimumDepositAmount) {\n revert LessThanMinDeposit(assets, minimumDepositAmount);\n }\n\n return super.deposit(assets, receiver);\n }\n\n /// @notice Mints shares to receiver by depositing tBTC tokens.\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\n /// which determines the minimum amount for a single deposit operation.\n /// The amount of the assets has to be pre-approved in the tBTC\n /// contract.\n /// The msg.sender is required to grant approval for the transfer of a\n /// certain amount of tBTC, and in addition, approval for the associated\n /// fee. Specifically, the total amount to be approved (amountToApprove)\n /// should be equal to the sum of the deposited amount and the fee.\n /// To determine the total assets amount necessary for approval\n /// corresponding to a given share amount, use the `previewMint` function.\n /// @param shares Amount of shares to mint.\n /// @param receiver The address to which the shares will be minted.\n function mint(\n uint256 shares,\n address receiver\n ) public override returns (uint256 assets) {\n if ((assets = super.mint(shares, receiver)) < minimumDepositAmount) {\n revert LessThanMinDeposit(assets, minimumDepositAmount);\n }\n }\n\n /// @notice Stakes a given amount of tBTC token and mints shares to a\n /// receiver.\n /// @dev This function calls `deposit` function from `ERC4626` contract. The\n /// amount of the assets has to be pre-approved in the tBTC contract.\n /// @param assets Approved amount for the transfer and stake.\n /// @param receiver The address to which the shares will be minted.\n /// @param referral Data used for referral program.\n /// @return shares Minted shares.\n function stake(\n uint256 assets,\n address receiver,\n uint16 referral\n ) public returns (uint256) {\n // TODO: revisit the type of referral.\n uint256 shares = deposit(assets, receiver);\n\n if (referral > 0) {\n emit StakeReferral(referral, assets);\n }\n\n return shares;\n }\n\n /// @notice Returns the maximum amount of the tBTC token that can be\n /// deposited into the vault for the receiver through a deposit\n /// call. It takes into account the deposit parameter, maximum total\n /// assets, which determines the total amount of tBTC token held by\n /// Acre. This function always returns available limit for deposits,\n /// but the fee is not taken into account. As a result of this, there\n /// always will be some dust left. If the dust is lower than the\n /// minimum deposit amount, this function will return 0.\n /// @return The maximum amount of tBTC token that can be deposited into\n /// Acre protocol for the receiver.\n function maxDeposit(address) public view override returns (uint256) {\n if (maximumTotalAssets == type(uint256).max) {\n return type(uint256).max;\n }\n\n uint256 currentTotalAssets = totalAssets();\n if (currentTotalAssets >= maximumTotalAssets) return 0;\n\n // Max amount left for next deposits. If it is lower than the minimum\n // deposit amount, return 0.\n uint256 unusedLimit = maximumTotalAssets - currentTotalAssets;\n\n return minimumDepositAmount > unusedLimit ? 0 : unusedLimit;\n }\n\n /// @notice Returns the maximum amount of the vault shares that can be\n /// minted for the receiver, through a mint call.\n /// @dev Since the stBTC contract limits the maximum total tBTC tokens this\n /// function converts the maximum deposit amount to shares.\n /// @return The maximum amount of the vault shares.\n function maxMint(address receiver) public view override returns (uint256) {\n uint256 _maxDeposit = maxDeposit(receiver);\n\n // slither-disable-next-line incorrect-equality\n return\n _maxDeposit == type(uint256).max\n ? type(uint256).max\n : convertToShares(_maxDeposit);\n }\n\n /// @return Returns deposit parameters.\n function depositParameters() public view returns (uint256, uint256) {\n return (minimumDepositAmount, maximumTotalAssets);\n }\n\n /// @notice Redeems shares for tBTC tokens.\n function _entryFeeBasisPoints() internal view override returns (uint256) {\n return entryFeeBasisPoints;\n }\n\n /// @notice Returns the address of the treasury wallet, where fees should be\n /// transferred to.\n function _feeRecipient() internal view override returns (address) {\n return treasury;\n }\n}\n" + }, + "contracts/TbtcDepositor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport {BTCUtils} from \"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\n\nimport \"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\";\n\nimport {stBTC} from \"./stBTC.sol\";\n\n// TODO: Add Missfund token protection.\n// TODO: Make Upgradable\n\n/// @title tBTC Depositor contract.\n/// @notice The contract integrates Acre staking with tBTC minting.\n/// User who wants to stake BTC in Acre should submit a Bitcoin transaction\n/// to the most recently created off-chain ECDSA wallets of the tBTC Bridge\n/// using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH)\n/// containing hashed information about this Depositor contract address,\n/// and staker's Ethereum address.\n/// Then, the staker initiates tBTC minting by revealing their Ethereum\n/// address along with their deposit blinding factor, refund public key\n/// hash and refund locktime on the tBTC Bridge through this Depositor\n/// contract.\n/// The off-chain ECDSA wallet listens for these sorts of\n/// messages and when it gets one, it checks the Bitcoin network to make\n/// sure the deposit lines up. If it does, the off-chain ECDSA wallet\n/// may decide to pick the deposit transaction for sweeping, and when\n/// the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge\n/// and tBTC vault mint the tBTC token to the Depositor address.\n/// After tBTC is minted to the Depositor, on the stake finalization\n/// tBTC is staked in stBTC contract and stBTC shares are emitted to the\n/// receiver pointed by the staker.\ncontract TbtcDepositor is AbstractTBTCDepositor, Ownable {\n using BTCUtils for bytes;\n using SafeERC20 for IERC20;\n\n struct StakeRequest {\n // Timestamp at which the deposit request was initialized is not stored\n // in this structure, as it is available under `Bridge.DepositRequest.revealedAt`.\n\n // UNIX timestamp at which the deposit request was finalized.\n // 0 if not yet finalized.\n uint64 finalizedAt;\n // The address to which the stBTC shares will be minted.\n address receiver;\n // Identifier of a partner in the referral program.\n uint16 referral;\n // tBTC token amount to stake after deducting tBTC minting fees and the\n // Depositor fee.\n uint256 amountToStake;\n }\n\n /// @notice tBTC Token contract.\n IERC20 public immutable tbtcToken;\n /// @notice stBTC contract.\n stBTC public immutable stbtc;\n\n /// @notice Mapping of stake requests.\n /// @dev The key is a deposit key identifying the deposit.\n mapping(uint256 => StakeRequest) public stakeRequests;\n\n /// @notice Divisor used to compute the depositor fee taken from each deposit\n /// and transferred to the treasury upon stake request finalization.\n /// @dev That fee is computed as follows:\n /// `depositorFee = depositedAmount / depositorFeeDivisor`\n /// for example, if the depositor fee needs to be 2% of each deposit,\n /// the `depositorFeeDivisor` should be set to `50` because\n /// `1/50 = 0.02 = 2%`.\n uint64 public depositorFeeDivisor;\n\n /// @notice Emitted when a stake request is initialized.\n /// @dev Deposit details can be fetched from {{ Bridge.DepositRevealed }}\n /// event emitted in the same transaction.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param caller Address that initialized the stake request.\n /// @param receiver The address to which the stBTC shares will be minted.\n event StakeRequestInitialized(\n uint256 indexed depositKey,\n address indexed caller,\n address indexed receiver\n );\n\n /// @notice Emitted when bridging completion has been notified.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param caller Address that notified about bridging completion.\n /// @param referral Identifier of a partner in the referral program.\n /// @param bridgedAmount Amount of tBTC tokens that was bridged by the tBTC bridge.\n /// @param depositorFee Depositor fee amount.\n event BridgingCompleted(\n uint256 indexed depositKey,\n address indexed caller,\n uint16 indexed referral,\n uint256 bridgedAmount,\n uint256 depositorFee\n );\n\n /// @notice Emitted when a stake request is finalized.\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\n /// event emitted in the same transaction.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param caller Address that finalized the stake request.\n /// @param amountToStake Amount of staked tBTC tokens.\n event StakeRequestFinalized(\n uint256 indexed depositKey,\n address indexed caller,\n uint256 amountToStake\n );\n\n /// @notice Emitted when a stake request is recalled.\n /// @param depositKey Deposit key identifying the deposit.\n /// @param receiver Address of the receiver.\n /// @param amountToStake Amount of recalled tBTC tokens.\n event StakeRequestRecalled(\n uint256 indexed depositKey,\n address indexed receiver,\n uint256 amountToStake\n );\n\n /// @notice Emitted when a depositor fee divisor is updated.\n /// @param depositorFeeDivisor New value of the depositor fee divisor.\n event DepositorFeeDivisorUpdated(uint64 depositorFeeDivisor);\n\n /// @dev Receiver address is zero.\n error ReceiverIsZeroAddress();\n\n /// @dev Attempted to finalize a stake request, while bridging completion has\n /// not been notified yet.\n error BridgingNotCompleted();\n\n /// @dev Calculated depositor fee exceeds the amount of minted tBTC tokens.\n error DepositorFeeExceedsBridgedAmount(\n uint256 depositorFee,\n uint256 bridgedAmount\n );\n\n /// @dev Attempted to finalize a stake request that was already finalized.\n error StakeRequestAlreadyFinalized();\n\n /// @dev Attempted to call function by an account that is not the receiver.\n error CallerNotReceiver();\n\n /// @notice Tbtc Depositor contract constructor.\n /// @param _bridge tBTC Bridge contract instance.\n /// @param _tbtcVault tBTC Vault contract instance.\n /// @param _stbtc stBTC contract instance.\n // TODO: Move to initializer when making the contract upgradeable.\n constructor(\n address _bridge,\n address _tbtcVault,\n address _tbtcToken,\n address _stbtc\n ) Ownable(msg.sender) {\n __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\n\n require(_tbtcToken != address(0), \"TBTCToken address cannot be zero\");\n require(_stbtc != address(0), \"stBTC address cannot be zero\");\n\n tbtcToken = IERC20(_tbtcToken);\n stbtc = stBTC(_stbtc);\n\n depositorFeeDivisor = 1000; // 1/1000 == 10bps == 0.1% == 0.001\n }\n\n /// @notice This function allows staking process initialization for a Bitcoin\n /// deposit made by an user with a P2(W)SH transaction. It uses the\n /// supplied information to reveal a deposit to the tBTC Bridge contract.\n /// @dev Requirements:\n /// - The revealed vault address must match the TBTCVault address,\n /// - All requirements from {Bridge#revealDepositWithExtraData}\n /// function must be met.\n /// - `receiver` must be the receiver address used in the P2(W)SH BTC\n /// deposit transaction as part of the extra data.\n /// - `referral` must be the referral info used in the P2(W)SH BTC\n /// deposit transaction as part of the extra data.\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\n /// can be revealed only one time.\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\n /// @param receiver The address to which the stBTC shares will be minted.\n /// @param referral Data used for referral program.\n function initializeStakeRequest(\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\n IBridgeTypes.DepositRevealInfo calldata reveal,\n address receiver,\n uint16 referral\n ) external {\n if (receiver == address(0)) revert ReceiverIsZeroAddress();\n\n // We don't check if the request was already initialized, as this check\n // is enforced in `_initializeDeposit` when calling the\n // `Bridge.revealDepositWithExtraData` function.\n\n uint256 depositKey = _initializeDeposit(\n fundingTx,\n reveal,\n encodeExtraData(receiver, referral)\n );\n\n StakeRequest storage request = stakeRequests[depositKey];\n request.receiver = receiver;\n request.referral = referral;\n\n emit StakeRequestInitialized(depositKey, msg.sender, receiver);\n }\n\n /// @notice This function should be called for previously initialized stake\n /// request, after tBTC minting process completed, meaning tBTC was\n /// minted to this contract.\n /// @dev It calculates the amount to stake based on the approximate minted\n /// tBTC amount reduced by the depositor fee.\n /// @dev IMPORTANT NOTE: The minted tBTC amount used by this function is an\n /// approximation. See documentation of the\n /// {{TBTCDepositorProxy#_calculateTbtcAmount}} responsible for calculating\n /// this value for more details.\n /// @param depositKey Deposit key identifying the deposit.\n function notifyBridgingCompleted(uint256 depositKey) external {\n (\n uint256 depositAmount,\n uint256 depositSubBridgingFeesAmount,\n\n ) = _finalizeDeposit(depositKey);\n\n // Compute depositor fee. The fee is calculated based on the initial funding\n // transaction amount, before the tBTC protocol network fees were taken.\n uint256 depositorFee = depositorFeeDivisor > 0\n ? (depositAmount / depositorFeeDivisor)\n : 0;\n\n // Ensure the depositor fee does not exceed the approximate minted tBTC\n // amount.\n if (depositorFee >= depositSubBridgingFeesAmount) {\n revert DepositorFeeExceedsBridgedAmount(\n depositorFee,\n depositSubBridgingFeesAmount\n );\n }\n\n StakeRequest storage request = stakeRequests[depositKey];\n\n request.amountToStake = depositSubBridgingFeesAmount - depositorFee;\n\n emit BridgingCompleted(\n depositKey,\n msg.sender,\n request.referral,\n depositSubBridgingFeesAmount,\n depositorFee\n );\n\n // Transfer depositor fee to the treasury wallet.\n if (depositorFee > 0) {\n tbtcToken.safeTransfer(stbtc.treasury(), depositorFee);\n }\n }\n\n /// @notice This function should be called for previously initialized stake\n /// request, after tBTC bridging process was finalized.\n /// It stakes the tBTC from the given deposit into stBTC, emitting the\n /// stBTC shares to the receiver specified in the deposit extra data\n /// and using the referral provided in the extra data.\n /// @dev This function is expected to be called after `notifyBridgingCompleted`.\n /// In case depositing in stBTC vault fails (e.g. because of the\n /// maximum deposit limit being reached), the function should be retried\n /// after the limit is increased or other user withdraws their funds\n /// from the stBTC contract to make place for another deposit.\n /// The staker has a possibility to submit `recallStakeRequest` that\n /// will withdraw the minted tBTC token and abort staking process.\n /// @param depositKey Deposit key identifying the deposit.\n function finalizeStakeRequest(uint256 depositKey) external {\n StakeRequest storage request = stakeRequests[depositKey];\n\n if (request.amountToStake == 0) revert BridgingNotCompleted();\n if (request.finalizedAt > 0) revert StakeRequestAlreadyFinalized();\n\n // solhint-disable-next-line not-rely-on-time\n request.finalizedAt = uint64(block.timestamp);\n\n emit StakeRequestFinalized(\n depositKey,\n msg.sender,\n request.amountToStake\n );\n\n // Deposit tBTC in stBTC.\n tbtcToken.safeIncreaseAllowance(address(stbtc), request.amountToStake);\n // slither-disable-next-line unused-return\n stbtc.deposit(request.amountToStake, request.receiver);\n }\n\n /// @notice Recall bridged tBTC tokens from being requested to stake. This\n /// function can be called by the staker to recover tBTC that cannot\n /// be finalized to stake in stBTC contract due to a deposit limit being\n /// reached.\n /// @dev This function can be called only after bridging in tBTC Bridge was\n /// completed. Only receiver provided in the extra data of the stake\n /// request can call this function.\n /// @param depositKey Deposit key identifying the deposit.\n function recallStakeRequest(uint256 depositKey) external {\n StakeRequest storage request = stakeRequests[depositKey];\n\n if (request.amountToStake == 0) revert BridgingNotCompleted();\n if (request.finalizedAt > 0) revert StakeRequestAlreadyFinalized();\n\n // Check if caller is the receiver.\n if (msg.sender != request.receiver) revert CallerNotReceiver();\n\n // solhint-disable-next-line not-rely-on-time\n request.finalizedAt = uint64(block.timestamp);\n\n emit StakeRequestRecalled(\n depositKey,\n request.receiver,\n request.amountToStake\n );\n\n tbtcToken.safeTransfer(request.receiver, request.amountToStake);\n }\n\n /// @notice Updates the depositor fee divisor.\n /// @param newDepositorFeeDivisor New depositor fee divisor value.\n function updateDepositorFeeDivisor(\n uint64 newDepositorFeeDivisor\n ) external onlyOwner {\n // TODO: Introduce a parameters update process.\n depositorFeeDivisor = newDepositorFeeDivisor;\n\n emit DepositorFeeDivisorUpdated(newDepositorFeeDivisor);\n }\n\n // TODO: Handle minimum deposit amount in tBTC Bridge vs stBTC.\n\n /// @notice Encode receiver address and referral as extra data.\n /// @dev Packs the data to bytes32: 20 bytes of receiver address and\n /// 2 bytes of referral, 10 bytes of trailing zeros.\n /// @param receiver The address to which the stBTC shares will be minted.\n /// @param referral Data used for referral program.\n /// @return Encoded extra data.\n function encodeExtraData(\n address receiver,\n uint16 referral\n ) public pure returns (bytes32) {\n return bytes32(abi.encodePacked(receiver, referral));\n }\n}\n" + }, + "contracts/test/MockTbtcBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport {MockBridge, MockTBTCVault} from \"@keep-network/tbtc-v2/contracts/test/TestTBTCDepositor.sol\";\nimport {IBridge} from \"@keep-network/tbtc-v2/contracts/integrator/IBridge.sol\";\nimport {IBridgeTypes} from \"@keep-network/tbtc-v2/contracts/integrator/IBridge.sol\";\n\nimport {TestERC20} from \"./TestERC20.sol\";\n\ncontract BridgeStub is MockBridge {}\n\ncontract TBTCVaultStub is MockTBTCVault {\n TestERC20 public immutable tbtc;\n IBridge public immutable bridge;\n\n /// @notice Multiplier to convert satoshi to TBTC token units.\n uint256 public constant SATOSHI_MULTIPLIER = 10 ** 10;\n\n constructor(TestERC20 _tbtc, IBridge _bridge) {\n tbtc = _tbtc;\n bridge = _bridge;\n }\n\n function finalizeOptimisticMintingRequestAndMint(\n uint256 depositKey\n ) public {\n MockTBTCVault.finalizeOptimisticMintingRequest(depositKey);\n\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\n depositKey\n );\n\n uint256 amountSubTreasury = (deposit.amount - deposit.treasuryFee) *\n SATOSHI_MULTIPLIER;\n\n uint256 omFee = optimisticMintingFeeDivisor > 0\n ? (amountSubTreasury / optimisticMintingFeeDivisor)\n : 0;\n\n // The deposit transaction max fee is in the 1e8 satoshi precision.\n // We need to convert them to the 1e18 TBTC precision.\n // slither-disable-next-line unused-return\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\n\n uint256 amountToMint = amountSubTreasury - omFee - txMaxFee;\n\n tbtc.mint(deposit.depositor, amountToMint);\n }\n}\n" + }, + "contracts/test/TestERC20.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract TestERC20 is ERC20 {\n constructor(string memory name, string memory symbol) ERC20(name, symbol) {}\n\n function mint(address account, uint256 value) external {\n _mint(account, value);\n }\n}\n" + }, + "contracts/test/TestERC4626.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.21;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\n\ncontract TestERC4626 is ERC4626 {\n constructor(\n IERC20 asset,\n string memory tokenName,\n string memory tokenSymbol\n ) ERC4626(asset) ERC20(tokenName, tokenSymbol) {}\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 1000 + }, + "evmVersion": "paris", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "devdoc", + "userdoc", + "storageLayout", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file diff --git a/sdk/src/lib/ethereum/artifacts/sepolia/AcreBitcoinDepositor.json b/sdk/src/lib/ethereum/artifacts/sepolia/AcreBitcoinDepositor.json new file mode 100644 index 000000000..c09f41dfd --- /dev/null +++ b/sdk/src/lib/ethereum/artifacts/sepolia/AcreBitcoinDepositor.json @@ -0,0 +1,1337 @@ +{ + "address": "0x37E34EbC743FFAf96b56b3f62854bb7E733a4B50", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "bridge", + "type": "address" + }, + { + "internalType": "address", + "name": "tbtcVault", + "type": "address" + }, + { + "internalType": "address", + "name": "_tbtcToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_stbtc", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "AddressEmptyCode", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "AddressInsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "BridgingCompletionAlreadyNotified", + "type": "error" + }, + { + "inputs": [], + "name": "BridgingFinalizationAlreadyCalled", + "type": "error" + }, + { + "inputs": [], + "name": "BridgingNotCompleted", + "type": "error" + }, + { + "inputs": [], + "name": "CallerNotStaker", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositorFee", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bridgedAmount", + "type": "uint256" + } + ], + "name": "DepositorFeeExceedsBridgedAmount", + "type": "error" + }, + { + "inputs": [], + "name": "FailedInnerCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountToStake", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "currentBalance", + "type": "uint256" + } + ], + "name": "InsufficientTbtcBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "bits", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "SafeCastOverflowedUintDowncast", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "inputs": [], + "name": "StakeRequestNotQueued", + "type": "error" + }, + { + "inputs": [], + "name": "StakerIsZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "StbtcZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "TbtcTokenZeroAddress", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "enum AcreBitcoinDepositor.StakeRequestState", + "name": "currentState", + "type": "uint8" + }, + { + "internalType": "enum AcreBitcoinDepositor.StakeRequestState", + "name": "expectedState", + "type": "uint8" + } + ], + "name": "UnexpectedStakeRequestState", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint16", + "name": "referral", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bridgedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "depositorFee", + "type": "uint256" + } + ], + "name": "BridgingCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tbtcAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "finalizedAt", + "type": "uint32" + } + ], + "name": "DepositFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "initializedAt", + "type": "uint32" + } + ], + "name": "DepositInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "depositorFeeDivisor", + "type": "uint64" + } + ], + "name": "DepositorFeeDivisorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountToStake", + "type": "uint256" + } + ], + "name": "StakeRequestCancelledFromQueue", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + } + ], + "name": "StakeRequestFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stakedAmount", + "type": "uint256" + } + ], + "name": "StakeRequestFinalizedFromQueue", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "staker", + "type": "address" + } + ], + "name": "StakeRequestInitialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "caller", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "queuedAmount", + "type": "uint256" + } + ], + "name": "StakeRequestQueued", + "type": "event" + }, + { + "inputs": [], + "name": "SATOSHI_MULTIPLIER", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "bridge", + "outputs": [ + { + "internalType": "contract IBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "cancelQueuedStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "extraData", + "type": "bytes32" + } + ], + "name": "decodeExtraData", + "outputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "uint16", + "name": "referral", + "type": "uint16" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "depositorFeeDivisor", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "uint16", + "name": "referral", + "type": "uint16" + } + ], + "name": "encodeExtraData", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "finalizeQueuedStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "finalizeStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct IBridgeTypes.BitcoinTxInfo", + "name": "fundingTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + }, + { + "internalType": "bytes8", + "name": "blindingFactor", + "type": "bytes8" + }, + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "bytes20", + "name": "refundPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "bytes4", + "name": "refundLocktime", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "internalType": "struct IBridgeTypes.DepositRevealInfo", + "name": "reveal", + "type": "tuple" + }, + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "uint16", + "name": "referral", + "type": "uint16" + } + ], + "name": "initializeStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "queueStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "stakeRequests", + "outputs": [ + { + "internalType": "enum AcreBitcoinDepositor.StakeRequestState", + "name": "state", + "type": "uint8" + }, + { + "internalType": "address", + "name": "staker", + "type": "address" + }, + { + "internalType": "uint88", + "name": "queuedAmount", + "type": "uint88" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "stbtc", + "outputs": [ + { + "internalType": "contract stBTC", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tbtcToken", + "outputs": [ + { + "internalType": "contract IERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tbtcVault", + "outputs": [ + { + "internalType": "contract ITBTCVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "newDepositorFeeDivisor", + "type": "uint64" + } + ], + "name": "updateDepositorFeeDivisor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x6f7d1a83200314126aa36f4aaac2450d2a0c1ffd77a53327d35bf6c0331d4bec", + "receipt": { + "to": null, + "from": "0x2d154A5c7cE9939274b89bbCe9f5B069E57b09A8", + "contractAddress": "0x37E34EbC743FFAf96b56b3f62854bb7E733a4B50", + "transactionIndex": 157, + "gasUsed": "2013605", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000002000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000001000000000000000000000000000000400000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000012000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x13e2258b7e01b5bb7b0c5d438c0e623c89056660447e4bff2cd8a812392a6df5", + "transactionHash": "0x6f7d1a83200314126aa36f4aaac2450d2a0c1ffd77a53327d35bf6c0331d4bec", + "logs": [ + { + "transactionIndex": 157, + "blockNumber": 5387080, + "transactionHash": "0x6f7d1a83200314126aa36f4aaac2450d2a0c1ffd77a53327d35bf6c0331d4bec", + "address": "0x37E34EbC743FFAf96b56b3f62854bb7E733a4B50", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x0000000000000000000000002d154a5c7ce9939274b89bbce9f5b069e57b09a8" + ], + "data": "0x", + "logIndex": 237, + "blockHash": "0x13e2258b7e01b5bb7b0c5d438c0e623c89056660447e4bff2cd8a812392a6df5" + } + ], + "blockNumber": 5387080, + "cumulativeGasUsed": "27025873", + "status": 1, + "byzantium": true + }, + "args": [ + "0x9b1a7fE5a16A15F2f9475C5B231750598b113403", + "0xB5679dE944A79732A75CE556191DF11F489448d5", + "0x517f2982701695D4E52f1ECFBEf3ba31Df470161", + "0xF99139f09164B092bD9e8558984Becfb0d2eCb87" + ], + "numDeployments": 1, + "solcInputHash": "49f0432287e96a47d66ba17ae7bf5d96", + "metadata": "{\"compiler\":{\"version\":\"0.8.21+commit.d9974bed\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"tbtcVault\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tbtcToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stbtc\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BridgingCompletionAlreadyNotified\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BridgingFinalizationAlreadyCalled\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BridgingNotCompleted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CallerNotStaker\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositorFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bridgedAmount\",\"type\":\"uint256\"}],\"name\":\"DepositorFeeExceedsBridgedAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentBalance\",\"type\":\"uint256\"}],\"name\":\"InsufficientTbtcBalance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"bits\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"SafeCastOverflowedUintDowncast\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"SafeERC20FailedOperation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeRequestNotQueued\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakerIsZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StbtcZeroAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"TbtcTokenZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"enum AcreBitcoinDepositor.StakeRequestState\",\"name\":\"currentState\",\"type\":\"uint8\"},{\"internalType\":\"enum AcreBitcoinDepositor.StakeRequestState\",\"name\":\"expectedState\",\"type\":\"uint8\"}],\"name\":\"UnexpectedStakeRequestState\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bridgedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"depositorFee\",\"type\":\"uint256\"}],\"name\":\"BridgingCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tbtcAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"finalizedAt\",\"type\":\"uint32\"}],\"name\":\"DepositFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"initializedAt\",\"type\":\"uint32\"}],\"name\":\"DepositInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositorFeeDivisor\",\"type\":\"uint64\"}],\"name\":\"DepositorFeeDivisorUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"}],\"name\":\"StakeRequestCancelledFromQueue\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"stakedAmount\",\"type\":\"uint256\"}],\"name\":\"StakeRequestFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"stakedAmount\",\"type\":\"uint256\"}],\"name\":\"StakeRequestFinalizedFromQueue\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"}],\"name\":\"StakeRequestInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"queuedAmount\",\"type\":\"uint256\"}],\"name\":\"StakeRequestQueued\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"SATOSHI_MULTIPLIER\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"acceptOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contract IBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"cancelQueuedStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"extraData\",\"type\":\"bytes32\"}],\"name\":\"decodeExtraData\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositorFeeDivisor\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"name\":\"encodeExtraData\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"finalizeQueuedStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"finalizeStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"struct IBridgeTypes.BitcoinTxInfo\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"struct IBridgeTypes.DepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"name\":\"initializeStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"queueStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"stakeRequests\",\"outputs\":[{\"internalType\":\"enum AcreBitcoinDepositor.StakeRequestState\",\"name\":\"state\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"staker\",\"type\":\"address\"},{\"internalType\":\"uint88\",\"name\":\"queuedAmount\",\"type\":\"uint88\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stbtc\",\"outputs\":[{\"internalType\":\"contract stBTC\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcVault\",\"outputs\":[{\"internalType\":\"contract ITBTCVault\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"newDepositorFeeDivisor\",\"type\":\"uint64\"}],\"name\":\"updateDepositorFeeDivisor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AddressEmptyCode(address)\":[{\"details\":\"There's no code at `target` (it is not a contract).\"}],\"AddressInsufficientBalance(address)\":[{\"details\":\"The ETH balance of the account is not enough to perform the operation.\"}],\"BridgingCompletionAlreadyNotified()\":[{\"details\":\"Attempted to notify a bridging completion, while it was already notified.\"}],\"BridgingFinalizationAlreadyCalled()\":[{\"details\":\"Attempted to call bridging finalization for a stake request for which the function was already called.\"}],\"BridgingNotCompleted()\":[{\"details\":\"Attempted to finalize a stake request, while bridging completion has not been notified yet.\"}],\"CallerNotStaker()\":[{\"details\":\"Attempted to call function by an account that is not the staker.\"}],\"DepositorFeeExceedsBridgedAmount(uint256,uint256)\":[{\"details\":\"Calculated depositor fee exceeds the amount of minted tBTC tokens.\"}],\"FailedInnerCall()\":[{\"details\":\"A call to an address target failed. The target may have reverted.\"}],\"InsufficientTbtcBalance(uint256,uint256)\":[{\"details\":\"Attempted to finalize bridging with depositor's contract tBTC balance lower than the calculated bridged tBTC amount. This error means that Governance should top-up the tBTC reserve for bridging fees approximation.\"}],\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}],\"SafeCastOverflowedUintDowncast(uint8,uint256)\":[{\"details\":\"Value doesn't fit in an uint of `bits` size.\"}],\"SafeERC20FailedOperation(address)\":[{\"details\":\"An operation with an ERC20 token failed.\"}],\"StakeRequestNotQueued()\":[{\"details\":\"Attempted to finalize or cancel a stake request that was not added to the queue, or was already finalized or cancelled.\"}],\"StakerIsZeroAddress()\":[{\"details\":\"Staker address is zero.\"}],\"UnexpectedStakeRequestState(uint8,uint8)\":[{\"details\":\"Attempted to execute function for stake request in unexpected current state.\"}]},\"events\":{\"BridgingCompleted(uint256,address,uint16,uint256,uint256)\":{\"params\":{\"bridgedAmount\":\"Amount of tBTC tokens that was bridged by the tBTC bridge.\",\"caller\":\"Address that notified about bridging completion.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"depositorFee\":\"Depositor fee amount.\",\"referral\":\"Identifier of a partner in the referral program.\"}},\"DepositorFeeDivisorUpdated(uint64)\":{\"params\":{\"depositorFeeDivisor\":\"New value of the depositor fee divisor.\"}},\"StakeRequestCancelledFromQueue(uint256,address,uint256)\":{\"params\":{\"amountToStake\":\"Amount of queued tBTC tokens that got cancelled.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"staker\":\"Address of the staker.\"}},\"StakeRequestFinalized(uint256,address,uint256)\":{\"details\":\"Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.\",\"params\":{\"caller\":\"Address that finalized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"stakedAmount\":\"Amount of staked tBTC tokens.\"}},\"StakeRequestFinalizedFromQueue(uint256,address,uint256)\":{\"details\":\"Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.\",\"params\":{\"caller\":\"Address that finalized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"stakedAmount\":\"Amount of staked tBTC tokens.\"}},\"StakeRequestInitialized(uint256,address,address)\":{\"details\":\"Deposit details can be fetched from {{ Bridge.DepositRevealed }} event emitted in the same transaction.\",\"params\":{\"caller\":\"Address that initialized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"staker\":\"The address to which the stBTC shares will be minted.\"}},\"StakeRequestQueued(uint256,address,uint256)\":{\"params\":{\"caller\":\"Address that finalized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"queuedAmount\":\"Amount of queued tBTC tokens.\"}}},\"kind\":\"dev\",\"methods\":{\"acceptOwnership()\":{\"details\":\"The new owner accepts the ownership transfer.\"},\"cancelQueuedStake(uint256)\":{\"details\":\"This function can be called only after the stake request was added to queue.Only staker provided in the extra data of the stake request can call this function.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"constructor\":{\"params\":{\"_stbtc\":\"stBTC contract instance.\",\"_tbtcToken\":\"tBTC token contract instance.\",\"bridge\":\"tBTC Bridge contract instance.\",\"tbtcVault\":\"tBTC Vault contract instance.\"}},\"decodeExtraData(bytes32)\":{\"details\":\"Unpacks the data from bytes32: 20 bytes of staker address and 2 bytes of referral, 10 bytes of trailing zeros.\",\"params\":{\"extraData\":\"Encoded extra data.\"},\"returns\":{\"referral\":\"Data used for referral program.\",\"staker\":\"The address to which the stBTC shares will be minted.\"}},\"encodeExtraData(address,uint16)\":{\"details\":\"Packs the data to bytes32: 20 bytes of staker address and 2 bytes of referral, 10 bytes of trailing zeros.\",\"params\":{\"referral\":\"Data used for referral program.\",\"staker\":\"The address to which the stBTC shares will be minted.\"},\"returns\":{\"_0\":\"Encoded extra data.\"}},\"finalizeQueuedStake(uint256)\":{\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"finalizeStake(uint256)\":{\"details\":\"In case depositing in stBTC vault fails (e.g. because of the maximum deposit limit being reached), the `queueStake` function should be called to add the stake request to the staking queue.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"initializeStake((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)\":{\"details\":\"Requirements: - The revealed vault address must match the TBTCVault address, - All requirements from {Bridge#revealDepositWithExtraData} function must be met. - `staker` must be the staker address used in the P2(W)SH BTC deposit transaction as part of the extra data. - `referral` must be the referral info used in the P2(W)SH BTC deposit transaction as part of the extra data. - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex` can be revealed only one time.\",\"params\":{\"fundingTx\":\"Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\",\"referral\":\"Data used for referral program.\",\"reveal\":\"Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\",\"staker\":\"The address to which the stBTC shares will be minted.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"pendingOwner()\":{\"details\":\"Returns the address of the pending owner.\"},\"queueStake(uint256)\":{\"details\":\"It queues the stake request, until the stBTC vault is ready to accept the deposit. The request must be finalized with `finalizeQueuedStake` after the limit is increased or other user withdraws their funds from the stBTC contract to make place for another deposit. The staker has a possibility to submit `cancelQueuedStake` that will withdraw the minted tBTC token and abort staking process.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.\"},\"updateDepositorFeeDivisor(uint64)\":{\"params\":{\"newDepositorFeeDivisor\":\"New depositor fee divisor value.\"}}},\"stateVariables\":{\"depositorFeeDivisor\":{\"details\":\"That fee is computed as follows: `depositorFee = depositedAmount / depositorFeeDivisor` for example, if the depositor fee needs to be 2% of each deposit, the `depositorFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`.\"},\"stakeRequests\":{\"details\":\"The key is a deposit key identifying the deposit.\"}},\"title\":\"Acre Bitcoin Depositor contract.\",\"version\":1},\"userdoc\":{\"errors\":{\"StbtcZeroAddress()\":[{\"notice\":\"Reverts if the stBTC address is zero.\"}],\"TbtcTokenZeroAddress()\":[{\"notice\":\"Reverts if the tBTC Token address is zero.\"}]},\"events\":{\"BridgingCompleted(uint256,address,uint16,uint256,uint256)\":{\"notice\":\"Emitted when bridging completion has been notified.\"},\"DepositorFeeDivisorUpdated(uint64)\":{\"notice\":\"Emitted when a depositor fee divisor is updated.\"},\"StakeRequestCancelledFromQueue(uint256,address,uint256)\":{\"notice\":\"Emitted when a queued stake request is cancelled.\"},\"StakeRequestFinalized(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is finalized.\"},\"StakeRequestFinalizedFromQueue(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is finalized from the queue.\"},\"StakeRequestInitialized(uint256,address,address)\":{\"notice\":\"Emitted when a stake request is initialized.\"},\"StakeRequestQueued(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is queued.\"}},\"kind\":\"user\",\"methods\":{\"SATOSHI_MULTIPLIER()\":{\"notice\":\"Multiplier to convert satoshi to TBTC token units.\"},\"bridge()\":{\"notice\":\"Bridge contract address.\"},\"cancelQueuedStake(uint256)\":{\"notice\":\"Cancel queued stake. The function can be called by the staker to recover tBTC that cannot be finalized to stake in stBTC contract due to a deposit limit being reached.\"},\"constructor\":{\"notice\":\"Acre Bitcoin Depositor contract constructor.\"},\"decodeExtraData(bytes32)\":{\"notice\":\"Decodes staker address and referral from extra data.\"},\"depositorFeeDivisor()\":{\"notice\":\"Divisor used to compute the depositor fee taken from each deposit and transferred to the treasury upon stake request finalization.\"},\"encodeExtraData(address,uint16)\":{\"notice\":\"Encodes staker address and referral as extra data.\"},\"finalizeQueuedStake(uint256)\":{\"notice\":\"This function should be called for previously queued stake request, when stBTC vault is able to accept a deposit.\"},\"finalizeStake(uint256)\":{\"notice\":\"This function should be called for previously initialized stake request, after tBTC bridging process was finalized. It stakes the tBTC from the given deposit into stBTC, emitting the stBTC shares to the staker specified in the deposit extra data and using the referral provided in the extra data.\"},\"initializeStake((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)\":{\"notice\":\"This function allows staking process initialization for a Bitcoin deposit made by an user with a P2(W)SH transaction. It uses the supplied information to reveal a deposit to the tBTC Bridge contract.\"},\"queueStake(uint256)\":{\"notice\":\"This function should be called for previously initialized stake request, after tBTC bridging process was finalized, in case the `finalizeStake` failed due to stBTC vault deposit limit being reached.\"},\"stakeRequests(uint256)\":{\"notice\":\"Mapping of stake requests.\"},\"stbtc()\":{\"notice\":\"stBTC contract.\"},\"tbtcToken()\":{\"notice\":\"tBTC Token contract.\"},\"tbtcVault()\":{\"notice\":\"TBTCVault contract address.\"},\"updateDepositorFeeDivisor(uint64)\":{\"notice\":\"Updates the depositor fee divisor.\"}},\"notice\":\"The contract integrates Acre staking with tBTC minting. User who wants to stake BTC in Acre should submit a Bitcoin transaction to the most recently created off-chain ECDSA wallets of the tBTC Bridge using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH) containing hashed information about this Depositor contract address, and staker's Ethereum address. Then, the staker initiates tBTC minting by revealing their Ethereum address along with their deposit blinding factor, refund public key hash and refund locktime on the tBTC Bridge through this Depositor contract. The off-chain ECDSA wallet and Optimistic Minting bots listen for these sorts of messages and when they get one, they check the Bitcoin network to make sure the deposit lines up. Majority of tBTC minting is finalized by the Optimistic Minting process, where Minter bot initializes minting process and if there is no veto from the Guardians, the process is finalized and tBTC minted to the Depositor address. If the revealed deposit is not handled by the Optimistic Minting process the off-chain ECDSA wallet may decide to pick the deposit transaction for sweeping, and when the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge and tBTC vault mint the tBTC token to the Depositor address. After tBTC is minted to the Depositor, on the stake finalization tBTC is staked in stBTC contract and stBTC shares are emitted to the staker.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/AcreBitcoinDepositor.sol\":\"AcreBitcoinDepositor\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to \\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\nPermission is hereby granted, free of charge, to any person obtaining\\na copy of this software and associated documentation files (the\\n\\\"Software\\\"), to deal in the Software without restriction, including\\nwithout limitation the rights to use, copy, modify, merge, publish,\\ndistribute, sublicense, and/or sell copies of the Software, and to\\npermit persons to whom the Software is furnished to do so, subject to\\nthe following conditions:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\\n*/\\n\\n\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\n\\nimport \\\"./IBridge.sol\\\";\\nimport \\\"./ITBTCVault.sol\\\";\\n\\n/// @title Abstract AbstractTBTCDepositor contract.\\n/// @notice This abstract contract is meant to facilitate integration of protocols\\n/// aiming to use tBTC as an underlying Bitcoin bridge.\\n///\\n/// Such an integrator is supposed to:\\n/// - Create a child contract inheriting from this abstract contract\\n/// - Call the `__AbstractTBTCDepositor_initialize` initializer function\\n/// - Use the `_initializeDeposit` and `_finalizeDeposit` as part of their\\n/// business logic in order to initialize and finalize deposits.\\n///\\n/// @dev Example usage:\\n/// ```\\n/// // Example upgradeable integrator contract.\\n/// contract ExampleTBTCIntegrator is AbstractTBTCDepositor, Initializable {\\n/// /// @custom:oz-upgrades-unsafe-allow constructor\\n/// constructor() {\\n/// // Prevents the contract from being initialized again.\\n/// _disableInitializers();\\n/// }\\n///\\n/// function initialize(\\n/// address _bridge,\\n/// address _tbtcVault\\n/// ) external initializer {\\n/// __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\\n/// }\\n///\\n/// function startProcess(\\n/// IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n/// IBridgeTypes.DepositRevealInfo calldata reveal\\n/// ) external {\\n/// // Embed necessary context as extra data.\\n/// bytes32 extraData = ...;\\n///\\n/// uint256 depositKey = _initializeDeposit(\\n/// fundingTx,\\n/// reveal,\\n/// extraData\\n/// );\\n///\\n/// // Use the depositKey to track the process.\\n/// }\\n///\\n/// function finalizeProcess(uint256 depositKey) external {\\n/// // Ensure the function cannot be called for the same deposit\\n/// // twice.\\n///\\n/// (\\n/// uint256 initialDepositAmount,\\n/// uint256 tbtcAmount,\\n/// bytes32 extraData\\n/// ) = _finalizeDeposit(depositKey);\\n///\\n/// // Do something with the minted TBTC using context\\n/// // embedded in the extraData.\\n/// }\\n/// }\\nabstract contract AbstractTBTCDepositor {\\n using BTCUtils for bytes;\\n\\n /// @notice Multiplier to convert satoshi to TBTC token units.\\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\\n\\n /// @notice Bridge contract address.\\n IBridge public bridge;\\n /// @notice TBTCVault contract address.\\n ITBTCVault public tbtcVault;\\n\\n // Reserved storage space that allows adding more variables without affecting\\n // the storage layout of the child contracts. The convention from OpenZeppelin\\n // suggests the storage space should add up to 50 slots. If more variables are\\n // added in the upcoming versions one need to reduce the array size accordingly.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n event DepositInitialized(uint256 indexed depositKey, uint32 initializedAt);\\n\\n event DepositFinalized(\\n uint256 indexed depositKey,\\n uint256 tbtcAmount,\\n uint32 finalizedAt\\n );\\n\\n /// @notice Initializes the contract. MUST BE CALLED from the child\\n /// contract initializer.\\n // slither-disable-next-line dead-code\\n function __AbstractTBTCDepositor_initialize(\\n address _bridge,\\n address _tbtcVault\\n ) internal {\\n require(\\n address(bridge) == address(0) && address(tbtcVault) == address(0),\\n \\\"AbstractTBTCDepositor already initialized\\\"\\n );\\n\\n require(_bridge != address(0), \\\"Bridge address cannot be zero\\\");\\n require(_tbtcVault != address(0), \\\"TBTCVault address cannot be zero\\\");\\n\\n bridge = IBridge(_bridge);\\n tbtcVault = ITBTCVault(_tbtcVault);\\n }\\n\\n /// @notice Initializes a deposit by revealing it to the Bridge.\\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo` struct.\\n /// @param extraData 32-byte deposit extra data.\\n /// @return depositKey Deposit key computed as\\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\\n /// key can be used to refer to the deposit in the Bridge and\\n /// TBTCVault contracts.\\n /// @dev Requirements:\\n /// - The revealed vault address must match the TBTCVault address,\\n /// - All requirements from {Bridge#revealDepositWithExtraData}\\n /// function must be met.\\n /// @dev This function doesn't validate if a deposit has been initialized before,\\n /// as the Bridge won't allow the same deposit to be revealed twice.\\n // slither-disable-next-line dead-code\\n function _initializeDeposit(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n bytes32 extraData\\n ) internal returns (uint256) {\\n require(reveal.vault == address(tbtcVault), \\\"Vault address mismatch\\\");\\n\\n uint256 depositKey = _calculateDepositKey(\\n _calculateBitcoinTxHash(fundingTx),\\n reveal.fundingOutputIndex\\n );\\n\\n emit DepositInitialized(\\n depositKey,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n // The Bridge does not allow to reveal the same deposit twice and\\n // revealed deposits stay there forever. The transaction will revert\\n // if the deposit has already been revealed so, there is no need to do\\n // an explicit check here.\\n bridge.revealDepositWithExtraData(fundingTx, reveal, extraData);\\n\\n return depositKey;\\n }\\n\\n /// @notice Finalizes a deposit by calculating the amount of TBTC minted\\n /// for the deposit.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @return initialDepositAmount Amount of funding transaction deposit. In\\n /// TBTC token decimals precision.\\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit. In\\n /// TBTC token decimals precision.\\n /// @return extraData 32-byte deposit extra data.\\n /// @dev Requirements:\\n /// - The deposit must be initialized but not finalized\\n /// (in the context of this contract) yet.\\n /// - The deposit must be finalized on the Bridge side. That means the\\n /// deposit must be either swept or optimistically minted.\\n /// @dev THIS FUNCTION DOESN'T VALIDATE IF A DEPOSIT HAS BEEN FINALIZED BEFORE,\\n /// IT IS A RESPONSIBILITY OF THE IMPLEMENTING CONTRACT TO ENSURE THIS\\n /// FUNCTION WON'T BE CALLED TWICE FOR THE SAME DEPOSIT.\\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function is an\\n /// approximation. See documentation of the `calculateTbtcAmount`\\n /// responsible for calculating this value for more details.\\n // slither-disable-next-line dead-code\\n function _finalizeDeposit(uint256 depositKey)\\n internal\\n returns (\\n uint256 initialDepositAmount,\\n uint256 tbtcAmount,\\n bytes32 extraData\\n )\\n {\\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\\n depositKey\\n );\\n require(deposit.revealedAt != 0, \\\"Deposit not initialized\\\");\\n\\n (, uint64 finalizedAt) = tbtcVault.optimisticMintingRequests(\\n depositKey\\n );\\n\\n require(\\n deposit.sweptAt != 0 || finalizedAt != 0,\\n \\\"Deposit not finalized by the bridge\\\"\\n );\\n\\n initialDepositAmount = deposit.amount * SATOSHI_MULTIPLIER;\\n\\n tbtcAmount = _calculateTbtcAmount(deposit.amount, deposit.treasuryFee);\\n\\n // slither-disable-next-line reentrancy-events\\n emit DepositFinalized(\\n depositKey,\\n tbtcAmount,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n extraData = deposit.extraData;\\n }\\n\\n /// @notice Calculates the amount of TBTC minted for the deposit.\\n /// @param depositAmountSat Deposit amount in satoshi (1e8 precision).\\n /// This is the actual amount deposited by the deposit creator, i.e.\\n /// the gross amount the Bridge's fees are cut from.\\n /// @param depositTreasuryFeeSat Deposit treasury fee in satoshi (1e8 precision).\\n /// This is an accurate value of the treasury fee that was actually\\n /// cut upon minting.\\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit.\\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function may\\n /// not correspond to the actual amount of TBTC minted for the deposit.\\n /// Although the treasury fee cut upon minting is known precisely,\\n /// this is not the case for the optimistic minting fee and the Bitcoin\\n /// transaction fee. To overcome that problem, this function just takes\\n /// the current maximum allowed values of both fees, at the moment of deposit\\n /// finalization. For the great majority of the deposits, such an\\n /// algorithm will return a tbtcAmount slightly lesser than the\\n /// actual amount of TBTC minted for the deposit. This will cause\\n /// some TBTC to be left in the contract and ensure there is enough\\n /// liquidity to finalize the deposit. However, in some rare cases,\\n /// where the actual values of those fees change between the deposit\\n /// minting and finalization, the tbtcAmount returned by this function\\n /// may be greater than the actual amount of TBTC minted for the deposit.\\n /// If this happens and the reserve coming from previous deposits\\n /// leftovers does not provide enough liquidity, the deposit will have\\n /// to wait for finalization until the reserve is refilled by subsequent\\n /// deposits or a manual top-up. The integrator is responsible for\\n /// handling such cases.\\n // slither-disable-next-line dead-code\\n function _calculateTbtcAmount(\\n uint64 depositAmountSat,\\n uint64 depositTreasuryFeeSat\\n ) internal view virtual returns (uint256) {\\n // Both deposit amount and treasury fee are in the 1e8 satoshi precision.\\n // We need to convert them to the 1e18 TBTC precision.\\n uint256 amountSubTreasury = (depositAmountSat - depositTreasuryFeeSat) *\\n SATOSHI_MULTIPLIER;\\n\\n uint256 omFeeDivisor = tbtcVault.optimisticMintingFeeDivisor();\\n uint256 omFee = omFeeDivisor > 0\\n ? (amountSubTreasury / omFeeDivisor)\\n : 0;\\n\\n // The deposit transaction max fee is in the 1e8 satoshi precision.\\n // We need to convert them to the 1e18 TBTC precision.\\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\\n\\n return amountSubTreasury - omFee - txMaxFee;\\n }\\n\\n /// @notice Calculates the deposit key for the given funding transaction\\n /// hash and funding output index.\\n /// @param fundingTxHash Funding transaction hash.\\n /// @param fundingOutputIndex Funding output index.\\n /// @return depositKey Deposit key computed as\\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\\n /// key can be used to refer to the deposit in the Bridge and\\n /// TBTCVault contracts.\\n // slither-disable-next-line dead-code\\n function _calculateDepositKey(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) internal pure returns (uint256) {\\n return\\n uint256(\\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\\n );\\n }\\n\\n /// @notice Calculates the Bitcoin transaction hash for the given Bitcoin\\n /// transaction data.\\n /// @param txInfo Bitcoin transaction data, see `IBridgeTypes.BitcoinTxInfo` struct.\\n /// @return txHash Bitcoin transaction hash.\\n // slither-disable-next-line dead-code\\n function _calculateBitcoinTxHash(IBridgeTypes.BitcoinTxInfo calldata txInfo)\\n internal\\n view\\n returns (bytes32)\\n {\\n return\\n abi\\n .encodePacked(\\n txInfo.version,\\n txInfo.inputVector,\\n txInfo.outputVector,\\n txInfo.locktime\\n )\\n .hash256View();\\n }\\n}\\n\",\"keccak256\":\"0x0cfd2215c106fc17c8166a31839243ad1575806401de60f80d0a4857a2a60078\",\"license\":\"GPL-3.0-only\"},\"@keep-network/tbtc-v2/contracts/integrator/IBridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\n/// @notice Namespace which groups all types relevant to the IBridge interface.\\n/// @dev This is a mirror of the real types used in the Bridge contract.\\n/// This way, the `integrator` subpackage does not need to import\\n/// anything from the `bridge` subpackage and explicitly depend on it.\\n/// This simplifies the dependency graph for integrators.\\nlibrary IBridgeTypes {\\n /// @dev See bridge/BitcoinTx.sol#Info\\n struct BitcoinTxInfo {\\n bytes4 version;\\n bytes inputVector;\\n bytes outputVector;\\n bytes4 locktime;\\n }\\n\\n /// @dev See bridge/Deposit.sol#DepositRevealInfo\\n struct DepositRevealInfo {\\n uint32 fundingOutputIndex;\\n bytes8 blindingFactor;\\n bytes20 walletPubKeyHash;\\n bytes20 refundPubKeyHash;\\n bytes4 refundLocktime;\\n address vault;\\n }\\n\\n /// @dev See bridge/Deposit.sol#DepositRequest\\n struct DepositRequest {\\n address depositor;\\n uint64 amount;\\n uint32 revealedAt;\\n address vault;\\n uint64 treasuryFee;\\n uint32 sweptAt;\\n bytes32 extraData;\\n }\\n}\\n\\n/// @notice Interface of the Bridge contract.\\n/// @dev See bridge/Bridge.sol\\ninterface IBridge {\\n /// @dev See {Bridge#revealDepositWithExtraData}\\n function revealDepositWithExtraData(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n bytes32 extraData\\n ) external;\\n\\n /// @dev See {Bridge#deposits}\\n function deposits(uint256 depositKey)\\n external\\n view\\n returns (IBridgeTypes.DepositRequest memory);\\n\\n /// @dev See {Bridge#depositParameters}\\n function depositParameters()\\n external\\n view\\n returns (\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n}\\n\",\"keccak256\":\"0x4e598d96404a19609f511f10503e80f457602ad694d081df739571f67f6e0c4e\",\"license\":\"GPL-3.0-only\"},\"@keep-network/tbtc-v2/contracts/integrator/ITBTCVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\n/// @notice Interface of the TBTCVault contract.\\n/// @dev See vault/TBTCVault.sol\\ninterface ITBTCVault {\\n /// @dev See {TBTCVault#optimisticMintingRequests}\\n function optimisticMintingRequests(uint256 depositKey)\\n external\\n returns (uint64 requestedAt, uint64 finalizedAt);\\n\\n /// @dev See {TBTCVault#optimisticMintingFeeDivisor}\\n function optimisticMintingFeeDivisor() external view returns (uint32);\\n}\\n\",\"keccak256\":\"0xf259d64c1040e2cbc3d17653491e45c5c3da17f575dac1c175c63c8a5308908e\",\"license\":\"GPL-3.0-only\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Context} from \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * The initial owner is set to the address provided by the deployer. This can\\n * later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n /**\\n * @dev The caller account is not authorized to perform an operation.\\n */\\n error OwnableUnauthorizedAccount(address account);\\n\\n /**\\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\\n */\\n error OwnableInvalidOwner(address owner);\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\\n */\\n constructor(address initialOwner) {\\n if (initialOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(initialOwner);\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n if (owner() != _msgSender()) {\\n revert OwnableUnauthorizedAccount(_msgSender());\\n }\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n if (newOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xff6d0bb2e285473e5311d9d3caacb525ae3538a80758c10649a4d61029b017bb\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable2Step.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Ownable} from \\\"./Ownable.sol\\\";\\n\\n/**\\n * @dev Contract module which provides access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * The initial owner is specified at deployment time in the constructor for `Ownable`. This\\n * can later be changed with {transferOwnership} and {acceptOwnership}.\\n *\\n * This module is used through inheritance. It will make available all functions\\n * from parent (Ownable).\\n */\\nabstract contract Ownable2Step is Ownable {\\n address private _pendingOwner;\\n\\n event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Returns the address of the pending owner.\\n */\\n function pendingOwner() public view virtual returns (address) {\\n return _pendingOwner;\\n }\\n\\n /**\\n * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual override onlyOwner {\\n _pendingOwner = newOwner;\\n emit OwnershipTransferStarted(owner(), newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual override {\\n delete _pendingOwner;\\n super._transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev The new owner accepts the ownership transfer.\\n */\\n function acceptOwnership() public virtual {\\n address sender = _msgSender();\\n if (pendingOwner() != sender) {\\n revert OwnableUnauthorizedAccount(sender);\\n }\\n _transferOwnership(sender);\\n }\\n}\\n\",\"keccak256\":\"0x5d3e5de9eadfa1f8a892eb2e95bbebd3e4b8c8ada5b76f104d383fea518fa688\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../token/ERC20/IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"../token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\n/**\\n * @dev Interface of the ERC4626 \\\"Tokenized Vault Standard\\\", as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\\n */\\ninterface IERC4626 is IERC20, IERC20Metadata {\\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed sender,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /**\\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\\n *\\n * - MUST be an ERC-20 token contract.\\n * - MUST NOT revert.\\n */\\n function asset() external view returns (address assetTokenAddress);\\n\\n /**\\n * @dev Returns the total amount of the underlying asset that is \\u201cmanaged\\u201d by Vault.\\n *\\n * - SHOULD include any compounding that occurs from yield.\\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT revert.\\n */\\n function totalAssets() external view returns (uint256 totalManagedAssets);\\n\\n /**\\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToShares(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\\n * through a deposit call.\\n *\\n * - MUST return a limited value if receiver is subject to some deposit limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\\n * - MUST NOT revert.\\n */\\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\\n * in the same transaction.\\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * deposit execution, and are accounted for during deposit.\\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\\n * - MUST return a limited value if receiver is subject to some mint limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\\n * - MUST NOT revert.\\n */\\n function maxMint(address receiver) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\\n * same transaction.\\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\\n * would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\\n */\\n function previewMint(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\\n * execution, and are accounted for during mint.\\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\\n * Vault, through a withdraw call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\\n * called\\n * in the same transaction.\\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * withdraw execution, and are accounted for during withdraw.\\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\\n * through a redeem call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxRedeem(address owner) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\\n * same transaction.\\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\\n * redemption would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\\n */\\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * redeem execution, and are accounted for during redeem.\\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\\n}\\n\",\"keccak256\":\"0x207f64371bc0fcc5be86713aa5da109a870cc3a6da50e93b64ee881e369b593d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC6093.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard ERC20 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\\n */\\ninterface IERC20Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC20InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC20InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `spender`\\u2019s `allowance`. Used in transfers.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC20InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC20InvalidSpender(address spender);\\n}\\n\\n/**\\n * @dev Standard ERC721 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\\n */\\ninterface IERC721Errors {\\n /**\\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\\n * Used in balance queries.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721InvalidOwner(address owner);\\n\\n /**\\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721NonexistentToken(uint256 tokenId);\\n\\n /**\\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param tokenId Identifier number of a token.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC721InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC721InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC721InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC721InvalidOperator(address operator);\\n}\\n\\n/**\\n * @dev Standard ERC1155 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\\n */\\ninterface IERC1155Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC1155InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC1155InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC1155MissingApprovalForAll(address operator, address owner);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC1155InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC1155InvalidOperator(address operator);\\n\\n /**\\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\\n * Used in batch transfers.\\n * @param idsLength Length of the array of token identifiers\\n * @param valuesLength Length of the array of token amounts\\n */\\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\\n}\\n\",\"keccak256\":\"0x60c65f701957fdd6faea1acb0bb45825791d473693ed9ecb34726fdfaa849dd7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"./IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"./extensions/IERC20Metadata.sol\\\";\\nimport {Context} from \\\"../../utils/Context.sol\\\";\\nimport {IERC20Errors} from \\\"../../interfaces/draft-IERC6093.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * The default value of {decimals} is 18. To change this, you should override\\n * this function so it returns a different value.\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n */\\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\\n mapping(address account => uint256) private _balances;\\n\\n mapping(address account => mapping(address spender => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the default value returned by this function, unless\\n * it's overridden.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return 18;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `value`.\\n */\\n function transfer(address to, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _approve(owner, spender, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `value`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `value`.\\n */\\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, value);\\n _transfer(from, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to`.\\n *\\n * This internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _transfer(address from, address to, uint256 value) internal {\\n if (from == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n if (to == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(from, to, value);\\n }\\n\\n /**\\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\\n * this function.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _update(address from, address to, uint256 value) internal virtual {\\n if (from == address(0)) {\\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\\n _totalSupply += value;\\n } else {\\n uint256 fromBalance = _balances[from];\\n if (fromBalance < value) {\\n revert ERC20InsufficientBalance(from, fromBalance, value);\\n }\\n unchecked {\\n // Overflow not possible: value <= fromBalance <= totalSupply.\\n _balances[from] = fromBalance - value;\\n }\\n }\\n\\n if (to == address(0)) {\\n unchecked {\\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\\n _totalSupply -= value;\\n }\\n } else {\\n unchecked {\\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\\n _balances[to] += value;\\n }\\n }\\n\\n emit Transfer(from, to, value);\\n }\\n\\n /**\\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\\n * Relies on the `_update` mechanism\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _mint(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(address(0), account, value);\\n }\\n\\n /**\\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\\n * Relies on the `_update` mechanism.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead\\n */\\n function _burn(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n _update(account, address(0), value);\\n }\\n\\n /**\\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n *\\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\\n */\\n function _approve(address owner, address spender, uint256 value) internal {\\n _approve(owner, spender, value, true);\\n }\\n\\n /**\\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\\n *\\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\\n * `Approval` event during `transferFrom` operations.\\n *\\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\\n * true using the following override:\\n * ```\\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\\n * super._approve(owner, spender, value, true);\\n * }\\n * ```\\n *\\n * Requirements are the same as {_approve}.\\n */\\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\\n if (owner == address(0)) {\\n revert ERC20InvalidApprover(address(0));\\n }\\n if (spender == address(0)) {\\n revert ERC20InvalidSpender(address(0));\\n }\\n _allowances[owner][spender] = value;\\n if (emitEvent) {\\n emit Approval(owner, spender, value);\\n }\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\\n *\\n * Does not update the allowance value in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Does not emit an {Approval} event.\\n */\\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n if (currentAllowance < value) {\\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\\n }\\n unchecked {\\n _approve(owner, spender, currentAllowance - value, false);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3e1fa9d1987f8d349dfb4d6fe93bf2ca014b52ba335cfac30bfe71e357e6f80\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the value of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the value of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\\n * caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\\n * allowance mechanism. `value` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 value) external returns (bool);\\n}\\n\",\"keccak256\":\"0xc6a8ff0ea489379b61faa647490411b80102578440ab9d84e9a957cc12164e70\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20, IERC20Metadata, ERC20} from \\\"../ERC20.sol\\\";\\nimport {SafeERC20} from \\\"../utils/SafeERC20.sol\\\";\\nimport {IERC4626} from \\\"../../../interfaces/IERC4626.sol\\\";\\nimport {Math} from \\\"../../../utils/math/Math.sol\\\";\\n\\n/**\\n * @dev Implementation of the ERC4626 \\\"Tokenized Vault Standard\\\" as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\\n *\\n * This extension allows the minting and burning of \\\"shares\\\" (represented using the ERC20 inheritance) in exchange for\\n * underlying \\\"assets\\\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\\n * the ERC20 standard. Any additional extensions included along it would affect the \\\"shares\\\" token represented by this\\n * contract and not the \\\"assets\\\" token which is an independent contract.\\n *\\n * [CAUTION]\\n * ====\\n * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning\\n * with a \\\"donation\\\" to the vault that inflates the price of a share. This is variously known as a donation or inflation\\n * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial\\n * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may\\n * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by\\n * verifying the amount received is as expected, using a wrapper that performs these checks such as\\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\\n *\\n * Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()`\\n * corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault\\n * decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself\\n * determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset\\n * (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's\\n * donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more\\n * expensive than it is profitable. More details about the underlying math can be found\\n * xref:erc4626.adoc#inflation-attack[here].\\n *\\n * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued\\n * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets\\n * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience\\n * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the\\n * `_convertToShares` and `_convertToAssets` functions.\\n *\\n * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].\\n * ====\\n */\\nabstract contract ERC4626 is ERC20, IERC4626 {\\n using Math for uint256;\\n\\n IERC20 private immutable _asset;\\n uint8 private immutable _underlyingDecimals;\\n\\n /**\\n * @dev Attempted to deposit more assets than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);\\n\\n /**\\n * @dev Attempted to mint more shares than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);\\n\\n /**\\n * @dev Attempted to withdraw more assets than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);\\n\\n /**\\n * @dev Attempted to redeem more shares than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);\\n\\n /**\\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\\n */\\n constructor(IERC20 asset_) {\\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\\n _underlyingDecimals = success ? assetDecimals : 18;\\n _asset = asset_;\\n }\\n\\n /**\\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\\n */\\n function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {\\n (bool success, bytes memory encodedDecimals) = address(asset_).staticcall(\\n abi.encodeCall(IERC20Metadata.decimals, ())\\n );\\n if (success && encodedDecimals.length >= 32) {\\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\\n if (returnedDecimals <= type(uint8).max) {\\n return (true, uint8(returnedDecimals));\\n }\\n }\\n return (false, 0);\\n }\\n\\n /**\\n * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This\\n * \\\"original\\\" value is cached during construction of the vault contract. If this read operation fails (e.g., the\\n * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.\\n *\\n * See {IERC20Metadata-decimals}.\\n */\\n function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {\\n return _underlyingDecimals + _decimalsOffset();\\n }\\n\\n /** @dev See {IERC4626-asset}. */\\n function asset() public view virtual returns (address) {\\n return address(_asset);\\n }\\n\\n /** @dev See {IERC4626-totalAssets}. */\\n function totalAssets() public view virtual returns (uint256) {\\n return _asset.balanceOf(address(this));\\n }\\n\\n /** @dev See {IERC4626-convertToShares}. */\\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-convertToAssets}. */\\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-maxDeposit}. */\\n function maxDeposit(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n /** @dev See {IERC4626-maxMint}. */\\n function maxMint(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n /** @dev See {IERC4626-maxWithdraw}. */\\n function maxWithdraw(address owner) public view virtual returns (uint256) {\\n return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-maxRedeem}. */\\n function maxRedeem(address owner) public view virtual returns (uint256) {\\n return balanceOf(owner);\\n }\\n\\n /** @dev See {IERC4626-previewDeposit}. */\\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-previewMint}. */\\n function previewMint(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Ceil);\\n }\\n\\n /** @dev See {IERC4626-previewWithdraw}. */\\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Ceil);\\n }\\n\\n /** @dev See {IERC4626-previewRedeem}. */\\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-deposit}. */\\n function deposit(uint256 assets, address receiver) public virtual returns (uint256) {\\n uint256 maxAssets = maxDeposit(receiver);\\n if (assets > maxAssets) {\\n revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);\\n }\\n\\n uint256 shares = previewDeposit(assets);\\n _deposit(_msgSender(), receiver, assets, shares);\\n\\n return shares;\\n }\\n\\n /** @dev See {IERC4626-mint}.\\n *\\n * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.\\n * In this case, the shares will be minted without requiring any assets to be deposited.\\n */\\n function mint(uint256 shares, address receiver) public virtual returns (uint256) {\\n uint256 maxShares = maxMint(receiver);\\n if (shares > maxShares) {\\n revert ERC4626ExceededMaxMint(receiver, shares, maxShares);\\n }\\n\\n uint256 assets = previewMint(shares);\\n _deposit(_msgSender(), receiver, assets, shares);\\n\\n return assets;\\n }\\n\\n /** @dev See {IERC4626-withdraw}. */\\n function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {\\n uint256 maxAssets = maxWithdraw(owner);\\n if (assets > maxAssets) {\\n revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);\\n }\\n\\n uint256 shares = previewWithdraw(assets);\\n _withdraw(_msgSender(), receiver, owner, assets, shares);\\n\\n return shares;\\n }\\n\\n /** @dev See {IERC4626-redeem}. */\\n function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {\\n uint256 maxShares = maxRedeem(owner);\\n if (shares > maxShares) {\\n revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);\\n }\\n\\n uint256 assets = previewRedeem(shares);\\n _withdraw(_msgSender(), receiver, owner, assets, shares);\\n\\n return assets;\\n }\\n\\n /**\\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\\n */\\n function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {\\n return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);\\n }\\n\\n /**\\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\\n */\\n function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {\\n return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);\\n }\\n\\n /**\\n * @dev Deposit/mint common workflow.\\n */\\n function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {\\n // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the\\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\\n // calls the vault, which is assumed not malicious.\\n //\\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\\n // assets are transferred and before the shares are minted, which is a valid state.\\n // slither-disable-next-line reentrancy-no-eth\\n SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\\n _mint(receiver, shares);\\n\\n emit Deposit(caller, receiver, assets, shares);\\n }\\n\\n /**\\n * @dev Withdraw/redeem common workflow.\\n */\\n function _withdraw(\\n address caller,\\n address receiver,\\n address owner,\\n uint256 assets,\\n uint256 shares\\n ) internal virtual {\\n if (caller != owner) {\\n _spendAllowance(owner, caller, shares);\\n }\\n\\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\\n // calls the vault, which is assumed not malicious.\\n //\\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\\n // shares are burned and after the assets are transferred, which is a valid state.\\n _burn(owner, shares);\\n SafeERC20.safeTransfer(_asset, receiver, assets);\\n\\n emit Withdraw(caller, receiver, owner, assets, shares);\\n }\\n\\n function _decimalsOffset() internal view virtual returns (uint8) {\\n return 0;\\n }\\n}\\n\",\"keccak256\":\"0x1837547e04d5fe5334eeb77a345683c22995f1e7aa033020757ddf83a80fc72d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0xaa761817f6cd7892fcf158b3c776b34551cde36f48ff9703d53898bc45a94ea2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x6008dabfe393240d73d7dd7688033f72740d570aa422254d29a7dce8568f3aff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\nimport {IERC20Permit} from \\\"../extensions/IERC20Permit.sol\\\";\\nimport {Address} from \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n /**\\n * @dev An operation with an ERC20 token failed.\\n */\\n error SafeERC20FailedOperation(address token);\\n\\n /**\\n * @dev Indicates a failed `decreaseAllowance` request.\\n */\\n error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\\n }\\n\\n /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n forceApprove(token, spender, oldAllowance + value);\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\\n * value, non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\\n unchecked {\\n uint256 currentAllowance = token.allowance(address(this), spender);\\n if (currentAllowance < requestedDecrease) {\\n revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\\n }\\n forceApprove(token, spender, currentAllowance - requestedDecrease);\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data);\\n if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\\n revert SafeERC20FailedOperation(address(token));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\\n }\\n}\\n\",\"keccak256\":\"0x37bb49513c49c87c4642a891b13b63571bc87013dde806617aa1efb54605f386\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev The ETH balance of the account is not enough to perform the operation.\\n */\\n error AddressInsufficientBalance(address account);\\n\\n /**\\n * @dev There's no code at `target` (it is not a contract).\\n */\\n error AddressEmptyCode(address target);\\n\\n /**\\n * @dev A call to an address target failed. The target may have reverted.\\n */\\n error FailedInnerCall();\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n if (address(this).balance < amount) {\\n revert AddressInsufficientBalance(address(this));\\n }\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n if (!success) {\\n revert FailedInnerCall();\\n }\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason or custom error, it is bubbled\\n * up by this function (like regular Solidity function calls). However, if\\n * the call reverted with no returned reason, this function reverts with a\\n * {FailedInnerCall} error.\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n if (address(this).balance < value) {\\n revert AddressInsufficientBalance(address(this));\\n }\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\\n * unsuccessful call.\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata\\n ) internal view returns (bytes memory) {\\n if (!success) {\\n _revert(returndata);\\n } else {\\n // only check if target is a contract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n if (returndata.length == 0 && target.code.length == 0) {\\n revert AddressEmptyCode(target);\\n }\\n return returndata;\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\\n * revert reason or with a default {FailedInnerCall} error.\\n */\\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\\n if (!success) {\\n _revert(returndata);\\n } else {\\n return returndata;\\n }\\n }\\n\\n /**\\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\\n */\\n function _revert(bytes memory returndata) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert FailedInnerCall();\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaf28a975a78550e45f65e559a3ad6a5ad43b9b8a37366999abd1b7084eb70721\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x75a4ee64c68dbd5f38bddd06e664a64c8271b4caa554fb6f0607dfd672bb4bf3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Muldiv operation overflow.\\n */\\n error MathOverflowedMulDiv();\\n\\n enum Rounding {\\n Floor, // Toward negative infinity\\n Ceil, // Toward positive infinity\\n Trunc, // Toward zero\\n Expand // Away from zero\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds towards infinity instead\\n * of rounding towards zero.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (b == 0) {\\n // Guarantee the same behavior as in a regular Solidity division.\\n return a / b;\\n }\\n\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\\n * denominator == 0.\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\\n * Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0 = x * y; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (denominator <= prod1) {\\n revert MathOverflowedMulDiv();\\n }\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\\n\\n uint256 twos = denominator & (0 - denominator);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\\n // works in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\\n * towards zero.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\\n */\\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\\n return uint8(rounding) % 2 == 1;\\n }\\n}\\n\",\"keccak256\":\"0x005ec64c6313f0555d59e278f9a7a5ab2db5bdc72a027f255a37c327af1ec02d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SafeCast.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)\\n// This file was procedurally generated from scripts/generate/templates/SafeCast.js.\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n */\\nlibrary SafeCast {\\n /**\\n * @dev Value doesn't fit in an uint of `bits` size.\\n */\\n error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);\\n\\n /**\\n * @dev An int value doesn't fit in an uint of `bits` size.\\n */\\n error SafeCastOverflowedIntToUint(int256 value);\\n\\n /**\\n * @dev Value doesn't fit in an int of `bits` size.\\n */\\n error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);\\n\\n /**\\n * @dev An uint value doesn't fit in an int of `bits` size.\\n */\\n error SafeCastOverflowedUintToInt(uint256 value);\\n\\n /**\\n * @dev Returns the downcasted uint248 from uint256, reverting on\\n * overflow (when the input is greater than largest uint248).\\n *\\n * Counterpart to Solidity's `uint248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n */\\n function toUint248(uint256 value) internal pure returns (uint248) {\\n if (value > type(uint248).max) {\\n revert SafeCastOverflowedUintDowncast(248, value);\\n }\\n return uint248(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint240 from uint256, reverting on\\n * overflow (when the input is greater than largest uint240).\\n *\\n * Counterpart to Solidity's `uint240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n */\\n function toUint240(uint256 value) internal pure returns (uint240) {\\n if (value > type(uint240).max) {\\n revert SafeCastOverflowedUintDowncast(240, value);\\n }\\n return uint240(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint232 from uint256, reverting on\\n * overflow (when the input is greater than largest uint232).\\n *\\n * Counterpart to Solidity's `uint232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n */\\n function toUint232(uint256 value) internal pure returns (uint232) {\\n if (value > type(uint232).max) {\\n revert SafeCastOverflowedUintDowncast(232, value);\\n }\\n return uint232(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n if (value > type(uint224).max) {\\n revert SafeCastOverflowedUintDowncast(224, value);\\n }\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint216 from uint256, reverting on\\n * overflow (when the input is greater than largest uint216).\\n *\\n * Counterpart to Solidity's `uint216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n */\\n function toUint216(uint256 value) internal pure returns (uint216) {\\n if (value > type(uint216).max) {\\n revert SafeCastOverflowedUintDowncast(216, value);\\n }\\n return uint216(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint208 from uint256, reverting on\\n * overflow (when the input is greater than largest uint208).\\n *\\n * Counterpart to Solidity's `uint208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n */\\n function toUint208(uint256 value) internal pure returns (uint208) {\\n if (value > type(uint208).max) {\\n revert SafeCastOverflowedUintDowncast(208, value);\\n }\\n return uint208(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint200 from uint256, reverting on\\n * overflow (when the input is greater than largest uint200).\\n *\\n * Counterpart to Solidity's `uint200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n */\\n function toUint200(uint256 value) internal pure returns (uint200) {\\n if (value > type(uint200).max) {\\n revert SafeCastOverflowedUintDowncast(200, value);\\n }\\n return uint200(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint192 from uint256, reverting on\\n * overflow (when the input is greater than largest uint192).\\n *\\n * Counterpart to Solidity's `uint192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n */\\n function toUint192(uint256 value) internal pure returns (uint192) {\\n if (value > type(uint192).max) {\\n revert SafeCastOverflowedUintDowncast(192, value);\\n }\\n return uint192(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint184 from uint256, reverting on\\n * overflow (when the input is greater than largest uint184).\\n *\\n * Counterpart to Solidity's `uint184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n */\\n function toUint184(uint256 value) internal pure returns (uint184) {\\n if (value > type(uint184).max) {\\n revert SafeCastOverflowedUintDowncast(184, value);\\n }\\n return uint184(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint176 from uint256, reverting on\\n * overflow (when the input is greater than largest uint176).\\n *\\n * Counterpart to Solidity's `uint176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n */\\n function toUint176(uint256 value) internal pure returns (uint176) {\\n if (value > type(uint176).max) {\\n revert SafeCastOverflowedUintDowncast(176, value);\\n }\\n return uint176(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint168 from uint256, reverting on\\n * overflow (when the input is greater than largest uint168).\\n *\\n * Counterpart to Solidity's `uint168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n */\\n function toUint168(uint256 value) internal pure returns (uint168) {\\n if (value > type(uint168).max) {\\n revert SafeCastOverflowedUintDowncast(168, value);\\n }\\n return uint168(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint160 from uint256, reverting on\\n * overflow (when the input is greater than largest uint160).\\n *\\n * Counterpart to Solidity's `uint160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n */\\n function toUint160(uint256 value) internal pure returns (uint160) {\\n if (value > type(uint160).max) {\\n revert SafeCastOverflowedUintDowncast(160, value);\\n }\\n return uint160(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint152 from uint256, reverting on\\n * overflow (when the input is greater than largest uint152).\\n *\\n * Counterpart to Solidity's `uint152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n */\\n function toUint152(uint256 value) internal pure returns (uint152) {\\n if (value > type(uint152).max) {\\n revert SafeCastOverflowedUintDowncast(152, value);\\n }\\n return uint152(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint144 from uint256, reverting on\\n * overflow (when the input is greater than largest uint144).\\n *\\n * Counterpart to Solidity's `uint144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n */\\n function toUint144(uint256 value) internal pure returns (uint144) {\\n if (value > type(uint144).max) {\\n revert SafeCastOverflowedUintDowncast(144, value);\\n }\\n return uint144(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint136 from uint256, reverting on\\n * overflow (when the input is greater than largest uint136).\\n *\\n * Counterpart to Solidity's `uint136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n */\\n function toUint136(uint256 value) internal pure returns (uint136) {\\n if (value > type(uint136).max) {\\n revert SafeCastOverflowedUintDowncast(136, value);\\n }\\n return uint136(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n if (value > type(uint128).max) {\\n revert SafeCastOverflowedUintDowncast(128, value);\\n }\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint120 from uint256, reverting on\\n * overflow (when the input is greater than largest uint120).\\n *\\n * Counterpart to Solidity's `uint120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n */\\n function toUint120(uint256 value) internal pure returns (uint120) {\\n if (value > type(uint120).max) {\\n revert SafeCastOverflowedUintDowncast(120, value);\\n }\\n return uint120(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint112 from uint256, reverting on\\n * overflow (when the input is greater than largest uint112).\\n *\\n * Counterpart to Solidity's `uint112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n */\\n function toUint112(uint256 value) internal pure returns (uint112) {\\n if (value > type(uint112).max) {\\n revert SafeCastOverflowedUintDowncast(112, value);\\n }\\n return uint112(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint104 from uint256, reverting on\\n * overflow (when the input is greater than largest uint104).\\n *\\n * Counterpart to Solidity's `uint104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n */\\n function toUint104(uint256 value) internal pure returns (uint104) {\\n if (value > type(uint104).max) {\\n revert SafeCastOverflowedUintDowncast(104, value);\\n }\\n return uint104(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n if (value > type(uint96).max) {\\n revert SafeCastOverflowedUintDowncast(96, value);\\n }\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint88 from uint256, reverting on\\n * overflow (when the input is greater than largest uint88).\\n *\\n * Counterpart to Solidity's `uint88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n */\\n function toUint88(uint256 value) internal pure returns (uint88) {\\n if (value > type(uint88).max) {\\n revert SafeCastOverflowedUintDowncast(88, value);\\n }\\n return uint88(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint80 from uint256, reverting on\\n * overflow (when the input is greater than largest uint80).\\n *\\n * Counterpart to Solidity's `uint80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n */\\n function toUint80(uint256 value) internal pure returns (uint80) {\\n if (value > type(uint80).max) {\\n revert SafeCastOverflowedUintDowncast(80, value);\\n }\\n return uint80(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint72 from uint256, reverting on\\n * overflow (when the input is greater than largest uint72).\\n *\\n * Counterpart to Solidity's `uint72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n */\\n function toUint72(uint256 value) internal pure returns (uint72) {\\n if (value > type(uint72).max) {\\n revert SafeCastOverflowedUintDowncast(72, value);\\n }\\n return uint72(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n if (value > type(uint64).max) {\\n revert SafeCastOverflowedUintDowncast(64, value);\\n }\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint56 from uint256, reverting on\\n * overflow (when the input is greater than largest uint56).\\n *\\n * Counterpart to Solidity's `uint56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n */\\n function toUint56(uint256 value) internal pure returns (uint56) {\\n if (value > type(uint56).max) {\\n revert SafeCastOverflowedUintDowncast(56, value);\\n }\\n return uint56(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint48 from uint256, reverting on\\n * overflow (when the input is greater than largest uint48).\\n *\\n * Counterpart to Solidity's `uint48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n */\\n function toUint48(uint256 value) internal pure returns (uint48) {\\n if (value > type(uint48).max) {\\n revert SafeCastOverflowedUintDowncast(48, value);\\n }\\n return uint48(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint40 from uint256, reverting on\\n * overflow (when the input is greater than largest uint40).\\n *\\n * Counterpart to Solidity's `uint40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n */\\n function toUint40(uint256 value) internal pure returns (uint40) {\\n if (value > type(uint40).max) {\\n revert SafeCastOverflowedUintDowncast(40, value);\\n }\\n return uint40(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n if (value > type(uint32).max) {\\n revert SafeCastOverflowedUintDowncast(32, value);\\n }\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint24 from uint256, reverting on\\n * overflow (when the input is greater than largest uint24).\\n *\\n * Counterpart to Solidity's `uint24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n */\\n function toUint24(uint256 value) internal pure returns (uint24) {\\n if (value > type(uint24).max) {\\n revert SafeCastOverflowedUintDowncast(24, value);\\n }\\n return uint24(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n if (value > type(uint16).max) {\\n revert SafeCastOverflowedUintDowncast(16, value);\\n }\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n if (value > type(uint8).max) {\\n revert SafeCastOverflowedUintDowncast(8, value);\\n }\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n if (value < 0) {\\n revert SafeCastOverflowedIntToUint(value);\\n }\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int248 from int256, reverting on\\n * overflow (when the input is less than smallest int248 or\\n * greater than largest int248).\\n *\\n * Counterpart to Solidity's `int248` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 248 bits\\n */\\n function toInt248(int256 value) internal pure returns (int248 downcasted) {\\n downcasted = int248(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(248, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int240 from int256, reverting on\\n * overflow (when the input is less than smallest int240 or\\n * greater than largest int240).\\n *\\n * Counterpart to Solidity's `int240` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 240 bits\\n */\\n function toInt240(int256 value) internal pure returns (int240 downcasted) {\\n downcasted = int240(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(240, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int232 from int256, reverting on\\n * overflow (when the input is less than smallest int232 or\\n * greater than largest int232).\\n *\\n * Counterpart to Solidity's `int232` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 232 bits\\n */\\n function toInt232(int256 value) internal pure returns (int232 downcasted) {\\n downcasted = int232(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(232, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int224 from int256, reverting on\\n * overflow (when the input is less than smallest int224 or\\n * greater than largest int224).\\n *\\n * Counterpart to Solidity's `int224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toInt224(int256 value) internal pure returns (int224 downcasted) {\\n downcasted = int224(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(224, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int216 from int256, reverting on\\n * overflow (when the input is less than smallest int216 or\\n * greater than largest int216).\\n *\\n * Counterpart to Solidity's `int216` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 216 bits\\n */\\n function toInt216(int256 value) internal pure returns (int216 downcasted) {\\n downcasted = int216(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(216, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int208 from int256, reverting on\\n * overflow (when the input is less than smallest int208 or\\n * greater than largest int208).\\n *\\n * Counterpart to Solidity's `int208` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 208 bits\\n */\\n function toInt208(int256 value) internal pure returns (int208 downcasted) {\\n downcasted = int208(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(208, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int200 from int256, reverting on\\n * overflow (when the input is less than smallest int200 or\\n * greater than largest int200).\\n *\\n * Counterpart to Solidity's `int200` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 200 bits\\n */\\n function toInt200(int256 value) internal pure returns (int200 downcasted) {\\n downcasted = int200(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(200, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int192 from int256, reverting on\\n * overflow (when the input is less than smallest int192 or\\n * greater than largest int192).\\n *\\n * Counterpart to Solidity's `int192` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 192 bits\\n */\\n function toInt192(int256 value) internal pure returns (int192 downcasted) {\\n downcasted = int192(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(192, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int184 from int256, reverting on\\n * overflow (when the input is less than smallest int184 or\\n * greater than largest int184).\\n *\\n * Counterpart to Solidity's `int184` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 184 bits\\n */\\n function toInt184(int256 value) internal pure returns (int184 downcasted) {\\n downcasted = int184(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(184, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int176 from int256, reverting on\\n * overflow (when the input is less than smallest int176 or\\n * greater than largest int176).\\n *\\n * Counterpart to Solidity's `int176` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 176 bits\\n */\\n function toInt176(int256 value) internal pure returns (int176 downcasted) {\\n downcasted = int176(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(176, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int168 from int256, reverting on\\n * overflow (when the input is less than smallest int168 or\\n * greater than largest int168).\\n *\\n * Counterpart to Solidity's `int168` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 168 bits\\n */\\n function toInt168(int256 value) internal pure returns (int168 downcasted) {\\n downcasted = int168(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(168, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int160 from int256, reverting on\\n * overflow (when the input is less than smallest int160 or\\n * greater than largest int160).\\n *\\n * Counterpart to Solidity's `int160` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 160 bits\\n */\\n function toInt160(int256 value) internal pure returns (int160 downcasted) {\\n downcasted = int160(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(160, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int152 from int256, reverting on\\n * overflow (when the input is less than smallest int152 or\\n * greater than largest int152).\\n *\\n * Counterpart to Solidity's `int152` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 152 bits\\n */\\n function toInt152(int256 value) internal pure returns (int152 downcasted) {\\n downcasted = int152(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(152, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int144 from int256, reverting on\\n * overflow (when the input is less than smallest int144 or\\n * greater than largest int144).\\n *\\n * Counterpart to Solidity's `int144` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 144 bits\\n */\\n function toInt144(int256 value) internal pure returns (int144 downcasted) {\\n downcasted = int144(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(144, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int136 from int256, reverting on\\n * overflow (when the input is less than smallest int136 or\\n * greater than largest int136).\\n *\\n * Counterpart to Solidity's `int136` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 136 bits\\n */\\n function toInt136(int256 value) internal pure returns (int136 downcasted) {\\n downcasted = int136(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(136, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toInt128(int256 value) internal pure returns (int128 downcasted) {\\n downcasted = int128(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(128, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int120 from int256, reverting on\\n * overflow (when the input is less than smallest int120 or\\n * greater than largest int120).\\n *\\n * Counterpart to Solidity's `int120` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 120 bits\\n */\\n function toInt120(int256 value) internal pure returns (int120 downcasted) {\\n downcasted = int120(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(120, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int112 from int256, reverting on\\n * overflow (when the input is less than smallest int112 or\\n * greater than largest int112).\\n *\\n * Counterpart to Solidity's `int112` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 112 bits\\n */\\n function toInt112(int256 value) internal pure returns (int112 downcasted) {\\n downcasted = int112(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(112, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int104 from int256, reverting on\\n * overflow (when the input is less than smallest int104 or\\n * greater than largest int104).\\n *\\n * Counterpart to Solidity's `int104` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 104 bits\\n */\\n function toInt104(int256 value) internal pure returns (int104 downcasted) {\\n downcasted = int104(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(104, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int96 from int256, reverting on\\n * overflow (when the input is less than smallest int96 or\\n * greater than largest int96).\\n *\\n * Counterpart to Solidity's `int96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toInt96(int256 value) internal pure returns (int96 downcasted) {\\n downcasted = int96(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(96, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int88 from int256, reverting on\\n * overflow (when the input is less than smallest int88 or\\n * greater than largest int88).\\n *\\n * Counterpart to Solidity's `int88` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 88 bits\\n */\\n function toInt88(int256 value) internal pure returns (int88 downcasted) {\\n downcasted = int88(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(88, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int80 from int256, reverting on\\n * overflow (when the input is less than smallest int80 or\\n * greater than largest int80).\\n *\\n * Counterpart to Solidity's `int80` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 80 bits\\n */\\n function toInt80(int256 value) internal pure returns (int80 downcasted) {\\n downcasted = int80(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(80, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int72 from int256, reverting on\\n * overflow (when the input is less than smallest int72 or\\n * greater than largest int72).\\n *\\n * Counterpart to Solidity's `int72` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 72 bits\\n */\\n function toInt72(int256 value) internal pure returns (int72 downcasted) {\\n downcasted = int72(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(72, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toInt64(int256 value) internal pure returns (int64 downcasted) {\\n downcasted = int64(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(64, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int56 from int256, reverting on\\n * overflow (when the input is less than smallest int56 or\\n * greater than largest int56).\\n *\\n * Counterpart to Solidity's `int56` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 56 bits\\n */\\n function toInt56(int256 value) internal pure returns (int56 downcasted) {\\n downcasted = int56(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(56, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int48 from int256, reverting on\\n * overflow (when the input is less than smallest int48 or\\n * greater than largest int48).\\n *\\n * Counterpart to Solidity's `int48` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 48 bits\\n */\\n function toInt48(int256 value) internal pure returns (int48 downcasted) {\\n downcasted = int48(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(48, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int40 from int256, reverting on\\n * overflow (when the input is less than smallest int40 or\\n * greater than largest int40).\\n *\\n * Counterpart to Solidity's `int40` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 40 bits\\n */\\n function toInt40(int256 value) internal pure returns (int40 downcasted) {\\n downcasted = int40(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(40, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toInt32(int256 value) internal pure returns (int32 downcasted) {\\n downcasted = int32(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(32, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int24 from int256, reverting on\\n * overflow (when the input is less than smallest int24 or\\n * greater than largest int24).\\n *\\n * Counterpart to Solidity's `int24` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 24 bits\\n */\\n function toInt24(int256 value) internal pure returns (int24 downcasted) {\\n downcasted = int24(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(24, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toInt16(int256 value) internal pure returns (int16 downcasted) {\\n downcasted = int16(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(16, value);\\n }\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits\\n */\\n function toInt8(int256 value) internal pure returns (int8 downcasted) {\\n downcasted = int8(value);\\n if (downcasted != value) {\\n revert SafeCastOverflowedIntDowncast(8, value);\\n }\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n if (value > uint256(type(int256).max)) {\\n revert SafeCastOverflowedUintToInt(value);\\n }\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xe19a4d5f31d2861e7344e8e535e2feafb913d806d3e2b5fe7782741a2a7094fe\",\"license\":\"MIT\"},\"contracts/AcreBitcoinDepositor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\nimport {SafeERC20} from \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {SafeCast} from \\\"@openzeppelin/contracts/utils/math/SafeCast.sol\\\";\\n\\nimport \\\"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\\\";\\n\\nimport {stBTC} from \\\"./stBTC.sol\\\";\\n\\n// TODO: Make Upgradable\\n// TODO: Make Pausable\\n\\n/// @title Acre Bitcoin Depositor contract.\\n/// @notice The contract integrates Acre staking with tBTC minting.\\n/// User who wants to stake BTC in Acre should submit a Bitcoin transaction\\n/// to the most recently created off-chain ECDSA wallets of the tBTC Bridge\\n/// using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH)\\n/// containing hashed information about this Depositor contract address,\\n/// and staker's Ethereum address.\\n/// Then, the staker initiates tBTC minting by revealing their Ethereum\\n/// address along with their deposit blinding factor, refund public key\\n/// hash and refund locktime on the tBTC Bridge through this Depositor\\n/// contract.\\n/// The off-chain ECDSA wallet and Optimistic Minting bots listen for these\\n/// sorts of messages and when they get one, they check the Bitcoin network\\n/// to make sure the deposit lines up. Majority of tBTC minting is finalized\\n/// by the Optimistic Minting process, where Minter bot initializes\\n/// minting process and if there is no veto from the Guardians, the\\n/// process is finalized and tBTC minted to the Depositor address. If\\n/// the revealed deposit is not handled by the Optimistic Minting process\\n/// the off-chain ECDSA wallet may decide to pick the deposit transaction\\n/// for sweeping, and when the sweep operation is confirmed on the Bitcoin\\n/// network, the tBTC Bridge and tBTC vault mint the tBTC token to the\\n/// Depositor address. After tBTC is minted to the Depositor, on the stake\\n/// finalization tBTC is staked in stBTC contract and stBTC shares are emitted\\n/// to the staker.\\ncontract AcreBitcoinDepositor is AbstractTBTCDepositor, Ownable2Step {\\n using SafeERC20 for IERC20;\\n\\n /// @notice State of the stake request.\\n enum StakeRequestState {\\n Unknown,\\n Initialized,\\n Finalized,\\n Queued,\\n FinalizedFromQueue,\\n CancelledFromQueue\\n }\\n\\n struct StakeRequest {\\n // State of the stake request.\\n StakeRequestState state;\\n // The address to which the stBTC shares will be minted. Stored only when\\n // request is queued.\\n address staker;\\n // tBTC token amount to stake after deducting tBTC minting fees and the\\n // Depositor fee. Stored only when request is queued.\\n uint88 queuedAmount;\\n }\\n\\n /// @notice Mapping of stake requests.\\n /// @dev The key is a deposit key identifying the deposit.\\n mapping(uint256 => StakeRequest) public stakeRequests;\\n\\n /// @notice tBTC Token contract.\\n // TODO: Remove slither disable when introducing upgradeability.\\n // slither-disable-next-line immutable-states\\n IERC20 public tbtcToken;\\n\\n /// @notice stBTC contract.\\n // TODO: Remove slither disable when introducing upgradeability.\\n // slither-disable-next-line immutable-states\\n stBTC public stbtc;\\n\\n /// @notice Divisor used to compute the depositor fee taken from each deposit\\n /// and transferred to the treasury upon stake request finalization.\\n /// @dev That fee is computed as follows:\\n /// `depositorFee = depositedAmount / depositorFeeDivisor`\\n /// for example, if the depositor fee needs to be 2% of each deposit,\\n /// the `depositorFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n uint64 public depositorFeeDivisor;\\n\\n /// @notice Emitted when a stake request is initialized.\\n /// @dev Deposit details can be fetched from {{ Bridge.DepositRevealed }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that initialized the stake request.\\n /// @param staker The address to which the stBTC shares will be minted.\\n event StakeRequestInitialized(\\n uint256 indexed depositKey,\\n address indexed caller,\\n address indexed staker\\n );\\n\\n /// @notice Emitted when bridging completion has been notified.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that notified about bridging completion.\\n /// @param referral Identifier of a partner in the referral program.\\n /// @param bridgedAmount Amount of tBTC tokens that was bridged by the tBTC bridge.\\n /// @param depositorFee Depositor fee amount.\\n event BridgingCompleted(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint16 indexed referral,\\n uint256 bridgedAmount,\\n uint256 depositorFee\\n );\\n\\n /// @notice Emitted when a stake request is finalized.\\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that finalized the stake request.\\n /// @param stakedAmount Amount of staked tBTC tokens.\\n event StakeRequestFinalized(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint256 stakedAmount\\n );\\n\\n /// @notice Emitted when a stake request is queued.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that finalized the stake request.\\n /// @param queuedAmount Amount of queued tBTC tokens.\\n event StakeRequestQueued(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint256 queuedAmount\\n );\\n\\n /// @notice Emitted when a stake request is finalized from the queue.\\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that finalized the stake request.\\n /// @param stakedAmount Amount of staked tBTC tokens.\\n event StakeRequestFinalizedFromQueue(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint256 stakedAmount\\n );\\n\\n /// @notice Emitted when a queued stake request is cancelled.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param staker Address of the staker.\\n /// @param amountToStake Amount of queued tBTC tokens that got cancelled.\\n event StakeRequestCancelledFromQueue(\\n uint256 indexed depositKey,\\n address indexed staker,\\n uint256 amountToStake\\n );\\n\\n /// @notice Emitted when a depositor fee divisor is updated.\\n /// @param depositorFeeDivisor New value of the depositor fee divisor.\\n event DepositorFeeDivisorUpdated(uint64 depositorFeeDivisor);\\n\\n /// Reverts if the tBTC Token address is zero.\\n error TbtcTokenZeroAddress();\\n\\n /// Reverts if the stBTC address is zero.\\n error StbtcZeroAddress();\\n\\n /// @dev Staker address is zero.\\n error StakerIsZeroAddress();\\n\\n /// @dev Attempted to execute function for stake request in unexpected current\\n /// state.\\n error UnexpectedStakeRequestState(\\n StakeRequestState currentState,\\n StakeRequestState expectedState\\n );\\n\\n /// @dev Attempted to finalize bridging with depositor's contract tBTC balance\\n /// lower than the calculated bridged tBTC amount. This error means\\n /// that Governance should top-up the tBTC reserve for bridging fees\\n /// approximation.\\n error InsufficientTbtcBalance(\\n uint256 amountToStake,\\n uint256 currentBalance\\n );\\n\\n /// @dev Attempted to notify a bridging completion, while it was already\\n /// notified.\\n error BridgingCompletionAlreadyNotified();\\n\\n /// @dev Attempted to finalize a stake request, while bridging completion has\\n /// not been notified yet.\\n error BridgingNotCompleted();\\n\\n /// @dev Calculated depositor fee exceeds the amount of minted tBTC tokens.\\n error DepositorFeeExceedsBridgedAmount(\\n uint256 depositorFee,\\n uint256 bridgedAmount\\n );\\n\\n /// @dev Attempted to call bridging finalization for a stake request for\\n /// which the function was already called.\\n error BridgingFinalizationAlreadyCalled();\\n\\n /// @dev Attempted to finalize or cancel a stake request that was not added\\n /// to the queue, or was already finalized or cancelled.\\n error StakeRequestNotQueued();\\n\\n /// @dev Attempted to call function by an account that is not the staker.\\n error CallerNotStaker();\\n\\n /// @notice Acre Bitcoin Depositor contract constructor.\\n /// @param bridge tBTC Bridge contract instance.\\n /// @param tbtcVault tBTC Vault contract instance.\\n /// @param _tbtcToken tBTC token contract instance.\\n /// @param _stbtc stBTC contract instance.\\n // TODO: Move to initializer when making the contract upgradeable.\\n constructor(\\n address bridge,\\n address tbtcVault,\\n address _tbtcToken,\\n address _stbtc\\n ) Ownable(msg.sender) {\\n __AbstractTBTCDepositor_initialize(bridge, tbtcVault);\\n\\n if (address(_tbtcToken) == address(0)) {\\n revert TbtcTokenZeroAddress();\\n }\\n if (address(_stbtc) == address(0)) {\\n revert StbtcZeroAddress();\\n }\\n\\n tbtcToken = IERC20(_tbtcToken);\\n stbtc = stBTC(_stbtc);\\n\\n depositorFeeDivisor = 1000; // 1/1000 == 10bps == 0.1% == 0.001\\n }\\n\\n /// @notice This function allows staking process initialization for a Bitcoin\\n /// deposit made by an user with a P2(W)SH transaction. It uses the\\n /// supplied information to reveal a deposit to the tBTC Bridge contract.\\n /// @dev Requirements:\\n /// - The revealed vault address must match the TBTCVault address,\\n /// - All requirements from {Bridge#revealDepositWithExtraData}\\n /// function must be met.\\n /// - `staker` must be the staker address used in the P2(W)SH BTC\\n /// deposit transaction as part of the extra data.\\n /// - `referral` must be the referral info used in the P2(W)SH BTC\\n /// deposit transaction as part of the extra data.\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\\n /// @param staker The address to which the stBTC shares will be minted.\\n /// @param referral Data used for referral program.\\n function initializeStake(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n address staker,\\n uint16 referral\\n ) external {\\n if (staker == address(0)) revert StakerIsZeroAddress();\\n\\n // We don't check if the request was already initialized, as this check\\n // is enforced in `_initializeDeposit` when calling the\\n // `Bridge.revealDepositWithExtraData` function.\\n uint256 depositKey = _initializeDeposit(\\n fundingTx,\\n reveal,\\n encodeExtraData(staker, referral)\\n );\\n\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Unknown,\\n StakeRequestState.Initialized\\n );\\n\\n emit StakeRequestInitialized(depositKey, msg.sender, staker);\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC bridging process was finalized.\\n /// It stakes the tBTC from the given deposit into stBTC, emitting the\\n /// stBTC shares to the staker specified in the deposit extra data\\n /// and using the referral provided in the extra data.\\n /// @dev In case depositing in stBTC vault fails (e.g. because of the\\n /// maximum deposit limit being reached), the `queueStake` function\\n /// should be called to add the stake request to the staking queue.\\n /// @param depositKey Deposit key identifying the deposit.\\n function finalizeStake(uint256 depositKey) external {\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Initialized,\\n StakeRequestState.Finalized\\n );\\n\\n (uint256 amountToStake, address staker) = finalizeBridging(depositKey);\\n\\n emit StakeRequestFinalized(depositKey, msg.sender, amountToStake);\\n\\n // Deposit tBTC in stBTC.\\n tbtcToken.safeIncreaseAllowance(address(stbtc), amountToStake);\\n // slither-disable-next-line unused-return\\n stbtc.deposit(amountToStake, staker);\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC bridging process was finalized, in case the\\n /// `finalizeStake` failed due to stBTC vault deposit limit\\n /// being reached.\\n /// @dev It queues the stake request, until the stBTC vault is ready to\\n /// accept the deposit. The request must be finalized with `finalizeQueuedStake`\\n /// after the limit is increased or other user withdraws their funds\\n /// from the stBTC contract to make place for another deposit.\\n /// The staker has a possibility to submit `cancelQueuedStake` that\\n /// will withdraw the minted tBTC token and abort staking process.\\n /// @param depositKey Deposit key identifying the deposit.\\n function queueStake(uint256 depositKey) external {\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Initialized,\\n StakeRequestState.Queued\\n );\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n uint256 amountToStake;\\n (amountToStake, request.staker) = finalizeBridging(depositKey);\\n\\n request.queuedAmount = SafeCast.toUint88(amountToStake);\\n\\n emit StakeRequestQueued(depositKey, msg.sender, request.queuedAmount);\\n }\\n\\n /// @notice This function should be called for previously queued stake\\n /// request, when stBTC vault is able to accept a deposit.\\n /// @param depositKey Deposit key identifying the deposit.\\n function finalizeQueuedStake(uint256 depositKey) external {\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Queued,\\n StakeRequestState.FinalizedFromQueue\\n );\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n if (request.queuedAmount == 0) revert StakeRequestNotQueued();\\n\\n uint256 amountToStake = request.queuedAmount;\\n delete (request.queuedAmount);\\n\\n emit StakeRequestFinalizedFromQueue(\\n depositKey,\\n msg.sender,\\n amountToStake\\n );\\n\\n // Deposit tBTC in stBTC.\\n tbtcToken.safeIncreaseAllowance(address(stbtc), amountToStake);\\n // slither-disable-next-line unused-return\\n stbtc.deposit(amountToStake, request.staker);\\n }\\n\\n /// @notice Cancel queued stake.\\n /// The function can be called by the staker to recover tBTC that cannot\\n /// be finalized to stake in stBTC contract due to a deposit limit being\\n /// reached.\\n /// @dev This function can be called only after the stake request was added\\n /// to queue.\\n /// @dev Only staker provided in the extra data of the stake request can\\n /// call this function.\\n /// @param depositKey Deposit key identifying the deposit.\\n function cancelQueuedStake(uint256 depositKey) external {\\n transitionStakeRequestState(\\n depositKey,\\n StakeRequestState.Queued,\\n StakeRequestState.CancelledFromQueue\\n );\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n if (request.queuedAmount == 0) revert StakeRequestNotQueued();\\n\\n // Check if caller is the staker.\\n if (msg.sender != request.staker) revert CallerNotStaker();\\n\\n uint256 amount = request.queuedAmount;\\n delete (request.queuedAmount);\\n\\n emit StakeRequestCancelledFromQueue(depositKey, request.staker, amount);\\n\\n tbtcToken.safeTransfer(request.staker, amount);\\n }\\n\\n /// @notice Updates the depositor fee divisor.\\n /// @param newDepositorFeeDivisor New depositor fee divisor value.\\n function updateDepositorFeeDivisor(\\n uint64 newDepositorFeeDivisor\\n ) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n depositorFeeDivisor = newDepositorFeeDivisor;\\n\\n emit DepositorFeeDivisorUpdated(newDepositorFeeDivisor);\\n }\\n\\n // TODO: Handle minimum deposit amount in tBTC Bridge vs stBTC.\\n\\n /// @notice Encodes staker address and referral as extra data.\\n /// @dev Packs the data to bytes32: 20 bytes of staker address and\\n /// 2 bytes of referral, 10 bytes of trailing zeros.\\n /// @param staker The address to which the stBTC shares will be minted.\\n /// @param referral Data used for referral program.\\n /// @return Encoded extra data.\\n function encodeExtraData(\\n address staker,\\n uint16 referral\\n ) public pure returns (bytes32) {\\n return bytes32(abi.encodePacked(staker, referral));\\n }\\n\\n /// @notice Decodes staker address and referral from extra data.\\n /// @dev Unpacks the data from bytes32: 20 bytes of staker address and\\n /// 2 bytes of referral, 10 bytes of trailing zeros.\\n /// @param extraData Encoded extra data.\\n /// @return staker The address to which the stBTC shares will be minted.\\n /// @return referral Data used for referral program.\\n function decodeExtraData(\\n bytes32 extraData\\n ) public pure returns (address staker, uint16 referral) {\\n // First 20 bytes of extra data is staker address.\\n staker = address(uint160(bytes20(extraData)));\\n // Next 2 bytes of extra data is referral info.\\n referral = uint16(bytes2(extraData << (8 * 20)));\\n }\\n\\n /// @notice This function is used for state transitions. It ensures the current\\n /// stakte matches expected, and updates the stake request to a new\\n /// state.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param expectedState Expected current stake request state.\\n /// @param newState New stake request state.\\n function transitionStakeRequestState(\\n uint256 depositKey,\\n StakeRequestState expectedState,\\n StakeRequestState newState\\n ) internal {\\n // Validate current stake request state.\\n if (stakeRequests[depositKey].state != expectedState)\\n revert UnexpectedStakeRequestState(\\n stakeRequests[depositKey].state,\\n expectedState\\n );\\n\\n // Transition to a new state.\\n stakeRequests[depositKey].state = newState;\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC minting process completed, meaning tBTC was\\n /// minted to this contract.\\n /// @dev It calculates the amount to stake based on the approximate minted\\n /// tBTC amount reduced by the depositor fee.\\n /// @dev IMPORTANT NOTE: The minted tBTC amount used by this function is an\\n /// approximation. See documentation of the\\n /// {{AbstractTBTCDepositor#_calculateTbtcAmount}} responsible for calculating\\n /// this value for more details.\\n /// @dev In case balance of tBTC tokens in this contract doesn't meet the\\n /// calculated tBTC amount, the function reverts with `InsufficientTbtcBalance`\\n /// error. This case requires Governance's validation, as tBTC Bridge minting\\n /// fees might changed in the way that reserve mentioned in\\n /// {{AbstractTBTCDepositor#_calculateTbtcAmount}} needs a top-up.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @return amountToStake tBTC token amount to stake after deducting tBTC bridging\\n /// fees and the depositor fee.\\n /// @return staker The address to which the stBTC shares will be minted.\\n function finalizeBridging(\\n uint256 depositKey\\n ) internal returns (uint256, address) {\\n (\\n uint256 initialDepositAmount,\\n uint256 tbtcAmount,\\n bytes32 extraData\\n ) = _finalizeDeposit(depositKey);\\n\\n // Check if current balance is sufficient to finalize bridging of `tbtcAmount`.\\n uint256 currentBalance = tbtcToken.balanceOf(address(this));\\n if (tbtcAmount > tbtcToken.balanceOf(address(this))) {\\n revert InsufficientTbtcBalance(tbtcAmount, currentBalance);\\n }\\n\\n // Compute depositor fee. The fee is calculated based on the initial funding\\n // transaction amount, before the tBTC protocol network fees were taken.\\n uint256 depositorFee = depositorFeeDivisor > 0\\n ? (initialDepositAmount / depositorFeeDivisor)\\n : 0;\\n\\n // Ensure the depositor fee does not exceed the approximate minted tBTC\\n // amount.\\n if (depositorFee >= tbtcAmount) {\\n revert DepositorFeeExceedsBridgedAmount(depositorFee, tbtcAmount);\\n }\\n\\n uint256 amountToStake = tbtcAmount - depositorFee;\\n\\n (address staker, uint16 referral) = decodeExtraData(extraData);\\n\\n // Emit event for accounting purposes to track partner's referral ID and\\n // depositor fee taken.\\n emit BridgingCompleted(\\n depositKey,\\n msg.sender,\\n referral,\\n tbtcAmount,\\n depositorFee\\n );\\n\\n // Transfer depositor fee to the treasury wallet.\\n if (depositorFee > 0) {\\n tbtcToken.safeTransfer(stbtc.treasury(), depositorFee);\\n }\\n\\n return (amountToStake, staker);\\n }\\n}\\n\",\"keccak256\":\"0x35f811a27cfb344b8153534c7e72388516e11de67f67179c467da0ad6c711711\",\"license\":\"GPL-3.0-only\"},\"contracts/Dispatcher.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\nimport \\\"./Router.sol\\\";\\nimport \\\"./stBTC.sol\\\";\\n\\n/// @title Dispatcher\\n/// @notice Dispatcher is a contract that routes tBTC from stBTC to\\n/// yield vaults and back. Vaults supply yield strategies with tBTC that\\n/// generate yield for Bitcoin holders.\\ncontract Dispatcher is Router, Ownable2Step {\\n using SafeERC20 for IERC20;\\n\\n /// Struct holds information about a vault.\\n struct VaultInfo {\\n bool authorized;\\n }\\n\\n /// The main stBTC contract holding tBTC deposited by stakers.\\n stBTC public immutable stbtc;\\n /// tBTC token contract.\\n IERC20 public immutable tbtc;\\n /// Address of the maintainer bot.\\n address public maintainer;\\n\\n /// Authorized Yield Vaults that implement ERC4626 standard. These\\n /// vaults deposit assets to yield strategies, e.g. Uniswap V3\\n /// WBTC/TBTC pool. Vault can be a part of Acre ecosystem or can be\\n /// implemented externally. As long as it complies with ERC4626\\n /// standard and is authorized by the owner it can be plugged into\\n /// Acre.\\n address[] public vaults;\\n /// Mapping of vaults to their information.\\n mapping(address => VaultInfo) public vaultsInfo;\\n\\n /// Emitted when a vault is authorized.\\n /// @param vault Address of the vault.\\n event VaultAuthorized(address indexed vault);\\n\\n /// Emitted when a vault is deauthorized.\\n /// @param vault Address of the vault.\\n event VaultDeauthorized(address indexed vault);\\n\\n /// Emitted when tBTC is routed to a vault.\\n /// @param vault Address of the vault.\\n /// @param amount Amount of tBTC.\\n /// @param sharesOut Amount of received shares.\\n event DepositAllocated(\\n address indexed vault,\\n uint256 amount,\\n uint256 sharesOut\\n );\\n\\n /// Emitted when the maintainer address is updated.\\n /// @param maintainer Address of the new maintainer.\\n event MaintainerUpdated(address indexed maintainer);\\n\\n /// Reverts if the vault is already authorized.\\n error VaultAlreadyAuthorized();\\n\\n /// Reverts if the vault is not authorized.\\n error VaultUnauthorized();\\n\\n /// Reverts if the caller is not the maintainer.\\n error NotMaintainer();\\n\\n /// Reverts if the address is zero.\\n error ZeroAddress();\\n\\n /// Modifier that reverts if the caller is not the maintainer.\\n modifier onlyMaintainer() {\\n if (msg.sender != maintainer) {\\n revert NotMaintainer();\\n }\\n _;\\n }\\n\\n constructor(stBTC _stbtc, IERC20 _tbtc) Ownable(msg.sender) {\\n stbtc = _stbtc;\\n tbtc = _tbtc;\\n }\\n\\n /// @notice Adds a vault to the list of authorized vaults.\\n /// @param vault Address of the vault to add.\\n function authorizeVault(address vault) external onlyOwner {\\n if (isVaultAuthorized(vault)) {\\n revert VaultAlreadyAuthorized();\\n }\\n\\n vaults.push(vault);\\n vaultsInfo[vault].authorized = true;\\n\\n emit VaultAuthorized(vault);\\n }\\n\\n /// @notice Removes a vault from the list of authorized vaults.\\n /// @param vault Address of the vault to remove.\\n function deauthorizeVault(address vault) external onlyOwner {\\n if (!isVaultAuthorized(vault)) {\\n revert VaultUnauthorized();\\n }\\n\\n vaultsInfo[vault].authorized = false;\\n\\n for (uint256 i = 0; i < vaults.length; i++) {\\n if (vaults[i] == vault) {\\n vaults[i] = vaults[vaults.length - 1];\\n // slither-disable-next-line costly-loop\\n vaults.pop();\\n break;\\n }\\n }\\n\\n emit VaultDeauthorized(vault);\\n }\\n\\n /// @notice Updates the maintainer address.\\n /// @param newMaintainer Address of the new maintainer.\\n function updateMaintainer(address newMaintainer) external onlyOwner {\\n if (newMaintainer == address(0)) {\\n revert ZeroAddress();\\n }\\n\\n maintainer = newMaintainer;\\n\\n emit MaintainerUpdated(maintainer);\\n }\\n\\n /// TODO: make this function internal once the allocation distribution is\\n /// implemented\\n /// @notice Routes tBTC from stBTC to a vault. Can be called by the maintainer\\n /// only.\\n /// @param vault Address of the vault to route the assets to.\\n /// @param amount Amount of tBTC to deposit.\\n /// @param minSharesOut Minimum amount of shares to receive.\\n function depositToVault(\\n address vault,\\n uint256 amount,\\n uint256 minSharesOut\\n ) public onlyMaintainer {\\n if (!isVaultAuthorized(vault)) {\\n revert VaultUnauthorized();\\n }\\n\\n // slither-disable-next-line arbitrary-send-erc20\\n tbtc.safeTransferFrom(address(stbtc), address(this), amount);\\n tbtc.forceApprove(address(vault), amount);\\n\\n uint256 sharesOut = deposit(\\n IERC4626(vault),\\n address(stbtc),\\n amount,\\n minSharesOut\\n );\\n // slither-disable-next-line reentrancy-events\\n emit DepositAllocated(vault, amount, sharesOut);\\n }\\n\\n /// @notice Returns the list of authorized vaults.\\n function getVaults() public view returns (address[] memory) {\\n return vaults;\\n }\\n\\n /// @notice Returns true if the vault is authorized.\\n /// @param vault Address of the vault to check.\\n function isVaultAuthorized(address vault) public view returns (bool) {\\n return vaultsInfo[vault].authorized;\\n }\\n\\n /// TODO: implement redeem() / withdraw() functions\\n}\\n\",\"keccak256\":\"0x5adb54e73b82adf0befabef894d99d9bb5eb785895851764ec9f497a055ae47f\",\"license\":\"GPL-3.0-only\"},\"contracts/Router.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\n\\n/// @title Router\\n/// @notice Router is a contract that routes tBTC from stBTC to\\n/// a given vault and back. Vaults supply yield strategies with tBTC that\\n/// generate yield for Bitcoin holders.\\nabstract contract Router {\\n /// Thrown when amount of shares received is below the min set by caller.\\n /// @param vault Address of the vault.\\n /// @param sharesOut Amount of received shares.\\n /// @param minSharesOut Minimum amount of shares expected to receive.\\n error MinSharesError(\\n address vault,\\n uint256 sharesOut,\\n uint256 minSharesOut\\n );\\n\\n /// @notice Routes funds from stBTC to a vault. The amount of tBTC to\\n /// Shares of deposited tBTC are minted to the stBTC contract.\\n /// @param vault Address of the vault to route the funds to.\\n /// @param receiver Address of the receiver of the shares.\\n /// @param amount Amount of tBTC to deposit.\\n /// @param minSharesOut Minimum amount of shares to receive.\\n function deposit(\\n IERC4626 vault,\\n address receiver,\\n uint256 amount,\\n uint256 minSharesOut\\n ) internal returns (uint256 sharesOut) {\\n if ((sharesOut = vault.deposit(amount, receiver)) < minSharesOut) {\\n revert MinSharesError(address(vault), sharesOut, minSharesOut);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x520e27c613f1234755c23402524b048a81abd15222d7f318504992d490248812\",\"license\":\"GPL-3.0-only\"},\"contracts/stBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable2Step.sol\\\";\\nimport \\\"./Dispatcher.sol\\\";\\n\\n/// @title stBTC\\n/// @notice This contract implements the ERC-4626 tokenized vault standard. By\\n/// staking tBTC, users acquire a liquid staking token called stBTC,\\n/// commonly referred to as \\\"shares\\\". The staked tBTC is securely\\n/// deposited into Acre's vaults, where it generates yield over time.\\n/// Users have the flexibility to redeem stBTC, enabling them to\\n/// withdraw their staked tBTC along with the accrued yield.\\n/// @dev ERC-4626 is a standard to optimize and unify the technical parameters\\n/// of yield-bearing vaults. This contract facilitates the minting and\\n/// burning of shares (stBTC), which are represented as standard ERC20\\n/// tokens, providing a seamless exchange with tBTC tokens.\\ncontract stBTC is ERC4626, Ownable2Step {\\n using SafeERC20 for IERC20;\\n\\n /// Dispatcher contract that routes tBTC from stBTC to a given vault and back.\\n Dispatcher public dispatcher;\\n\\n /// Address of the treasury wallet, where fees should be transferred to.\\n address public treasury;\\n\\n /// Minimum amount for a single deposit operation. The value should be set\\n /// low enough so the deposits routed through Bitcoin Depositor contract won't\\n /// be rejected. It means that minimumDepositAmount should be lower than\\n /// tBTC protocol's depositDustThreshold reduced by all the minting fees taken\\n /// before depositing in the Acre contract.\\n uint256 public minimumDepositAmount;\\n\\n /// Maximum total amount of tBTC token held by Acre protocol.\\n uint256 public maximumTotalAssets;\\n\\n /// Emitted when the treasury wallet address is updated.\\n /// @param treasury New treasury wallet address.\\n event TreasuryUpdated(address treasury);\\n\\n /// Emitted when deposit parameters are updated.\\n /// @param minimumDepositAmount New value of the minimum deposit amount.\\n /// @param maximumTotalAssets New value of the maximum total assets amount.\\n event DepositParametersUpdated(\\n uint256 minimumDepositAmount,\\n uint256 maximumTotalAssets\\n );\\n\\n /// Emitted when the dispatcher contract is updated.\\n /// @param oldDispatcher Address of the old dispatcher contract.\\n /// @param newDispatcher Address of the new dispatcher contract.\\n event DispatcherUpdated(address oldDispatcher, address newDispatcher);\\n\\n /// Reverts if the amount is less than the minimum deposit amount.\\n /// @param amount Amount to check.\\n /// @param min Minimum amount to check 'amount' against.\\n error LessThanMinDeposit(uint256 amount, uint256 min);\\n\\n /// Reverts if the address is zero.\\n error ZeroAddress();\\n\\n /// Reverts if the address is disallowed.\\n error DisallowedAddress();\\n\\n constructor(\\n IERC20 _tbtc,\\n address _treasury\\n ) ERC4626(_tbtc) ERC20(\\\"Acre Staked Bitcoin\\\", \\\"stBTC\\\") Ownable(msg.sender) {\\n if (address(_treasury) == address(0)) {\\n revert ZeroAddress();\\n }\\n treasury = _treasury;\\n // TODO: Revisit the exact values closer to the launch.\\n minimumDepositAmount = 0.001 * 1e18; // 0.001 tBTC\\n maximumTotalAssets = 25 * 1e18; // 25 tBTC\\n }\\n\\n /// @notice Updates treasury wallet address.\\n /// @param newTreasury New treasury wallet address.\\n function updateTreasury(address newTreasury) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n if (newTreasury == address(0)) {\\n revert ZeroAddress();\\n }\\n if (newTreasury == address(this)) {\\n revert DisallowedAddress();\\n }\\n treasury = newTreasury;\\n\\n emit TreasuryUpdated(newTreasury);\\n }\\n\\n /// @notice Updates deposit parameters.\\n /// @dev To disable the limit for deposits, set the maximum total assets to\\n /// maximum (`type(uint256).max`).\\n /// @param _minimumDepositAmount New value of the minimum deposit amount. It\\n /// is the minimum amount for a single deposit operation.\\n /// @param _maximumTotalAssets New value of the maximum total assets amount.\\n /// It is the maximum amount of the tBTC token that the Acre protocol\\n /// can hold.\\n function updateDepositParameters(\\n uint256 _minimumDepositAmount,\\n uint256 _maximumTotalAssets\\n ) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n minimumDepositAmount = _minimumDepositAmount;\\n maximumTotalAssets = _maximumTotalAssets;\\n\\n emit DepositParametersUpdated(\\n _minimumDepositAmount,\\n _maximumTotalAssets\\n );\\n }\\n\\n // TODO: Implement a governed upgrade process that initiates an update and\\n // then finalizes it after a delay.\\n /// @notice Updates the dispatcher contract and gives it an unlimited\\n /// allowance to transfer staked tBTC.\\n /// @param newDispatcher Address of the new dispatcher contract.\\n function updateDispatcher(Dispatcher newDispatcher) external onlyOwner {\\n if (address(newDispatcher) == address(0)) {\\n revert ZeroAddress();\\n }\\n\\n address oldDispatcher = address(dispatcher);\\n\\n emit DispatcherUpdated(oldDispatcher, address(newDispatcher));\\n dispatcher = newDispatcher;\\n\\n // TODO: Once withdrawal/rebalancing is implemented, we need to revoke the\\n // approval of the vaults share tokens from the old dispatcher and approve\\n // a new dispatcher to manage the share tokens.\\n\\n if (oldDispatcher != address(0)) {\\n // Setting allowance to zero for the old dispatcher\\n IERC20(asset()).forceApprove(oldDispatcher, 0);\\n }\\n\\n // Setting allowance to max for the new dispatcher\\n IERC20(asset()).forceApprove(address(dispatcher), type(uint256).max);\\n }\\n\\n /// @notice Mints shares to receiver by depositing exactly amount of\\n /// tBTC tokens.\\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\\n /// which determines the minimum amount for a single deposit operation.\\n /// The amount of the assets has to be pre-approved in the tBTC\\n /// contract.\\n /// @param assets Approved amount of tBTC tokens to deposit.\\n /// @param receiver The address to which the shares will be minted.\\n /// @return Minted shares.\\n function deposit(\\n uint256 assets,\\n address receiver\\n ) public override returns (uint256) {\\n if (assets < minimumDepositAmount) {\\n revert LessThanMinDeposit(assets, minimumDepositAmount);\\n }\\n\\n return super.deposit(assets, receiver);\\n }\\n\\n /// @notice Mints shares to receiver by depositing tBTC tokens.\\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\\n /// which determines the minimum amount for a single deposit operation.\\n /// The amount of the assets has to be pre-approved in the tBTC\\n /// contract.\\n /// The msg.sender is required to grant approval for tBTC transfer.\\n /// To determine the total assets amount necessary for approval\\n /// corresponding to a given share amount, use the `previewMint` function.\\n /// @param shares Amount of shares to mint.\\n /// @param receiver The address to which the shares will be minted.\\n function mint(\\n uint256 shares,\\n address receiver\\n ) public override returns (uint256 assets) {\\n if ((assets = super.mint(shares, receiver)) < minimumDepositAmount) {\\n revert LessThanMinDeposit(assets, minimumDepositAmount);\\n }\\n }\\n\\n /// @notice Returns value of assets that would be exchanged for the amount of\\n /// shares owned by the `account`.\\n /// @param account Owner of shares.\\n /// @return Assets amount.\\n function assetsBalanceOf(address account) public view returns (uint256) {\\n return convertToAssets(balanceOf(account));\\n }\\n\\n /// @notice Returns the maximum amount of the tBTC token that can be\\n /// deposited into the vault for the receiver through a deposit\\n /// call. It takes into account the deposit parameter, maximum total\\n /// assets, which determines the total amount of tBTC token held by\\n /// Acre protocol.\\n /// @dev When the remaining amount of unused limit is less than the minimum\\n /// deposit amount, this function returns 0.\\n /// @return The maximum amount of tBTC token that can be deposited into\\n /// Acre protocol for the receiver.\\n function maxDeposit(address) public view override returns (uint256) {\\n if (maximumTotalAssets == type(uint256).max) {\\n return type(uint256).max;\\n }\\n\\n uint256 _totalAssets = totalAssets();\\n\\n return\\n _totalAssets >= maximumTotalAssets\\n ? 0\\n : maximumTotalAssets - _totalAssets;\\n }\\n\\n /// @notice Returns the maximum amount of the vault shares that can be\\n /// minted for the receiver, through a mint call.\\n /// @dev Since the stBTC contract limits the maximum total tBTC tokens this\\n /// function converts the maximum deposit amount to shares.\\n /// @return The maximum amount of the vault shares.\\n function maxMint(address receiver) public view override returns (uint256) {\\n uint256 _maxDeposit = maxDeposit(receiver);\\n\\n // slither-disable-next-line incorrect-equality\\n return\\n _maxDeposit == type(uint256).max\\n ? type(uint256).max\\n : convertToShares(_maxDeposit);\\n }\\n\\n /// @return Returns deposit parameters.\\n function depositParameters() public view returns (uint256, uint256) {\\n return (minimumDepositAmount, maximumTotalAssets);\\n }\\n}\\n\",\"keccak256\":\"0x6d980629590d39aa0c1acb2f38c1f100ef08e976cd67ba76c6f99b07ed43865b\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60806040523480156200001157600080fd5b506040516200249b3803806200249b8339810160408190526200003491620002f4565b33806200005c57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000678162000106565b5062000074848462000124565b6001600160a01b0382166200009c5760405163182b2a8160e21b815260040160405180910390fd5b6001600160a01b038116620000c45760405163e4ee787760e01b815260040160405180910390fd5b603480546001600160a01b0319166001600160a01b0393841617905560358054919092166001600160e01b031990911617607d60a31b17905550620003519050565b603280546001600160a01b0319169055620001218162000285565b50565b6000546001600160a01b03161580156200014757506001546001600160a01b0316155b620001a75760405162461bcd60e51b815260206004820152602960248201527f4162737472616374544254434465706f7369746f7220616c726561647920696e6044820152681a5d1a585b1a5e995960ba1b606482015260840162000053565b6001600160a01b038216620001ff5760405162461bcd60e51b815260206004820152601d60248201527f42726964676520616464726573732063616e6e6f74206265207a65726f000000604482015260640162000053565b6001600160a01b038116620002575760405162461bcd60e51b815260206004820181905260248201527f544254435661756c7420616464726573732063616e6e6f74206265207a65726f604482015260640162000053565b600080546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b603180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516001600160a01b0381168114620002ef57600080fd5b919050565b600080600080608085870312156200030b57600080fd5b6200031685620002d7565b93506200032660208601620002d7565b92506200033660408601620002d7565b91506200034660608601620002d7565b905092959194509250565b61213a80620003616000396000f3fe608060405234801561001057600080fd5b506004361061016c5760003560e01c8063c143d675116100cd578063da9ad53c11610081578063e5d3d71411610066578063e5d3d71414610355578063e78cea9214610368578063f2fde38b1461037b57600080fd5b8063da9ad53c14610331578063e30c39781461034457600080fd5b8063c9f5a5d8116100b2578063c9f5a5d8146102b4578063d0714ad5146102c7578063d990d3ff1461031e57600080fd5b8063c143d67514610274578063c7ba0347146102a857600080fd5b8063774e2e90116101245780638da5cb5b116101095780638da5cb5b1461023d5780639bef6d521461024e578063b2e665bf1461026157600080fd5b8063774e2e90146101f257806379ba50971461023557600080fd5b80633d11a6ae116101555780633d11a6ae146101b657806369e1df8b146101d7578063715018a6146101ea57600080fd5b80630f36403a146101715780633647b205146101a1575b600080fd5b600154610184906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b46101af366004611977565b61038e565b005b6101c96101c43660046119cb565b61040c565b604051908152602001610198565b6101b46101e5366004611a00565b61047b565b6101b461055a565b610213610200366004611a00565b606081901c9160509190911c61ffff1690565b604080516001600160a01b03909316835261ffff909116602083015201610198565b6101b461056e565b6031546001600160a01b0316610184565b603554610184906001600160a01b031681565b6101b461026f366004611a00565b6105b7565b60355461028f90600160a01b900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610198565b6101c96402540be40081565b6101b46102c2366004611a00565b610714565b61030f6102d5366004611a00565b60336020526000908152604090205460ff81169061010081046001600160a01b031690600160a81b90046affffffffffffffffffffff1683565b60405161019893929190611a51565b6101b461032c366004611a89565b61084e565b6101b461033f366004611a00565b6108f2565b6032546001600160a01b0316610184565b603454610184906001600160a01b031681565b600054610184906001600160a01b031681565b6101b4610389366004611b0d565b6109a9565b610396610a27565b603580547fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b67ffffffffffffffff8416908102919091179091556040519081527f53a618edd6eab9ce346f438670ebd45da60fa3d85662375fae2b8beadf08faf39060200160405180910390a150565b6040516bffffffffffffffffffffffff19606084901b1660208201527fffff00000000000000000000000000000000000000000000000000000000000060f083901b16603482015260009060360160405160208183030381529060405261047290611b2a565b90505b92915050565b6104888160016003610a54565b6000818152603360205260408120906104a083610b0b565b83546001600160a01b03909116610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff90911617835590506104e381610dd7565b825474ffffffffffffffffffffffffffffffffffffffffff16600160a81b6affffffffffffffffffffff9283168102919091178085556040519190049091168152339084907ff412c1941036889a8a2aec22dca20565f685239ac78976dab58b52eb70f972fa9060200160405180910390a3505050565b610562610a27565b61056c6000610e2c565b565b60325433906001600160a01b031681146105ab5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b6105b481610e2c565b50565b6105c48160036004610a54565b600081815260336020526040812080549091600160a81b9091046affffffffffffffffffffff16900361060a57604051632145277d60e21b815260040160405180910390fd5b805474ffffffffffffffffffffffffffffffffffffffffff81168255604051600160a81b9091046affffffffffffffffffffff1680825290339084907ff0a477d0ba7b549d19236a4c6517edef5574c03ed185bad57c92c9323091af8f9060200160405180910390a3603554603454610690916001600160a01b03918216911683610e52565b6035548254604051636e553f6560e01b8152600481018490526001600160a01b0361010090920482166024820152911690636e553f65906044015b6020604051808303816000875af11580156106ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070e9190611b51565b50505050565b6107218160036005610a54565b600081815260336020526040812080549091600160a81b9091046affffffffffffffffffffff16900361076757604051632145277d60e21b815260040160405180910390fd5b805461010090046001600160a01b031633146107af576040517f709d46f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805474ffffffffffffffffffffffffffffffffffffffffff8116808355604051600160a81b9092046affffffffffffffffffffff16808352916101009091046001600160a01b03169084907f32aa57d54fb0ee2c9617ac9d5982ba7d88869fcbf89542a285d6c07b03dc504e9060200160405180910390a38154603454610849916001600160a01b03918216916101009091041683610ef5565b505050565b6001600160a01b03821661088e576040517ff606bf2a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006108a4858561089f868661040c565b610f69565b90506108b38160006001610a54565b6040516001600160a01b03841690339083907f8d019883471b734b0033fe25a5b76c3afefbbfa9e9b3dacdbabf505b9e4f455d90600090a45050505050565b6108ff8160016002610a54565b60008061090b83610b0b565b91509150336001600160a01b0316837f2b57d79a66895fd41ae6d27049952259b0d40a9b7c563a99b3f1844b288da08c8460405161094b91815260200190565b60405180910390a3603554603454610970916001600160a01b03918216911684610e52565b603554604051636e553f6560e01b8152600481018490526001600160a01b03838116602483015290911690636e553f65906044016106cb565b6109b1610a27565b603280546001600160a01b03831673ffffffffffffffffffffffffffffffffffffffff1990911681179091556109ef6031546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6031546001600160a01b0316331461056c5760405163118cdaa760e01b81523360048201526024016105a2565b816005811115610a6657610a66611a19565b60008481526033602052604090205460ff166005811115610a8957610a89611a19565b14610ad657600083815260336020526040908190205490517fbcbf502b0000000000000000000000000000000000000000000000000000000081526105a29160ff16908490600401611b6a565b6000838152603360205260409020805482919060ff19166001836005811115610b0157610b01611a19565b0217905550505050565b6000806000806000610b1c866110c6565b6034546040516370a0823160e01b815230600482015293965091945092506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b939190611b51565b6034546040516370a0823160e01b81523060048201529192506001600160a01b0316906370a0823190602401602060405180830381865afa158015610bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c009190611b51565b831115610c43576040517fcad48b6900000000000000000000000000000000000000000000000000000000815260048101849052602481018290526044016105a2565b603554600090600160a01b900467ffffffffffffffff16610c65576000610c83565b603554610c8390600160a01b900467ffffffffffffffff1686611b9b565b9050838110610cc8576040517f2395edf200000000000000000000000000000000000000000000000000000000815260048101829052602481018590526044016105a2565b6000610cd48286611bbd565b6040805187815260208101859052919250606086901c9161ffff605088901c1691829133918e917f6410e64d304208a5e90fc76ab4fbf4e7b8836705daeda8dde27611ae0524490a910160405180910390a48315610dc757603554604080517f61d027b30000000000000000000000000000000000000000000000000000000081529051610dc7926001600160a01b0316916361d027b39160048083019260209291908290030181865afa158015610d90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db49190611bdb565b6034546001600160a01b03169086610ef5565b5090999098509650505050505050565b60006affffffffffffffffffffff821115610e28576040517f6dfcc65000000000000000000000000000000000000000000000000000000000815260586004820152602481018390526044016105a2565b5090565b6032805473ffffffffffffffffffffffffffffffffffffffff191690556105b481611350565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edf9190611b51565b905061070e8484610ef08585611bf8565b6113af565b6040516001600160a01b0383811660248301526044820183905261084991859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611469565b6001546000906001600160a01b0316610f8860c0850160a08601611b0d565b6001600160a01b031614610fde5760405162461bcd60e51b815260206004820152601660248201527f5661756c742061646472657373206d69736d617463680000000000000000000060448201526064016105a2565b6000610ffe610fec866114e5565b610ff96020870187611c1d565b61154a565b60405163ffffffff4216815290915081907fa3ed7aef0745e1a91addae9e5daee7a8ace74852fec840b9d93da747855dd7b99060200160405180910390a26000546040517f86f014390000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906386f014399061108990889088908890600401611ce5565b600060405180830381600087803b1580156110a357600080fd5b505af11580156110b7573d6000803e3d6000fd5b509293505050505b9392505050565b600080546040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018490528291829182916001600160a01b03169063b02c43d09060240160e060405180830381865afa15801561112d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111519190611e60565b9050806040015163ffffffff166000036111ad5760405162461bcd60e51b815260206004820152601760248201527f4465706f736974206e6f7420696e697469616c697a656400000000000000000060448201526064016105a2565b6001546040517f6c626aa4000000000000000000000000000000000000000000000000000000008152600481018790526000916001600160a01b031690636c626aa49060240160408051808303816000875af1158015611211573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112359190611f1a565b9150508160a0015163ffffffff16600014158061125b575067ffffffffffffffff811615155b6112cd5760405162461bcd60e51b815260206004820152602360248201527f4465706f736974206e6f742066696e616c697a6564206279207468652062726960448201527f646765000000000000000000000000000000000000000000000000000000000060648201526084016105a2565b6402540be400826020015167ffffffffffffffff166112ec9190611f54565b945061130082602001518360800151611594565b6040805182815263ffffffff4216602082015291955087917f417b6288c9f637614f8b3f7a275fb4e44e517930fde949e463d58dfe0b97f28b910160405180910390a25060c00151929491935050565b603180546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261142e8482611717565b61070e576040516001600160a01b0384811660248301526000604483015261146391869182169063095ea7b390606401610f22565b61070e84825b600061147e6001600160a01b038416836117bf565b905080516000141580156114a35750808060200190518101906114a19190611f6b565b155b15610849576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105a2565b60006104756114f76020840184611f8d565b6115046020850185611fa8565b6115116040870187611fa8565b6115216080890160608a01611f8d565b60405160200161153696959493929190611fef565b6040516020818303038152906040526117cd565b6000828260405160200161157592919091825260e01b6001600160e01b031916602082015260240190565b60408051601f1981840301815291905280516020909101209392505050565b6000806402540be4006115a78486612031565b67ffffffffffffffff166115bb9190611f54565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166309b53f516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611612573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116369190612059565b63ffffffff169050600080821161164e576000611658565b6116588284611b9b565b905060008060009054906101000a90046001600160a01b03166001600160a01b031663c42b64d06040518163ffffffff1660e01b8152600401608060405180830381865afa1580156116ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d29190612076565b509250505060006402540be4008267ffffffffffffffff166116f49190611f54565b9050806117018487611bbd565b61170b9190611bbd565b98975050505050505050565b6000806000846001600160a01b03168460405161173491906120d5565b6000604051808303816000865af19150503d8060008114611771576040519150601f19603f3d011682016040523d82523d6000602084013e611776565b606091505b50915091508180156117a05750805115806117a05750808060200190518101906117a09190611f6b565b80156117b657506000856001600160a01b03163b115b95945050505050565b6060610472838360006117f4565b60006020600083516020850160025afa50602060006020600060025afa5050600051919050565b606081471015611832576040517fcd7860590000000000000000000000000000000000000000000000000000000081523060048201526024016105a2565b600080856001600160a01b0316848660405161184e91906120d5565b60006040518083038185875af1925050503d806000811461188b576040519150601f19603f3d011682016040523d82523d6000602084013e611890565b606091505b50915091506118a08683836118aa565b9695505050505050565b6060826118bf576118ba8261191f565b6110bf565b81511580156118d657506001600160a01b0384163b155b15611918576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016105a2565b50806110bf565b80511561192f5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff811681146105b457600080fd5b60006020828403121561198957600080fd5b81356110bf81611961565b6001600160a01b03811681146105b457600080fd5b80356119b481611994565b919050565b803561ffff811681146119b457600080fd5b600080604083850312156119de57600080fd5b82356119e981611994565b91506119f7602084016119b9565b90509250929050565b600060208284031215611a1257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60068110611a4d57634e487b7160e01b600052602160045260246000fd5b9052565b60608101611a5f8286611a2f565b6001600160a01b03841660208301526affffffffffffffffffffff83166040830152949350505050565b600080600080848603610120811215611aa157600080fd5b853567ffffffffffffffff811115611ab857600080fd5b860160808189031215611aca57600080fd5b945060c0601f1982011215611ade57600080fd5b5060208501925060e0850135611af381611994565b9150611b0261010086016119b9565b905092959194509250565b600060208284031215611b1f57600080fd5b81356110bf81611994565b80516020808301519190811015611b4b576000198160200360031b1b821691505b50919050565b600060208284031215611b6357600080fd5b5051919050565b60408101611b788285611a2f565b6110bf6020830184611a2f565b634e487b7160e01b600052601160045260246000fd5b600082611bb857634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561047557610475611b85565b80516119b481611994565b600060208284031215611bed57600080fd5b81516110bf81611994565b8082018082111561047557610475611b85565b63ffffffff811681146105b457600080fd5b600060208284031215611c2f57600080fd5b81356110bf81611c0b565b80356001600160e01b0319811681146119b457600080fd5b6000808335601e19843603018112611c6957600080fd5b830160208101925035905067ffffffffffffffff811115611c8957600080fd5b803603821315611c9857600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b80356bffffffffffffffffffffffff19811681146119b457600080fd5b60006101008083526001600160e01b031980611d0088611c3a565b1682850152611d126020880188611c52565b92506080610120860152611d2b61018086018483611c9f565b925050611d3b6040880188611c52565b85840360ff1901610140870152611d53848284611c9f565b9350505080611d6460608901611c3a565b166101608501525090508335611d7981611c0b565b63ffffffff811660208401525060208401357fffffffffffffffff0000000000000000000000000000000000000000000000008116808214611dba57600080fd5b80604085015250506bffffffffffffffffffffffff19611ddc60408601611cc8565b166060830152611dee60608501611cc8565b6bffffffffffffffffffffffff198116608084015250611e1060808501611c3a565b6001600160e01b0319811660a084015250611e2d60a085016119a9565b6001600160a01b031660c083015260e09091019190915292915050565b80516119b481611961565b80516119b481611c0b565b600060e08284031215611e7257600080fd5b60405160e0810181811067ffffffffffffffff82111715611ea357634e487b7160e01b600052604160045260246000fd5b604052611eaf83611bd0565b8152611ebd60208401611e4a565b6020820152611ece60408401611e55565b6040820152611edf60608401611bd0565b6060820152611ef060808401611e4a565b6080820152611f0160a08401611e55565b60a082015260c083015160c08201528091505092915050565b60008060408385031215611f2d57600080fd5b8251611f3881611961565b6020840151909250611f4981611961565b809150509250929050565b808202811582820484141761047557610475611b85565b600060208284031215611f7d57600080fd5b815180151581146110bf57600080fd5b600060208284031215611f9f57600080fd5b61047282611c3a565b6000808335601e19843603018112611fbf57600080fd5b83018035915067ffffffffffffffff821115611fda57600080fd5b602001915036819003821315611c9857600080fd5b60006001600160e01b03198089168352868860048501378683016004810160008152868882375093169390920160048101939093525050600801949350505050565b67ffffffffffffffff82811682821603908082111561205257612052611b85565b5092915050565b60006020828403121561206b57600080fd5b81516110bf81611c0b565b6000806000806080858703121561208c57600080fd5b845161209781611961565b60208601519094506120a881611961565b60408601519093506120b981611961565b60608601519092506120ca81611c0b565b939692955090935050565b6000825160005b818110156120f657602081860181015185830152016120dc565b50600092019182525091905056fea2646970667358221220462bf22e2a3e5c424c7897cc702ca2994745ded2b209ca480d6b59b6977ef88a64736f6c63430008150033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061016c5760003560e01c8063c143d675116100cd578063da9ad53c11610081578063e5d3d71411610066578063e5d3d71414610355578063e78cea9214610368578063f2fde38b1461037b57600080fd5b8063da9ad53c14610331578063e30c39781461034457600080fd5b8063c9f5a5d8116100b2578063c9f5a5d8146102b4578063d0714ad5146102c7578063d990d3ff1461031e57600080fd5b8063c143d67514610274578063c7ba0347146102a857600080fd5b8063774e2e90116101245780638da5cb5b116101095780638da5cb5b1461023d5780639bef6d521461024e578063b2e665bf1461026157600080fd5b8063774e2e90146101f257806379ba50971461023557600080fd5b80633d11a6ae116101555780633d11a6ae146101b657806369e1df8b146101d7578063715018a6146101ea57600080fd5b80630f36403a146101715780633647b205146101a1575b600080fd5b600154610184906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6101b46101af366004611977565b61038e565b005b6101c96101c43660046119cb565b61040c565b604051908152602001610198565b6101b46101e5366004611a00565b61047b565b6101b461055a565b610213610200366004611a00565b606081901c9160509190911c61ffff1690565b604080516001600160a01b03909316835261ffff909116602083015201610198565b6101b461056e565b6031546001600160a01b0316610184565b603554610184906001600160a01b031681565b6101b461026f366004611a00565b6105b7565b60355461028f90600160a01b900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610198565b6101c96402540be40081565b6101b46102c2366004611a00565b610714565b61030f6102d5366004611a00565b60336020526000908152604090205460ff81169061010081046001600160a01b031690600160a81b90046affffffffffffffffffffff1683565b60405161019893929190611a51565b6101b461032c366004611a89565b61084e565b6101b461033f366004611a00565b6108f2565b6032546001600160a01b0316610184565b603454610184906001600160a01b031681565b600054610184906001600160a01b031681565b6101b4610389366004611b0d565b6109a9565b610396610a27565b603580547fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b67ffffffffffffffff8416908102919091179091556040519081527f53a618edd6eab9ce346f438670ebd45da60fa3d85662375fae2b8beadf08faf39060200160405180910390a150565b6040516bffffffffffffffffffffffff19606084901b1660208201527fffff00000000000000000000000000000000000000000000000000000000000060f083901b16603482015260009060360160405160208183030381529060405261047290611b2a565b90505b92915050565b6104888160016003610a54565b6000818152603360205260408120906104a083610b0b565b83546001600160a01b03909116610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff90911617835590506104e381610dd7565b825474ffffffffffffffffffffffffffffffffffffffffff16600160a81b6affffffffffffffffffffff9283168102919091178085556040519190049091168152339084907ff412c1941036889a8a2aec22dca20565f685239ac78976dab58b52eb70f972fa9060200160405180910390a3505050565b610562610a27565b61056c6000610e2c565b565b60325433906001600160a01b031681146105ab5760405163118cdaa760e01b81526001600160a01b03821660048201526024015b60405180910390fd5b6105b481610e2c565b50565b6105c48160036004610a54565b600081815260336020526040812080549091600160a81b9091046affffffffffffffffffffff16900361060a57604051632145277d60e21b815260040160405180910390fd5b805474ffffffffffffffffffffffffffffffffffffffffff81168255604051600160a81b9091046affffffffffffffffffffff1680825290339084907ff0a477d0ba7b549d19236a4c6517edef5574c03ed185bad57c92c9323091af8f9060200160405180910390a3603554603454610690916001600160a01b03918216911683610e52565b6035548254604051636e553f6560e01b8152600481018490526001600160a01b0361010090920482166024820152911690636e553f65906044015b6020604051808303816000875af11580156106ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070e9190611b51565b50505050565b6107218160036005610a54565b600081815260336020526040812080549091600160a81b9091046affffffffffffffffffffff16900361076757604051632145277d60e21b815260040160405180910390fd5b805461010090046001600160a01b031633146107af576040517f709d46f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805474ffffffffffffffffffffffffffffffffffffffffff8116808355604051600160a81b9092046affffffffffffffffffffff16808352916101009091046001600160a01b03169084907f32aa57d54fb0ee2c9617ac9d5982ba7d88869fcbf89542a285d6c07b03dc504e9060200160405180910390a38154603454610849916001600160a01b03918216916101009091041683610ef5565b505050565b6001600160a01b03821661088e576040517ff606bf2a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006108a4858561089f868661040c565b610f69565b90506108b38160006001610a54565b6040516001600160a01b03841690339083907f8d019883471b734b0033fe25a5b76c3afefbbfa9e9b3dacdbabf505b9e4f455d90600090a45050505050565b6108ff8160016002610a54565b60008061090b83610b0b565b91509150336001600160a01b0316837f2b57d79a66895fd41ae6d27049952259b0d40a9b7c563a99b3f1844b288da08c8460405161094b91815260200190565b60405180910390a3603554603454610970916001600160a01b03918216911684610e52565b603554604051636e553f6560e01b8152600481018490526001600160a01b03838116602483015290911690636e553f65906044016106cb565b6109b1610a27565b603280546001600160a01b03831673ffffffffffffffffffffffffffffffffffffffff1990911681179091556109ef6031546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6031546001600160a01b0316331461056c5760405163118cdaa760e01b81523360048201526024016105a2565b816005811115610a6657610a66611a19565b60008481526033602052604090205460ff166005811115610a8957610a89611a19565b14610ad657600083815260336020526040908190205490517fbcbf502b0000000000000000000000000000000000000000000000000000000081526105a29160ff16908490600401611b6a565b6000838152603360205260409020805482919060ff19166001836005811115610b0157610b01611a19565b0217905550505050565b6000806000806000610b1c866110c6565b6034546040516370a0823160e01b815230600482015293965091945092506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610b6f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b939190611b51565b6034546040516370a0823160e01b81523060048201529192506001600160a01b0316906370a0823190602401602060405180830381865afa158015610bdc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c009190611b51565b831115610c43576040517fcad48b6900000000000000000000000000000000000000000000000000000000815260048101849052602481018290526044016105a2565b603554600090600160a01b900467ffffffffffffffff16610c65576000610c83565b603554610c8390600160a01b900467ffffffffffffffff1686611b9b565b9050838110610cc8576040517f2395edf200000000000000000000000000000000000000000000000000000000815260048101829052602481018590526044016105a2565b6000610cd48286611bbd565b6040805187815260208101859052919250606086901c9161ffff605088901c1691829133918e917f6410e64d304208a5e90fc76ab4fbf4e7b8836705daeda8dde27611ae0524490a910160405180910390a48315610dc757603554604080517f61d027b30000000000000000000000000000000000000000000000000000000081529051610dc7926001600160a01b0316916361d027b39160048083019260209291908290030181865afa158015610d90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db49190611bdb565b6034546001600160a01b03169086610ef5565b5090999098509650505050505050565b60006affffffffffffffffffffff821115610e28576040517f6dfcc65000000000000000000000000000000000000000000000000000000000815260586004820152602481018390526044016105a2565b5090565b6032805473ffffffffffffffffffffffffffffffffffffffff191690556105b481611350565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610ebb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610edf9190611b51565b905061070e8484610ef08585611bf8565b6113af565b6040516001600160a01b0383811660248301526044820183905261084991859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611469565b6001546000906001600160a01b0316610f8860c0850160a08601611b0d565b6001600160a01b031614610fde5760405162461bcd60e51b815260206004820152601660248201527f5661756c742061646472657373206d69736d617463680000000000000000000060448201526064016105a2565b6000610ffe610fec866114e5565b610ff96020870187611c1d565b61154a565b60405163ffffffff4216815290915081907fa3ed7aef0745e1a91addae9e5daee7a8ace74852fec840b9d93da747855dd7b99060200160405180910390a26000546040517f86f014390000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906386f014399061108990889088908890600401611ce5565b600060405180830381600087803b1580156110a357600080fd5b505af11580156110b7573d6000803e3d6000fd5b509293505050505b9392505050565b600080546040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018490528291829182916001600160a01b03169063b02c43d09060240160e060405180830381865afa15801561112d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111519190611e60565b9050806040015163ffffffff166000036111ad5760405162461bcd60e51b815260206004820152601760248201527f4465706f736974206e6f7420696e697469616c697a656400000000000000000060448201526064016105a2565b6001546040517f6c626aa4000000000000000000000000000000000000000000000000000000008152600481018790526000916001600160a01b031690636c626aa49060240160408051808303816000875af1158015611211573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112359190611f1a565b9150508160a0015163ffffffff16600014158061125b575067ffffffffffffffff811615155b6112cd5760405162461bcd60e51b815260206004820152602360248201527f4465706f736974206e6f742066696e616c697a6564206279207468652062726960448201527f646765000000000000000000000000000000000000000000000000000000000060648201526084016105a2565b6402540be400826020015167ffffffffffffffff166112ec9190611f54565b945061130082602001518360800151611594565b6040805182815263ffffffff4216602082015291955087917f417b6288c9f637614f8b3f7a275fb4e44e517930fde949e463d58dfe0b97f28b910160405180910390a25060c00151929491935050565b603180546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261142e8482611717565b61070e576040516001600160a01b0384811660248301526000604483015261146391869182169063095ea7b390606401610f22565b61070e84825b600061147e6001600160a01b038416836117bf565b905080516000141580156114a35750808060200190518101906114a19190611f6b565b155b15610849576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105a2565b60006104756114f76020840184611f8d565b6115046020850185611fa8565b6115116040870187611fa8565b6115216080890160608a01611f8d565b60405160200161153696959493929190611fef565b6040516020818303038152906040526117cd565b6000828260405160200161157592919091825260e01b6001600160e01b031916602082015260240190565b60408051601f1981840301815291905280516020909101209392505050565b6000806402540be4006115a78486612031565b67ffffffffffffffff166115bb9190611f54565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166309b53f516040518163ffffffff1660e01b8152600401602060405180830381865afa158015611612573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116369190612059565b63ffffffff169050600080821161164e576000611658565b6116588284611b9b565b905060008060009054906101000a90046001600160a01b03166001600160a01b031663c42b64d06040518163ffffffff1660e01b8152600401608060405180830381865afa1580156116ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d29190612076565b509250505060006402540be4008267ffffffffffffffff166116f49190611f54565b9050806117018487611bbd565b61170b9190611bbd565b98975050505050505050565b6000806000846001600160a01b03168460405161173491906120d5565b6000604051808303816000865af19150503d8060008114611771576040519150601f19603f3d011682016040523d82523d6000602084013e611776565b606091505b50915091508180156117a05750805115806117a05750808060200190518101906117a09190611f6b565b80156117b657506000856001600160a01b03163b115b95945050505050565b6060610472838360006117f4565b60006020600083516020850160025afa50602060006020600060025afa5050600051919050565b606081471015611832576040517fcd7860590000000000000000000000000000000000000000000000000000000081523060048201526024016105a2565b600080856001600160a01b0316848660405161184e91906120d5565b60006040518083038185875af1925050503d806000811461188b576040519150601f19603f3d011682016040523d82523d6000602084013e611890565b606091505b50915091506118a08683836118aa565b9695505050505050565b6060826118bf576118ba8261191f565b6110bf565b81511580156118d657506001600160a01b0384163b155b15611918576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016105a2565b50806110bf565b80511561192f5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b67ffffffffffffffff811681146105b457600080fd5b60006020828403121561198957600080fd5b81356110bf81611961565b6001600160a01b03811681146105b457600080fd5b80356119b481611994565b919050565b803561ffff811681146119b457600080fd5b600080604083850312156119de57600080fd5b82356119e981611994565b91506119f7602084016119b9565b90509250929050565b600060208284031215611a1257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60068110611a4d57634e487b7160e01b600052602160045260246000fd5b9052565b60608101611a5f8286611a2f565b6001600160a01b03841660208301526affffffffffffffffffffff83166040830152949350505050565b600080600080848603610120811215611aa157600080fd5b853567ffffffffffffffff811115611ab857600080fd5b860160808189031215611aca57600080fd5b945060c0601f1982011215611ade57600080fd5b5060208501925060e0850135611af381611994565b9150611b0261010086016119b9565b905092959194509250565b600060208284031215611b1f57600080fd5b81356110bf81611994565b80516020808301519190811015611b4b576000198160200360031b1b821691505b50919050565b600060208284031215611b6357600080fd5b5051919050565b60408101611b788285611a2f565b6110bf6020830184611a2f565b634e487b7160e01b600052601160045260246000fd5b600082611bb857634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561047557610475611b85565b80516119b481611994565b600060208284031215611bed57600080fd5b81516110bf81611994565b8082018082111561047557610475611b85565b63ffffffff811681146105b457600080fd5b600060208284031215611c2f57600080fd5b81356110bf81611c0b565b80356001600160e01b0319811681146119b457600080fd5b6000808335601e19843603018112611c6957600080fd5b830160208101925035905067ffffffffffffffff811115611c8957600080fd5b803603821315611c9857600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b80356bffffffffffffffffffffffff19811681146119b457600080fd5b60006101008083526001600160e01b031980611d0088611c3a565b1682850152611d126020880188611c52565b92506080610120860152611d2b61018086018483611c9f565b925050611d3b6040880188611c52565b85840360ff1901610140870152611d53848284611c9f565b9350505080611d6460608901611c3a565b166101608501525090508335611d7981611c0b565b63ffffffff811660208401525060208401357fffffffffffffffff0000000000000000000000000000000000000000000000008116808214611dba57600080fd5b80604085015250506bffffffffffffffffffffffff19611ddc60408601611cc8565b166060830152611dee60608501611cc8565b6bffffffffffffffffffffffff198116608084015250611e1060808501611c3a565b6001600160e01b0319811660a084015250611e2d60a085016119a9565b6001600160a01b031660c083015260e09091019190915292915050565b80516119b481611961565b80516119b481611c0b565b600060e08284031215611e7257600080fd5b60405160e0810181811067ffffffffffffffff82111715611ea357634e487b7160e01b600052604160045260246000fd5b604052611eaf83611bd0565b8152611ebd60208401611e4a565b6020820152611ece60408401611e55565b6040820152611edf60608401611bd0565b6060820152611ef060808401611e4a565b6080820152611f0160a08401611e55565b60a082015260c083015160c08201528091505092915050565b60008060408385031215611f2d57600080fd5b8251611f3881611961565b6020840151909250611f4981611961565b809150509250929050565b808202811582820484141761047557610475611b85565b600060208284031215611f7d57600080fd5b815180151581146110bf57600080fd5b600060208284031215611f9f57600080fd5b61047282611c3a565b6000808335601e19843603018112611fbf57600080fd5b83018035915067ffffffffffffffff821115611fda57600080fd5b602001915036819003821315611c9857600080fd5b60006001600160e01b03198089168352868860048501378683016004810160008152868882375093169390920160048101939093525050600801949350505050565b67ffffffffffffffff82811682821603908082111561205257612052611b85565b5092915050565b60006020828403121561206b57600080fd5b81516110bf81611c0b565b6000806000806080858703121561208c57600080fd5b845161209781611961565b60208601519094506120a881611961565b60408601519093506120b981611961565b60608601519092506120ca81611c0b565b939692955090935050565b6000825160005b818110156120f657602081860181015185830152016120dc565b50600092019182525091905056fea2646970667358221220462bf22e2a3e5c424c7897cc702ca2994745ded2b209ca480d6b59b6977ef88a64736f6c63430008150033", + "devdoc": { + "errors": { + "AddressEmptyCode(address)": [ + { + "details": "There's no code at `target` (it is not a contract)." + } + ], + "AddressInsufficientBalance(address)": [ + { + "details": "The ETH balance of the account is not enough to perform the operation." + } + ], + "BridgingCompletionAlreadyNotified()": [ + { + "details": "Attempted to notify a bridging completion, while it was already notified." + } + ], + "BridgingFinalizationAlreadyCalled()": [ + { + "details": "Attempted to call bridging finalization for a stake request for which the function was already called." + } + ], + "BridgingNotCompleted()": [ + { + "details": "Attempted to finalize a stake request, while bridging completion has not been notified yet." + } + ], + "CallerNotStaker()": [ + { + "details": "Attempted to call function by an account that is not the staker." + } + ], + "DepositorFeeExceedsBridgedAmount(uint256,uint256)": [ + { + "details": "Calculated depositor fee exceeds the amount of minted tBTC tokens." + } + ], + "FailedInnerCall()": [ + { + "details": "A call to an address target failed. The target may have reverted." + } + ], + "InsufficientTbtcBalance(uint256,uint256)": [ + { + "details": "Attempted to finalize bridging with depositor's contract tBTC balance lower than the calculated bridged tBTC amount. This error means that Governance should top-up the tBTC reserve for bridging fees approximation." + } + ], + "OwnableInvalidOwner(address)": [ + { + "details": "The owner is not a valid owner account. (eg. `address(0)`)" + } + ], + "OwnableUnauthorizedAccount(address)": [ + { + "details": "The caller account is not authorized to perform an operation." + } + ], + "SafeCastOverflowedUintDowncast(uint8,uint256)": [ + { + "details": "Value doesn't fit in an uint of `bits` size." + } + ], + "SafeERC20FailedOperation(address)": [ + { + "details": "An operation with an ERC20 token failed." + } + ], + "StakeRequestNotQueued()": [ + { + "details": "Attempted to finalize or cancel a stake request that was not added to the queue, or was already finalized or cancelled." + } + ], + "StakerIsZeroAddress()": [ + { + "details": "Staker address is zero." + } + ], + "UnexpectedStakeRequestState(uint8,uint8)": [ + { + "details": "Attempted to execute function for stake request in unexpected current state." + } + ] + }, + "events": { + "BridgingCompleted(uint256,address,uint16,uint256,uint256)": { + "params": { + "bridgedAmount": "Amount of tBTC tokens that was bridged by the tBTC bridge.", + "caller": "Address that notified about bridging completion.", + "depositKey": "Deposit key identifying the deposit.", + "depositorFee": "Depositor fee amount.", + "referral": "Identifier of a partner in the referral program." + } + }, + "DepositorFeeDivisorUpdated(uint64)": { + "params": { + "depositorFeeDivisor": "New value of the depositor fee divisor." + } + }, + "StakeRequestCancelledFromQueue(uint256,address,uint256)": { + "params": { + "amountToStake": "Amount of queued tBTC tokens that got cancelled.", + "depositKey": "Deposit key identifying the deposit.", + "staker": "Address of the staker." + } + }, + "StakeRequestFinalized(uint256,address,uint256)": { + "details": "Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.", + "params": { + "caller": "Address that finalized the stake request.", + "depositKey": "Deposit key identifying the deposit.", + "stakedAmount": "Amount of staked tBTC tokens." + } + }, + "StakeRequestFinalizedFromQueue(uint256,address,uint256)": { + "details": "Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.", + "params": { + "caller": "Address that finalized the stake request.", + "depositKey": "Deposit key identifying the deposit.", + "stakedAmount": "Amount of staked tBTC tokens." + } + }, + "StakeRequestInitialized(uint256,address,address)": { + "details": "Deposit details can be fetched from {{ Bridge.DepositRevealed }} event emitted in the same transaction.", + "params": { + "caller": "Address that initialized the stake request.", + "depositKey": "Deposit key identifying the deposit.", + "staker": "The address to which the stBTC shares will be minted." + } + }, + "StakeRequestQueued(uint256,address,uint256)": { + "params": { + "caller": "Address that finalized the stake request.", + "depositKey": "Deposit key identifying the deposit.", + "queuedAmount": "Amount of queued tBTC tokens." + } + } + }, + "kind": "dev", + "methods": { + "acceptOwnership()": { + "details": "The new owner accepts the ownership transfer." + }, + "cancelQueuedStake(uint256)": { + "details": "This function can be called only after the stake request was added to queue.Only staker provided in the extra data of the stake request can call this function.", + "params": { + "depositKey": "Deposit key identifying the deposit." + } + }, + "constructor": { + "params": { + "_stbtc": "stBTC contract instance.", + "_tbtcToken": "tBTC token contract instance.", + "bridge": "tBTC Bridge contract instance.", + "tbtcVault": "tBTC Vault contract instance." + } + }, + "decodeExtraData(bytes32)": { + "details": "Unpacks the data from bytes32: 20 bytes of staker address and 2 bytes of referral, 10 bytes of trailing zeros.", + "params": { + "extraData": "Encoded extra data." + }, + "returns": { + "referral": "Data used for referral program.", + "staker": "The address to which the stBTC shares will be minted." + } + }, + "encodeExtraData(address,uint16)": { + "details": "Packs the data to bytes32: 20 bytes of staker address and 2 bytes of referral, 10 bytes of trailing zeros.", + "params": { + "referral": "Data used for referral program.", + "staker": "The address to which the stBTC shares will be minted." + }, + "returns": { + "_0": "Encoded extra data." + } + }, + "finalizeQueuedStake(uint256)": { + "params": { + "depositKey": "Deposit key identifying the deposit." + } + }, + "finalizeStake(uint256)": { + "details": "In case depositing in stBTC vault fails (e.g. because of the maximum deposit limit being reached), the `queueStake` function should be called to add the stake request to the staking queue.", + "params": { + "depositKey": "Deposit key identifying the deposit." + } + }, + "initializeStake((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)": { + "details": "Requirements: - The revealed vault address must match the TBTCVault address, - All requirements from {Bridge#revealDepositWithExtraData} function must be met. - `staker` must be the staker address used in the P2(W)SH BTC deposit transaction as part of the extra data. - `referral` must be the referral info used in the P2(W)SH BTC deposit transaction as part of the extra data. - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex` can be revealed only one time.", + "params": { + "fundingTx": "Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.", + "referral": "Data used for referral program.", + "reveal": "Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.", + "staker": "The address to which the stBTC shares will be minted." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "pendingOwner()": { + "details": "Returns the address of the pending owner." + }, + "queueStake(uint256)": { + "details": "It queues the stake request, until the stBTC vault is ready to accept the deposit. The request must be finalized with `finalizeQueuedStake` after the limit is increased or other user withdraws their funds from the stBTC contract to make place for another deposit. The staker has a possibility to submit `cancelQueuedStake` that will withdraw the minted tBTC token and abort staking process.", + "params": { + "depositKey": "Deposit key identifying the deposit." + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner." + }, + "updateDepositorFeeDivisor(uint64)": { + "params": { + "newDepositorFeeDivisor": "New depositor fee divisor value." + } + } + }, + "stateVariables": { + "depositorFeeDivisor": { + "details": "That fee is computed as follows: `depositorFee = depositedAmount / depositorFeeDivisor` for example, if the depositor fee needs to be 2% of each deposit, the `depositorFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`." + }, + "stakeRequests": { + "details": "The key is a deposit key identifying the deposit." + } + }, + "title": "Acre Bitcoin Depositor contract.", + "version": 1 + }, + "userdoc": { + "errors": { + "StbtcZeroAddress()": [ + { + "notice": "Reverts if the stBTC address is zero." + } + ], + "TbtcTokenZeroAddress()": [ + { + "notice": "Reverts if the tBTC Token address is zero." + } + ] + }, + "events": { + "BridgingCompleted(uint256,address,uint16,uint256,uint256)": { + "notice": "Emitted when bridging completion has been notified." + }, + "DepositorFeeDivisorUpdated(uint64)": { + "notice": "Emitted when a depositor fee divisor is updated." + }, + "StakeRequestCancelledFromQueue(uint256,address,uint256)": { + "notice": "Emitted when a queued stake request is cancelled." + }, + "StakeRequestFinalized(uint256,address,uint256)": { + "notice": "Emitted when a stake request is finalized." + }, + "StakeRequestFinalizedFromQueue(uint256,address,uint256)": { + "notice": "Emitted when a stake request is finalized from the queue." + }, + "StakeRequestInitialized(uint256,address,address)": { + "notice": "Emitted when a stake request is initialized." + }, + "StakeRequestQueued(uint256,address,uint256)": { + "notice": "Emitted when a stake request is queued." + } + }, + "kind": "user", + "methods": { + "SATOSHI_MULTIPLIER()": { + "notice": "Multiplier to convert satoshi to TBTC token units." + }, + "bridge()": { + "notice": "Bridge contract address." + }, + "cancelQueuedStake(uint256)": { + "notice": "Cancel queued stake. The function can be called by the staker to recover tBTC that cannot be finalized to stake in stBTC contract due to a deposit limit being reached." + }, + "constructor": { + "notice": "Acre Bitcoin Depositor contract constructor." + }, + "decodeExtraData(bytes32)": { + "notice": "Decodes staker address and referral from extra data." + }, + "depositorFeeDivisor()": { + "notice": "Divisor used to compute the depositor fee taken from each deposit and transferred to the treasury upon stake request finalization." + }, + "encodeExtraData(address,uint16)": { + "notice": "Encodes staker address and referral as extra data." + }, + "finalizeQueuedStake(uint256)": { + "notice": "This function should be called for previously queued stake request, when stBTC vault is able to accept a deposit." + }, + "finalizeStake(uint256)": { + "notice": "This function should be called for previously initialized stake request, after tBTC bridging process was finalized. It stakes the tBTC from the given deposit into stBTC, emitting the stBTC shares to the staker specified in the deposit extra data and using the referral provided in the extra data." + }, + "initializeStake((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)": { + "notice": "This function allows staking process initialization for a Bitcoin deposit made by an user with a P2(W)SH transaction. It uses the supplied information to reveal a deposit to the tBTC Bridge contract." + }, + "queueStake(uint256)": { + "notice": "This function should be called for previously initialized stake request, after tBTC bridging process was finalized, in case the `finalizeStake` failed due to stBTC vault deposit limit being reached." + }, + "stakeRequests(uint256)": { + "notice": "Mapping of stake requests." + }, + "stbtc()": { + "notice": "stBTC contract." + }, + "tbtcToken()": { + "notice": "tBTC Token contract." + }, + "tbtcVault()": { + "notice": "TBTCVault contract address." + }, + "updateDepositorFeeDivisor(uint64)": { + "notice": "Updates the depositor fee divisor." + } + }, + "notice": "The contract integrates Acre staking with tBTC minting. User who wants to stake BTC in Acre should submit a Bitcoin transaction to the most recently created off-chain ECDSA wallets of the tBTC Bridge using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH) containing hashed information about this Depositor contract address, and staker's Ethereum address. Then, the staker initiates tBTC minting by revealing their Ethereum address along with their deposit blinding factor, refund public key hash and refund locktime on the tBTC Bridge through this Depositor contract. The off-chain ECDSA wallet and Optimistic Minting bots listen for these sorts of messages and when they get one, they check the Bitcoin network to make sure the deposit lines up. Majority of tBTC minting is finalized by the Optimistic Minting process, where Minter bot initializes minting process and if there is no veto from the Guardians, the process is finalized and tBTC minted to the Depositor address. If the revealed deposit is not handled by the Optimistic Minting process the off-chain ECDSA wallet may decide to pick the deposit transaction for sweeping, and when the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge and tBTC vault mint the tBTC token to the Depositor address. After tBTC is minted to the Depositor, on the stake finalization tBTC is staked in stBTC contract and stBTC shares are emitted to the staker.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 2683, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "bridge", + "offset": 0, + "slot": "0", + "type": "t_contract(IBridge)3087" + }, + { + "astId": 2687, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "tbtcVault", + "offset": 0, + "slot": "1", + "type": "t_contract(ITBTCVault)3107" + }, + { + "astId": 2691, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "__gap", + "offset": 0, + "slot": "2", + "type": "t_array(t_uint256)47_storage" + }, + { + "astId": 3585, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "_owner", + "offset": 0, + "slot": "49", + "type": "t_address" + }, + { + "astId": 3733, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "_pendingOwner", + "offset": 0, + "slot": "50", + "type": "t_address" + }, + { + "astId": 8874, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "stakeRequests", + "offset": 0, + "slot": "51", + "type": "t_mapping(t_uint256,t_struct(StakeRequest)8868_storage)" + }, + { + "astId": 8878, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "tbtcToken", + "offset": 0, + "slot": "52", + "type": "t_contract(IERC20)4710" + }, + { + "astId": 8882, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "stbtc", + "offset": 0, + "slot": "53", + "type": "t_contract(stBTC)10351" + }, + { + "astId": 8885, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "depositorFeeDivisor", + "offset": 20, + "slot": "53", + "type": "t_uint64" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)47_storage": { + "base": "t_uint256", + "encoding": "inplace", + "label": "uint256[47]", + "numberOfBytes": "1504" + }, + "t_contract(IBridge)3087": { + "encoding": "inplace", + "label": "contract IBridge", + "numberOfBytes": "20" + }, + "t_contract(IERC20)4710": { + "encoding": "inplace", + "label": "contract IERC20", + "numberOfBytes": "20" + }, + "t_contract(ITBTCVault)3107": { + "encoding": "inplace", + "label": "contract ITBTCVault", + "numberOfBytes": "20" + }, + "t_contract(stBTC)10351": { + "encoding": "inplace", + "label": "contract stBTC", + "numberOfBytes": "20" + }, + "t_enum(StakeRequestState)8860": { + "encoding": "inplace", + "label": "enum AcreBitcoinDepositor.StakeRequestState", + "numberOfBytes": "1" + }, + "t_mapping(t_uint256,t_struct(StakeRequest)8868_storage)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => struct AcreBitcoinDepositor.StakeRequest)", + "numberOfBytes": "32", + "value": "t_struct(StakeRequest)8868_storage" + }, + "t_struct(StakeRequest)8868_storage": { + "encoding": "inplace", + "label": "struct AcreBitcoinDepositor.StakeRequest", + "members": [ + { + "astId": 8863, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "state", + "offset": 0, + "slot": "0", + "type": "t_enum(StakeRequestState)8860" + }, + { + "astId": 8865, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "staker", + "offset": 1, + "slot": "0", + "type": "t_address" + }, + { + "astId": 8867, + "contract": "contracts/AcreBitcoinDepositor.sol:AcreBitcoinDepositor", + "label": "queuedAmount", + "offset": 21, + "slot": "0", + "type": "t_uint88" + } + ], + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint64": { + "encoding": "inplace", + "label": "uint64", + "numberOfBytes": "8" + }, + "t_uint88": { + "encoding": "inplace", + "label": "uint88", + "numberOfBytes": "11" + } + } + } +} \ No newline at end of file diff --git a/sdk/src/lib/ethereum/artifacts/sepolia/TbtcDepositor.json b/sdk/src/lib/ethereum/artifacts/sepolia/TbtcDepositor.json deleted file mode 100644 index e0adc1fc6..000000000 --- a/sdk/src/lib/ethereum/artifacts/sepolia/TbtcDepositor.json +++ /dev/null @@ -1,1073 +0,0 @@ -{ - "address": "0x94c99365944F122EeD3860696D3964D6B5c3c730", - "abi": [ - { - "inputs": [ - { - "internalType": "address", - "name": "_bridge", - "type": "address" - }, - { - "internalType": "address", - "name": "_tbtcVault", - "type": "address" - }, - { - "internalType": "address", - "name": "_tbtcToken", - "type": "address" - }, - { - "internalType": "address", - "name": "_stbtc", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "target", - "type": "address" - } - ], - "name": "AddressEmptyCode", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "AddressInsufficientBalance", - "type": "error" - }, - { - "inputs": [], - "name": "BridgingNotCompleted", - "type": "error" - }, - { - "inputs": [], - "name": "CallerNotReceiver", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "depositorFee", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bridgedAmount", - "type": "uint256" - } - ], - "name": "DepositorFeeExceedsBridgedAmount", - "type": "error" - }, - { - "inputs": [], - "name": "FailedInnerCall", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "OwnableInvalidOwner", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "OwnableUnauthorizedAccount", - "type": "error" - }, - { - "inputs": [], - "name": "ReceiverIsZeroAddress", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - } - ], - "name": "SafeERC20FailedOperation", - "type": "error" - }, - { - "inputs": [], - "name": "StakeRequestAlreadyFinalized", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": true, - "internalType": "uint16", - "name": "referral", - "type": "uint16" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bridgedAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "depositorFee", - "type": "uint256" - } - ], - "name": "BridgingCompleted", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "tbtcAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "finalizedAt", - "type": "uint32" - } - ], - "name": "DepositFinalized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint32", - "name": "initializedAt", - "type": "uint32" - } - ], - "name": "DepositInitialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint64", - "name": "depositorFeeDivisor", - "type": "uint64" - } - ], - "name": "DepositorFeeDivisorUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferred", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountToStake", - "type": "uint256" - } - ], - "name": "StakeRequestFinalized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "caller", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "receiver", - "type": "address" - } - ], - "name": "StakeRequestInitialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amountToStake", - "type": "uint256" - } - ], - "name": "StakeRequestRecalled", - "type": "event" - }, - { - "inputs": [], - "name": "SATOSHI_MULTIPLIER", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "bridge", - "outputs": [ - { - "internalType": "contract IBridge", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "depositorFeeDivisor", - "outputs": [ - { - "internalType": "uint64", - "name": "", - "type": "uint64" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "uint16", - "name": "referral", - "type": "uint16" - } - ], - "name": "encodeExtraData", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "pure", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - } - ], - "name": "finalizeStakeRequest", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "bytes4", - "name": "version", - "type": "bytes4" - }, - { - "internalType": "bytes", - "name": "inputVector", - "type": "bytes" - }, - { - "internalType": "bytes", - "name": "outputVector", - "type": "bytes" - }, - { - "internalType": "bytes4", - "name": "locktime", - "type": "bytes4" - } - ], - "internalType": "struct IBridgeTypes.BitcoinTxInfo", - "name": "fundingTx", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint32", - "name": "fundingOutputIndex", - "type": "uint32" - }, - { - "internalType": "bytes8", - "name": "blindingFactor", - "type": "bytes8" - }, - { - "internalType": "bytes20", - "name": "walletPubKeyHash", - "type": "bytes20" - }, - { - "internalType": "bytes20", - "name": "refundPubKeyHash", - "type": "bytes20" - }, - { - "internalType": "bytes4", - "name": "refundLocktime", - "type": "bytes4" - }, - { - "internalType": "address", - "name": "vault", - "type": "address" - } - ], - "internalType": "struct IBridgeTypes.DepositRevealInfo", - "name": "reveal", - "type": "tuple" - }, - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "uint16", - "name": "referral", - "type": "uint16" - } - ], - "name": "initializeStakeRequest", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - } - ], - "name": "notifyBridgingCompleted", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "pendingDeposits", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "depositKey", - "type": "uint256" - } - ], - "name": "recallStakeRequest", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "stakeRequests", - "outputs": [ - { - "internalType": "uint64", - "name": "finalizedAt", - "type": "uint64" - }, - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "uint16", - "name": "referral", - "type": "uint16" - }, - { - "internalType": "uint256", - "name": "amountToStake", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "stbtc", - "outputs": [ - { - "internalType": "contract stBTC", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "tbtcToken", - "outputs": [ - { - "internalType": "contract IERC20", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "tbtcVault", - "outputs": [ - { - "internalType": "contract ITBTCVault", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint64", - "name": "newDepositorFeeDivisor", - "type": "uint64" - } - ], - "name": "updateDepositorFeeDivisor", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } - ], - "transactionHash": "0x3011d3cfe0b5c46457b742615b27e2bf14d600d0b5065d9fbecf5a4aaa156f9a", - "receipt": { - "to": null, - "from": "0x2d154A5c7cE9939274b89bbCe9f5B069E57b09A8", - "contractAddress": "0x94c99365944F122EeD3860696D3964D6B5c3c730", - "transactionIndex": 82, - "gasUsed": "1782857", - "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000400000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000c01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000012000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0x400ca15fec6b03138b76dcf24adb360bae43054b70be28ee09ca072bdfe9b971", - "transactionHash": "0x3011d3cfe0b5c46457b742615b27e2bf14d600d0b5065d9fbecf5a4aaa156f9a", - "logs": [ - { - "transactionIndex": 82, - "blockNumber": 5206362, - "transactionHash": "0x3011d3cfe0b5c46457b742615b27e2bf14d600d0b5065d9fbecf5a4aaa156f9a", - "address": "0x94c99365944F122EeD3860696D3964D6B5c3c730", - "topics": [ - "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "0x0000000000000000000000002d154a5c7ce9939274b89bbce9f5b069e57b09a8" - ], - "data": "0x", - "logIndex": 108, - "blockHash": "0x400ca15fec6b03138b76dcf24adb360bae43054b70be28ee09ca072bdfe9b971" - } - ], - "blockNumber": 5206362, - "cumulativeGasUsed": "8847472", - "status": 1, - "byzantium": true - }, - "args": [ - "0x9b1a7fE5a16A15F2f9475C5B231750598b113403", - "0xB5679dE944A79732A75CE556191DF11F489448d5", - "0x517f2982701695D4E52f1ECFBEf3ba31Df470161", - "0xF99139f09164B092bD9e8558984Becfb0d2eCb87" - ], - "numDeployments": 1, - "solcInputHash": "b22c277b248ba02f9ec5bf62d176f9ce", - "metadata": "{\"compiler\":{\"version\":\"0.8.21+commit.d9974bed\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_bridge\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tbtcVault\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tbtcToken\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stbtc\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"}],\"name\":\"AddressEmptyCode\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"AddressInsufficientBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BridgingNotCompleted\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"CallerNotReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositorFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"bridgedAmount\",\"type\":\"uint256\"}],\"name\":\"DepositorFeeExceedsBridgedAmount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FailedInnerCall\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ReceiverIsZeroAddress\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"name\":\"SafeERC20FailedOperation\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeRequestAlreadyFinalized\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"bridgedAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"depositorFee\",\"type\":\"uint256\"}],\"name\":\"BridgingCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tbtcAmount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"finalizedAt\",\"type\":\"uint32\"}],\"name\":\"DepositFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"initializedAt\",\"type\":\"uint32\"}],\"name\":\"DepositInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositorFeeDivisor\",\"type\":\"uint64\"}],\"name\":\"DepositorFeeDivisorUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"}],\"name\":\"StakeRequestFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"caller\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"StakeRequestInitialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"}],\"name\":\"StakeRequestRecalled\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"SATOSHI_MULTIPLIER\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contract IBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositorFeeDivisor\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"name\":\"encodeExtraData\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"finalizeStakeRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"struct IBridgeTypes.BitcoinTxInfo\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"struct IBridgeTypes.DepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"}],\"name\":\"initializeStakeRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"notifyBridgingCompleted\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"pendingDeposits\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"recallStakeRequest\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"stakeRequests\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"finalizedAt\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referral\",\"type\":\"uint16\"},{\"internalType\":\"uint256\",\"name\":\"amountToStake\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stbtc\",\"outputs\":[{\"internalType\":\"contract stBTC\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcVault\",\"outputs\":[{\"internalType\":\"contract ITBTCVault\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"newDepositorFeeDivisor\",\"type\":\"uint64\"}],\"name\":\"updateDepositorFeeDivisor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"AddressEmptyCode(address)\":[{\"details\":\"There's no code at `target` (it is not a contract).\"}],\"AddressInsufficientBalance(address)\":[{\"details\":\"The ETH balance of the account is not enough to perform the operation.\"}],\"BridgingNotCompleted()\":[{\"details\":\"Attempted to finalize a stake request, while bridging completion has not been notified yet.\"}],\"CallerNotReceiver()\":[{\"details\":\"Attempted to call function by an account that is not the receiver.\"}],\"DepositorFeeExceedsBridgedAmount(uint256,uint256)\":[{\"details\":\"Calculated depositor fee exceeds the amount of minted tBTC tokens.\"}],\"FailedInnerCall()\":[{\"details\":\"A call to an address target failed. The target may have reverted.\"}],\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}],\"ReceiverIsZeroAddress()\":[{\"details\":\"Receiver address is zero.\"}],\"SafeERC20FailedOperation(address)\":[{\"details\":\"An operation with an ERC20 token failed.\"}],\"StakeRequestAlreadyFinalized()\":[{\"details\":\"Attempted to finalize a stake request that was already finalized.\"}]},\"events\":{\"BridgingCompleted(uint256,address,uint16,uint256,uint256)\":{\"params\":{\"bridgedAmount\":\"Amount of tBTC tokens that was bridged by the tBTC bridge.\",\"caller\":\"Address that notified about bridging completion.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"depositorFee\":\"Depositor fee amount.\",\"referral\":\"Identifier of a partner in the referral program.\"}},\"DepositorFeeDivisorUpdated(uint64)\":{\"params\":{\"depositorFeeDivisor\":\"New value of the depositor fee divisor.\"}},\"StakeRequestFinalized(uint256,address,uint256)\":{\"details\":\"Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.\",\"params\":{\"amountToStake\":\"Amount of staked tBTC tokens.\",\"caller\":\"Address that finalized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\"}},\"StakeRequestInitialized(uint256,address,address)\":{\"details\":\"Deposit details can be fetched from {{ Bridge.DepositRevealed }} event emitted in the same transaction.\",\"params\":{\"caller\":\"Address that initialized the stake request.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"receiver\":\"The address to which the stBTC shares will be minted.\"}},\"StakeRequestRecalled(uint256,address,uint256)\":{\"params\":{\"amountToStake\":\"Amount of recalled tBTC tokens.\",\"depositKey\":\"Deposit key identifying the deposit.\",\"receiver\":\"Address of the receiver.\"}}},\"kind\":\"dev\",\"methods\":{\"constructor\":{\"params\":{\"_bridge\":\"tBTC Bridge contract instance.\",\"_stbtc\":\"stBTC contract instance.\",\"_tbtcVault\":\"tBTC Vault contract instance.\"}},\"encodeExtraData(address,uint16)\":{\"details\":\"Packs the data to bytes32: 20 bytes of receiver address and 2 bytes of referral, 10 bytes of trailing zeros.\",\"params\":{\"receiver\":\"The address to which the stBTC shares will be minted.\",\"referral\":\"Data used for referral program.\"},\"returns\":{\"_0\":\"Encoded extra data.\"}},\"finalizeStakeRequest(uint256)\":{\"details\":\"This function is expected to be called after `notifyBridgingCompleted`. In case depositing in stBTC vault fails (e.g. because of the maximum deposit limit being reached), the function should be retried after the limit is increased or other user withdraws their funds from the stBTC contract to make place for another deposit. The staker has a possibility to submit `recallStakeRequest` that will withdraw the minted tBTC token and abort staking process.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"initializeStakeRequest((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)\":{\"details\":\"Requirements: - The revealed vault address must match the TBTCVault address, - All requirements from {Bridge#revealDepositWithExtraData} function must be met. - `receiver` must be the receiver address used in the P2(W)SH BTC deposit transaction as part of the extra data. - `referral` must be the referral info used in the P2(W)SH BTC deposit transaction as part of the extra data. - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex` can be revealed only one time.\",\"params\":{\"fundingTx\":\"Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\",\"receiver\":\"The address to which the stBTC shares will be minted.\",\"referral\":\"Data used for referral program.\",\"reveal\":\"Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\"}},\"notifyBridgingCompleted(uint256)\":{\"details\":\"It calculates the amount to stake based on the approximate minted tBTC amount reduced by the depositor fee.IMPORTANT NOTE: The minted tBTC amount used by this function is an approximation. See documentation of the {{TBTCDepositorProxy#_calculateTbtcAmount}} responsible for calculating this value for more details.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"recallStakeRequest(uint256)\":{\"details\":\"This function can be called only after bridging in tBTC Bridge was completed. Only receiver provided in the extra data of the stake request can call this function.\",\"params\":{\"depositKey\":\"Deposit key identifying the deposit.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"updateDepositorFeeDivisor(uint64)\":{\"params\":{\"newDepositorFeeDivisor\":\"New depositor fee divisor value.\"}}},\"stateVariables\":{\"depositorFeeDivisor\":{\"details\":\"That fee is computed as follows: `depositorFee = depositedAmount / depositorFeeDivisor` for example, if the depositor fee needs to be 2% of each deposit, the `depositorFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`.\"},\"stakeRequests\":{\"details\":\"The key is a deposit key identifying the deposit.\"}},\"title\":\"tBTC Depositor contract.\",\"version\":1},\"userdoc\":{\"events\":{\"BridgingCompleted(uint256,address,uint16,uint256,uint256)\":{\"notice\":\"Emitted when bridging completion has been notified.\"},\"DepositorFeeDivisorUpdated(uint64)\":{\"notice\":\"Emitted when a depositor fee divisor is updated.\"},\"StakeRequestFinalized(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is finalized.\"},\"StakeRequestInitialized(uint256,address,address)\":{\"notice\":\"Emitted when a stake request is initialized.\"},\"StakeRequestRecalled(uint256,address,uint256)\":{\"notice\":\"Emitted when a stake request is recalled.\"}},\"kind\":\"user\",\"methods\":{\"SATOSHI_MULTIPLIER()\":{\"notice\":\"Multiplier to convert satoshi to TBTC token units.\"},\"bridge()\":{\"notice\":\"Bridge contract address.\"},\"constructor\":{\"notice\":\"Tbtc Depositor contract constructor.\"},\"depositorFeeDivisor()\":{\"notice\":\"Divisor used to compute the depositor fee taken from each deposit and transferred to the treasury upon stake request finalization.\"},\"encodeExtraData(address,uint16)\":{\"notice\":\"Encode receiver address and referral as extra data.\"},\"finalizeStakeRequest(uint256)\":{\"notice\":\"This function should be called for previously initialized stake request, after tBTC bridging process was finalized. It stakes the tBTC from the given deposit into stBTC, emitting the stBTC shares to the receiver specified in the deposit extra data and using the referral provided in the extra data.\"},\"initializeStakeRequest((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)\":{\"notice\":\"This function allows staking process initialization for a Bitcoin deposit made by an user with a P2(W)SH transaction. It uses the supplied information to reveal a deposit to the tBTC Bridge contract.\"},\"notifyBridgingCompleted(uint256)\":{\"notice\":\"This function should be called for previously initialized stake request, after tBTC minting process completed, meaning tBTC was minted to this contract.\"},\"pendingDeposits(uint256)\":{\"notice\":\"Mapping holding information about pending deposits that have been initialized but not finalized yet. If the deposit is not in this mapping it means it has already been finalized or it has not been initialized yet.\"},\"recallStakeRequest(uint256)\":{\"notice\":\"Recall bridged tBTC tokens from being requested to stake. This function can be called by the staker to recover tBTC that cannot be finalized to stake in stBTC contract due to a deposit limit being reached.\"},\"stakeRequests(uint256)\":{\"notice\":\"Mapping of stake requests.\"},\"stbtc()\":{\"notice\":\"stBTC contract.\"},\"tbtcToken()\":{\"notice\":\"tBTC Token contract.\"},\"tbtcVault()\":{\"notice\":\"TBTCVault contract address.\"},\"updateDepositorFeeDivisor(uint64)\":{\"notice\":\"Updates the depositor fee divisor.\"}},\"notice\":\"The contract integrates Acre staking with tBTC minting. User who wants to stake BTC in Acre should submit a Bitcoin transaction to the most recently created off-chain ECDSA wallets of the tBTC Bridge using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH) containing hashed information about this Depositor contract address, and staker's Ethereum address. Then, the staker initiates tBTC minting by revealing their Ethereum address along with their deposit blinding factor, refund public key hash and refund locktime on the tBTC Bridge through this Depositor contract. The off-chain ECDSA wallet listens for these sorts of messages and when it gets one, it checks the Bitcoin network to make sure the deposit lines up. If it does, the off-chain ECDSA wallet may decide to pick the deposit transaction for sweeping, and when the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge and tBTC vault mint the tBTC token to the Depositor address. After tBTC is minted to the Depositor, on the stake finalization tBTC is staked in stBTC contract and stBTC shares are emitted to the receiver pointed by the staker.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/TbtcDepositor.sol\":\"TbtcDepositor\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to \\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\nPermission is hereby granted, free of charge, to any person obtaining\\na copy of this software and associated documentation files (the\\n\\\"Software\\\"), to deal in the Software without restriction, including\\nwithout limitation the rights to use, copy, modify, merge, publish,\\ndistribute, sublicense, and/or sell copies of the Software, and to\\npermit persons to whom the Software is furnished to do so, subject to\\nthe following conditions:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\\n*/\\n\\n\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\n\\nimport \\\"./IBridge.sol\\\";\\nimport \\\"./ITBTCVault.sol\\\";\\n\\n/// @title Abstract AbstractTBTCDepositor contract.\\n/// @notice This abstract contract is meant to facilitate integration of protocols\\n/// aiming to use tBTC as an underlying Bitcoin bridge.\\n///\\n/// Such an integrator is supposed to:\\n/// - Create a child contract inheriting from this abstract contract\\n/// - Call the `__AbstractTBTCDepositor_initialize` initializer function\\n/// - Use the `_initializeDeposit` and `_finalizeDeposit` as part of their\\n/// business logic in order to initialize and finalize deposits.\\n///\\n/// @dev Example usage:\\n/// ```\\n/// // Example upgradeable integrator contract.\\n/// contract ExampleTBTCIntegrator is AbstractTBTCDepositor, Initializable {\\n/// /// @custom:oz-upgrades-unsafe-allow constructor\\n/// constructor() {\\n/// // Prevents the contract from being initialized again.\\n/// _disableInitializers();\\n/// }\\n///\\n/// function initialize(\\n/// address _bridge,\\n/// address _tbtcVault\\n/// ) external initializer {\\n/// __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\\n/// }\\n///\\n/// function startProcess(\\n/// IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n/// IBridgeTypes.DepositRevealInfo calldata reveal\\n/// ) external {\\n/// // Embed necessary context as extra data.\\n/// bytes32 extraData = ...;\\n///\\n/// uint256 depositKey = _initializeDeposit(\\n/// fundingTx,\\n/// reveal,\\n/// extraData\\n/// );\\n///\\n/// // Use the depositKey to track the process.\\n/// }\\n///\\n/// function finalizeProcess(uint256 depositKey) external {\\n/// (\\n/// uint256 initialDepositAmount,\\n/// uint256 tbtcAmount,\\n/// bytes32 extraData\\n/// ) = _finalizeDeposit(depositKey);\\n///\\n/// // Do something with the minted TBTC using context\\n/// // embedded in the extraData.\\n/// }\\n/// }\\nabstract contract AbstractTBTCDepositor {\\n using BTCUtils for bytes;\\n\\n /// @notice Multiplier to convert satoshi to TBTC token units.\\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\\n\\n /// @notice Bridge contract address.\\n IBridge public bridge;\\n /// @notice TBTCVault contract address.\\n ITBTCVault public tbtcVault;\\n /// @notice Mapping holding information about pending deposits that have\\n /// been initialized but not finalized yet. If the deposit is not\\n /// in this mapping it means it has already been finalized or it\\n /// has not been initialized yet.\\n mapping(uint256 => bool) public pendingDeposits;\\n\\n // Reserved storage space that allows adding more variables without affecting\\n // the storage layout of the child contracts. The convention from OpenZeppelin\\n // suggests the storage space should add up to 50 slots. If more variables are\\n // added in the upcoming versions one need to reduce the array size accordingly.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[47] private __gap;\\n\\n event DepositInitialized(uint256 indexed depositKey, uint32 initializedAt);\\n\\n event DepositFinalized(\\n uint256 indexed depositKey,\\n uint256 tbtcAmount,\\n uint32 finalizedAt\\n );\\n\\n /// @notice Initializes the contract. MUST BE CALLED from the child\\n /// contract initializer.\\n // slither-disable-next-line dead-code\\n function __AbstractTBTCDepositor_initialize(\\n address _bridge,\\n address _tbtcVault\\n ) internal {\\n require(\\n address(bridge) == address(0) && address(tbtcVault) == address(0),\\n \\\"AbstractTBTCDepositor already initialized\\\"\\n );\\n\\n require(_bridge != address(0), \\\"Bridge address cannot be zero\\\");\\n require(_tbtcVault != address(0), \\\"TBTCVault address cannot be zero\\\");\\n\\n bridge = IBridge(_bridge);\\n tbtcVault = ITBTCVault(_tbtcVault);\\n }\\n\\n /// @notice Initializes a deposit by revealing it to the Bridge.\\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo` struct.\\n /// @param extraData 32-byte deposit extra data.\\n /// @return depositKey Deposit key computed as\\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\\n /// key can be used to refer to the deposit in the Bridge and\\n /// TBTCVault contracts.\\n /// @dev Requirements:\\n /// - The revealed vault address must match the TBTCVault address,\\n /// - All requirements from {Bridge#revealDepositWithExtraData}\\n /// function must be met.\\n // slither-disable-next-line dead-code\\n function _initializeDeposit(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n bytes32 extraData\\n ) internal returns (uint256) {\\n require(reveal.vault == address(tbtcVault), \\\"Vault address mismatch\\\");\\n\\n uint256 depositKey = _calculateDepositKey(\\n _calculateBitcoinTxHash(fundingTx),\\n reveal.fundingOutputIndex\\n );\\n\\n pendingDeposits[depositKey] = true;\\n\\n emit DepositInitialized(\\n depositKey,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n // The Bridge does not allow to reveal the same deposit twice and\\n // revealed deposits stay there forever. The transaction will revert\\n // if the deposit has already been revealed so, there is no need to do\\n // an explicit check here.\\n bridge.revealDepositWithExtraData(fundingTx, reveal, extraData);\\n\\n return depositKey;\\n }\\n\\n /// @notice Finalizes a deposit by calculating the amount of TBTC minted\\n /// for the deposit\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @return initialDepositAmount Amount of funding transaction deposit. In\\n /// TBTC token decimals precision.\\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit. In\\n /// TBTC token decimals precision.\\n /// @return extraData 32-byte deposit extra data.\\n /// @dev Requirements:\\n /// - The deposit must be initialized but not finalized\\n /// (in the context of this contract) yet.\\n /// - The deposit must be finalized on the Bridge side. That means the\\n /// deposit must be either swept or optimistically minted.\\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function is an\\n /// approximation. See documentation of the `calculateTbtcAmount`\\n /// responsible for calculating this value for more details.\\n // slither-disable-next-line dead-code\\n function _finalizeDeposit(uint256 depositKey)\\n internal\\n returns (\\n uint256 initialDepositAmount,\\n uint256 tbtcAmount,\\n bytes32 extraData\\n )\\n {\\n require(pendingDeposits[depositKey], \\\"Deposit not initialized\\\");\\n\\n IBridgeTypes.DepositRequest memory deposit = bridge.deposits(\\n depositKey\\n );\\n (, uint64 finalizedAt) = tbtcVault.optimisticMintingRequests(\\n depositKey\\n );\\n\\n require(\\n deposit.sweptAt != 0 || finalizedAt != 0,\\n \\\"Deposit not finalized by the bridge\\\"\\n );\\n\\n // We can safely delete the deposit from the pending deposits mapping.\\n // This deposit cannot be initialized again because the bridge does not\\n // allow to reveal the same deposit twice. Deleting the deposit from\\n // the mapping will also prevent the finalizeDeposit function from\\n // being called again for the same deposit.\\n // slither-disable-next-line reentrancy-no-eth\\n delete pendingDeposits[depositKey];\\n\\n initialDepositAmount = deposit.amount * SATOSHI_MULTIPLIER;\\n\\n tbtcAmount = _calculateTbtcAmount(deposit.amount, deposit.treasuryFee);\\n\\n // slither-disable-next-line reentrancy-events\\n emit DepositFinalized(\\n depositKey,\\n tbtcAmount,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n extraData = deposit.extraData;\\n }\\n\\n /// @notice Calculates the amount of TBTC minted for the deposit.\\n /// @param depositAmountSat Deposit amount in satoshi (1e8 precision).\\n /// This is the actual amount deposited by the deposit creator, i.e.\\n /// the gross amount the Bridge's fees are cut from.\\n /// @param depositTreasuryFeeSat Deposit treasury fee in satoshi (1e8 precision).\\n /// This is an accurate value of the treasury fee that was actually\\n /// cut upon minting.\\n /// @return tbtcAmount Approximate amount of TBTC minted for the deposit.\\n /// @dev IMPORTANT NOTE: The tbtcAmount returned by this function may\\n /// not correspond to the actual amount of TBTC minted for the deposit.\\n /// Although the treasury fee cut upon minting is known precisely,\\n /// this is not the case for the optimistic minting fee and the Bitcoin\\n /// transaction fee. To overcome that problem, this function just takes\\n /// the current maximum allowed values of both fees, at the moment of deposit\\n /// finalization. For the great majority of the deposits, such an\\n /// algorithm will return a tbtcAmount slightly lesser than the\\n /// actual amount of TBTC minted for the deposit. This will cause\\n /// some TBTC to be left in the contract and ensure there is enough\\n /// liquidity to finalize the deposit. However, in some rare cases,\\n /// where the actual values of those fees change between the deposit\\n /// minting and finalization, the tbtcAmount returned by this function\\n /// may be greater than the actual amount of TBTC minted for the deposit.\\n /// If this happens and the reserve coming from previous deposits\\n /// leftovers does not provide enough liquidity, the deposit will have\\n /// to wait for finalization until the reserve is refilled by subsequent\\n /// deposits or a manual top-up. The integrator is responsible for\\n /// handling such cases.\\n // slither-disable-next-line dead-code\\n function _calculateTbtcAmount(\\n uint64 depositAmountSat,\\n uint64 depositTreasuryFeeSat\\n ) internal view virtual returns (uint256) {\\n // Both deposit amount and treasury fee are in the 1e8 satoshi precision.\\n // We need to convert them to the 1e18 TBTC precision.\\n uint256 amountSubTreasury = (depositAmountSat - depositTreasuryFeeSat) *\\n SATOSHI_MULTIPLIER;\\n\\n uint256 omFeeDivisor = tbtcVault.optimisticMintingFeeDivisor();\\n uint256 omFee = omFeeDivisor > 0\\n ? (amountSubTreasury / omFeeDivisor)\\n : 0;\\n\\n // The deposit transaction max fee is in the 1e8 satoshi precision.\\n // We need to convert them to the 1e18 TBTC precision.\\n (, , uint64 depositTxMaxFee, ) = bridge.depositParameters();\\n uint256 txMaxFee = depositTxMaxFee * SATOSHI_MULTIPLIER;\\n\\n return amountSubTreasury - omFee - txMaxFee;\\n }\\n\\n /// @notice Calculates the deposit key for the given funding transaction\\n /// hash and funding output index.\\n /// @param fundingTxHash Funding transaction hash.\\n /// @param fundingOutputIndex Funding output index.\\n /// @return depositKey Deposit key computed as\\n /// `keccak256(fundingTxHash | reveal.fundingOutputIndex)`. This\\n /// key can be used to refer to the deposit in the Bridge and\\n /// TBTCVault contracts.\\n // slither-disable-next-line dead-code\\n function _calculateDepositKey(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) internal pure returns (uint256) {\\n return\\n uint256(\\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\\n );\\n }\\n\\n /// @notice Calculates the Bitcoin transaction hash for the given Bitcoin\\n /// transaction data.\\n /// @param txInfo Bitcoin transaction data, see `IBridgeTypes.BitcoinTxInfo` struct.\\n /// @return txHash Bitcoin transaction hash.\\n // slither-disable-next-line dead-code\\n function _calculateBitcoinTxHash(IBridgeTypes.BitcoinTxInfo calldata txInfo)\\n internal\\n view\\n returns (bytes32)\\n {\\n return\\n abi\\n .encodePacked(\\n txInfo.version,\\n txInfo.inputVector,\\n txInfo.outputVector,\\n txInfo.locktime\\n )\\n .hash256View();\\n }\\n}\\n\",\"keccak256\":\"0xb9ad6f43c942e00dfe0591c94ccda43354d5cc14e4dec41aef721d7b947a4fb8\",\"license\":\"GPL-3.0-only\"},\"@keep-network/tbtc-v2/contracts/integrator/IBridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\n/// @notice Namespace which groups all types relevant to the IBridge interface.\\n/// @dev This is a mirror of the real types used in the Bridge contract.\\n/// This way, the `integrator` subpackage does not need to import\\n/// anything from the `bridge` subpackage and explicitly depend on it.\\n/// This simplifies the dependency graph for integrators.\\nlibrary IBridgeTypes {\\n /// @dev See bridge/BitcoinTx.sol#Info\\n struct BitcoinTxInfo {\\n bytes4 version;\\n bytes inputVector;\\n bytes outputVector;\\n bytes4 locktime;\\n }\\n\\n /// @dev See bridge/Deposit.sol#DepositRevealInfo\\n struct DepositRevealInfo {\\n uint32 fundingOutputIndex;\\n bytes8 blindingFactor;\\n bytes20 walletPubKeyHash;\\n bytes20 refundPubKeyHash;\\n bytes4 refundLocktime;\\n address vault;\\n }\\n\\n /// @dev See bridge/Deposit.sol#DepositRequest\\n struct DepositRequest {\\n address depositor;\\n uint64 amount;\\n uint32 revealedAt;\\n address vault;\\n uint64 treasuryFee;\\n uint32 sweptAt;\\n bytes32 extraData;\\n }\\n}\\n\\n/// @notice Interface of the Bridge contract.\\n/// @dev See bridge/Bridge.sol\\ninterface IBridge {\\n /// @dev See {Bridge#revealDepositWithExtraData}\\n function revealDepositWithExtraData(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n bytes32 extraData\\n ) external;\\n\\n /// @dev See {Bridge#deposits}\\n function deposits(uint256 depositKey)\\n external\\n view\\n returns (IBridgeTypes.DepositRequest memory);\\n\\n /// @dev See {Bridge#depositParameters}\\n function depositParameters()\\n external\\n view\\n returns (\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n}\\n\",\"keccak256\":\"0x4e598d96404a19609f511f10503e80f457602ad694d081df739571f67f6e0c4e\",\"license\":\"GPL-3.0-only\"},\"@keep-network/tbtc-v2/contracts/integrator/ITBTCVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity ^0.8.0;\\n\\n/// @notice Interface of the TBTCVault contract.\\n/// @dev See vault/TBTCVault.sol\\ninterface ITBTCVault {\\n /// @dev See {TBTCVault#optimisticMintingRequests}\\n function optimisticMintingRequests(uint256 depositKey)\\n external\\n returns (uint64 requestedAt, uint64 finalizedAt);\\n\\n /// @dev See {TBTCVault#optimisticMintingFeeDivisor}\\n function optimisticMintingFeeDivisor() external view returns (uint32);\\n}\\n\",\"keccak256\":\"0xf259d64c1040e2cbc3d17653491e45c5c3da17f575dac1c175c63c8a5308908e\",\"license\":\"GPL-3.0-only\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Context} from \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * The initial owner is set to the address provided by the deployer. This can\\n * later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n /**\\n * @dev The caller account is not authorized to perform an operation.\\n */\\n error OwnableUnauthorizedAccount(address account);\\n\\n /**\\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\\n */\\n error OwnableInvalidOwner(address owner);\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\\n */\\n constructor(address initialOwner) {\\n if (initialOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(initialOwner);\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n if (owner() != _msgSender()) {\\n revert OwnableUnauthorizedAccount(_msgSender());\\n }\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n if (newOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xff6d0bb2e285473e5311d9d3caacb525ae3538a80758c10649a4d61029b017bb\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/IERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../token/ERC20/IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"../token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\n/**\\n * @dev Interface of the ERC4626 \\\"Tokenized Vault Standard\\\", as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\\n */\\ninterface IERC4626 is IERC20, IERC20Metadata {\\n event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\\n\\n event Withdraw(\\n address indexed sender,\\n address indexed receiver,\\n address indexed owner,\\n uint256 assets,\\n uint256 shares\\n );\\n\\n /**\\n * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\\n *\\n * - MUST be an ERC-20 token contract.\\n * - MUST NOT revert.\\n */\\n function asset() external view returns (address assetTokenAddress);\\n\\n /**\\n * @dev Returns the total amount of the underlying asset that is \\u201cmanaged\\u201d by Vault.\\n *\\n * - SHOULD include any compounding that occurs from yield.\\n * - MUST be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT revert.\\n */\\n function totalAssets() external view returns (uint256 totalManagedAssets);\\n\\n /**\\n * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToShares(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\\n * scenario where all the conditions are met.\\n *\\n * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\\n * - MUST NOT show any variations depending on the caller.\\n * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\\n * - MUST NOT revert.\\n *\\n * NOTE: This calculation MAY NOT reflect the \\u201cper-user\\u201d price-per-share, and instead should reflect the\\n * \\u201caverage-user\\u2019s\\u201d price-per-share, meaning what the average user should expect to see when exchanging to and\\n * from.\\n */\\n function convertToAssets(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\\n * through a deposit call.\\n *\\n * - MUST return a limited value if receiver is subject to some deposit limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\\n * - MUST NOT revert.\\n */\\n function maxDeposit(address receiver) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\\n * call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\\n * in the same transaction.\\n * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\\n * deposit would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewDeposit(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * deposit execution, and are accounted for during deposit.\\n * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function deposit(uint256 assets, address receiver) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\\n * - MUST return a limited value if receiver is subject to some mint limit.\\n * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\\n * - MUST NOT revert.\\n */\\n function maxMint(address receiver) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\\n * current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\\n * in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\\n * same transaction.\\n * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\\n * would be accepted, regardless if the user has enough tokens approved, etc.\\n * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by minting.\\n */\\n function previewMint(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\\n *\\n * - MUST emit the Deposit event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\\n * execution, and are accounted for during mint.\\n * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\\n * approving enough underlying tokens to the Vault contract, etc).\\n *\\n * NOTE: most implementations will require pre-approval of the Vault with the Vault\\u2019s underlying asset token.\\n */\\n function mint(uint256 shares, address receiver) external returns (uint256 assets);\\n\\n /**\\n * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\\n * Vault, through a withdraw call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxWithdraw(address owner) external view returns (uint256 maxAssets);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\\n * call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\\n * called\\n * in the same transaction.\\n * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\\n * the withdrawal would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by depositing.\\n */\\n function previewWithdraw(uint256 assets) external view returns (uint256 shares);\\n\\n /**\\n * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * withdraw execution, and are accounted for during withdraw.\\n * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\\n\\n /**\\n * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\\n * through a redeem call.\\n *\\n * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\\n * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\\n * - MUST NOT revert.\\n */\\n function maxRedeem(address owner) external view returns (uint256 maxShares);\\n\\n /**\\n * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\\n * given current on-chain conditions.\\n *\\n * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\\n * in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\\n * same transaction.\\n * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\\n * redemption would be accepted, regardless if the user has enough shares, etc.\\n * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\\n * - MUST NOT revert.\\n *\\n * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\\n * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\\n */\\n function previewRedeem(uint256 shares) external view returns (uint256 assets);\\n\\n /**\\n * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\\n *\\n * - MUST emit the Withdraw event.\\n * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\\n * redeem execution, and are accounted for during redeem.\\n * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\\n * not having enough shares, etc).\\n *\\n * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\\n * Those methods should be performed separately.\\n */\\n function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\\n}\\n\",\"keccak256\":\"0x207f64371bc0fcc5be86713aa5da109a870cc3a6da50e93b64ee881e369b593d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/interfaces/draft-IERC6093.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard ERC20 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\\n */\\ninterface IERC20Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC20InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC20InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `spender`\\u2019s `allowance`. Used in transfers.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\\n * @param needed Minimum amount required to perform a transfer.\\n */\\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC20InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\\n * @param spender Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC20InvalidSpender(address spender);\\n}\\n\\n/**\\n * @dev Standard ERC721 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\\n */\\ninterface IERC721Errors {\\n /**\\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\\n * Used in balance queries.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721InvalidOwner(address owner);\\n\\n /**\\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721NonexistentToken(uint256 tokenId);\\n\\n /**\\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param tokenId Identifier number of a token.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC721InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC721InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC721InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC721InvalidOperator(address operator);\\n}\\n\\n/**\\n * @dev Standard ERC1155 Errors\\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\\n */\\ninterface IERC1155Errors {\\n /**\\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n * @param balance Current balance for the interacting account.\\n * @param needed Minimum amount required to perform a transfer.\\n * @param tokenId Identifier number of a token.\\n */\\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\\n\\n /**\\n * @dev Indicates a failure with the token `sender`. Used in transfers.\\n * @param sender Address whose tokens are being transferred.\\n */\\n error ERC1155InvalidSender(address sender);\\n\\n /**\\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\\n * @param receiver Address to which tokens are being transferred.\\n */\\n error ERC1155InvalidReceiver(address receiver);\\n\\n /**\\n * @dev Indicates a failure with the `operator`\\u2019s approval. Used in transfers.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n * @param owner Address of the current owner of a token.\\n */\\n error ERC1155MissingApprovalForAll(address operator, address owner);\\n\\n /**\\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\\n * @param approver Address initiating an approval operation.\\n */\\n error ERC1155InvalidApprover(address approver);\\n\\n /**\\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\\n * @param operator Address that may be allowed to operate on tokens without being their owner.\\n */\\n error ERC1155InvalidOperator(address operator);\\n\\n /**\\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\\n * Used in batch transfers.\\n * @param idsLength Length of the array of token identifiers\\n * @param valuesLength Length of the array of token amounts\\n */\\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\\n}\\n\",\"keccak256\":\"0x60c65f701957fdd6faea1acb0bb45825791d473693ed9ecb34726fdfaa849dd7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"./IERC20.sol\\\";\\nimport {IERC20Metadata} from \\\"./extensions/IERC20Metadata.sol\\\";\\nimport {Context} from \\\"../../utils/Context.sol\\\";\\nimport {IERC20Errors} from \\\"../../interfaces/draft-IERC6093.sol\\\";\\n\\n/**\\n * @dev Implementation of the {IERC20} interface.\\n *\\n * This implementation is agnostic to the way tokens are created. This means\\n * that a supply mechanism has to be added in a derived contract using {_mint}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\n *\\n * The default value of {decimals} is 18. To change this, you should override\\n * this function so it returns a different value.\\n *\\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\\n * instead returning `false` on failure. This behavior is nonetheless\\n * conventional and does not conflict with the expectations of ERC20\\n * applications.\\n *\\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\\n * This allows applications to reconstruct the allowance for all accounts just\\n * by listening to said events. Other implementations of the EIP may not emit\\n * these events, as it isn't required by the specification.\\n */\\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\\n mapping(address account => uint256) private _balances;\\n\\n mapping(address account => mapping(address spender => uint256)) private _allowances;\\n\\n uint256 private _totalSupply;\\n\\n string private _name;\\n string private _symbol;\\n\\n /**\\n * @dev Sets the values for {name} and {symbol}.\\n *\\n * All two of these values are immutable: they can only be set once during\\n * construction.\\n */\\n constructor(string memory name_, string memory symbol_) {\\n _name = name_;\\n _symbol = symbol_;\\n }\\n\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() public view virtual returns (string memory) {\\n return _name;\\n }\\n\\n /**\\n * @dev Returns the symbol of the token, usually a shorter version of the\\n * name.\\n */\\n function symbol() public view virtual returns (string memory) {\\n return _symbol;\\n }\\n\\n /**\\n * @dev Returns the number of decimals used to get its user representation.\\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\\n *\\n * Tokens usually opt for a value of 18, imitating the relationship between\\n * Ether and Wei. This is the default value returned by this function, unless\\n * it's overridden.\\n *\\n * NOTE: This information is only used for _display_ purposes: it in\\n * no way affects any of the arithmetic of the contract, including\\n * {IERC20-balanceOf} and {IERC20-transfer}.\\n */\\n function decimals() public view virtual returns (uint8) {\\n return 18;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual returns (uint256) {\\n return _balances[account];\\n }\\n\\n /**\\n * @dev See {IERC20-transfer}.\\n *\\n * Requirements:\\n *\\n * - `to` cannot be the zero address.\\n * - the caller must have a balance of at least `value`.\\n */\\n function transfer(address to, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\\n * `transferFrom`. This is semantically equivalent to an infinite approval.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function approve(address spender, uint256 value) public virtual returns (bool) {\\n address owner = _msgSender();\\n _approve(owner, spender, value);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-transferFrom}.\\n *\\n * Emits an {Approval} event indicating the updated allowance. This is not\\n * required by the EIP. See the note at the beginning of {ERC20}.\\n *\\n * NOTE: Does not update the allowance if the current allowance\\n * is the maximum `uint256`.\\n *\\n * Requirements:\\n *\\n * - `from` and `to` cannot be the zero address.\\n * - `from` must have a balance of at least `value`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `value`.\\n */\\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, value);\\n _transfer(from, to, value);\\n return true;\\n }\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to`.\\n *\\n * This internal function is equivalent to {transfer}, and can be used to\\n * e.g. implement automatic token fees, slashing mechanisms, etc.\\n *\\n * Emits a {Transfer} event.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _transfer(address from, address to, uint256 value) internal {\\n if (from == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n if (to == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(from, to, value);\\n }\\n\\n /**\\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\\n * this function.\\n *\\n * Emits a {Transfer} event.\\n */\\n function _update(address from, address to, uint256 value) internal virtual {\\n if (from == address(0)) {\\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\\n _totalSupply += value;\\n } else {\\n uint256 fromBalance = _balances[from];\\n if (fromBalance < value) {\\n revert ERC20InsufficientBalance(from, fromBalance, value);\\n }\\n unchecked {\\n // Overflow not possible: value <= fromBalance <= totalSupply.\\n _balances[from] = fromBalance - value;\\n }\\n }\\n\\n if (to == address(0)) {\\n unchecked {\\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\\n _totalSupply -= value;\\n }\\n } else {\\n unchecked {\\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\\n _balances[to] += value;\\n }\\n }\\n\\n emit Transfer(from, to, value);\\n }\\n\\n /**\\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\\n * Relies on the `_update` mechanism\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead.\\n */\\n function _mint(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidReceiver(address(0));\\n }\\n _update(address(0), account, value);\\n }\\n\\n /**\\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\\n * Relies on the `_update` mechanism.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * NOTE: This function is not virtual, {_update} should be overridden instead\\n */\\n function _burn(address account, uint256 value) internal {\\n if (account == address(0)) {\\n revert ERC20InvalidSender(address(0));\\n }\\n _update(account, address(0), value);\\n }\\n\\n /**\\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\\n *\\n * This internal function is equivalent to `approve`, and can be used to\\n * e.g. set automatic allowances for certain subsystems, etc.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `owner` cannot be the zero address.\\n * - `spender` cannot be the zero address.\\n *\\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\\n */\\n function _approve(address owner, address spender, uint256 value) internal {\\n _approve(owner, spender, value, true);\\n }\\n\\n /**\\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\\n *\\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\\n * `Approval` event during `transferFrom` operations.\\n *\\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\\n * true using the following override:\\n * ```\\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\\n * super._approve(owner, spender, value, true);\\n * }\\n * ```\\n *\\n * Requirements are the same as {_approve}.\\n */\\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\\n if (owner == address(0)) {\\n revert ERC20InvalidApprover(address(0));\\n }\\n if (spender == address(0)) {\\n revert ERC20InvalidSpender(address(0));\\n }\\n _allowances[owner][spender] = value;\\n if (emitEvent) {\\n emit Approval(owner, spender, value);\\n }\\n }\\n\\n /**\\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\\n *\\n * Does not update the allowance value in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Does not emit an {Approval} event.\\n */\\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n if (currentAllowance < value) {\\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\\n }\\n unchecked {\\n _approve(owner, spender, currentAllowance - value, false);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3e1fa9d1987f8d349dfb4d6fe93bf2ca014b52ba335cfac30bfe71e357e6f80\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the value of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the value of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\\n * caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 value) external returns (bool);\\n\\n /**\\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\\n * allowance mechanism. `value` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(address from, address to, uint256 value) external returns (bool);\\n}\\n\",\"keccak256\":\"0xc6a8ff0ea489379b61faa647490411b80102578440ab9d84e9a957cc12164e70\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20, IERC20Metadata, ERC20} from \\\"../ERC20.sol\\\";\\nimport {SafeERC20} from \\\"../utils/SafeERC20.sol\\\";\\nimport {IERC4626} from \\\"../../../interfaces/IERC4626.sol\\\";\\nimport {Math} from \\\"../../../utils/math/Math.sol\\\";\\n\\n/**\\n * @dev Implementation of the ERC4626 \\\"Tokenized Vault Standard\\\" as defined in\\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\\n *\\n * This extension allows the minting and burning of \\\"shares\\\" (represented using the ERC20 inheritance) in exchange for\\n * underlying \\\"assets\\\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\\n * the ERC20 standard. Any additional extensions included along it would affect the \\\"shares\\\" token represented by this\\n * contract and not the \\\"assets\\\" token which is an independent contract.\\n *\\n * [CAUTION]\\n * ====\\n * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning\\n * with a \\\"donation\\\" to the vault that inflates the price of a share. This is variously known as a donation or inflation\\n * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial\\n * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may\\n * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by\\n * verifying the amount received is as expected, using a wrapper that performs these checks such as\\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\\n *\\n * Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()`\\n * corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault\\n * decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself\\n * determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset\\n * (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's\\n * donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more\\n * expensive than it is profitable. More details about the underlying math can be found\\n * xref:erc4626.adoc#inflation-attack[here].\\n *\\n * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued\\n * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets\\n * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience\\n * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the\\n * `_convertToShares` and `_convertToAssets` functions.\\n *\\n * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].\\n * ====\\n */\\nabstract contract ERC4626 is ERC20, IERC4626 {\\n using Math for uint256;\\n\\n IERC20 private immutable _asset;\\n uint8 private immutable _underlyingDecimals;\\n\\n /**\\n * @dev Attempted to deposit more assets than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);\\n\\n /**\\n * @dev Attempted to mint more shares than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);\\n\\n /**\\n * @dev Attempted to withdraw more assets than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);\\n\\n /**\\n * @dev Attempted to redeem more shares than the max amount for `receiver`.\\n */\\n error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);\\n\\n /**\\n * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\\n */\\n constructor(IERC20 asset_) {\\n (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\\n _underlyingDecimals = success ? assetDecimals : 18;\\n _asset = asset_;\\n }\\n\\n /**\\n * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\\n */\\n function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {\\n (bool success, bytes memory encodedDecimals) = address(asset_).staticcall(\\n abi.encodeCall(IERC20Metadata.decimals, ())\\n );\\n if (success && encodedDecimals.length >= 32) {\\n uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\\n if (returnedDecimals <= type(uint8).max) {\\n return (true, uint8(returnedDecimals));\\n }\\n }\\n return (false, 0);\\n }\\n\\n /**\\n * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This\\n * \\\"original\\\" value is cached during construction of the vault contract. If this read operation fails (e.g., the\\n * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.\\n *\\n * See {IERC20Metadata-decimals}.\\n */\\n function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {\\n return _underlyingDecimals + _decimalsOffset();\\n }\\n\\n /** @dev See {IERC4626-asset}. */\\n function asset() public view virtual returns (address) {\\n return address(_asset);\\n }\\n\\n /** @dev See {IERC4626-totalAssets}. */\\n function totalAssets() public view virtual returns (uint256) {\\n return _asset.balanceOf(address(this));\\n }\\n\\n /** @dev See {IERC4626-convertToShares}. */\\n function convertToShares(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-convertToAssets}. */\\n function convertToAssets(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-maxDeposit}. */\\n function maxDeposit(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n /** @dev See {IERC4626-maxMint}. */\\n function maxMint(address) public view virtual returns (uint256) {\\n return type(uint256).max;\\n }\\n\\n /** @dev See {IERC4626-maxWithdraw}. */\\n function maxWithdraw(address owner) public view virtual returns (uint256) {\\n return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-maxRedeem}. */\\n function maxRedeem(address owner) public view virtual returns (uint256) {\\n return balanceOf(owner);\\n }\\n\\n /** @dev See {IERC4626-previewDeposit}. */\\n function previewDeposit(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-previewMint}. */\\n function previewMint(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Ceil);\\n }\\n\\n /** @dev See {IERC4626-previewWithdraw}. */\\n function previewWithdraw(uint256 assets) public view virtual returns (uint256) {\\n return _convertToShares(assets, Math.Rounding.Ceil);\\n }\\n\\n /** @dev See {IERC4626-previewRedeem}. */\\n function previewRedeem(uint256 shares) public view virtual returns (uint256) {\\n return _convertToAssets(shares, Math.Rounding.Floor);\\n }\\n\\n /** @dev See {IERC4626-deposit}. */\\n function deposit(uint256 assets, address receiver) public virtual returns (uint256) {\\n uint256 maxAssets = maxDeposit(receiver);\\n if (assets > maxAssets) {\\n revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);\\n }\\n\\n uint256 shares = previewDeposit(assets);\\n _deposit(_msgSender(), receiver, assets, shares);\\n\\n return shares;\\n }\\n\\n /** @dev See {IERC4626-mint}.\\n *\\n * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.\\n * In this case, the shares will be minted without requiring any assets to be deposited.\\n */\\n function mint(uint256 shares, address receiver) public virtual returns (uint256) {\\n uint256 maxShares = maxMint(receiver);\\n if (shares > maxShares) {\\n revert ERC4626ExceededMaxMint(receiver, shares, maxShares);\\n }\\n\\n uint256 assets = previewMint(shares);\\n _deposit(_msgSender(), receiver, assets, shares);\\n\\n return assets;\\n }\\n\\n /** @dev See {IERC4626-withdraw}. */\\n function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {\\n uint256 maxAssets = maxWithdraw(owner);\\n if (assets > maxAssets) {\\n revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);\\n }\\n\\n uint256 shares = previewWithdraw(assets);\\n _withdraw(_msgSender(), receiver, owner, assets, shares);\\n\\n return shares;\\n }\\n\\n /** @dev See {IERC4626-redeem}. */\\n function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {\\n uint256 maxShares = maxRedeem(owner);\\n if (shares > maxShares) {\\n revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);\\n }\\n\\n uint256 assets = previewRedeem(shares);\\n _withdraw(_msgSender(), receiver, owner, assets, shares);\\n\\n return assets;\\n }\\n\\n /**\\n * @dev Internal conversion function (from assets to shares) with support for rounding direction.\\n */\\n function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {\\n return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);\\n }\\n\\n /**\\n * @dev Internal conversion function (from shares to assets) with support for rounding direction.\\n */\\n function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {\\n return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);\\n }\\n\\n /**\\n * @dev Deposit/mint common workflow.\\n */\\n function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {\\n // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the\\n // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\\n // calls the vault, which is assumed not malicious.\\n //\\n // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\\n // assets are transferred and before the shares are minted, which is a valid state.\\n // slither-disable-next-line reentrancy-no-eth\\n SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\\n _mint(receiver, shares);\\n\\n emit Deposit(caller, receiver, assets, shares);\\n }\\n\\n /**\\n * @dev Withdraw/redeem common workflow.\\n */\\n function _withdraw(\\n address caller,\\n address receiver,\\n address owner,\\n uint256 assets,\\n uint256 shares\\n ) internal virtual {\\n if (caller != owner) {\\n _spendAllowance(owner, caller, shares);\\n }\\n\\n // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\\n // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\\n // calls the vault, which is assumed not malicious.\\n //\\n // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\\n // shares are burned and after the assets are transferred, which is a valid state.\\n _burn(owner, shares);\\n SafeERC20.safeTransfer(_asset, receiver, assets);\\n\\n emit Withdraw(caller, receiver, owner, assets, shares);\\n }\\n\\n function _decimalsOffset() internal view virtual returns (uint8) {\\n return 0;\\n }\\n}\\n\",\"keccak256\":\"0x1837547e04d5fe5334eeb77a345683c22995f1e7aa033020757ddf83a80fc72d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0xaa761817f6cd7892fcf158b3c776b34551cde36f48ff9703d53898bc45a94ea2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\\n *\\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\\n * need to send a transaction, and thus is not required to hold Ether at all.\\n *\\n * ==== Security Considerations\\n *\\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\\n * generally recommended is:\\n *\\n * ```solidity\\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\\n * doThing(..., value);\\n * }\\n *\\n * function doThing(..., uint256 value) public {\\n * token.safeTransferFrom(msg.sender, address(this), value);\\n * ...\\n * }\\n * ```\\n *\\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\\n * {SafeERC20-safeTransferFrom}).\\n *\\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\\n * contracts should have entry points that don't rely on permit.\\n */\\ninterface IERC20Permit {\\n /**\\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\\n * given ``owner``'s signed approval.\\n *\\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\\n * ordering also apply here.\\n *\\n * Emits an {Approval} event.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `deadline` must be a timestamp in the future.\\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\\n * over the EIP712-formatted function arguments.\\n * - the signature must use ``owner``'s current nonce (see {nonces}).\\n *\\n * For more information on the signature format, see the\\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\\n * section].\\n *\\n * CAUTION: See Security Considerations above.\\n */\\n function permit(\\n address owner,\\n address spender,\\n uint256 value,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /**\\n * @dev Returns the current nonce for `owner`. This value must be\\n * included whenever a signature is generated for {permit}.\\n *\\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\\n * prevents a signature from being used multiple times.\\n */\\n function nonces(address owner) external view returns (uint256);\\n\\n /**\\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\\n */\\n // solhint-disable-next-line func-name-mixedcase\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n}\\n\",\"keccak256\":\"0x6008dabfe393240d73d7dd7688033f72740d570aa422254d29a7dce8568f3aff\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"../IERC20.sol\\\";\\nimport {IERC20Permit} from \\\"../extensions/IERC20Permit.sol\\\";\\nimport {Address} from \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n /**\\n * @dev An operation with an ERC20 token failed.\\n */\\n error SafeERC20FailedOperation(address token);\\n\\n /**\\n * @dev Indicates a failed `decreaseAllowance` request.\\n */\\n error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\\n\\n /**\\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\\n }\\n\\n /**\\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\\n */\\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\\n _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\\n }\\n\\n /**\\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful.\\n */\\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n forceApprove(token, spender, oldAllowance + value);\\n }\\n\\n /**\\n * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\\n * value, non-reverting calls are assumed to be successful.\\n */\\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\\n unchecked {\\n uint256 currentAllowance = token.allowance(address(this), spender);\\n if (currentAllowance < requestedDecrease) {\\n revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\\n }\\n forceApprove(token, spender, currentAllowance - requestedDecrease);\\n }\\n }\\n\\n /**\\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\\n * to be set to zero before setting it to a non-zero value, such as USDT.\\n */\\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\\n bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\\n\\n if (!_callOptionalReturnBool(token, approvalCall)) {\\n _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\\n _callOptionalReturn(token, approvalCall);\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data);\\n if (returndata.length != 0 && !abi.decode(returndata, (bool))) {\\n revert SafeERC20FailedOperation(address(token));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n *\\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\\n */\\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\\n // and not revert is the subcall reverts.\\n\\n (bool success, bytes memory returndata) = address(token).call(data);\\n return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;\\n }\\n}\\n\",\"keccak256\":\"0x37bb49513c49c87c4642a891b13b63571bc87013dde806617aa1efb54605f386\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev The ETH balance of the account is not enough to perform the operation.\\n */\\n error AddressInsufficientBalance(address account);\\n\\n /**\\n * @dev There's no code at `target` (it is not a contract).\\n */\\n error AddressEmptyCode(address target);\\n\\n /**\\n * @dev A call to an address target failed. The target may have reverted.\\n */\\n error FailedInnerCall();\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n if (address(this).balance < amount) {\\n revert AddressInsufficientBalance(address(this));\\n }\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n if (!success) {\\n revert FailedInnerCall();\\n }\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason or custom error, it is bubbled\\n * up by this function (like regular Solidity function calls). However, if\\n * the call reverted with no returned reason, this function reverts with a\\n * {FailedInnerCall} error.\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n if (address(this).balance < value) {\\n revert AddressInsufficientBalance(address(this));\\n }\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResultFromTarget(target, success, returndata);\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\\n * unsuccessful call.\\n */\\n function verifyCallResultFromTarget(\\n address target,\\n bool success,\\n bytes memory returndata\\n ) internal view returns (bytes memory) {\\n if (!success) {\\n _revert(returndata);\\n } else {\\n // only check if target is a contract if the call was successful and the return data is empty\\n // otherwise we already know that it was a contract\\n if (returndata.length == 0 && target.code.length == 0) {\\n revert AddressEmptyCode(target);\\n }\\n return returndata;\\n }\\n }\\n\\n /**\\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\\n * revert reason or with a default {FailedInnerCall} error.\\n */\\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\\n if (!success) {\\n _revert(returndata);\\n } else {\\n return returndata;\\n }\\n }\\n\\n /**\\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\\n */\\n function _revert(bytes memory returndata) private pure {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n /// @solidity memory-safe-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert FailedInnerCall();\\n }\\n }\\n}\\n\",\"keccak256\":\"0xaf28a975a78550e45f65e559a3ad6a5ad43b9b8a37366999abd1b7084eb70721\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x75a4ee64c68dbd5f38bddd06e664a64c8271b4caa554fb6f0607dfd672bb4bf3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Muldiv operation overflow.\\n */\\n error MathOverflowedMulDiv();\\n\\n enum Rounding {\\n Floor, // Toward negative infinity\\n Ceil, // Toward positive infinity\\n Trunc, // Toward zero\\n Expand // Away from zero\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds towards infinity instead\\n * of rounding towards zero.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (b == 0) {\\n // Guarantee the same behavior as in a regular Solidity division.\\n return a / b;\\n }\\n\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\\n * denominator == 0.\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\\n * Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0 = x * y; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (denominator <= prod1) {\\n revert MathOverflowedMulDiv();\\n }\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\\n\\n uint256 twos = denominator & (0 - denominator);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\\n // works in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\\n * towards zero.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\\n */\\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\\n return uint8(rounding) % 2 == 1;\\n }\\n}\\n\",\"keccak256\":\"0x005ec64c6313f0555d59e278f9a7a5ab2db5bdc72a027f255a37c327af1ec02d\",\"license\":\"MIT\"},\"contracts/Dispatcher.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\nimport \\\"./Router.sol\\\";\\nimport \\\"./stBTC.sol\\\";\\n\\n/// @title Dispatcher\\n/// @notice Dispatcher is a contract that routes tBTC from stBTC to\\n/// yield vaults and back. Vaults supply yield strategies with tBTC that\\n/// generate yield for Bitcoin holders.\\ncontract Dispatcher is Router, Ownable {\\n using SafeERC20 for IERC20;\\n\\n /// Struct holds information about a vault.\\n struct VaultInfo {\\n bool authorized;\\n }\\n\\n /// The main stBTC contract holding tBTC deposited by stakers.\\n stBTC public immutable stbtc;\\n /// tBTC token contract.\\n IERC20 public immutable tbtc;\\n /// Address of the maintainer bot.\\n address public maintainer;\\n\\n /// Authorized Yield Vaults that implement ERC4626 standard. These\\n /// vaults deposit assets to yield strategies, e.g. Uniswap V3\\n /// WBTC/TBTC pool. Vault can be a part of Acre ecosystem or can be\\n /// implemented externally. As long as it complies with ERC4626\\n /// standard and is authorized by the owner it can be plugged into\\n /// Acre.\\n address[] public vaults;\\n /// Mapping of vaults to their information.\\n mapping(address => VaultInfo) public vaultsInfo;\\n\\n /// Emitted when a vault is authorized.\\n /// @param vault Address of the vault.\\n event VaultAuthorized(address indexed vault);\\n\\n /// Emitted when a vault is deauthorized.\\n /// @param vault Address of the vault.\\n event VaultDeauthorized(address indexed vault);\\n\\n /// Emitted when tBTC is routed to a vault.\\n /// @param vault Address of the vault.\\n /// @param amount Amount of tBTC.\\n /// @param sharesOut Amount of received shares.\\n event DepositAllocated(\\n address indexed vault,\\n uint256 amount,\\n uint256 sharesOut\\n );\\n\\n /// Emitted when the maintainer address is updated.\\n /// @param maintainer Address of the new maintainer.\\n event MaintainerUpdated(address indexed maintainer);\\n\\n /// Reverts if the vault is already authorized.\\n error VaultAlreadyAuthorized();\\n\\n /// Reverts if the vault is not authorized.\\n error VaultUnauthorized();\\n\\n /// Reverts if the caller is not the maintainer.\\n error NotMaintainer();\\n\\n /// Reverts if the address is zero.\\n error ZeroAddress();\\n\\n /// Modifier that reverts if the caller is not the maintainer.\\n modifier onlyMaintainer() {\\n if (msg.sender != maintainer) {\\n revert NotMaintainer();\\n }\\n _;\\n }\\n\\n constructor(stBTC _stbtc, IERC20 _tbtc) Ownable(msg.sender) {\\n stbtc = _stbtc;\\n tbtc = _tbtc;\\n }\\n\\n /// @notice Adds a vault to the list of authorized vaults.\\n /// @param vault Address of the vault to add.\\n function authorizeVault(address vault) external onlyOwner {\\n if (isVaultAuthorized(vault)) {\\n revert VaultAlreadyAuthorized();\\n }\\n\\n vaults.push(vault);\\n vaultsInfo[vault].authorized = true;\\n\\n emit VaultAuthorized(vault);\\n }\\n\\n /// @notice Removes a vault from the list of authorized vaults.\\n /// @param vault Address of the vault to remove.\\n function deauthorizeVault(address vault) external onlyOwner {\\n if (!isVaultAuthorized(vault)) {\\n revert VaultUnauthorized();\\n }\\n\\n vaultsInfo[vault].authorized = false;\\n\\n for (uint256 i = 0; i < vaults.length; i++) {\\n if (vaults[i] == vault) {\\n vaults[i] = vaults[vaults.length - 1];\\n // slither-disable-next-line costly-loop\\n vaults.pop();\\n break;\\n }\\n }\\n\\n emit VaultDeauthorized(vault);\\n }\\n\\n /// @notice Updates the maintainer address.\\n /// @param newMaintainer Address of the new maintainer.\\n function updateMaintainer(address newMaintainer) external onlyOwner {\\n if (newMaintainer == address(0)) {\\n revert ZeroAddress();\\n }\\n\\n maintainer = newMaintainer;\\n\\n emit MaintainerUpdated(maintainer);\\n }\\n\\n /// TODO: make this function internal once the allocation distribution is\\n /// implemented\\n /// @notice Routes tBTC from stBTC to a vault. Can be called by the maintainer\\n /// only.\\n /// @param vault Address of the vault to route the assets to.\\n /// @param amount Amount of tBTC to deposit.\\n /// @param minSharesOut Minimum amount of shares to receive.\\n function depositToVault(\\n address vault,\\n uint256 amount,\\n uint256 minSharesOut\\n ) public onlyMaintainer {\\n if (!isVaultAuthorized(vault)) {\\n revert VaultUnauthorized();\\n }\\n\\n // slither-disable-next-line arbitrary-send-erc20\\n tbtc.safeTransferFrom(address(stbtc), address(this), amount);\\n tbtc.forceApprove(address(vault), amount);\\n\\n uint256 sharesOut = deposit(\\n IERC4626(vault),\\n address(stbtc),\\n amount,\\n minSharesOut\\n );\\n // slither-disable-next-line reentrancy-events\\n emit DepositAllocated(vault, amount, sharesOut);\\n }\\n\\n /// @notice Returns the list of authorized vaults.\\n function getVaults() public view returns (address[] memory) {\\n return vaults;\\n }\\n\\n /// @notice Returns true if the vault is authorized.\\n /// @param vault Address of the vault to check.\\n function isVaultAuthorized(address vault) public view returns (bool) {\\n return vaultsInfo[vault].authorized;\\n }\\n\\n /// TODO: implement redeem() / withdraw() functions\\n}\\n\",\"keccak256\":\"0x0dd77692ab8c6059afa7b4a90f26733560b53fb66192e9912a2064103c5d41fb\",\"license\":\"GPL-3.0-only\"},\"contracts/Router.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/interfaces/IERC4626.sol\\\";\\n\\n/// @title Router\\n/// @notice Router is a contract that routes tBTC from stBTC to\\n/// a given vault and back. Vaults supply yield strategies with tBTC that\\n/// generate yield for Bitcoin holders.\\nabstract contract Router {\\n /// Thrown when amount of shares received is below the min set by caller.\\n /// @param vault Address of the vault.\\n /// @param sharesOut Amount of received shares.\\n /// @param minSharesOut Minimum amount of shares expected to receive.\\n error MinSharesError(\\n address vault,\\n uint256 sharesOut,\\n uint256 minSharesOut\\n );\\n\\n /// @notice Routes funds from stBTC to a vault. The amount of tBTC to\\n /// Shares of deposited tBTC are minted to the stBTC contract.\\n /// @param vault Address of the vault to route the funds to.\\n /// @param receiver Address of the receiver of the shares.\\n /// @param amount Amount of tBTC to deposit.\\n /// @param minSharesOut Minimum amount of shares to receive.\\n function deposit(\\n IERC4626 vault,\\n address receiver,\\n uint256 amount,\\n uint256 minSharesOut\\n ) internal returns (uint256 sharesOut) {\\n if ((sharesOut = vault.deposit(amount, receiver)) < minSharesOut) {\\n revert MinSharesError(address(vault), sharesOut, minSharesOut);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x520e27c613f1234755c23402524b048a81abd15222d7f318504992d490248812\",\"license\":\"GPL-3.0-only\"},\"contracts/TbtcDepositor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {Ownable} from \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport {SafeERC20} from \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {Math} from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\n\\nimport \\\"@keep-network/tbtc-v2/contracts/integrator/AbstractTBTCDepositor.sol\\\";\\n\\nimport {stBTC} from \\\"./stBTC.sol\\\";\\n\\n// TODO: Add Missfund token protection.\\n// TODO: Make Upgradable\\n\\n/// @title tBTC Depositor contract.\\n/// @notice The contract integrates Acre staking with tBTC minting.\\n/// User who wants to stake BTC in Acre should submit a Bitcoin transaction\\n/// to the most recently created off-chain ECDSA wallets of the tBTC Bridge\\n/// using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH)\\n/// containing hashed information about this Depositor contract address,\\n/// and staker's Ethereum address.\\n/// Then, the staker initiates tBTC minting by revealing their Ethereum\\n/// address along with their deposit blinding factor, refund public key\\n/// hash and refund locktime on the tBTC Bridge through this Depositor\\n/// contract.\\n/// The off-chain ECDSA wallet listens for these sorts of\\n/// messages and when it gets one, it checks the Bitcoin network to make\\n/// sure the deposit lines up. If it does, the off-chain ECDSA wallet\\n/// may decide to pick the deposit transaction for sweeping, and when\\n/// the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge\\n/// and tBTC vault mint the tBTC token to the Depositor address.\\n/// After tBTC is minted to the Depositor, on the stake finalization\\n/// tBTC is staked in stBTC contract and stBTC shares are emitted to the\\n/// receiver pointed by the staker.\\ncontract TbtcDepositor is AbstractTBTCDepositor, Ownable {\\n using BTCUtils for bytes;\\n using SafeERC20 for IERC20;\\n\\n struct StakeRequest {\\n // Timestamp at which the deposit request was initialized is not stored\\n // in this structure, as it is available under `Bridge.DepositRequest.revealedAt`.\\n\\n // UNIX timestamp at which the deposit request was finalized.\\n // 0 if not yet finalized.\\n uint64 finalizedAt;\\n // The address to which the stBTC shares will be minted.\\n address receiver;\\n // Identifier of a partner in the referral program.\\n uint16 referral;\\n // tBTC token amount to stake after deducting tBTC minting fees and the\\n // Depositor fee.\\n uint256 amountToStake;\\n }\\n\\n /// @notice tBTC Token contract.\\n IERC20 public immutable tbtcToken;\\n /// @notice stBTC contract.\\n stBTC public immutable stbtc;\\n\\n /// @notice Mapping of stake requests.\\n /// @dev The key is a deposit key identifying the deposit.\\n mapping(uint256 => StakeRequest) public stakeRequests;\\n\\n /// @notice Divisor used to compute the depositor fee taken from each deposit\\n /// and transferred to the treasury upon stake request finalization.\\n /// @dev That fee is computed as follows:\\n /// `depositorFee = depositedAmount / depositorFeeDivisor`\\n /// for example, if the depositor fee needs to be 2% of each deposit,\\n /// the `depositorFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n uint64 public depositorFeeDivisor;\\n\\n /// @notice Emitted when a stake request is initialized.\\n /// @dev Deposit details can be fetched from {{ Bridge.DepositRevealed }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that initialized the stake request.\\n /// @param receiver The address to which the stBTC shares will be minted.\\n event StakeRequestInitialized(\\n uint256 indexed depositKey,\\n address indexed caller,\\n address indexed receiver\\n );\\n\\n /// @notice Emitted when bridging completion has been notified.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that notified about bridging completion.\\n /// @param referral Identifier of a partner in the referral program.\\n /// @param bridgedAmount Amount of tBTC tokens that was bridged by the tBTC bridge.\\n /// @param depositorFee Depositor fee amount.\\n event BridgingCompleted(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint16 indexed referral,\\n uint256 bridgedAmount,\\n uint256 depositorFee\\n );\\n\\n /// @notice Emitted when a stake request is finalized.\\n /// @dev Deposit details can be fetched from {{ ERC4626.Deposit }}\\n /// event emitted in the same transaction.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param caller Address that finalized the stake request.\\n /// @param amountToStake Amount of staked tBTC tokens.\\n event StakeRequestFinalized(\\n uint256 indexed depositKey,\\n address indexed caller,\\n uint256 amountToStake\\n );\\n\\n /// @notice Emitted when a stake request is recalled.\\n /// @param depositKey Deposit key identifying the deposit.\\n /// @param receiver Address of the receiver.\\n /// @param amountToStake Amount of recalled tBTC tokens.\\n event StakeRequestRecalled(\\n uint256 indexed depositKey,\\n address indexed receiver,\\n uint256 amountToStake\\n );\\n\\n /// @notice Emitted when a depositor fee divisor is updated.\\n /// @param depositorFeeDivisor New value of the depositor fee divisor.\\n event DepositorFeeDivisorUpdated(uint64 depositorFeeDivisor);\\n\\n /// @dev Receiver address is zero.\\n error ReceiverIsZeroAddress();\\n\\n /// @dev Attempted to finalize a stake request, while bridging completion has\\n /// not been notified yet.\\n error BridgingNotCompleted();\\n\\n /// @dev Calculated depositor fee exceeds the amount of minted tBTC tokens.\\n error DepositorFeeExceedsBridgedAmount(\\n uint256 depositorFee,\\n uint256 bridgedAmount\\n );\\n\\n /// @dev Attempted to finalize a stake request that was already finalized.\\n error StakeRequestAlreadyFinalized();\\n\\n /// @dev Attempted to call function by an account that is not the receiver.\\n error CallerNotReceiver();\\n\\n /// @notice Tbtc Depositor contract constructor.\\n /// @param _bridge tBTC Bridge contract instance.\\n /// @param _tbtcVault tBTC Vault contract instance.\\n /// @param _stbtc stBTC contract instance.\\n // TODO: Move to initializer when making the contract upgradeable.\\n constructor(\\n address _bridge,\\n address _tbtcVault,\\n address _tbtcToken,\\n address _stbtc\\n ) Ownable(msg.sender) {\\n __AbstractTBTCDepositor_initialize(_bridge, _tbtcVault);\\n\\n require(_tbtcToken != address(0), \\\"TBTCToken address cannot be zero\\\");\\n require(_stbtc != address(0), \\\"stBTC address cannot be zero\\\");\\n\\n tbtcToken = IERC20(_tbtcToken);\\n stbtc = stBTC(_stbtc);\\n\\n depositorFeeDivisor = 1000; // 1/1000 == 10bps == 0.1% == 0.001\\n }\\n\\n /// @notice This function allows staking process initialization for a Bitcoin\\n /// deposit made by an user with a P2(W)SH transaction. It uses the\\n /// supplied information to reveal a deposit to the tBTC Bridge contract.\\n /// @dev Requirements:\\n /// - The revealed vault address must match the TBTCVault address,\\n /// - All requirements from {Bridge#revealDepositWithExtraData}\\n /// function must be met.\\n /// - `receiver` must be the receiver address used in the P2(W)SH BTC\\n /// deposit transaction as part of the extra data.\\n /// - `referral` must be the referral info used in the P2(W)SH BTC\\n /// deposit transaction as part of the extra data.\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n /// @param fundingTx Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.\\n /// @param reveal Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`.\\n /// @param receiver The address to which the stBTC shares will be minted.\\n /// @param referral Data used for referral program.\\n function initializeStakeRequest(\\n IBridgeTypes.BitcoinTxInfo calldata fundingTx,\\n IBridgeTypes.DepositRevealInfo calldata reveal,\\n address receiver,\\n uint16 referral\\n ) external {\\n if (receiver == address(0)) revert ReceiverIsZeroAddress();\\n\\n // We don't check if the request was already initialized, as this check\\n // is enforced in `_initializeDeposit` when calling the\\n // `Bridge.revealDepositWithExtraData` function.\\n\\n uint256 depositKey = _initializeDeposit(\\n fundingTx,\\n reveal,\\n encodeExtraData(receiver, referral)\\n );\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n request.receiver = receiver;\\n request.referral = referral;\\n\\n emit StakeRequestInitialized(depositKey, msg.sender, receiver);\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC minting process completed, meaning tBTC was\\n /// minted to this contract.\\n /// @dev It calculates the amount to stake based on the approximate minted\\n /// tBTC amount reduced by the depositor fee.\\n /// @dev IMPORTANT NOTE: The minted tBTC amount used by this function is an\\n /// approximation. See documentation of the\\n /// {{TBTCDepositorProxy#_calculateTbtcAmount}} responsible for calculating\\n /// this value for more details.\\n /// @param depositKey Deposit key identifying the deposit.\\n function notifyBridgingCompleted(uint256 depositKey) external {\\n (\\n uint256 depositAmount,\\n uint256 depositSubBridgingFeesAmount,\\n\\n ) = _finalizeDeposit(depositKey);\\n\\n // Compute depositor fee. The fee is calculated based on the initial funding\\n // transaction amount, before the tBTC protocol network fees were taken.\\n uint256 depositorFee = depositorFeeDivisor > 0\\n ? (depositAmount / depositorFeeDivisor)\\n : 0;\\n\\n // Ensure the depositor fee does not exceed the approximate minted tBTC\\n // amount.\\n if (depositorFee >= depositSubBridgingFeesAmount) {\\n revert DepositorFeeExceedsBridgedAmount(\\n depositorFee,\\n depositSubBridgingFeesAmount\\n );\\n }\\n\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n request.amountToStake = depositSubBridgingFeesAmount - depositorFee;\\n\\n emit BridgingCompleted(\\n depositKey,\\n msg.sender,\\n request.referral,\\n depositSubBridgingFeesAmount,\\n depositorFee\\n );\\n\\n // Transfer depositor fee to the treasury wallet.\\n if (depositorFee > 0) {\\n tbtcToken.safeTransfer(stbtc.treasury(), depositorFee);\\n }\\n }\\n\\n /// @notice This function should be called for previously initialized stake\\n /// request, after tBTC bridging process was finalized.\\n /// It stakes the tBTC from the given deposit into stBTC, emitting the\\n /// stBTC shares to the receiver specified in the deposit extra data\\n /// and using the referral provided in the extra data.\\n /// @dev This function is expected to be called after `notifyBridgingCompleted`.\\n /// In case depositing in stBTC vault fails (e.g. because of the\\n /// maximum deposit limit being reached), the function should be retried\\n /// after the limit is increased or other user withdraws their funds\\n /// from the stBTC contract to make place for another deposit.\\n /// The staker has a possibility to submit `recallStakeRequest` that\\n /// will withdraw the minted tBTC token and abort staking process.\\n /// @param depositKey Deposit key identifying the deposit.\\n function finalizeStakeRequest(uint256 depositKey) external {\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n if (request.amountToStake == 0) revert BridgingNotCompleted();\\n if (request.finalizedAt > 0) revert StakeRequestAlreadyFinalized();\\n\\n // solhint-disable-next-line not-rely-on-time\\n request.finalizedAt = uint64(block.timestamp);\\n\\n emit StakeRequestFinalized(\\n depositKey,\\n msg.sender,\\n request.amountToStake\\n );\\n\\n // Deposit tBTC in stBTC.\\n tbtcToken.safeIncreaseAllowance(address(stbtc), request.amountToStake);\\n // slither-disable-next-line unused-return\\n stbtc.deposit(request.amountToStake, request.receiver);\\n }\\n\\n /// @notice Recall bridged tBTC tokens from being requested to stake. This\\n /// function can be called by the staker to recover tBTC that cannot\\n /// be finalized to stake in stBTC contract due to a deposit limit being\\n /// reached.\\n /// @dev This function can be called only after bridging in tBTC Bridge was\\n /// completed. Only receiver provided in the extra data of the stake\\n /// request can call this function.\\n /// @param depositKey Deposit key identifying the deposit.\\n function recallStakeRequest(uint256 depositKey) external {\\n StakeRequest storage request = stakeRequests[depositKey];\\n\\n if (request.amountToStake == 0) revert BridgingNotCompleted();\\n if (request.finalizedAt > 0) revert StakeRequestAlreadyFinalized();\\n\\n // Check if caller is the receiver.\\n if (msg.sender != request.receiver) revert CallerNotReceiver();\\n\\n // solhint-disable-next-line not-rely-on-time\\n request.finalizedAt = uint64(block.timestamp);\\n\\n emit StakeRequestRecalled(\\n depositKey,\\n request.receiver,\\n request.amountToStake\\n );\\n\\n tbtcToken.safeTransfer(request.receiver, request.amountToStake);\\n }\\n\\n /// @notice Updates the depositor fee divisor.\\n /// @param newDepositorFeeDivisor New depositor fee divisor value.\\n function updateDepositorFeeDivisor(\\n uint64 newDepositorFeeDivisor\\n ) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n depositorFeeDivisor = newDepositorFeeDivisor;\\n\\n emit DepositorFeeDivisorUpdated(newDepositorFeeDivisor);\\n }\\n\\n // TODO: Handle minimum deposit amount in tBTC Bridge vs stBTC.\\n\\n /// @notice Encode receiver address and referral as extra data.\\n /// @dev Packs the data to bytes32: 20 bytes of receiver address and\\n /// 2 bytes of referral, 10 bytes of trailing zeros.\\n /// @param receiver The address to which the stBTC shares will be minted.\\n /// @param referral Data used for referral program.\\n /// @return Encoded extra data.\\n function encodeExtraData(\\n address receiver,\\n uint16 referral\\n ) public pure returns (bytes32) {\\n return bytes32(abi.encodePacked(receiver, referral));\\n }\\n}\\n\",\"keccak256\":\"0x1dc56bb3b4e6212341be7899343ae55fac01910dbeed6bef0088f722ad67a017\",\"license\":\"GPL-3.0-only\"},\"contracts/lib/ERC4626Fees.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\n// Inspired by https://docs.openzeppelin.com/contracts/5.x/erc4626#fees\\n\\npragma solidity ^0.8.20;\\n\\nimport {IERC20} from \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport {ERC4626} from \\\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\\\";\\nimport {SafeERC20} from \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport {Math} from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\n\\n/// @dev ERC4626 vault with entry/exit fees expressed in https://en.wikipedia.org/wiki/Basis_point[basis point (bp)].\\nabstract contract ERC4626Fees is ERC4626 {\\n using Math for uint256;\\n\\n uint256 private constant _BASIS_POINT_SCALE = 1e4;\\n\\n // === Overrides ===\\n\\n /// @dev Preview taking an entry fee on deposit. See {IERC4626-previewDeposit}.\\n function previewDeposit(\\n uint256 assets\\n ) public view virtual override returns (uint256) {\\n uint256 fee = _feeOnTotal(assets, _entryFeeBasisPoints());\\n return super.previewDeposit(assets - fee);\\n }\\n\\n /// @dev Preview adding an entry fee on mint. See {IERC4626-previewMint}.\\n function previewMint(\\n uint256 shares\\n ) public view virtual override returns (uint256) {\\n uint256 assets = super.previewMint(shares);\\n return assets + _feeOnRaw(assets, _entryFeeBasisPoints());\\n }\\n\\n // TODO: add previewWithraw\\n\\n // TODO: add previewRedeem\\n\\n /// @dev Send entry fee to {_feeRecipient}. See {IERC4626-_deposit}.\\n function _deposit(\\n address caller,\\n address receiver,\\n uint256 assets,\\n uint256 shares\\n ) internal virtual override {\\n uint256 fee = _feeOnTotal(assets, _entryFeeBasisPoints());\\n address recipient = _feeRecipient();\\n\\n super._deposit(caller, receiver, assets, shares);\\n\\n if (fee > 0 && recipient != address(this)) {\\n SafeERC20.safeTransfer(IERC20(asset()), recipient, fee);\\n }\\n }\\n\\n // TODO: add withdraw\\n\\n // === Fee configuration ===\\n\\n // slither-disable-next-line dead-code\\n function _entryFeeBasisPoints() internal view virtual returns (uint256);\\n\\n // TODO: add exitFeeBasisPoints\\n\\n // slither-disable-next-line dead-code\\n function _feeRecipient() internal view virtual returns (address);\\n\\n // === Fee operations ===\\n\\n /// @dev Calculates the fees that should be added to an amount `assets`\\n /// that does not already include fees.\\n /// Used in {IERC4626-mint} and {IERC4626-withdraw} operations.\\n function _feeOnRaw(\\n uint256 assets,\\n uint256 feeBasisPoints\\n ) private pure returns (uint256) {\\n return\\n assets.mulDiv(\\n feeBasisPoints,\\n _BASIS_POINT_SCALE,\\n Math.Rounding.Ceil\\n );\\n }\\n\\n /// @dev Calculates the fee part of an amount `assets` that already includes fees.\\n /// Used in {IERC4626-deposit} and {IERC4626-redeem} operations.\\n function _feeOnTotal(\\n uint256 assets,\\n uint256 feeBasisPoints\\n ) private pure returns (uint256) {\\n return\\n assets.mulDiv(\\n feeBasisPoints,\\n feeBasisPoints + _BASIS_POINT_SCALE,\\n Math.Rounding.Ceil\\n );\\n }\\n}\\n\",\"keccak256\":\"0xccfc01be23cbc979745a6e7f3421c4d050dc2ad7ddb6d9e1543c8e681e91d596\",\"license\":\"MIT\"},\"contracts/stBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity ^0.8.21;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"./Dispatcher.sol\\\";\\nimport \\\"./lib/ERC4626Fees.sol\\\";\\n\\n/// @title stBTC\\n/// @notice This contract implements the ERC-4626 tokenized vault standard. By\\n/// staking tBTC, users acquire a liquid staking token called stBTC,\\n/// commonly referred to as \\\"shares\\\". The staked tBTC is securely\\n/// deposited into Acre's vaults, where it generates yield over time.\\n/// Users have the flexibility to redeem stBTC, enabling them to\\n/// withdraw their staked tBTC along with the accrued yield.\\n/// @dev ERC-4626 is a standard to optimize and unify the technical parameters\\n/// of yield-bearing vaults. This contract facilitates the minting and\\n/// burning of shares (stBTC), which are represented as standard ERC20\\n/// tokens, providing a seamless exchange with tBTC tokens.\\ncontract stBTC is ERC4626Fees, Ownable {\\n using SafeERC20 for IERC20;\\n\\n /// Dispatcher contract that routes tBTC from stBTC to a given vault and back.\\n Dispatcher public dispatcher;\\n\\n /// Address of the treasury wallet, where fees should be transferred to.\\n address public treasury;\\n\\n /// Entry fee basis points applied to entry fee calculation.\\n uint256 public entryFeeBasisPoints;\\n\\n /// Minimum amount for a single deposit operation. The value should be set\\n /// low enough so the deposits routed through TbtcDepositor contract won't\\n /// be rejected. It means that minimumDepositAmount should be lower than\\n /// tBTC protocol's depositDustThreshold reduced by all the minting fees taken\\n /// before depositing in the Acre contract.\\n uint256 public minimumDepositAmount;\\n\\n /// Maximum total amount of tBTC token held by Acre protocol.\\n uint256 public maximumTotalAssets;\\n\\n /// Emitted when a referral is used.\\n /// @param referral Used for referral program.\\n /// @param assets Amount of tBTC tokens staked.\\n event StakeReferral(uint16 indexed referral, uint256 assets);\\n\\n /// Emitted when the treasury wallet address is updated.\\n /// @param treasury New treasury wallet address.\\n event TreasuryUpdated(address treasury);\\n\\n /// Emitted when deposit parameters are updated.\\n /// @param minimumDepositAmount New value of the minimum deposit amount.\\n /// @param maximumTotalAssets New value of the maximum total assets amount.\\n event DepositParametersUpdated(\\n uint256 minimumDepositAmount,\\n uint256 maximumTotalAssets\\n );\\n\\n /// Emitted when the dispatcher contract is updated.\\n /// @param oldDispatcher Address of the old dispatcher contract.\\n /// @param newDispatcher Address of the new dispatcher contract.\\n event DispatcherUpdated(address oldDispatcher, address newDispatcher);\\n\\n /// Emitted when the entry fee basis points are updated.\\n /// @param entryFeeBasisPoints New value of the fee basis points.\\n event EntryFeeBasisPointsUpdated(uint256 entryFeeBasisPoints);\\n\\n /// Reverts if the amount is less than the minimum deposit amount.\\n /// @param amount Amount to check.\\n /// @param min Minimum amount to check 'amount' against.\\n error LessThanMinDeposit(uint256 amount, uint256 min);\\n\\n /// Reverts if the address is zero.\\n error ZeroAddress();\\n\\n /// Reverts if the address is disallowed.\\n error DisallowedAddress();\\n\\n constructor(\\n IERC20 _tbtc,\\n address _treasury\\n ) ERC4626(_tbtc) ERC20(\\\"Acre Staked Bitcoin\\\", \\\"stBTC\\\") Ownable(msg.sender) {\\n if (address(_treasury) == address(0)) {\\n revert ZeroAddress();\\n }\\n treasury = _treasury;\\n // TODO: Revisit the exact values closer to the launch.\\n minimumDepositAmount = 0.001 * 1e18; // 0.001 tBTC\\n maximumTotalAssets = 25 * 1e18; // 25 tBTC\\n entryFeeBasisPoints = 5; // 5bps == 0.05% == 0.0005\\n }\\n\\n /// @notice Updates treasury wallet address.\\n /// @param newTreasury New treasury wallet address.\\n function updateTreasury(address newTreasury) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n if (newTreasury == address(0)) {\\n revert ZeroAddress();\\n }\\n if (newTreasury == address(this)) {\\n revert DisallowedAddress();\\n }\\n treasury = newTreasury;\\n\\n emit TreasuryUpdated(newTreasury);\\n }\\n\\n /// @notice Updates deposit parameters.\\n /// @dev To disable the limit for deposits, set the maximum total assets to\\n /// maximum (`type(uint256).max`).\\n /// @param _minimumDepositAmount New value of the minimum deposit amount. It\\n /// is the minimum amount for a single deposit operation.\\n /// @param _maximumTotalAssets New value of the maximum total assets amount.\\n /// It is the maximum amount of the tBTC token that the Acre protocol\\n /// can hold.\\n function updateDepositParameters(\\n uint256 _minimumDepositAmount,\\n uint256 _maximumTotalAssets\\n ) external onlyOwner {\\n // TODO: Introduce a parameters update process.\\n minimumDepositAmount = _minimumDepositAmount;\\n maximumTotalAssets = _maximumTotalAssets;\\n\\n emit DepositParametersUpdated(\\n _minimumDepositAmount,\\n _maximumTotalAssets\\n );\\n }\\n\\n // TODO: Implement a governed upgrade process that initiates an update and\\n // then finalizes it after a delay.\\n /// @notice Updates the dispatcher contract and gives it an unlimited\\n /// allowance to transfer staked tBTC.\\n /// @param newDispatcher Address of the new dispatcher contract.\\n function updateDispatcher(Dispatcher newDispatcher) external onlyOwner {\\n if (address(newDispatcher) == address(0)) {\\n revert ZeroAddress();\\n }\\n\\n address oldDispatcher = address(dispatcher);\\n\\n emit DispatcherUpdated(oldDispatcher, address(newDispatcher));\\n dispatcher = newDispatcher;\\n\\n // TODO: Once withdrawal/rebalancing is implemented, we need to revoke the\\n // approval of the vaults share tokens from the old dispatcher and approve\\n // a new dispatcher to manage the share tokens.\\n\\n if (oldDispatcher != address(0)) {\\n // Setting allowance to zero for the old dispatcher\\n IERC20(asset()).forceApprove(oldDispatcher, 0);\\n }\\n\\n // Setting allowance to max for the new dispatcher\\n IERC20(asset()).forceApprove(address(dispatcher), type(uint256).max);\\n }\\n\\n // TODO: Implement a governed upgrade process that initiates an update and\\n // then finalizes it after a delay.\\n /// @notice Update the entry fee basis points.\\n /// @param newEntryFeeBasisPoints New value of the fee basis points.\\n function updateEntryFeeBasisPoints(\\n uint256 newEntryFeeBasisPoints\\n ) external onlyOwner {\\n entryFeeBasisPoints = newEntryFeeBasisPoints;\\n\\n emit EntryFeeBasisPointsUpdated(newEntryFeeBasisPoints);\\n }\\n\\n /// @notice Mints shares to receiver by depositing exactly amount of\\n /// tBTC tokens.\\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\\n /// which determines the minimum amount for a single deposit operation.\\n /// The amount of the assets has to be pre-approved in the tBTC\\n /// contract.\\n /// @param assets Approved amount of tBTC tokens to deposit. This includes\\n /// treasury fees for staking tBTC.\\n /// @param receiver The address to which the shares will be minted.\\n /// @return Minted shares adjusted for the fees taken by the treasury.\\n function deposit(\\n uint256 assets,\\n address receiver\\n ) public override returns (uint256) {\\n if (assets < minimumDepositAmount) {\\n revert LessThanMinDeposit(assets, minimumDepositAmount);\\n }\\n\\n return super.deposit(assets, receiver);\\n }\\n\\n /// @notice Mints shares to receiver by depositing tBTC tokens.\\n /// @dev Takes into account a deposit parameter, minimum deposit amount,\\n /// which determines the minimum amount for a single deposit operation.\\n /// The amount of the assets has to be pre-approved in the tBTC\\n /// contract.\\n /// The msg.sender is required to grant approval for the transfer of a\\n /// certain amount of tBTC, and in addition, approval for the associated\\n /// fee. Specifically, the total amount to be approved (amountToApprove)\\n /// should be equal to the sum of the deposited amount and the fee.\\n /// To determine the total assets amount necessary for approval\\n /// corresponding to a given share amount, use the `previewMint` function.\\n /// @param shares Amount of shares to mint.\\n /// @param receiver The address to which the shares will be minted.\\n function mint(\\n uint256 shares,\\n address receiver\\n ) public override returns (uint256 assets) {\\n if ((assets = super.mint(shares, receiver)) < minimumDepositAmount) {\\n revert LessThanMinDeposit(assets, minimumDepositAmount);\\n }\\n }\\n\\n /// @notice Stakes a given amount of tBTC token and mints shares to a\\n /// receiver.\\n /// @dev This function calls `deposit` function from `ERC4626` contract. The\\n /// amount of the assets has to be pre-approved in the tBTC contract.\\n /// @param assets Approved amount for the transfer and stake.\\n /// @param receiver The address to which the shares will be minted.\\n /// @param referral Data used for referral program.\\n /// @return shares Minted shares.\\n function stake(\\n uint256 assets,\\n address receiver,\\n uint16 referral\\n ) public returns (uint256) {\\n // TODO: revisit the type of referral.\\n uint256 shares = deposit(assets, receiver);\\n\\n if (referral > 0) {\\n emit StakeReferral(referral, assets);\\n }\\n\\n return shares;\\n }\\n\\n /// @notice Returns the maximum amount of the tBTC token that can be\\n /// deposited into the vault for the receiver through a deposit\\n /// call. It takes into account the deposit parameter, maximum total\\n /// assets, which determines the total amount of tBTC token held by\\n /// Acre. This function always returns available limit for deposits,\\n /// but the fee is not taken into account. As a result of this, there\\n /// always will be some dust left. If the dust is lower than the\\n /// minimum deposit amount, this function will return 0.\\n /// @return The maximum amount of tBTC token that can be deposited into\\n /// Acre protocol for the receiver.\\n function maxDeposit(address) public view override returns (uint256) {\\n if (maximumTotalAssets == type(uint256).max) {\\n return type(uint256).max;\\n }\\n\\n uint256 currentTotalAssets = totalAssets();\\n if (currentTotalAssets >= maximumTotalAssets) return 0;\\n\\n // Max amount left for next deposits. If it is lower than the minimum\\n // deposit amount, return 0.\\n uint256 unusedLimit = maximumTotalAssets - currentTotalAssets;\\n\\n return minimumDepositAmount > unusedLimit ? 0 : unusedLimit;\\n }\\n\\n /// @notice Returns the maximum amount of the vault shares that can be\\n /// minted for the receiver, through a mint call.\\n /// @dev Since the stBTC contract limits the maximum total tBTC tokens this\\n /// function converts the maximum deposit amount to shares.\\n /// @return The maximum amount of the vault shares.\\n function maxMint(address receiver) public view override returns (uint256) {\\n uint256 _maxDeposit = maxDeposit(receiver);\\n\\n // slither-disable-next-line incorrect-equality\\n return\\n _maxDeposit == type(uint256).max\\n ? type(uint256).max\\n : convertToShares(_maxDeposit);\\n }\\n\\n /// @return Returns deposit parameters.\\n function depositParameters() public view returns (uint256, uint256) {\\n return (minimumDepositAmount, maximumTotalAssets);\\n }\\n\\n /// @notice Redeems shares for tBTC tokens.\\n function _entryFeeBasisPoints() internal view override returns (uint256) {\\n return entryFeeBasisPoints;\\n }\\n\\n /// @notice Returns the address of the treasury wallet, where fees should be\\n /// transferred to.\\n function _feeRecipient() internal view override returns (address) {\\n return treasury;\\n }\\n}\\n\",\"keccak256\":\"0x5e622d3cef791a39b7089c64cacd5c62f14c13af316e2e8a3141244f7f69324e\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", - "bytecode": "0x60c06040523480156200001157600080fd5b506040516200215538038062002155833981016040819052620000349162000322565b33806200005c57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000678162000152565b50620000748484620001a4565b6001600160a01b038216620000cc5760405162461bcd60e51b815260206004820181905260248201527f54425443546f6b656e20616464726573732063616e6e6f74206265207a65726f604482015260640162000053565b6001600160a01b038116620001245760405162461bcd60e51b815260206004820152601c60248201527f737442544320616464726573732063616e6e6f74206265207a65726f00000000604482015260640162000053565b6001600160a01b039182166080521660a0525050603480546001600160401b0319166103e81790556200037f565b603280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000546001600160a01b0316158015620001c757506001546001600160a01b0316155b620002275760405162461bcd60e51b815260206004820152602960248201527f4162737472616374544254434465706f7369746f7220616c726561647920696e6044820152681a5d1a585b1a5e995960ba1b606482015260840162000053565b6001600160a01b0382166200027f5760405162461bcd60e51b815260206004820152601d60248201527f42726964676520616464726573732063616e6e6f74206265207a65726f000000604482015260640162000053565b6001600160a01b038116620002d75760405162461bcd60e51b815260206004820181905260248201527f544254435661756c7420616464726573732063616e6e6f74206265207a65726f604482015260640162000053565b600080546001600160a01b039384166001600160a01b03199182161790915560018054929093169116179055565b80516001600160a01b03811681146200031d57600080fd5b919050565b600080600080608085870312156200033957600080fd5b620003448562000305565b9350620003546020860162000305565b9250620003646040860162000305565b9150620003746060860162000305565b905092959194509250565b60805160a051611d86620003cf600039600081816101dd01528181610447015281816104bf015261063301526000818161031501528181610424015281816106bd01526108fa0152611d866000f3fe608060405234801561001057600080fd5b506004361061011b5760003560e01c80639bef6d52116100b2578063d0714ad511610081578063e5d3d71411610066578063e5d3d71414610310578063e78cea9214610337578063f2fde38b1461034a57600080fd5b8063d0714ad51461026b578063d7820273146102fd57600080fd5b80639bef6d52146101d8578063a7932794146101ff578063c143d67514610232578063c7ba03471461025f57600080fd5b80633d11a6ae116100ee5780633d11a6ae1461018b578063715018a6146101ac5780637cea8689146101b45780638da5cb5b146101c757600080fd5b80630e8491c5146101205780630f36403a146101355780631dc2004d146101655780633647b20514610178575b600080fd5b61013361012e366004611638565b61035d565b005b600154610148906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610133610173366004611638565b610531565b610133610186366004611667565b6106eb565b61019e6101993660046116bb565b610749565b60405190815260200161015c565b6101336107b8565b6101336101c2366004611638565b6107cc565b6032546001600160a01b0316610148565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b61022261020d366004611638565b60026020526000908152604090205460ff1681565b604051901515815260200161015c565b6034546102469067ffffffffffffffff1681565b60405167ffffffffffffffff909116815260200161015c565b61019e6402540be40081565b6102c1610279366004611638565b6033602052600090815260409020805460019091015467ffffffffffffffff8216916801000000000000000081046001600160a01b031691600160e01b90910461ffff169084565b6040805167ffffffffffffffff90951685526001600160a01b03909316602085015261ffff90911691830191909152606082015260800161015c565b61013361030b3660046116f0565b610934565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b600054610148906001600160a01b031681565b610133610358366004611774565b610a3f565b6000818152603360205260408120600181015490910361039057604051632f3d137560e11b815260040160405180910390fd5b805467ffffffffffffffff16156103ba57604051631960824560e01b815260040160405180910390fd5b805467ffffffffffffffff19164267ffffffffffffffff161781556001810154604051908152339083907f2b57d79a66895fd41ae6d27049952259b0d40a9b7c563a99b3f1844b288da08c9060200160405180910390a3600181015461046c906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016907f000000000000000000000000000000000000000000000000000000000000000090610a96565b600181015481546040517f6e553f6500000000000000000000000000000000000000000000000000000000815260048101929092526801000000000000000090046001600160a01b0390811660248301527f00000000000000000000000000000000000000000000000000000000000000001690636e553f65906044016020604051808303816000875af1158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c9190611791565b505050565b60008061053d83610b3f565b50603454919350915060009067ffffffffffffffff1661055e576000610575565b6034546105759067ffffffffffffffff16846117c0565b90508181106105bf576040517f2395edf200000000000000000000000000000000000000000000000000000000815260048101829052602481018390526044015b60405180910390fd5b60008481526033602052604090206105d782846117e2565b600182015580546040805185815260208101859052600160e01b90920461ffff1691339188917f6410e64d304208a5e90fc76ab4fbf4e7b8836705daeda8dde27611ae0524490a910160405180910390a481156106e4576106e47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b39190611800565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169084610de7565b5050505050565b6106f3610e5b565b6034805467ffffffffffffffff191667ffffffffffffffff83169081179091556040519081527f53a618edd6eab9ce346f438670ebd45da60fa3d85662375fae2b8beadf08faf39060200160405180910390a150565b6040516bffffffffffffffffffffffff19606084901b1660208201527fffff00000000000000000000000000000000000000000000000000000000000060f083901b1660348201526000906036016040516020818303038152906040526107af9061181d565b90505b92915050565b6107c0610e5b565b6107ca6000610ea1565b565b600081815260336020526040812060018101549091036107ff57604051632f3d137560e11b815260040160405180910390fd5b805467ffffffffffffffff161561082957604051631960824560e01b815260040160405180910390fd5b80546801000000000000000090046001600160a01b03163314610878576040517f93f2d2aa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805467ffffffffffffffff19164267ffffffffffffffff16178082556001820154604051908152680100000000000000009091046001600160a01b03169083907f27cfa5af2e7eaf7c58bf2ba2ee252e69260b83b8efc6fb2c1f4563e4d4b70f769060200160405180910390a380546001820154610930916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811692680100000000000000009092041690610de7565b5050565b6001600160a01b038216610974576040517f80f67d2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061098a85856109858686610749565b610f0b565b60008181526033602052604080822080547fffff00000000000000000000000000000000000000000000ffffffffffffffff16680100000000000000006001600160a01b0389169081027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691909117600160e01b61ffff8916021782559151939450929091339185917f8d019883471b734b0033fe25a5b76c3afefbbfa9e9b3dacdbabf505b9e4f455d91a4505050505050565b610a47610e5b565b6001600160a01b038116610a8a576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016105b6565b610a9381610ea1565b50565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b239190611791565b9050610b398484610b348585611844565b611082565b50505050565b6000818152600260205260408120548190819060ff16610ba15760405162461bcd60e51b815260206004820152601760248201527f4465706f736974206e6f7420696e697469616c697a656400000000000000000060448201526064016105b6565b600080546040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b039091169063b02c43d09060240160e060405180830381865afa158015610c04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c28919061187f565b6001546040517f6c626aa4000000000000000000000000000000000000000000000000000000008152600481018890529192506000916001600160a01b0390911690636c626aa49060240160408051808303816000875af1158015610c91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb59190611939565b9150508160a0015163ffffffff166000141580610cdb575067ffffffffffffffff811615155b610d4d5760405162461bcd60e51b815260206004820152602360248201527f4465706f736974206e6f742066696e616c697a6564206279207468652062726960448201527f646765000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6000868152600260209081526040909120805460ff19169055820151610d83906402540be4009067ffffffffffffffff16611973565b9450610d9782602001518360800151611140565b6040805182815263ffffffff4216602082015291955087917f417b6288c9f637614f8b3f7a275fb4e44e517930fde949e463d58dfe0b97f28b910160405180910390a25060c00151929491935050565b6040516001600160a01b0383811660248301526044820183905261052c91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506112c3565b6032546001600160a01b031633146107ca576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016105b6565b603280546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001546000906001600160a01b0316610f2a60c0850160a08601611774565b6001600160a01b031614610f805760405162461bcd60e51b815260206004820152601660248201527f5661756c742061646472657373206d69736d617463680000000000000000000060448201526064016105b6565b6000610fa0610f8e8661133f565b610f9b602087018761198a565b6113a4565b600081815260026020908152604091829020805460ff1916600117905590514263ffffffff16815291925082917fa3ed7aef0745e1a91addae9e5daee7a8ace74852fec840b9d93da747855dd7b9910160405180910390a26000546040517f86f014390000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906386f014399061104590889088908890600401611a52565b600060405180830381600087803b15801561105f57600080fd5b505af1158015611073573d6000803e3d6000fd5b509293505050505b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261110184826113ee565b610b39576040516001600160a01b0384811660248301526000604483015261113691869182169063095ea7b390606401610e14565b610b3984826112c3565b6000806402540be4006111538486611bb7565b67ffffffffffffffff166111679190611973565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166309b53f516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e29190611bdf565b63ffffffff16905060008082116111fa576000611204565b61120482846117c0565b905060008060009054906101000a90046001600160a01b03166001600160a01b031663c42b64d06040518163ffffffff1660e01b8152600401608060405180830381865afa15801561125a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127e9190611bfc565b509250505060006402540be4008267ffffffffffffffff166112a09190611973565b9050806112ad84876117e2565b6112b791906117e2565b98975050505050505050565b60006112d86001600160a01b03841683611496565b905080516000141580156112fd5750808060200190518101906112fb9190611c5b565b155b1561052c576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105b6565b60006107b26113516020840184611c7d565b61135e6020850185611c98565b61136b6040870187611c98565b61137b6080890160608a01611c7d565b60405160200161139096959493929190611cdf565b6040516020818303038152906040526114a4565b600082826040516020016113cf92919091825260e01b6001600160e01b031916602082015260240190565b60408051601f1981840301815291905280516020909101209392505050565b6000806000846001600160a01b03168460405161140b9190611d21565b6000604051808303816000865af19150503d8060008114611448576040519150601f19603f3d011682016040523d82523d6000602084013e61144d565b606091505b50915091508180156114775750805115806114775750808060200190518101906114779190611c5b565b801561148d57506000856001600160a01b03163b115b95945050505050565b60606107af838360006114cb565b60006020600083516020850160025afa50602060006020600060025afa5050600051919050565b606081471015611509576040517fcd7860590000000000000000000000000000000000000000000000000000000081523060048201526024016105b6565b600080856001600160a01b031684866040516115259190611d21565b60006040518083038185875af1925050503d8060008114611562576040519150601f19603f3d011682016040523d82523d6000602084013e611567565b606091505b5091509150611577868383611581565b9695505050505050565b60608261159657611591826115f6565b61107b565b81511580156115ad57506001600160a01b0384163b155b156115ef576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016105b6565b508061107b565b8051156116065780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006020828403121561164a57600080fd5b5035919050565b67ffffffffffffffff81168114610a9357600080fd5b60006020828403121561167957600080fd5b813561107b81611651565b6001600160a01b0381168114610a9357600080fd5b80356116a481611684565b919050565b803561ffff811681146116a457600080fd5b600080604083850312156116ce57600080fd5b82356116d981611684565b91506116e7602084016116a9565b90509250929050565b60008060008084860361012081121561170857600080fd5b853567ffffffffffffffff81111561171f57600080fd5b86016080818903121561173157600080fd5b945060c0601f198201121561174557600080fd5b5060208501925060e085013561175a81611684565b915061176961010086016116a9565b905092959194509250565b60006020828403121561178657600080fd5b813561107b81611684565b6000602082840312156117a357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000826117dd57634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156107b2576107b26117aa565b80516116a481611684565b60006020828403121561181257600080fd5b815161107b81611684565b8051602080830151919081101561183e576000198160200360031b1b821691505b50919050565b808201808211156107b2576107b26117aa565b80516116a481611651565b63ffffffff81168114610a9357600080fd5b80516116a481611862565b600060e0828403121561189157600080fd5b60405160e0810181811067ffffffffffffffff821117156118c257634e487b7160e01b600052604160045260246000fd5b6040526118ce836117f5565b81526118dc60208401611857565b60208201526118ed60408401611874565b60408201526118fe606084016117f5565b606082015261190f60808401611857565b608082015261192060a08401611874565b60a082015260c083015160c08201528091505092915050565b6000806040838503121561194c57600080fd5b825161195781611651565b602084015190925061196881611651565b809150509250929050565b80820281158282048414176107b2576107b26117aa565b60006020828403121561199c57600080fd5b813561107b81611862565b80356001600160e01b0319811681146116a457600080fd5b6000808335601e198436030181126119d657600080fd5b830160208101925035905067ffffffffffffffff8111156119f657600080fd5b803603821315611a0557600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b80356bffffffffffffffffffffffff19811681146116a457600080fd5b60006101008083526001600160e01b031980611a6d886119a7565b1682850152611a7f60208801886119bf565b92506080610120860152611a9861018086018483611a0c565b925050611aa860408801886119bf565b85840360ff1901610140870152611ac0848284611a0c565b9350505080611ad1606089016119a7565b166101608501525090508335611ae681611862565b63ffffffff811660208401525060208401357fffffffffffffffff0000000000000000000000000000000000000000000000008116808214611b2757600080fd5b80604085015250506bffffffffffffffffffffffff19611b4960408601611a35565b166060830152611b5b60608501611a35565b6bffffffffffffffffffffffff198116608084015250611b7d608085016119a7565b6001600160e01b0319811660a084015250611b9a60a08501611699565b6001600160a01b031660c083015260e09091019190915292915050565b67ffffffffffffffff828116828216039080821115611bd857611bd86117aa565b5092915050565b600060208284031215611bf157600080fd5b815161107b81611862565b60008060008060808587031215611c1257600080fd5b8451611c1d81611651565b6020860151909450611c2e81611651565b6040860151909350611c3f81611651565b6060860151909250611c5081611862565b939692955090935050565b600060208284031215611c6d57600080fd5b8151801515811461107b57600080fd5b600060208284031215611c8f57600080fd5b6107af826119a7565b6000808335601e19843603018112611caf57600080fd5b83018035915067ffffffffffffffff821115611cca57600080fd5b602001915036819003821315611a0557600080fd5b60006001600160e01b03198089168352868860048501378683016004810160008152868882375093169390920160048101939093525050600801949350505050565b6000825160005b81811015611d425760208186018101518583015201611d28565b50600092019182525091905056fea2646970667358221220d7e96a88169fbbb6355b500c970d1027a84d03bce2cf68304d33d263b06d67d964736f6c63430008150033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061011b5760003560e01c80639bef6d52116100b2578063d0714ad511610081578063e5d3d71411610066578063e5d3d71414610310578063e78cea9214610337578063f2fde38b1461034a57600080fd5b8063d0714ad51461026b578063d7820273146102fd57600080fd5b80639bef6d52146101d8578063a7932794146101ff578063c143d67514610232578063c7ba03471461025f57600080fd5b80633d11a6ae116100ee5780633d11a6ae1461018b578063715018a6146101ac5780637cea8689146101b45780638da5cb5b146101c757600080fd5b80630e8491c5146101205780630f36403a146101355780631dc2004d146101655780633647b20514610178575b600080fd5b61013361012e366004611638565b61035d565b005b600154610148906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610133610173366004611638565b610531565b610133610186366004611667565b6106eb565b61019e6101993660046116bb565b610749565b60405190815260200161015c565b6101336107b8565b6101336101c2366004611638565b6107cc565b6032546001600160a01b0316610148565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b61022261020d366004611638565b60026020526000908152604090205460ff1681565b604051901515815260200161015c565b6034546102469067ffffffffffffffff1681565b60405167ffffffffffffffff909116815260200161015c565b61019e6402540be40081565b6102c1610279366004611638565b6033602052600090815260409020805460019091015467ffffffffffffffff8216916801000000000000000081046001600160a01b031691600160e01b90910461ffff169084565b6040805167ffffffffffffffff90951685526001600160a01b03909316602085015261ffff90911691830191909152606082015260800161015c565b61013361030b3660046116f0565b610934565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b600054610148906001600160a01b031681565b610133610358366004611774565b610a3f565b6000818152603360205260408120600181015490910361039057604051632f3d137560e11b815260040160405180910390fd5b805467ffffffffffffffff16156103ba57604051631960824560e01b815260040160405180910390fd5b805467ffffffffffffffff19164267ffffffffffffffff161781556001810154604051908152339083907f2b57d79a66895fd41ae6d27049952259b0d40a9b7c563a99b3f1844b288da08c9060200160405180910390a3600181015461046c906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016907f000000000000000000000000000000000000000000000000000000000000000090610a96565b600181015481546040517f6e553f6500000000000000000000000000000000000000000000000000000000815260048101929092526801000000000000000090046001600160a01b0390811660248301527f00000000000000000000000000000000000000000000000000000000000000001690636e553f65906044016020604051808303816000875af1158015610508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052c9190611791565b505050565b60008061053d83610b3f565b50603454919350915060009067ffffffffffffffff1661055e576000610575565b6034546105759067ffffffffffffffff16846117c0565b90508181106105bf576040517f2395edf200000000000000000000000000000000000000000000000000000000815260048101829052602481018390526044015b60405180910390fd5b60008481526033602052604090206105d782846117e2565b600182015580546040805185815260208101859052600160e01b90920461ffff1691339188917f6410e64d304208a5e90fc76ab4fbf4e7b8836705daeda8dde27611ae0524490a910160405180910390a481156106e4576106e47f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561068f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106b39190611800565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169084610de7565b5050505050565b6106f3610e5b565b6034805467ffffffffffffffff191667ffffffffffffffff83169081179091556040519081527f53a618edd6eab9ce346f438670ebd45da60fa3d85662375fae2b8beadf08faf39060200160405180910390a150565b6040516bffffffffffffffffffffffff19606084901b1660208201527fffff00000000000000000000000000000000000000000000000000000000000060f083901b1660348201526000906036016040516020818303038152906040526107af9061181d565b90505b92915050565b6107c0610e5b565b6107ca6000610ea1565b565b600081815260336020526040812060018101549091036107ff57604051632f3d137560e11b815260040160405180910390fd5b805467ffffffffffffffff161561082957604051631960824560e01b815260040160405180910390fd5b80546801000000000000000090046001600160a01b03163314610878576040517f93f2d2aa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805467ffffffffffffffff19164267ffffffffffffffff16178082556001820154604051908152680100000000000000009091046001600160a01b03169083907f27cfa5af2e7eaf7c58bf2ba2ee252e69260b83b8efc6fb2c1f4563e4d4b70f769060200160405180910390a380546001820154610930916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811692680100000000000000009092041690610de7565b5050565b6001600160a01b038216610974576040517f80f67d2300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061098a85856109858686610749565b610f0b565b60008181526033602052604080822080547fffff00000000000000000000000000000000000000000000ffffffffffffffff16680100000000000000006001600160a01b0389169081027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff1691909117600160e01b61ffff8916021782559151939450929091339185917f8d019883471b734b0033fe25a5b76c3afefbbfa9e9b3dacdbabf505b9e4f455d91a4505050505050565b610a47610e5b565b6001600160a01b038116610a8a576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016105b6565b610a9381610ea1565b50565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610aff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b239190611791565b9050610b398484610b348585611844565b611082565b50505050565b6000818152600260205260408120548190819060ff16610ba15760405162461bcd60e51b815260206004820152601760248201527f4465706f736974206e6f7420696e697469616c697a656400000000000000000060448201526064016105b6565b600080546040517fb02c43d0000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b039091169063b02c43d09060240160e060405180830381865afa158015610c04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c28919061187f565b6001546040517f6c626aa4000000000000000000000000000000000000000000000000000000008152600481018890529192506000916001600160a01b0390911690636c626aa49060240160408051808303816000875af1158015610c91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb59190611939565b9150508160a0015163ffffffff166000141580610cdb575067ffffffffffffffff811615155b610d4d5760405162461bcd60e51b815260206004820152602360248201527f4465706f736974206e6f742066696e616c697a6564206279207468652062726960448201527f646765000000000000000000000000000000000000000000000000000000000060648201526084016105b6565b6000868152600260209081526040909120805460ff19169055820151610d83906402540be4009067ffffffffffffffff16611973565b9450610d9782602001518360800151611140565b6040805182815263ffffffff4216602082015291955087917f417b6288c9f637614f8b3f7a275fb4e44e517930fde949e463d58dfe0b97f28b910160405180910390a25060c00151929491935050565b6040516001600160a01b0383811660248301526044820183905261052c91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506112c3565b6032546001600160a01b031633146107ca576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016105b6565b603280546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001546000906001600160a01b0316610f2a60c0850160a08601611774565b6001600160a01b031614610f805760405162461bcd60e51b815260206004820152601660248201527f5661756c742061646472657373206d69736d617463680000000000000000000060448201526064016105b6565b6000610fa0610f8e8661133f565b610f9b602087018761198a565b6113a4565b600081815260026020908152604091829020805460ff1916600117905590514263ffffffff16815291925082917fa3ed7aef0745e1a91addae9e5daee7a8ace74852fec840b9d93da747855dd7b9910160405180910390a26000546040517f86f014390000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906386f014399061104590889088908890600401611a52565b600060405180830381600087803b15801561105f57600080fd5b505af1158015611073573d6000803e3d6000fd5b509293505050505b9392505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261110184826113ee565b610b39576040516001600160a01b0384811660248301526000604483015261113691869182169063095ea7b390606401610e14565b610b3984826112c3565b6000806402540be4006111538486611bb7565b67ffffffffffffffff166111679190611973565b90506000600160009054906101000a90046001600160a01b03166001600160a01b03166309b53f516040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e29190611bdf565b63ffffffff16905060008082116111fa576000611204565b61120482846117c0565b905060008060009054906101000a90046001600160a01b03166001600160a01b031663c42b64d06040518163ffffffff1660e01b8152600401608060405180830381865afa15801561125a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127e9190611bfc565b509250505060006402540be4008267ffffffffffffffff166112a09190611973565b9050806112ad84876117e2565b6112b791906117e2565b98975050505050505050565b60006112d86001600160a01b03841683611496565b905080516000141580156112fd5750808060200190518101906112fb9190611c5b565b155b1561052c576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024016105b6565b60006107b26113516020840184611c7d565b61135e6020850185611c98565b61136b6040870187611c98565b61137b6080890160608a01611c7d565b60405160200161139096959493929190611cdf565b6040516020818303038152906040526114a4565b600082826040516020016113cf92919091825260e01b6001600160e01b031916602082015260240190565b60408051601f1981840301815291905280516020909101209392505050565b6000806000846001600160a01b03168460405161140b9190611d21565b6000604051808303816000865af19150503d8060008114611448576040519150601f19603f3d011682016040523d82523d6000602084013e61144d565b606091505b50915091508180156114775750805115806114775750808060200190518101906114779190611c5b565b801561148d57506000856001600160a01b03163b115b95945050505050565b60606107af838360006114cb565b60006020600083516020850160025afa50602060006020600060025afa5050600051919050565b606081471015611509576040517fcd7860590000000000000000000000000000000000000000000000000000000081523060048201526024016105b6565b600080856001600160a01b031684866040516115259190611d21565b60006040518083038185875af1925050503d8060008114611562576040519150601f19603f3d011682016040523d82523d6000602084013e611567565b606091505b5091509150611577868383611581565b9695505050505050565b60608261159657611591826115f6565b61107b565b81511580156115ad57506001600160a01b0384163b155b156115ef576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016105b6565b508061107b565b8051156116065780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006020828403121561164a57600080fd5b5035919050565b67ffffffffffffffff81168114610a9357600080fd5b60006020828403121561167957600080fd5b813561107b81611651565b6001600160a01b0381168114610a9357600080fd5b80356116a481611684565b919050565b803561ffff811681146116a457600080fd5b600080604083850312156116ce57600080fd5b82356116d981611684565b91506116e7602084016116a9565b90509250929050565b60008060008084860361012081121561170857600080fd5b853567ffffffffffffffff81111561171f57600080fd5b86016080818903121561173157600080fd5b945060c0601f198201121561174557600080fd5b5060208501925060e085013561175a81611684565b915061176961010086016116a9565b905092959194509250565b60006020828403121561178657600080fd5b813561107b81611684565b6000602082840312156117a357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000826117dd57634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156107b2576107b26117aa565b80516116a481611684565b60006020828403121561181257600080fd5b815161107b81611684565b8051602080830151919081101561183e576000198160200360031b1b821691505b50919050565b808201808211156107b2576107b26117aa565b80516116a481611651565b63ffffffff81168114610a9357600080fd5b80516116a481611862565b600060e0828403121561189157600080fd5b60405160e0810181811067ffffffffffffffff821117156118c257634e487b7160e01b600052604160045260246000fd5b6040526118ce836117f5565b81526118dc60208401611857565b60208201526118ed60408401611874565b60408201526118fe606084016117f5565b606082015261190f60808401611857565b608082015261192060a08401611874565b60a082015260c083015160c08201528091505092915050565b6000806040838503121561194c57600080fd5b825161195781611651565b602084015190925061196881611651565b809150509250929050565b80820281158282048414176107b2576107b26117aa565b60006020828403121561199c57600080fd5b813561107b81611862565b80356001600160e01b0319811681146116a457600080fd5b6000808335601e198436030181126119d657600080fd5b830160208101925035905067ffffffffffffffff8111156119f657600080fd5b803603821315611a0557600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b80356bffffffffffffffffffffffff19811681146116a457600080fd5b60006101008083526001600160e01b031980611a6d886119a7565b1682850152611a7f60208801886119bf565b92506080610120860152611a9861018086018483611a0c565b925050611aa860408801886119bf565b85840360ff1901610140870152611ac0848284611a0c565b9350505080611ad1606089016119a7565b166101608501525090508335611ae681611862565b63ffffffff811660208401525060208401357fffffffffffffffff0000000000000000000000000000000000000000000000008116808214611b2757600080fd5b80604085015250506bffffffffffffffffffffffff19611b4960408601611a35565b166060830152611b5b60608501611a35565b6bffffffffffffffffffffffff198116608084015250611b7d608085016119a7565b6001600160e01b0319811660a084015250611b9a60a08501611699565b6001600160a01b031660c083015260e09091019190915292915050565b67ffffffffffffffff828116828216039080821115611bd857611bd86117aa565b5092915050565b600060208284031215611bf157600080fd5b815161107b81611862565b60008060008060808587031215611c1257600080fd5b8451611c1d81611651565b6020860151909450611c2e81611651565b6040860151909350611c3f81611651565b6060860151909250611c5081611862565b939692955090935050565b600060208284031215611c6d57600080fd5b8151801515811461107b57600080fd5b600060208284031215611c8f57600080fd5b6107af826119a7565b6000808335601e19843603018112611caf57600080fd5b83018035915067ffffffffffffffff821115611cca57600080fd5b602001915036819003821315611a0557600080fd5b60006001600160e01b03198089168352868860048501378683016004810160008152868882375093169390920160048101939093525050600801949350505050565b6000825160005b81811015611d425760208186018101518583015201611d28565b50600092019182525091905056fea2646970667358221220d7e96a88169fbbb6355b500c970d1027a84d03bce2cf68304d33d263b06d67d964736f6c63430008150033", - "devdoc": { - "errors": { - "AddressEmptyCode(address)": [ - { - "details": "There's no code at `target` (it is not a contract)." - } - ], - "AddressInsufficientBalance(address)": [ - { - "details": "The ETH balance of the account is not enough to perform the operation." - } - ], - "BridgingNotCompleted()": [ - { - "details": "Attempted to finalize a stake request, while bridging completion has not been notified yet." - } - ], - "CallerNotReceiver()": [ - { - "details": "Attempted to call function by an account that is not the receiver." - } - ], - "DepositorFeeExceedsBridgedAmount(uint256,uint256)": [ - { - "details": "Calculated depositor fee exceeds the amount of minted tBTC tokens." - } - ], - "FailedInnerCall()": [ - { - "details": "A call to an address target failed. The target may have reverted." - } - ], - "OwnableInvalidOwner(address)": [ - { - "details": "The owner is not a valid owner account. (eg. `address(0)`)" - } - ], - "OwnableUnauthorizedAccount(address)": [ - { - "details": "The caller account is not authorized to perform an operation." - } - ], - "ReceiverIsZeroAddress()": [ - { - "details": "Receiver address is zero." - } - ], - "SafeERC20FailedOperation(address)": [ - { - "details": "An operation with an ERC20 token failed." - } - ], - "StakeRequestAlreadyFinalized()": [ - { - "details": "Attempted to finalize a stake request that was already finalized." - } - ] - }, - "events": { - "BridgingCompleted(uint256,address,uint16,uint256,uint256)": { - "params": { - "bridgedAmount": "Amount of tBTC tokens that was bridged by the tBTC bridge.", - "caller": "Address that notified about bridging completion.", - "depositKey": "Deposit key identifying the deposit.", - "depositorFee": "Depositor fee amount.", - "referral": "Identifier of a partner in the referral program." - } - }, - "DepositorFeeDivisorUpdated(uint64)": { - "params": { - "depositorFeeDivisor": "New value of the depositor fee divisor." - } - }, - "StakeRequestFinalized(uint256,address,uint256)": { - "details": "Deposit details can be fetched from {{ ERC4626.Deposit }} event emitted in the same transaction.", - "params": { - "amountToStake": "Amount of staked tBTC tokens.", - "caller": "Address that finalized the stake request.", - "depositKey": "Deposit key identifying the deposit." - } - }, - "StakeRequestInitialized(uint256,address,address)": { - "details": "Deposit details can be fetched from {{ Bridge.DepositRevealed }} event emitted in the same transaction.", - "params": { - "caller": "Address that initialized the stake request.", - "depositKey": "Deposit key identifying the deposit.", - "receiver": "The address to which the stBTC shares will be minted." - } - }, - "StakeRequestRecalled(uint256,address,uint256)": { - "params": { - "amountToStake": "Amount of recalled tBTC tokens.", - "depositKey": "Deposit key identifying the deposit.", - "receiver": "Address of the receiver." - } - } - }, - "kind": "dev", - "methods": { - "constructor": { - "params": { - "_bridge": "tBTC Bridge contract instance.", - "_stbtc": "stBTC contract instance.", - "_tbtcVault": "tBTC Vault contract instance." - } - }, - "encodeExtraData(address,uint16)": { - "details": "Packs the data to bytes32: 20 bytes of receiver address and 2 bytes of referral, 10 bytes of trailing zeros.", - "params": { - "receiver": "The address to which the stBTC shares will be minted.", - "referral": "Data used for referral program." - }, - "returns": { - "_0": "Encoded extra data." - } - }, - "finalizeStakeRequest(uint256)": { - "details": "This function is expected to be called after `notifyBridgingCompleted`. In case depositing in stBTC vault fails (e.g. because of the maximum deposit limit being reached), the function should be retried after the limit is increased or other user withdraws their funds from the stBTC contract to make place for another deposit. The staker has a possibility to submit `recallStakeRequest` that will withdraw the minted tBTC token and abort staking process.", - "params": { - "depositKey": "Deposit key identifying the deposit." - } - }, - "initializeStakeRequest((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)": { - "details": "Requirements: - The revealed vault address must match the TBTCVault address, - All requirements from {Bridge#revealDepositWithExtraData} function must be met. - `receiver` must be the receiver address used in the P2(W)SH BTC deposit transaction as part of the extra data. - `referral` must be the referral info used in the P2(W)SH BTC deposit transaction as part of the extra data. - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex` can be revealed only one time.", - "params": { - "fundingTx": "Bitcoin funding transaction data, see `IBridgeTypes.BitcoinTxInfo`.", - "receiver": "The address to which the stBTC shares will be minted.", - "referral": "Data used for referral program.", - "reveal": "Deposit reveal data, see `IBridgeTypes.DepositRevealInfo`." - } - }, - "notifyBridgingCompleted(uint256)": { - "details": "It calculates the amount to stake based on the approximate minted tBTC amount reduced by the depositor fee.IMPORTANT NOTE: The minted tBTC amount used by this function is an approximation. See documentation of the {{TBTCDepositorProxy#_calculateTbtcAmount}} responsible for calculating this value for more details.", - "params": { - "depositKey": "Deposit key identifying the deposit." - } - }, - "owner()": { - "details": "Returns the address of the current owner." - }, - "recallStakeRequest(uint256)": { - "details": "This function can be called only after bridging in tBTC Bridge was completed. Only receiver provided in the extra data of the stake request can call this function.", - "params": { - "depositKey": "Deposit key identifying the deposit." - } - }, - "renounceOwnership()": { - "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." - }, - "transferOwnership(address)": { - "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." - }, - "updateDepositorFeeDivisor(uint64)": { - "params": { - "newDepositorFeeDivisor": "New depositor fee divisor value." - } - } - }, - "stateVariables": { - "depositorFeeDivisor": { - "details": "That fee is computed as follows: `depositorFee = depositedAmount / depositorFeeDivisor` for example, if the depositor fee needs to be 2% of each deposit, the `depositorFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`." - }, - "stakeRequests": { - "details": "The key is a deposit key identifying the deposit." - } - }, - "title": "tBTC Depositor contract.", - "version": 1 - }, - "userdoc": { - "events": { - "BridgingCompleted(uint256,address,uint16,uint256,uint256)": { - "notice": "Emitted when bridging completion has been notified." - }, - "DepositorFeeDivisorUpdated(uint64)": { - "notice": "Emitted when a depositor fee divisor is updated." - }, - "StakeRequestFinalized(uint256,address,uint256)": { - "notice": "Emitted when a stake request is finalized." - }, - "StakeRequestInitialized(uint256,address,address)": { - "notice": "Emitted when a stake request is initialized." - }, - "StakeRequestRecalled(uint256,address,uint256)": { - "notice": "Emitted when a stake request is recalled." - } - }, - "kind": "user", - "methods": { - "SATOSHI_MULTIPLIER()": { - "notice": "Multiplier to convert satoshi to TBTC token units." - }, - "bridge()": { - "notice": "Bridge contract address." - }, - "constructor": { - "notice": "Tbtc Depositor contract constructor." - }, - "depositorFeeDivisor()": { - "notice": "Divisor used to compute the depositor fee taken from each deposit and transferred to the treasury upon stake request finalization." - }, - "encodeExtraData(address,uint16)": { - "notice": "Encode receiver address and referral as extra data." - }, - "finalizeStakeRequest(uint256)": { - "notice": "This function should be called for previously initialized stake request, after tBTC bridging process was finalized. It stakes the tBTC from the given deposit into stBTC, emitting the stBTC shares to the receiver specified in the deposit extra data and using the referral provided in the extra data." - }, - "initializeStakeRequest((bytes4,bytes,bytes,bytes4),(uint32,bytes8,bytes20,bytes20,bytes4,address),address,uint16)": { - "notice": "This function allows staking process initialization for a Bitcoin deposit made by an user with a P2(W)SH transaction. It uses the supplied information to reveal a deposit to the tBTC Bridge contract." - }, - "notifyBridgingCompleted(uint256)": { - "notice": "This function should be called for previously initialized stake request, after tBTC minting process completed, meaning tBTC was minted to this contract." - }, - "pendingDeposits(uint256)": { - "notice": "Mapping holding information about pending deposits that have been initialized but not finalized yet. If the deposit is not in this mapping it means it has already been finalized or it has not been initialized yet." - }, - "recallStakeRequest(uint256)": { - "notice": "Recall bridged tBTC tokens from being requested to stake. This function can be called by the staker to recover tBTC that cannot be finalized to stake in stBTC contract due to a deposit limit being reached." - }, - "stakeRequests(uint256)": { - "notice": "Mapping of stake requests." - }, - "stbtc()": { - "notice": "stBTC contract." - }, - "tbtcToken()": { - "notice": "tBTC Token contract." - }, - "tbtcVault()": { - "notice": "TBTCVault contract address." - }, - "updateDepositorFeeDivisor(uint64)": { - "notice": "Updates the depositor fee divisor." - } - }, - "notice": "The contract integrates Acre staking with tBTC minting. User who wants to stake BTC in Acre should submit a Bitcoin transaction to the most recently created off-chain ECDSA wallets of the tBTC Bridge using pay-to-script-hash (P2SH) or pay-to-witness-script-hash (P2WSH) containing hashed information about this Depositor contract address, and staker's Ethereum address. Then, the staker initiates tBTC minting by revealing their Ethereum address along with their deposit blinding factor, refund public key hash and refund locktime on the tBTC Bridge through this Depositor contract. The off-chain ECDSA wallet listens for these sorts of messages and when it gets one, it checks the Bitcoin network to make sure the deposit lines up. If it does, the off-chain ECDSA wallet may decide to pick the deposit transaction for sweeping, and when the sweep operation is confirmed on the Bitcoin network, the tBTC Bridge and tBTC vault mint the tBTC token to the Depositor address. After tBTC is minted to the Depositor, on the stake finalization tBTC is staked in stBTC contract and stBTC shares are emitted to the receiver pointed by the staker.", - "version": 1 - }, - "storageLayout": { - "storage": [ - { - "astId": 2683, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "bridge", - "offset": 0, - "slot": "0", - "type": "t_contract(IBridge)3102" - }, - { - "astId": 2687, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "tbtcVault", - "offset": 0, - "slot": "1", - "type": "t_contract(ITBTCVault)3122" - }, - { - "astId": 2692, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "pendingDeposits", - "offset": 0, - "slot": "2", - "type": "t_mapping(t_uint256,t_bool)" - }, - { - "astId": 2696, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "__gap", - "offset": 0, - "slot": "3", - "type": "t_array(t_uint256)47_storage" - }, - { - "astId": 3597, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "_owner", - "offset": 0, - "slot": "50", - "type": "t_address" - }, - { - "astId": 7435, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "stakeRequests", - "offset": 0, - "slot": "51", - "type": "t_mapping(t_uint256,t_struct(StakeRequest)7421_storage)" - }, - { - "astId": 7438, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "depositorFeeDivisor", - "offset": 0, - "slot": "52", - "type": "t_uint64" - } - ], - "types": { - "t_address": { - "encoding": "inplace", - "label": "address", - "numberOfBytes": "20" - }, - "t_array(t_uint256)47_storage": { - "base": "t_uint256", - "encoding": "inplace", - "label": "uint256[47]", - "numberOfBytes": "1504" - }, - "t_bool": { - "encoding": "inplace", - "label": "bool", - "numberOfBytes": "1" - }, - "t_contract(IBridge)3102": { - "encoding": "inplace", - "label": "contract IBridge", - "numberOfBytes": "20" - }, - "t_contract(ITBTCVault)3122": { - "encoding": "inplace", - "label": "contract ITBTCVault", - "numberOfBytes": "20" - }, - "t_mapping(t_uint256,t_bool)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => bool)", - "numberOfBytes": "32", - "value": "t_bool" - }, - "t_mapping(t_uint256,t_struct(StakeRequest)7421_storage)": { - "encoding": "mapping", - "key": "t_uint256", - "label": "mapping(uint256 => struct TbtcDepositor.StakeRequest)", - "numberOfBytes": "32", - "value": "t_struct(StakeRequest)7421_storage" - }, - "t_struct(StakeRequest)7421_storage": { - "encoding": "inplace", - "label": "struct TbtcDepositor.StakeRequest", - "members": [ - { - "astId": 7414, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "finalizedAt", - "offset": 0, - "slot": "0", - "type": "t_uint64" - }, - { - "astId": 7416, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "receiver", - "offset": 8, - "slot": "0", - "type": "t_address" - }, - { - "astId": 7418, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "referral", - "offset": 28, - "slot": "0", - "type": "t_uint16" - }, - { - "astId": 7420, - "contract": "contracts/TbtcDepositor.sol:TbtcDepositor", - "label": "amountToStake", - "offset": 0, - "slot": "1", - "type": "t_uint256" - } - ], - "numberOfBytes": "64" - }, - "t_uint16": { - "encoding": "inplace", - "label": "uint16", - "numberOfBytes": "2" - }, - "t_uint256": { - "encoding": "inplace", - "label": "uint256", - "numberOfBytes": "32" - }, - "t_uint64": { - "encoding": "inplace", - "label": "uint64", - "numberOfBytes": "8" - } - } - } -} diff --git a/sdk/src/lib/ethereum/tbtc-depositor.ts b/sdk/src/lib/ethereum/tbtc-depositor.ts index 7ce185d09..9379bed76 100644 --- a/sdk/src/lib/ethereum/tbtc-depositor.ts +++ b/sdk/src/lib/ethereum/tbtc-depositor.ts @@ -24,7 +24,7 @@ import { import { Hex } from "../utils" import { EthereumNetwork } from "./network" -import SepoliaTbtcDepositor from "./artifacts/sepolia/TbtcDepositor.json" +import SepoliaBitcoinDepositor from "./artifacts/sepolia/AcreBitcoinDepositor.json" // TODO: Rename TBTCDepositor to AcreBitcoinDepositor @@ -43,7 +43,7 @@ class EthereumTBTCDepositor switch (network) { case "sepolia": - artifact = SepoliaTbtcDepositor + artifact = SepoliaBitcoinDepositor break case "mainnet": default: