diff --git a/deploy/pegged-bridge/tokens/002_multi_bridge_token.ts b/deploy/pegged-bridge/tokens/002_multi_bridge_token.ts index 5ae993775..030a7abf3 100644 --- a/deploy/pegged-bridge/tokens/002_multi_bridge_token.ts +++ b/deploy/pegged-bridge/tokens/002_multi_bridge_token.ts @@ -9,15 +9,17 @@ const deployFunc: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { const { deploy } = deployments; const { deployer } = await getNamedAccounts(); - await deploy('MultiBridgeToken', { + const args = [ + process.env.MULTI_BRIDGE_TOKEN_NAME, + process.env.MULTI_BRIDGE_TOKEN_SYMBOL, + process.env.MULTI_BRIDGE_TOKEN_DECIMALS + ]; + const multiBridgeToken = await deploy('MultiBridgeToken', { from: deployer, log: true, - args: [ - process.env.MULTI_BRIDGE_TOKEN_NAME, - process.env.MULTI_BRIDGE_TOKEN_SYMBOL, - process.env.MULTI_BRIDGE_TOKEN_DECIMALS - ] + args: args }); + await hre.run('verify:verify', { address: multiBridgeToken.address, constructorArguments: args }); }; deployFunc.tags = ['MultiBridgeToken']; diff --git a/deployments/linea/.chainId b/deployments/linea/.chainId new file mode 100644 index 000000000..c9e6af42c --- /dev/null +++ b/deployments/linea/.chainId @@ -0,0 +1 @@ +59144 \ No newline at end of file diff --git a/deployments/linea/Bridge.json b/deployments/linea/Bridge.json new file mode 100644 index 000000000..06a60b227 --- /dev/null +++ b/deployments/linea/Bridge.json @@ -0,0 +1,1916 @@ +{ + "address": "0x9B36f165baB9ebe611d491180418d8De4b8f3a1f", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "period", + "type": "uint256" + } + ], + "name": "DelayPeriodUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "threshold", + "type": "uint256" + } + ], + "name": "DelayThresholdUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "name": "DelayedTransferAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "DelayedTransferExecuted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "EpochLengthUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cap", + "type": "uint256" + } + ], + "name": "EpochVolumeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "GovernorAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "GovernorRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "seqnum", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "address", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "LiquidityAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "MaxSendUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "MinAddUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "MinSendUpdated", + "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": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "PauserAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "PauserRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "transferId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "srcChainId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "srcTransferId", + "type": "bytes32" + } + ], + "name": "Relay", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "resetTime", + "type": "uint256" + } + ], + "name": "ResetNotification", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "transferId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "dstChainId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "maxSlippage", + "type": "uint32" + } + ], + "name": "Send", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address[]", + "name": "_signers", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "_powers", + "type": "uint256[]" + } + ], + "name": "SignersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "withdrawId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "seqnum", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "refid", + "type": "bytes32" + } + ], + "name": "WithdrawDone", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "addGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "addLiquidity", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "addNativeLiquidity", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "addPauser", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "addseq", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "delayPeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "delayThresholds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "delayedTransfers", + "outputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "epochLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "epochVolumeCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "epochVolumes", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "name": "executeDelayedTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "governors", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "period", + "type": "uint256" + } + ], + "name": "increaseNoticePeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "isGovernor", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "isPauser", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastOpTimestamps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxSend", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "minAdd", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "minSend", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minimalMaxSlippage", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nativeTokenTransferGas", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nativeWrap", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "noticePeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "notifyResetSigners", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pausers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_relayRequest", + "type": "bytes" + }, + { + "internalType": "bytes[]", + "name": "_sigs", + "type": "bytes[]" + }, + { + "internalType": "address[]", + "name": "_signers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_powers", + "type": "uint256[]" + } + ], + "name": "relay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "removeGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "removePauser", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renouncePauser", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_signers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_powers", + "type": "uint256[]" + } + ], + "name": "resetSigners", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resetTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "_dstChainId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "_nonce", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "_maxSlippage", + "type": "uint32" + } + ], + "name": "send", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "_dstChainId", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "_nonce", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "_maxSlippage", + "type": "uint32" + } + ], + "name": "sendNative", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_period", + "type": "uint256" + } + ], + "name": "setDelayPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_thresholds", + "type": "uint256[]" + } + ], + "name": "setDelayThresholds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_length", + "type": "uint256" + } + ], + "name": "setEpochLength", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_caps", + "type": "uint256[]" + } + ], + "name": "setEpochVolumeCaps", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_amounts", + "type": "uint256[]" + } + ], + "name": "setMaxSend", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_amounts", + "type": "uint256[]" + } + ], + "name": "setMinAdd", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_amounts", + "type": "uint256[]" + } + ], + "name": "setMinSend", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_minimalMaxSlippage", + "type": "uint32" + } + ], + "name": "setMinimalMaxSlippage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_gasUsed", + "type": "uint256" + } + ], + "name": "setNativeTokenTransferGas", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_weth", + "type": "address" + } + ], + "name": "setWrap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "ssHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "transfers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "triggerTime", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_triggerTime", + "type": "uint256" + }, + { + "internalType": "address[]", + "name": "_newSigners", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_newPowers", + "type": "uint256[]" + }, + { + "internalType": "bytes[]", + "name": "_sigs", + "type": "bytes[]" + }, + { + "internalType": "address[]", + "name": "_curSigners", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_curPowers", + "type": "uint256[]" + } + ], + "name": "updateSigners", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_msg", + "type": "bytes" + }, + { + "internalType": "bytes[]", + "name": "_sigs", + "type": "bytes[]" + }, + { + "internalType": "address[]", + "name": "_signers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_powers", + "type": "uint256[]" + } + ], + "name": "verifySigs", + "outputs": [], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_wdmsg", + "type": "bytes" + }, + { + "internalType": "bytes[]", + "name": "_sigs", + "type": "bytes[]" + }, + { + "internalType": "address[]", + "name": "_signers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_powers", + "type": "uint256[]" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "withdraws", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } + ], + "transactionHash": "0xba65e37a36a99274e4596804a5f40425c3d32b0b7535637dd760c5f7948a95af", + "receipt": { + "to": null, + "from": "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1", + "contractAddress": "0x9B36f165baB9ebe611d491180418d8De4b8f3a1f", + "transactionIndex": 0, + "gasUsed": "4700350", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000010000000000000000000000000000000000000000000000000000000000000000000080000001000000000000000001000000000000000100000000000000802000020000000000000000000900000000000000000000000000000000400000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000010020000000000000020000000000000000000000000000000040000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xbc306c8634464886327ae6f7ca01d56d3b8693d8eca271d5297e83062d40fa8d", + "transactionHash": "0xba65e37a36a99274e4596804a5f40425c3d32b0b7535637dd760c5f7948a95af", + "logs": [ + { + "transactionIndex": 0, + "blockNumber": 445, + "transactionHash": "0xba65e37a36a99274e4596804a5f40425c3d32b0b7535637dd760c5f7948a95af", + "address": "0x9B36f165baB9ebe611d491180418d8De4b8f3a1f", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000058b529f9084d7eaa598eb3477fe36064c5b7bbc1" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xbc306c8634464886327ae6f7ca01d56d3b8693d8eca271d5297e83062d40fa8d" + }, + { + "transactionIndex": 0, + "blockNumber": 445, + "transactionHash": "0xba65e37a36a99274e4596804a5f40425c3d32b0b7535637dd760c5f7948a95af", + "address": "0x9B36f165baB9ebe611d491180418d8De4b8f3a1f", + "topics": [ + "0x6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f8" + ], + "data": "0x00000000000000000000000058b529f9084d7eaa598eb3477fe36064c5b7bbc1", + "logIndex": 1, + "blockHash": "0xbc306c8634464886327ae6f7ca01d56d3b8693d8eca271d5297e83062d40fa8d" + }, + { + "transactionIndex": 0, + "blockNumber": 445, + "transactionHash": "0xba65e37a36a99274e4596804a5f40425c3d32b0b7535637dd760c5f7948a95af", + "address": "0x9B36f165baB9ebe611d491180418d8De4b8f3a1f", + "topics": [ + "0xdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b5" + ], + "data": "0x00000000000000000000000058b529f9084d7eaa598eb3477fe36064c5b7bbc1", + "logIndex": 2, + "blockHash": "0xbc306c8634464886327ae6f7ca01d56d3b8693d8eca271d5297e83062d40fa8d" + } + ], + "blockNumber": 445, + "cumulativeGasUsed": "4700350", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "63e7586ecff740f5cf7af58b7e60f225", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"}],\"name\":\"DelayPeriodUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"threshold\",\"type\":\"uint256\"}],\"name\":\"DelayThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"DelayedTransferAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DelayedTransferExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"EpochLengthUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"}],\"name\":\"EpochVolumeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"GovernorAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"GovernorRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"seqnum\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"LiquidityAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MaxSendUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MinAddUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MinSendUpdated\",\"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\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"PauserAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"PauserRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"transferId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"srcChainId\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"srcTransferId\",\"type\":\"bytes32\"}],\"name\":\"Relay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"resetTime\",\"type\":\"uint256\"}],\"name\":\"ResetNotification\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"transferId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"dstChainId\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"nonce\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"maxSlippage\",\"type\":\"uint32\"}],\"name\":\"Send\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address[]\",\"name\":\"_signers\",\"type\":\"address[]\"},{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"_powers\",\"type\":\"uint256[]\"}],\"name\":\"SignersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"withdrawId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"seqnum\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"refid\",\"type\":\"bytes32\"}],\"name\":\"WithdrawDone\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"addGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"addLiquidity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"addNativeLiquidity\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"addPauser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"addseq\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"delayPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"delayThresholds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"delayedTransfers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"epochLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"epochVolumeCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"epochVolumes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"executeDelayedTransfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"governors\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"}],\"name\":\"increaseNoticePeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"isGovernor\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isPauser\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastOpTimestamps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"maxSend\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"minAdd\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"minSend\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minimalMaxSlippage\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nativeTokenTransferGas\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"nativeWrap\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"noticePeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"notifyResetSigners\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pausers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_relayRequest\",\"type\":\"bytes\"},{\"internalType\":\"bytes[]\",\"name\":\"_sigs\",\"type\":\"bytes[]\"},{\"internalType\":\"address[]\",\"name\":\"_signers\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_powers\",\"type\":\"uint256[]\"}],\"name\":\"relay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"removeGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"removePauser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renouncePauser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_signers\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_powers\",\"type\":\"uint256[]\"}],\"name\":\"resetSigners\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"resetTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"_dstChainId\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"_maxSlippage\",\"type\":\"uint32\"}],\"name\":\"send\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_receiver\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"_dstChainId\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"_maxSlippage\",\"type\":\"uint32\"}],\"name\":\"sendNative\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"setDelayPeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_thresholds\",\"type\":\"uint256[]\"}],\"name\":\"setDelayThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_length\",\"type\":\"uint256\"}],\"name\":\"setEpochLength\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_caps\",\"type\":\"uint256[]\"}],\"name\":\"setEpochVolumeCaps\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"setMaxSend\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"setMinAdd\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"setMinSend\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_minimalMaxSlippage\",\"type\":\"uint32\"}],\"name\":\"setMinimalMaxSlippage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_gasUsed\",\"type\":\"uint256\"}],\"name\":\"setNativeTokenTransferGas\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_weth\",\"type\":\"address\"}],\"name\":\"setWrap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ssHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"transfers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"triggerTime\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_triggerTime\",\"type\":\"uint256\"},{\"internalType\":\"address[]\",\"name\":\"_newSigners\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_newPowers\",\"type\":\"uint256[]\"},{\"internalType\":\"bytes[]\",\"name\":\"_sigs\",\"type\":\"bytes[]\"},{\"internalType\":\"address[]\",\"name\":\"_curSigners\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_curPowers\",\"type\":\"uint256[]\"}],\"name\":\"updateSigners\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_msg\",\"type\":\"bytes\"},{\"internalType\":\"bytes[]\",\"name\":\"_sigs\",\"type\":\"bytes[]\"},{\"internalType\":\"address[]\",\"name\":\"_signers\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_powers\",\"type\":\"uint256[]\"}],\"name\":\"verifySigs\",\"outputs\":[],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_wdmsg\",\"type\":\"bytes\"},{\"internalType\":\"bytes[]\",\"name\":\"_sigs\",\"type\":\"bytes[]\"},{\"internalType\":\"address[]\",\"name\":\"_signers\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_powers\",\"type\":\"uint256[]\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"withdraws\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"addLiquidity(address,uint256)\":{\"params\":{\"_amount\":\"The amount to add.\",\"_token\":\"The address of the token.\"}},\"addNativeLiquidity(uint256)\":{\"params\":{\"_amount\":\"The amount to add.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"relay(bytes,bytes[],address[],uint256[])\":{\"params\":{\"_powers\":\"The signing powers of the signers.\",\"_relayRequest\":\"The serialized Relay protobuf.\",\"_signers\":\"The sorted list of signers.\",\"_sigs\":\"The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by +2/3 of the bridge's current signing power to be delivered.\"}},\"send(address,address,uint256,uint64,uint64,uint32)\":{\"params\":{\"_amount\":\"The amount of the transfer.\",\"_dstChainId\":\"The destination chain ID.\",\"_maxSlippage\":\"The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%. Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the transfer can be refunded.\",\"_nonce\":\"A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\",\"_receiver\":\"The address of the receiver.\",\"_token\":\"The address of the token.\"}},\"sendNative(address,uint256,uint64,uint64,uint32)\":{\"params\":{\"_amount\":\"The amount of the transfer.\",\"_dstChainId\":\"The destination chain ID.\",\"_maxSlippage\":\"The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%. Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the transfer can be refunded.\",\"_nonce\":\"A unique number. Can be timestamp in practice.\",\"_receiver\":\"The address of the receiver.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"updateSigners(uint256,address[],uint256[],bytes[],address[],uint256[])\":{\"params\":{\"_curPowers\":\"powers of current signers\",\"_curSigners\":\"sorted list of current signers\",\"_newSigners\":\"sorted list of new signers\",\"_sigs\":\"list of signatures sorted by signer addresses in ascending order\"}},\"verifySigs(bytes,bytes[],address[],uint256[])\":{\"params\":{\"_msg\":\"signed message\",\"_powers\":\"powers of current signers\",\"_signers\":\"sorted list of current signers\",\"_sigs\":\"list of signatures sorted by signer addresses in ascending order\"}},\"withdraw(bytes,bytes[],address[],uint256[])\":{\"params\":{\"_powers\":\"The signing powers of the signers.\",\"_signers\":\"The sorted list of signers.\",\"_sigs\":\"The list of signatures sorted by signing addresses in ascending order. A withdrawal must be signed-off by +2/3 of the bridge's current signing power to be delivered.\",\"_wdmsg\":\"The serialized Withdraw protobuf.\"}}},\"title\":\"The liquidity-pool based bridge.\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addLiquidity(address,uint256)\":{\"notice\":\"Add liquidity to the pool-based bridge. NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\"},\"addNativeLiquidity(uint256)\":{\"notice\":\"Add native token liquidity to the pool-based bridge.\"},\"relay(bytes,bytes[],address[],uint256[])\":{\"notice\":\"Relay a cross-chain transfer sent from a liquidity pool-based bridge on another chain.\"},\"resetSigners(address[],uint256[])\":{\"notice\":\"reset signers, only used for init setup and emergency recovery\"},\"send(address,address,uint256,uint64,uint64,uint32)\":{\"notice\":\"Send a cross-chain transfer via the liquidity pool-based bridge. NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\"},\"sendNative(address,uint256,uint64,uint64,uint32)\":{\"notice\":\"Send a cross-chain transfer via the liquidity pool-based bridge using the native token.\"},\"updateSigners(uint256,address[],uint256[],bytes[],address[],uint256[])\":{\"notice\":\"Update new signers.\"},\"verifySigs(bytes,bytes[],address[],uint256[])\":{\"notice\":\"Verifies that a message is signed by a quorum among the signers The sigs must be sorted by signer addresses in ascending order.\"},\"withdraw(bytes,bytes[],address[],uint256[])\":{\"notice\":\"Withdraw funds from the bridge pool.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/liquidity-bridge/Bridge.sol\":\"Bridge\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":800},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/security/Pausable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract Pausable is Context {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n constructor() {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n require(!paused(), \\\"Pausable: paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n require(paused(), \\\"Pausable: not paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n}\\n\",\"keccak256\":\"0xe68ed7fb8766ed1e888291f881e36b616037f852b37d96877045319ad298ba87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x0e9621f60b2faabe65549f7ed0f24e8853a45c1b7990d47e8160e523683f3935\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../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 function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\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, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\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, it is bubbled up by this\\n * function (like regular Solidity function calls).\\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 * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\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 * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\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\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x32c202bd28995dd20c4347b7c6467a6d3241c74c8ad3edcbb610cd9205916c45\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n // Check the signature length\\n // - case 65: r,s,v signature (standard)\\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else if (signature.length == 64) {\\n bytes32 r;\\n bytes32 vs;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n vs := mload(add(signature, 0x40))\\n }\\n return tryRecover(hash, r, vs);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0x3c07f43e60e099b3b157243b3152722e73b80eeb7985c2cd73712828d7f7da29\",\"license\":\"MIT\"},\"contracts/interfaces/ISigsVerifier.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity >=0.8.0;\\n\\ninterface ISigsVerifier {\\n /**\\n * @notice Verifies that a message is signed by a quorum among the signers.\\n * @param _msg signed message\\n * @param _sigs list of signatures sorted by signer addresses in ascending order\\n * @param _signers sorted list of current signers\\n * @param _powers powers of current signers\\n */\\n function verifySigs(\\n bytes memory _msg,\\n bytes[] calldata _sigs,\\n address[] calldata _signers,\\n uint256[] calldata _powers\\n ) external view;\\n}\\n\",\"keccak256\":\"0x0d0b090d078a5f50ea7b751331614785e536fc09bcff28bfe08a60613ebca1ae\",\"license\":\"GPL-3.0-only\"},\"contracts/interfaces/IWETH.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity >=0.8.0;\\n\\ninterface IWETH {\\n function deposit() external payable;\\n\\n function withdraw(uint256) external;\\n}\\n\",\"keccak256\":\"0x99ab1a3c396cc7ebbae940fd4e73f209c692afe86f221d4e1352b0fe27953bc8\",\"license\":\"GPL-3.0-only\"},\"contracts/libraries/Pb.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\n// runtime proto sol library\\nlibrary Pb {\\n enum WireType {\\n Varint,\\n Fixed64,\\n LengthDelim,\\n StartGroup,\\n EndGroup,\\n Fixed32\\n }\\n\\n struct Buffer {\\n uint256 idx; // the start index of next read. when idx=b.length, we're done\\n bytes b; // hold serialized proto msg, readonly\\n }\\n\\n // create a new in-memory Buffer object from raw msg bytes\\n function fromBytes(bytes memory raw) internal pure returns (Buffer memory buf) {\\n buf.b = raw;\\n buf.idx = 0;\\n }\\n\\n // whether there are unread bytes\\n function hasMore(Buffer memory buf) internal pure returns (bool) {\\n return buf.idx < buf.b.length;\\n }\\n\\n // decode current field number and wiretype\\n function decKey(Buffer memory buf) internal pure returns (uint256 tag, WireType wiretype) {\\n uint256 v = decVarint(buf);\\n tag = v / 8;\\n wiretype = WireType(v & 7);\\n }\\n\\n // count tag occurrences, return an array due to no memory map support\\n // have to create array for (maxtag+1) size. cnts[tag] = occurrences\\n // should keep buf.idx unchanged because this is only a count function\\n function cntTags(Buffer memory buf, uint256 maxtag) internal pure returns (uint256[] memory cnts) {\\n uint256 originalIdx = buf.idx;\\n cnts = new uint256[](maxtag + 1); // protobuf's tags are from 1 rather than 0\\n uint256 tag;\\n WireType wire;\\n while (hasMore(buf)) {\\n (tag, wire) = decKey(buf);\\n cnts[tag] += 1;\\n skipValue(buf, wire);\\n }\\n buf.idx = originalIdx;\\n }\\n\\n // read varint from current buf idx, move buf.idx to next read, return the int value\\n function decVarint(Buffer memory buf) internal pure returns (uint256 v) {\\n bytes10 tmp; // proto int is at most 10 bytes (7 bits can be used per byte)\\n bytes memory bb = buf.b; // get buf.b mem addr to use in assembly\\n v = buf.idx; // use v to save one additional uint variable\\n assembly {\\n tmp := mload(add(add(bb, 32), v)) // load 10 bytes from buf.b[buf.idx] to tmp\\n }\\n uint256 b; // store current byte content\\n v = 0; // reset to 0 for return value\\n for (uint256 i = 0; i < 10; i++) {\\n assembly {\\n b := byte(i, tmp) // don't use tmp[i] because it does bound check and costs extra\\n }\\n v |= (b & 0x7F) << (i * 7);\\n if (b & 0x80 == 0) {\\n buf.idx += i + 1;\\n return v;\\n }\\n }\\n revert(); // i=10, invalid varint stream\\n }\\n\\n // read length delimited field and return bytes\\n function decBytes(Buffer memory buf) internal pure returns (bytes memory b) {\\n uint256 len = decVarint(buf);\\n uint256 end = buf.idx + len;\\n require(end <= buf.b.length); // avoid overflow\\n b = new bytes(len);\\n bytes memory bufB = buf.b; // get buf.b mem addr to use in assembly\\n uint256 bStart;\\n uint256 bufBStart = buf.idx;\\n assembly {\\n bStart := add(b, 32)\\n bufBStart := add(add(bufB, 32), bufBStart)\\n }\\n for (uint256 i = 0; i < len; i += 32) {\\n assembly {\\n mstore(add(bStart, i), mload(add(bufBStart, i)))\\n }\\n }\\n buf.idx = end;\\n }\\n\\n // return packed ints\\n function decPacked(Buffer memory buf) internal pure returns (uint256[] memory t) {\\n uint256 len = decVarint(buf);\\n uint256 end = buf.idx + len;\\n require(end <= buf.b.length); // avoid overflow\\n // array in memory must be init w/ known length\\n // so we have to create a tmp array w/ max possible len first\\n uint256[] memory tmp = new uint256[](len);\\n uint256 i = 0; // count how many ints are there\\n while (buf.idx < end) {\\n tmp[i] = decVarint(buf);\\n i++;\\n }\\n t = new uint256[](i); // init t with correct length\\n for (uint256 j = 0; j < i; j++) {\\n t[j] = tmp[j];\\n }\\n return t;\\n }\\n\\n // move idx pass current value field, to beginning of next tag or msg end\\n function skipValue(Buffer memory buf, WireType wire) internal pure {\\n if (wire == WireType.Varint) {\\n decVarint(buf);\\n } else if (wire == WireType.LengthDelim) {\\n uint256 len = decVarint(buf);\\n buf.idx += len; // skip len bytes value data\\n require(buf.idx <= buf.b.length); // avoid overflow\\n } else {\\n revert();\\n } // unsupported wiretype\\n }\\n\\n // type conversion help utils\\n function _bool(uint256 x) internal pure returns (bool v) {\\n return x != 0;\\n }\\n\\n function _uint256(bytes memory b) internal pure returns (uint256 v) {\\n require(b.length <= 32); // b's length must be smaller than or equal to 32\\n assembly {\\n v := mload(add(b, 32))\\n } // load all 32bytes to v\\n v = v >> (8 * (32 - b.length)); // only first b.length is valid\\n }\\n\\n function _address(bytes memory b) internal pure returns (address v) {\\n v = _addressPayable(b);\\n }\\n\\n function _addressPayable(bytes memory b) internal pure returns (address payable v) {\\n require(b.length == 20);\\n //load 32bytes then shift right 12 bytes\\n assembly {\\n v := div(mload(add(b, 32)), 0x1000000000000000000000000)\\n }\\n }\\n\\n function _bytes32(bytes memory b) internal pure returns (bytes32 v) {\\n require(b.length == 32);\\n assembly {\\n v := mload(add(b, 32))\\n }\\n }\\n\\n // uint[] to uint8[]\\n function uint8s(uint256[] memory arr) internal pure returns (uint8[] memory t) {\\n t = new uint8[](arr.length);\\n for (uint256 i = 0; i < t.length; i++) {\\n t[i] = uint8(arr[i]);\\n }\\n }\\n\\n function uint32s(uint256[] memory arr) internal pure returns (uint32[] memory t) {\\n t = new uint32[](arr.length);\\n for (uint256 i = 0; i < t.length; i++) {\\n t[i] = uint32(arr[i]);\\n }\\n }\\n\\n function uint64s(uint256[] memory arr) internal pure returns (uint64[] memory t) {\\n t = new uint64[](arr.length);\\n for (uint256 i = 0; i < t.length; i++) {\\n t[i] = uint64(arr[i]);\\n }\\n }\\n\\n function bools(uint256[] memory arr) internal pure returns (bool[] memory t) {\\n t = new bool[](arr.length);\\n for (uint256 i = 0; i < t.length; i++) {\\n t[i] = arr[i] != 0;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf8c5573d5b5a9bed5ed42254fadce2feeb64bbf81cc0aa4b30b80769c26ad149\",\"license\":\"GPL-3.0-only\"},\"contracts/libraries/PbBridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// Code generated by protoc-gen-sol. DO NOT EDIT.\\n// source: bridge.proto\\npragma solidity 0.8.17;\\nimport \\\"./Pb.sol\\\";\\n\\nlibrary PbBridge {\\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\\n\\n struct Relay {\\n address sender; // tag: 1\\n address receiver; // tag: 2\\n address token; // tag: 3\\n uint256 amount; // tag: 4\\n uint64 srcChainId; // tag: 5\\n uint64 dstChainId; // tag: 6\\n bytes32 srcTransferId; // tag: 7\\n } // end struct Relay\\n\\n function decRelay(bytes memory raw) internal pure returns (Relay memory m) {\\n Pb.Buffer memory buf = Pb.fromBytes(raw);\\n\\n uint256 tag;\\n Pb.WireType wire;\\n while (buf.hasMore()) {\\n (tag, wire) = buf.decKey();\\n if (false) {}\\n // solidity has no switch/case\\n else if (tag == 1) {\\n m.sender = Pb._address(buf.decBytes());\\n } else if (tag == 2) {\\n m.receiver = Pb._address(buf.decBytes());\\n } else if (tag == 3) {\\n m.token = Pb._address(buf.decBytes());\\n } else if (tag == 4) {\\n m.amount = Pb._uint256(buf.decBytes());\\n } else if (tag == 5) {\\n m.srcChainId = uint64(buf.decVarint());\\n } else if (tag == 6) {\\n m.dstChainId = uint64(buf.decVarint());\\n } else if (tag == 7) {\\n m.srcTransferId = Pb._bytes32(buf.decBytes());\\n } else {\\n buf.skipValue(wire);\\n } // skip value of unknown tag\\n }\\n } // end decoder Relay\\n}\\n\",\"keccak256\":\"0x7f5c3fbd9ab93a48c74ba13ea08c581dff864aa8a3e5f8ebf7ddd5ac5c6e1c58\",\"license\":\"GPL-3.0-only\"},\"contracts/libraries/PbPool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// Code generated by protoc-gen-sol. DO NOT EDIT.\\n// source: contracts/libraries/proto/pool.proto\\npragma solidity 0.8.17;\\nimport \\\"./Pb.sol\\\";\\n\\nlibrary PbPool {\\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\\n\\n struct WithdrawMsg {\\n uint64 chainid; // tag: 1\\n uint64 seqnum; // tag: 2\\n address receiver; // tag: 3\\n address token; // tag: 4\\n uint256 amount; // tag: 5\\n bytes32 refid; // tag: 6\\n } // end struct WithdrawMsg\\n\\n function decWithdrawMsg(bytes memory raw) internal pure returns (WithdrawMsg memory m) {\\n Pb.Buffer memory buf = Pb.fromBytes(raw);\\n\\n uint256 tag;\\n Pb.WireType wire;\\n while (buf.hasMore()) {\\n (tag, wire) = buf.decKey();\\n if (false) {}\\n // solidity has no switch/case\\n else if (tag == 1) {\\n m.chainid = uint64(buf.decVarint());\\n } else if (tag == 2) {\\n m.seqnum = uint64(buf.decVarint());\\n } else if (tag == 3) {\\n m.receiver = Pb._address(buf.decBytes());\\n } else if (tag == 4) {\\n m.token = Pb._address(buf.decBytes());\\n } else if (tag == 5) {\\n m.amount = Pb._uint256(buf.decBytes());\\n } else if (tag == 6) {\\n m.refid = Pb._bytes32(buf.decBytes());\\n } else {\\n buf.skipValue(wire);\\n } // skip value of unknown tag\\n }\\n } // end decoder WithdrawMsg\\n}\\n\",\"keccak256\":\"0x80917b507ebb9b8eda7875c30c63725f9976fdde9a7d2003b0da31bea1f44324\",\"license\":\"GPL-3.0-only\"},\"contracts/liquidity-bridge/Bridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"../libraries/PbBridge.sol\\\";\\nimport \\\"./Pool.sol\\\";\\n\\n/**\\n * @title The liquidity-pool based bridge.\\n */\\ncontract Bridge is Pool {\\n using SafeERC20 for IERC20;\\n\\n // liquidity events\\n event Send(\\n bytes32 transferId,\\n address sender,\\n address receiver,\\n address token,\\n uint256 amount,\\n uint64 dstChainId,\\n uint64 nonce,\\n uint32 maxSlippage\\n );\\n event Relay(\\n bytes32 transferId,\\n address sender,\\n address receiver,\\n address token,\\n uint256 amount,\\n uint64 srcChainId,\\n bytes32 srcTransferId\\n );\\n // gov events\\n event MinSendUpdated(address token, uint256 amount);\\n event MaxSendUpdated(address token, uint256 amount);\\n\\n mapping(bytes32 => bool) public transfers;\\n mapping(address => uint256) public minSend; // send _amount must > minSend\\n mapping(address => uint256) public maxSend;\\n\\n // min allowed max slippage uint32 value is slippage * 1M, eg. 0.5% -> 5000\\n uint32 public minimalMaxSlippage;\\n\\n /**\\n * @notice Send a cross-chain transfer via the liquidity pool-based bridge.\\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\\n * @param _receiver The address of the receiver.\\n * @param _token The address of the token.\\n * @param _amount The amount of the transfer.\\n * @param _dstChainId The destination chain ID.\\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the\\n * transfer can be refunded.\\n */\\n function send(\\n address _receiver,\\n address _token,\\n uint256 _amount,\\n uint64 _dstChainId,\\n uint64 _nonce,\\n uint32 _maxSlippage // slippage * 1M, eg. 0.5% -> 5000\\n ) external nonReentrant whenNotPaused {\\n bytes32 transferId = _send(_receiver, _token, _amount, _dstChainId, _nonce, _maxSlippage);\\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\\n emit Send(transferId, msg.sender, _receiver, _token, _amount, _dstChainId, _nonce, _maxSlippage);\\n }\\n\\n /**\\n * @notice Send a cross-chain transfer via the liquidity pool-based bridge using the native token.\\n * @param _receiver The address of the receiver.\\n * @param _amount The amount of the transfer.\\n * @param _dstChainId The destination chain ID.\\n * @param _nonce A unique number. Can be timestamp in practice.\\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the\\n * transfer can be refunded.\\n */\\n function sendNative(\\n address _receiver,\\n uint256 _amount,\\n uint64 _dstChainId,\\n uint64 _nonce,\\n uint32 _maxSlippage\\n ) external payable nonReentrant whenNotPaused {\\n require(msg.value == _amount, \\\"Amount mismatch\\\");\\n require(nativeWrap != address(0), \\\"Native wrap not set\\\");\\n bytes32 transferId = _send(_receiver, nativeWrap, _amount, _dstChainId, _nonce, _maxSlippage);\\n IWETH(nativeWrap).deposit{value: _amount}();\\n emit Send(transferId, msg.sender, _receiver, nativeWrap, _amount, _dstChainId, _nonce, _maxSlippage);\\n }\\n\\n function _send(\\n address _receiver,\\n address _token,\\n uint256 _amount,\\n uint64 _dstChainId,\\n uint64 _nonce,\\n uint32 _maxSlippage\\n ) private returns (bytes32) {\\n require(_amount > minSend[_token], \\\"amount too small\\\");\\n require(maxSend[_token] == 0 || _amount <= maxSend[_token], \\\"amount too large\\\");\\n require(_maxSlippage > minimalMaxSlippage, \\\"max slippage too small\\\");\\n bytes32 transferId = keccak256(\\n // uint64(block.chainid) for consistency as entire system uses uint64 for chain id\\n // len = 20 + 20 + 20 + 32 + 8 + 8 + 8 = 116\\n abi.encodePacked(msg.sender, _receiver, _token, _amount, _dstChainId, _nonce, uint64(block.chainid))\\n );\\n require(transfers[transferId] == false, \\\"transfer exists\\\");\\n transfers[transferId] = true;\\n return transferId;\\n }\\n\\n /**\\n * @notice Relay a cross-chain transfer sent from a liquidity pool-based bridge on another chain.\\n * @param _relayRequest The serialized Relay protobuf.\\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\\n * +2/3 of the bridge's current signing power to be delivered.\\n * @param _signers The sorted list of signers.\\n * @param _powers The signing powers of the signers.\\n */\\n function relay(\\n bytes calldata _relayRequest,\\n bytes[] calldata _sigs,\\n address[] calldata _signers,\\n uint256[] calldata _powers\\n ) external whenNotPaused {\\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \\\"Relay\\\"));\\n verifySigs(abi.encodePacked(domain, _relayRequest), _sigs, _signers, _powers);\\n PbBridge.Relay memory request = PbBridge.decRelay(_relayRequest);\\n // len = 20 + 20 + 20 + 32 + 8 + 8 + 32 = 140\\n bytes32 transferId = keccak256(\\n abi.encodePacked(\\n request.sender,\\n request.receiver,\\n request.token,\\n request.amount,\\n request.srcChainId,\\n request.dstChainId,\\n request.srcTransferId\\n )\\n );\\n require(transfers[transferId] == false, \\\"transfer exists\\\");\\n transfers[transferId] = true;\\n _updateVolume(request.token, request.amount);\\n uint256 delayThreshold = delayThresholds[request.token];\\n if (delayThreshold > 0 && request.amount > delayThreshold) {\\n _addDelayedTransfer(transferId, request.receiver, request.token, request.amount);\\n } else {\\n _sendToken(request.receiver, request.token, request.amount);\\n }\\n\\n emit Relay(\\n transferId,\\n request.sender,\\n request.receiver,\\n request.token,\\n request.amount,\\n request.srcChainId,\\n request.srcTransferId\\n );\\n }\\n\\n function setMinSend(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\\n require(_tokens.length == _amounts.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n minSend[_tokens[i]] = _amounts[i];\\n emit MinSendUpdated(_tokens[i], _amounts[i]);\\n }\\n }\\n\\n function setMaxSend(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\\n require(_tokens.length == _amounts.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n maxSend[_tokens[i]] = _amounts[i];\\n emit MaxSendUpdated(_tokens[i], _amounts[i]);\\n }\\n }\\n\\n function setMinimalMaxSlippage(uint32 _minimalMaxSlippage) external onlyGovernor {\\n minimalMaxSlippage = _minimalMaxSlippage;\\n }\\n\\n // This is needed to receive ETH when calling `IWETH.withdraw`\\n receive() external payable {}\\n}\\n\",\"keccak256\":\"0xfc600eb7a2ac37c6e27960356715cd8bc6bcd0777f13135d512cc0fce75454ba\",\"license\":\"GPL-3.0-only\"},\"contracts/liquidity-bridge/Pool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\nimport \\\"../interfaces/IWETH.sol\\\";\\nimport \\\"../libraries/PbPool.sol\\\";\\nimport \\\"../safeguard/Pauser.sol\\\";\\nimport \\\"../safeguard/VolumeControl.sol\\\";\\nimport \\\"../safeguard/DelayedTransfer.sol\\\";\\nimport \\\"./Signers.sol\\\";\\n\\n/**\\n * @title Liquidity pool functions for {Bridge}.\\n */\\ncontract Pool is Signers, ReentrancyGuard, Pauser, VolumeControl, DelayedTransfer {\\n using SafeERC20 for IERC20;\\n\\n uint64 public addseq; // ensure unique LiquidityAdded event, start from 1\\n mapping(address => uint256) public minAdd; // add _amount must > minAdd\\n\\n // map of successful withdraws, if true means already withdrew money or added to delayedTransfers\\n mapping(bytes32 => bool) public withdraws;\\n\\n // erc20 wrap of gas token of this chain, eg. WETH, when relay ie. pay out,\\n // if request.token equals this, will withdraw and send native token to receiver\\n // note we don't check whether it's zero address. when this isn't set, and request.token\\n // is all 0 address, guarantee fail\\n address public nativeWrap;\\n\\n // when transfer native token after wrap, use this gas used config.\\n uint256 public nativeTokenTransferGas = 50000;\\n\\n // liquidity events\\n event LiquidityAdded(\\n uint64 seqnum,\\n address provider,\\n address token,\\n uint256 amount // how many tokens were added\\n );\\n event WithdrawDone(\\n bytes32 withdrawId,\\n uint64 seqnum,\\n address receiver,\\n address token,\\n uint256 amount,\\n bytes32 refid\\n );\\n event MinAddUpdated(address token, uint256 amount);\\n\\n /**\\n * @notice Add liquidity to the pool-based bridge.\\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\\n * @param _token The address of the token.\\n * @param _amount The amount to add.\\n */\\n function addLiquidity(address _token, uint256 _amount) external nonReentrant whenNotPaused {\\n require(_amount > minAdd[_token], \\\"amount too small\\\");\\n addseq += 1;\\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\\n emit LiquidityAdded(addseq, msg.sender, _token, _amount);\\n }\\n\\n /**\\n * @notice Add native token liquidity to the pool-based bridge.\\n * @param _amount The amount to add.\\n */\\n function addNativeLiquidity(uint256 _amount) external payable nonReentrant whenNotPaused {\\n require(msg.value == _amount, \\\"Amount mismatch\\\");\\n require(nativeWrap != address(0), \\\"Native wrap not set\\\");\\n require(_amount > minAdd[nativeWrap], \\\"amount too small\\\");\\n addseq += 1;\\n IWETH(nativeWrap).deposit{value: _amount}();\\n emit LiquidityAdded(addseq, msg.sender, nativeWrap, _amount);\\n }\\n\\n /**\\n * @notice Withdraw funds from the bridge pool.\\n * @param _wdmsg The serialized Withdraw protobuf.\\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A withdrawal must be\\n * signed-off by +2/3 of the bridge's current signing power to be delivered.\\n * @param _signers The sorted list of signers.\\n * @param _powers The signing powers of the signers.\\n */\\n function withdraw(\\n bytes calldata _wdmsg,\\n bytes[] calldata _sigs,\\n address[] calldata _signers,\\n uint256[] calldata _powers\\n ) external whenNotPaused {\\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \\\"WithdrawMsg\\\"));\\n verifySigs(abi.encodePacked(domain, _wdmsg), _sigs, _signers, _powers);\\n // decode and check wdmsg\\n PbPool.WithdrawMsg memory wdmsg = PbPool.decWithdrawMsg(_wdmsg);\\n // len = 8 + 8 + 20 + 20 + 32 = 88\\n bytes32 wdId = keccak256(\\n abi.encodePacked(wdmsg.chainid, wdmsg.seqnum, wdmsg.receiver, wdmsg.token, wdmsg.amount)\\n );\\n require(withdraws[wdId] == false, \\\"withdraw already succeeded\\\");\\n withdraws[wdId] = true;\\n _updateVolume(wdmsg.token, wdmsg.amount);\\n uint256 delayThreshold = delayThresholds[wdmsg.token];\\n if (delayThreshold > 0 && wdmsg.amount > delayThreshold) {\\n _addDelayedTransfer(wdId, wdmsg.receiver, wdmsg.token, wdmsg.amount);\\n } else {\\n _sendToken(wdmsg.receiver, wdmsg.token, wdmsg.amount);\\n }\\n emit WithdrawDone(wdId, wdmsg.seqnum, wdmsg.receiver, wdmsg.token, wdmsg.amount, wdmsg.refid);\\n }\\n\\n function executeDelayedTransfer(bytes32 id) external whenNotPaused {\\n delayedTransfer memory transfer = _executeDelayedTransfer(id);\\n _sendToken(transfer.receiver, transfer.token, transfer.amount);\\n }\\n\\n function setMinAdd(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\\n require(_tokens.length == _amounts.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n minAdd[_tokens[i]] = _amounts[i];\\n emit MinAddUpdated(_tokens[i], _amounts[i]);\\n }\\n }\\n\\n function _sendToken(\\n address _receiver,\\n address _token,\\n uint256 _amount\\n ) internal {\\n if (_token == nativeWrap) {\\n // withdraw then transfer native to receiver\\n IWETH(nativeWrap).withdraw(_amount);\\n (bool sent, ) = _receiver.call{value: _amount, gas: nativeTokenTransferGas}(\\\"\\\");\\n require(sent, \\\"failed to send native token\\\");\\n } else {\\n IERC20(_token).safeTransfer(_receiver, _amount);\\n }\\n }\\n\\n // set nativeWrap, for relay requests, if token == nativeWrap, will withdraw first then transfer native to receiver\\n function setWrap(address _weth) external onlyOwner {\\n nativeWrap = _weth;\\n }\\n\\n // setNativeTransferGasUsed, native transfer will use this config.\\n function setNativeTokenTransferGas(uint256 _gasUsed) external onlyGovernor {\\n nativeTokenTransferGas = _gasUsed;\\n }\\n}\\n\",\"keccak256\":\"0xf1bfca4bf2af0d4c66ded2f7bb32593fac6df1a739854f9f0e901f6021fb3b66\",\"license\":\"GPL-3.0-only\"},\"contracts/liquidity-bridge/Signers.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"../safeguard/Ownable.sol\\\";\\nimport \\\"../interfaces/ISigsVerifier.sol\\\";\\n\\n/**\\n * @title Multi-sig verification and management functions for {Bridge}.\\n */\\ncontract Signers is Ownable, ISigsVerifier {\\n using ECDSA for bytes32;\\n\\n bytes32 public ssHash;\\n uint256 public triggerTime; // timestamp when last update was triggered\\n\\n // reset can be called by the owner address for emergency recovery\\n uint256 public resetTime;\\n uint256 public noticePeriod; // advance notice period as seconds for reset\\n uint256 constant MAX_INT = 2**256 - 1;\\n\\n event SignersUpdated(address[] _signers, uint256[] _powers);\\n\\n event ResetNotification(uint256 resetTime);\\n\\n /**\\n * @notice Verifies that a message is signed by a quorum among the signers\\n * The sigs must be sorted by signer addresses in ascending order.\\n * @param _msg signed message\\n * @param _sigs list of signatures sorted by signer addresses in ascending order\\n * @param _signers sorted list of current signers\\n * @param _powers powers of current signers\\n */\\n function verifySigs(\\n bytes memory _msg,\\n bytes[] calldata _sigs,\\n address[] calldata _signers,\\n uint256[] calldata _powers\\n ) public view override {\\n bytes32 h = keccak256(abi.encodePacked(_signers, _powers));\\n require(ssHash == h, \\\"Mismatch current signers\\\");\\n _verifySignedPowers(keccak256(_msg).toEthSignedMessageHash(), _sigs, _signers, _powers);\\n }\\n\\n /**\\n * @notice Update new signers.\\n * @param _newSigners sorted list of new signers\\n * @param _curPowers powers of new signers\\n * @param _sigs list of signatures sorted by signer addresses in ascending order\\n * @param _curSigners sorted list of current signers\\n * @param _curPowers powers of current signers\\n */\\n function updateSigners(\\n uint256 _triggerTime,\\n address[] calldata _newSigners,\\n uint256[] calldata _newPowers,\\n bytes[] calldata _sigs,\\n address[] calldata _curSigners,\\n uint256[] calldata _curPowers\\n ) external {\\n // use trigger time for nonce protection, must be ascending\\n require(_triggerTime > triggerTime, \\\"Trigger time is not increasing\\\");\\n // make sure triggerTime is not too large, as it cannot be decreased once set\\n require(_triggerTime < block.timestamp + 3600, \\\"Trigger time is too large\\\");\\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \\\"UpdateSigners\\\"));\\n verifySigs(abi.encodePacked(domain, _triggerTime, _newSigners, _newPowers), _sigs, _curSigners, _curPowers);\\n _updateSigners(_newSigners, _newPowers);\\n triggerTime = _triggerTime;\\n }\\n\\n /**\\n * @notice reset signers, only used for init setup and emergency recovery\\n */\\n function resetSigners(address[] calldata _signers, uint256[] calldata _powers) external onlyOwner {\\n require(block.timestamp > resetTime, \\\"not reach reset time\\\");\\n resetTime = MAX_INT;\\n _updateSigners(_signers, _powers);\\n }\\n\\n function notifyResetSigners() external onlyOwner {\\n resetTime = block.timestamp + noticePeriod;\\n emit ResetNotification(resetTime);\\n }\\n\\n function increaseNoticePeriod(uint256 period) external onlyOwner {\\n require(period > noticePeriod, \\\"notice period can only be increased\\\");\\n noticePeriod = period;\\n }\\n\\n // separate from verifySigs func to avoid \\\"stack too deep\\\" issue\\n function _verifySignedPowers(\\n bytes32 _hash,\\n bytes[] calldata _sigs,\\n address[] calldata _signers,\\n uint256[] calldata _powers\\n ) private pure {\\n require(_signers.length == _powers.length, \\\"signers and powers length not match\\\");\\n uint256 totalPower; // sum of all signer.power\\n for (uint256 i = 0; i < _signers.length; i++) {\\n totalPower += _powers[i];\\n }\\n uint256 quorum = (totalPower * 2) / 3 + 1;\\n\\n uint256 signedPower; // sum of signer powers who are in sigs\\n address prev = address(0);\\n uint256 index = 0;\\n for (uint256 i = 0; i < _sigs.length; i++) {\\n address signer = _hash.recover(_sigs[i]);\\n require(signer > prev, \\\"signers not in ascending order\\\");\\n prev = signer;\\n // now find match signer add its power\\n while (signer > _signers[index]) {\\n index += 1;\\n require(index < _signers.length, \\\"signer not found\\\");\\n }\\n if (signer == _signers[index]) {\\n signedPower += _powers[index];\\n }\\n if (signedPower >= quorum) {\\n // return early to save gas\\n return;\\n }\\n }\\n revert(\\\"quorum not reached\\\");\\n }\\n\\n function _updateSigners(address[] calldata _signers, uint256[] calldata _powers) private {\\n require(_signers.length == _powers.length, \\\"signers and powers length not match\\\");\\n address prev = address(0);\\n for (uint256 i = 0; i < _signers.length; i++) {\\n require(_signers[i] > prev, \\\"New signers not in ascending order\\\");\\n prev = _signers[i];\\n }\\n ssHash = keccak256(abi.encodePacked(_signers, _powers));\\n emit SignersUpdated(_signers, _powers);\\n }\\n}\\n\",\"keccak256\":\"0x7220bc3aea38832e86185152c6219f267f1bf59c1a7100f3660eb45c5ae5f640\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/DelayedTransfer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"./Governor.sol\\\";\\n\\nabstract contract DelayedTransfer is Governor {\\n struct delayedTransfer {\\n address receiver;\\n address token;\\n uint256 amount;\\n uint256 timestamp;\\n }\\n mapping(bytes32 => delayedTransfer) public delayedTransfers;\\n mapping(address => uint256) public delayThresholds;\\n uint256 public delayPeriod; // in seconds\\n\\n event DelayedTransferAdded(bytes32 id);\\n event DelayedTransferExecuted(bytes32 id, address receiver, address token, uint256 amount);\\n\\n event DelayPeriodUpdated(uint256 period);\\n event DelayThresholdUpdated(address token, uint256 threshold);\\n\\n function setDelayThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external onlyGovernor {\\n require(_tokens.length == _thresholds.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n delayThresholds[_tokens[i]] = _thresholds[i];\\n emit DelayThresholdUpdated(_tokens[i], _thresholds[i]);\\n }\\n }\\n\\n function setDelayPeriod(uint256 _period) external onlyGovernor {\\n delayPeriod = _period;\\n emit DelayPeriodUpdated(_period);\\n }\\n\\n function _addDelayedTransfer(\\n bytes32 id,\\n address receiver,\\n address token,\\n uint256 amount\\n ) internal {\\n require(delayedTransfers[id].timestamp == 0, \\\"delayed transfer already exists\\\");\\n delayedTransfers[id] = delayedTransfer({\\n receiver: receiver,\\n token: token,\\n amount: amount,\\n timestamp: block.timestamp\\n });\\n emit DelayedTransferAdded(id);\\n }\\n\\n // caller needs to do the actual token transfer\\n function _executeDelayedTransfer(bytes32 id) internal returns (delayedTransfer memory) {\\n delayedTransfer memory transfer = delayedTransfers[id];\\n require(transfer.timestamp > 0, \\\"delayed transfer not exist\\\");\\n require(block.timestamp > transfer.timestamp + delayPeriod, \\\"delayed transfer still locked\\\");\\n delete delayedTransfers[id];\\n emit DelayedTransferExecuted(id, transfer.receiver, transfer.token, transfer.amount);\\n return transfer;\\n }\\n}\\n\",\"keccak256\":\"0xabc30b51461760fca2280c892430e2890a3dca109df98ce351c0964f1114eaa3\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/Governor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"./Ownable.sol\\\";\\n\\nabstract contract Governor is Ownable {\\n mapping(address => bool) public governors;\\n\\n event GovernorAdded(address account);\\n event GovernorRemoved(address account);\\n\\n modifier onlyGovernor() {\\n require(isGovernor(msg.sender), \\\"Caller is not governor\\\");\\n _;\\n }\\n\\n constructor() {\\n _addGovernor(msg.sender);\\n }\\n\\n function isGovernor(address _account) public view returns (bool) {\\n return governors[_account];\\n }\\n\\n function addGovernor(address _account) public onlyOwner {\\n _addGovernor(_account);\\n }\\n\\n function removeGovernor(address _account) public onlyOwner {\\n _removeGovernor(_account);\\n }\\n\\n function renounceGovernor() public {\\n _removeGovernor(msg.sender);\\n }\\n\\n function _addGovernor(address _account) private {\\n require(!isGovernor(_account), \\\"Account is already governor\\\");\\n governors[_account] = true;\\n emit GovernorAdded(_account);\\n }\\n\\n function _removeGovernor(address _account) private {\\n require(isGovernor(_account), \\\"Account is not governor\\\");\\n governors[_account] = false;\\n emit GovernorRemoved(_account);\\n }\\n}\\n\",\"keccak256\":\"0x2c05629097c488feb0f1cc9d832397c7d4c419cdd00545465f83f3b58aea0c48\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity ^0.8.0;\\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 * By default, the owner account will be the one that deploys the contract. This\\n * can 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 *\\n * This adds a normal func that setOwner if _owner is address(0). So we can't allow\\n * renounceOwnership. So we can support Proxy based upgradable contract\\n */\\nabstract contract Ownable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _setOwner(msg.sender);\\n }\\n\\n /**\\n * @dev Only to be called by inherit contracts, in their init func called by Proxy\\n * we require _owner == address(0), which is only possible when it's a delegateCall\\n * because constructor sets _owner in contract state.\\n */\\n function initOwner() internal {\\n require(_owner == address(0), \\\"owner already set\\\");\\n _setOwner(msg.sender);\\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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == msg.sender, \\\"Ownable: caller is not the owner\\\");\\n _;\\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 require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _setOwner(newOwner);\\n }\\n\\n function _setOwner(address newOwner) private {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x2a92103195b8dce0f34fdf9bf7f94ddf38bf8edf0c0fd4be21323c47016687e9\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/Pauser.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/security/Pausable.sol\\\";\\nimport \\\"./Ownable.sol\\\";\\n\\nabstract contract Pauser is Ownable, Pausable {\\n mapping(address => bool) public pausers;\\n\\n event PauserAdded(address account);\\n event PauserRemoved(address account);\\n\\n constructor() {\\n _addPauser(msg.sender);\\n }\\n\\n modifier onlyPauser() {\\n require(isPauser(msg.sender), \\\"Caller is not pauser\\\");\\n _;\\n }\\n\\n function pause() public onlyPauser {\\n _pause();\\n }\\n\\n function unpause() public onlyPauser {\\n _unpause();\\n }\\n\\n function isPauser(address account) public view returns (bool) {\\n return pausers[account];\\n }\\n\\n function addPauser(address account) public onlyOwner {\\n _addPauser(account);\\n }\\n\\n function removePauser(address account) public onlyOwner {\\n _removePauser(account);\\n }\\n\\n function renouncePauser() public {\\n _removePauser(msg.sender);\\n }\\n\\n function _addPauser(address account) private {\\n require(!isPauser(account), \\\"Account is already pauser\\\");\\n pausers[account] = true;\\n emit PauserAdded(account);\\n }\\n\\n function _removePauser(address account) private {\\n require(isPauser(account), \\\"Account is not pauser\\\");\\n pausers[account] = false;\\n emit PauserRemoved(account);\\n }\\n}\\n\",\"keccak256\":\"0xe260d8e1780ca5f7ee0bedb8d1f7415bfd1e42b2b5f6d191a8e3e741ab0af5fd\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/VolumeControl.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"./Governor.sol\\\";\\n\\nabstract contract VolumeControl is Governor {\\n uint256 public epochLength; // seconds\\n mapping(address => uint256) public epochVolumes; // key is token\\n mapping(address => uint256) public epochVolumeCaps; // key is token\\n mapping(address => uint256) public lastOpTimestamps; // key is token\\n\\n event EpochLengthUpdated(uint256 length);\\n event EpochVolumeUpdated(address token, uint256 cap);\\n\\n function setEpochLength(uint256 _length) external onlyGovernor {\\n epochLength = _length;\\n emit EpochLengthUpdated(_length);\\n }\\n\\n function setEpochVolumeCaps(address[] calldata _tokens, uint256[] calldata _caps) external onlyGovernor {\\n require(_tokens.length == _caps.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n epochVolumeCaps[_tokens[i]] = _caps[i];\\n emit EpochVolumeUpdated(_tokens[i], _caps[i]);\\n }\\n }\\n\\n function _updateVolume(address _token, uint256 _amount) internal {\\n if (epochLength == 0) {\\n return;\\n }\\n uint256 cap = epochVolumeCaps[_token];\\n if (cap == 0) {\\n return;\\n }\\n uint256 volume = epochVolumes[_token];\\n uint256 timestamp = block.timestamp;\\n uint256 epochStartTime = (timestamp / epochLength) * epochLength;\\n if (lastOpTimestamps[_token] < epochStartTime) {\\n volume = _amount;\\n } else {\\n volume += _amount;\\n }\\n require(volume <= cap, \\\"volume exceeds cap\\\");\\n epochVolumes[_token] = volume;\\n lastOpTimestamps[_token] = timestamp;\\n }\\n}\\n\",\"keccak256\":\"0xe66e0543c641d3f0a38fa35a5f39c3cfe289b08a95bb77d3fbcaf3426479cb4d\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x608060405261c3506014553480156200001757600080fd5b5062000023336200004e565b60016005556006805460ff191690556200003d336200009e565b620000483362000168565b62000228565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811660009081526007602052604090205460ff16156200010d5760405162461bcd60e51b815260206004820152601960248201527f4163636f756e7420697320616c7265616479207061757365720000000000000060448201526064015b60405180910390fd5b6001600160a01b038116600081815260076020908152604091829020805460ff1916600117905590519182527f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f891015b60405180910390a150565b6001600160a01b03811660009081526008602052604090205460ff1615620001d35760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920676f7665726e6f720000000000604482015260640162000104565b6001600160a01b038116600081815260086020908152604091829020805460ff1916600117905590519182527fdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b591016200015d565b6151da80620002386000396000f3fe60806040526004361061037a5760003560e01c80638456cb59116101d1578063ba2cb25c11610102578063e3eece26116100a0578063f20c922a1161006f578063f20c922a14610afb578063f2fde38b14610b1b578063f832138314610b3b578063f8b30d7d14610b6857600080fd5b8063e3eece2614610a52578063e43581b814610a82578063e999e5f414610abb578063eecdac8814610adb57600080fd5b8063cefe0df5116100dc578063cefe0df5146109d7578063d0790da9146109f7578063e026049c14610a0d578063e09ab42814610a2257600080fd5b8063ba2cb25c1461096a578063ccde517a1461098a578063cdd1b25d146109b757600080fd5b8063a21a92801161016f578063adc0d57f11610149578063adc0d57f14610897578063b1c94d9414610911578063b517b55014610927578063b5f2bc471461093d57600080fd5b8063a21a928014610837578063a5977fbb14610857578063a7bdf45a1461087757600080fd5b80638da5cb5b116101ab5780638da5cb5b146107c35780639b14d4c6146107e15780639e25fc5c146107f75780639ff9001a1461081757600080fd5b80638456cb5914610754578063878fe1ce1461076957806389e391271461078957600080fd5b806352532faa116102ab57806365a114f1116102495780636ef8d66d116102235780636ef8d66d146106dc5780637044c89e146106f157806380f51c121461070457806382dc1ec41461073457600080fd5b806365a114f114610686578063682dbc221461069c5780636b2c0f55146106bc57600080fd5b806357d775f81161028557806357d775f8146105fe5780635c975abb1461061457806360216b001461062c578063618ee0551461065957600080fd5b806352532faa1461059157806354eea796146105be57806356688700146105de57600080fd5b80633d57210711610318578063457bfa2f116102f2578063457bfa2f146104e057806346fbf68e1461051857806347b16c6c14610551578063482341261461057157600080fd5b80633d572107146104985780633f2e5fc3146104b85780633f4ba83a146104cb57600080fd5b80632fd1b0a4116103545780632fd1b0a4146103dd578063370fb47b146104145780633c4a25d0146104385780633c64f04b1461045857600080fd5b8063089927411461038657806317bdbae5146103a857806325c38b9f146103c857600080fd5b3661038157005b600080fd5b34801561039257600080fd5b506103a66103a1366004614954565b610b95565b005b3480156103b457600080fd5b506103a66103c3366004614954565b610d38565b3480156103d457600080fd5b506103a6610ecf565b3480156103e957600080fd5b506018546103fa9063ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b34801561042057600080fd5b5061042a60025481565b60405190815260200161040b565b34801561044457600080fd5b506103a66104533660046149dc565b610f6e565b34801561046457600080fd5b506104886104733660046149f7565b60156020526000908152604090205460ff1681565b604051901515815260200161040b565b3480156104a457600080fd5b506103a66104b33660046149f7565b610fd1565b6103a66104c6366004614a3c565b611065565b3480156104d757600080fd5b506103a66112ba565b3480156104ec57600080fd5b50601354610500906001600160a01b031681565b6040516001600160a01b03909116815260200161040b565b34801561052457600080fd5b506104886105333660046149dc565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561055d57600080fd5b506103a661056c366004614954565b611323565b34801561057d57600080fd5b506103a661058c366004614a9a565b6114ba565b34801561059d57600080fd5b5061042a6105ac3660046149dc565b600e6020526000908152604090205481565b3480156105ca57600080fd5b506103a66105d93660046149f7565b61152e565b3480156105ea57600080fd5b506103a66105f9366004614ab5565b6115bb565b34801561060a57600080fd5b5061042a60095481565b34801561062057600080fd5b5060065460ff16610488565b34801561063857600080fd5b5061042a6106473660046149dc565b600a6020526000908152604090205481565b34801561066557600080fd5b5061042a6106743660046149dc565b60176020526000908152604090205481565b34801561069257600080fd5b5061042a60035481565b3480156106a857600080fd5b506103a66106b7366004614af5565b61177c565b3480156106c857600080fd5b506103a66106d73660046149dc565b611868565b3480156106e857600080fd5b506103a66118c8565b6103a66106ff3660046149f7565b6118d1565b34801561071057600080fd5b5061048861071f3660046149dc565b60076020526000908152604090205460ff1681565b34801561074057600080fd5b506103a661074f3660046149dc565b611b82565b34801561076057600080fd5b506103a6611be2565b34801561077557600080fd5b506103a6610784366004614954565b611c49565b34801561079557600080fd5b506010546107aa9067ffffffffffffffff1681565b60405167ffffffffffffffff909116815260200161040b565b3480156107cf57600080fd5b506000546001600160a01b0316610500565b3480156107ed57600080fd5b5061042a60045481565b34801561080357600080fd5b506103a66108123660046149f7565b611de0565b34801561082357600080fd5b506103a66108323660046149dc565b611e4e565b34801561084357600080fd5b506103a6610852366004614c23565b611ec7565b34801561086357600080fd5b506103a6610872366004614d12565b61220e565b34801561088357600080fd5b506103a6610892366004614954565b61235b565b3480156108a357600080fd5b506108e66108b23660046149f7565b600d6020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b604080516001600160a01b03958616815294909316602085015291830152606082015260800161040b565b34801561091d57600080fd5b5061042a600f5481565b34801561093357600080fd5b5061042a60145481565b34801561094957600080fd5b5061042a6109583660046149dc565b600b6020526000908152604090205481565b34801561097657600080fd5b506103a6610985366004614d7f565b61241b565b34801561099657600080fd5b5061042a6109a53660046149dc565b60116020526000908152604090205481565b3480156109c357600080fd5b506103a66109d2366004614c23565b612571565b3480156109e357600080fd5b506103a66109f23660046149f7565b612896565b348015610a0357600080fd5b5061042a60015481565b348015610a1957600080fd5b506103a66128f3565b348015610a2e57600080fd5b50610488610a3d3660046149f7565b60126020526000908152604090205460ff1681565b348015610a5e57600080fd5b50610488610a6d3660046149dc565b60086020526000908152604090205460ff1681565b348015610a8e57600080fd5b50610488610a9d3660046149dc565b6001600160a01b031660009081526008602052604090205460ff1690565b348015610ac757600080fd5b506103a6610ad6366004614954565b6128fc565b348015610ae757600080fd5b506103a6610af63660046149dc565b612a93565b348015610b0757600080fd5b506103a6610b163660046149f7565b612af3565b348015610b2757600080fd5b506103a6610b363660046149dc565b612bac565b348015610b4757600080fd5b5061042a610b563660046149dc565b600c6020526000908152604090205481565b348015610b7457600080fd5b5061042a610b833660046149dc565b60166020526000908152604090205481565b3360009081526008602052604090205460ff16610bf25760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b60448201526064015b60405180910390fd5b828114610c335760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d3157828282818110610c5057610c50614e7f565b9050602002013560166000878785818110610c6d57610c6d614e7f565b9050602002016020810190610c8291906149dc565b6001600160a01b031681526020810191909152604001600020557f8b59d386e660418a48d742213ad5ce7c4dd51ae81f30e4e2c387f17d907010c9858583818110610ccf57610ccf614e7f565b9050602002016020810190610ce491906149dc565b848484818110610cf657610cf6614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180610d2981614eab565b915050610c36565b5050505050565b3360009081526008602052604090205460ff16610d905760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b828114610dd15760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d3157828282818110610dee57610dee614e7f565b90506020020135600e6000878785818110610e0b57610e0b614e7f565b9050602002016020810190610e2091906149dc565b6001600160a01b031681526020810191909152604001600020557fceaad6533bfb481492fb3e08ef19297f46611b8fa9de5ef4cf8dc23a56ad09ce858583818110610e6d57610e6d614e7f565b9050602002016020810190610e8291906149dc565b848484818110610e9457610e94614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180610ec781614eab565b915050610dd4565b33610ee26000546001600160a01b031690565b6001600160a01b031614610f265760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b600454610f339042614ec4565b60038190556040519081527f68e825132f7d4bc837dea2d64ac9fc19912bf0224b67f9317d8f1a917f5304a1906020015b60405180910390a1565b33610f816000546001600160a01b031690565b6001600160a01b031614610fc55760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b610fce81612c88565b50565b3360009081526008602052604090205460ff166110295760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b600f8190556040518181527fc0a39f234199b125fb93713c4d067bdcebbf691087f87b79c0feb92b156ba8b6906020015b60405180910390a150565b6002600554036110b75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be9565b600260055560065460ff16156111025760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b8334146111435760405162461bcd60e51b815260206004820152600f60248201526e082dadeeadce840dad2e6dac2e8c6d608b1b6044820152606401610be9565b6013546001600160a01b031661119b5760405162461bcd60e51b815260206004820152601360248201527f4e61746976652077726170206e6f7420736574000000000000000000000000006044820152606401610be9565b6013546000906111b99087906001600160a01b031687878787612d45565b9050601360009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b15801561120b57600080fd5b505af115801561121f573d6000803e3d6000fd5b5050601354604080518681523360208201526001600160a01b03808d1692820192909252911660608201526080810189905267ffffffffffffffff80891660a0830152871660c082015263ffffffff861660e08201527f89d8051e597ab4178a863a5190407b98abfeff406aa8db90c59af76612e58f0193506101000191506112a59050565b60405180910390a15050600160055550505050565b3360009081526007602052604090205460ff166113195760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206973206e6f74207061757365720000000000000000000000006044820152606401610be9565b611321612f78565b565b3360009081526008602052604090205460ff1661137b5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b8281146113bc5760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d31578282828181106113d9576113d9614e7f565b90506020020135600b60008787858181106113f6576113f6614e7f565b905060200201602081019061140b91906149dc565b6001600160a01b031681526020810191909152604001600020557f608e49c22994f20b5d3496dca088b88dfd81b4a3e8cc3809ea1e10a320107e8985858381811061145857611458614e7f565b905060200201602081019061146d91906149dc565b84848481811061147f5761147f614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a1806114b281614eab565b9150506113bf565b3360009081526008602052604090205460ff166115125760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b6018805463ffffffff191663ffffffff92909216919091179055565b3360009081526008602052604090205460ff166115865760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b60098190556040518181527f2664fec2ff76486ac58ed087310855b648b15b9d19f3de8529e95f7c46b7d6b39060200161105a565b60026005540361160d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be9565b600260055560065460ff16156116585760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b6001600160a01b03821660009081526011602052604090205481116116b25760405162461bcd60e51b815260206004820152601060248201526f185b5bdd5b9d081d1bdbc81cdb585b1b60821b6044820152606401610be9565b60108054600191906000906116d290849067ffffffffffffffff16614ed7565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550611718333083856001600160a01b031661300f909392919063ffffffff16565b6010546040805167ffffffffffffffff90921682523360208301526001600160a01b0384168282015260608201839052517fd5d28426c3248963b1719df49aa4c665120372e02c8249bbea03d019c39ce7649181900360800190a150506001600555565b6000848484846040516020016117959493929190614f67565b60405160208183030381529060405280519060200120905080600154146117fe5760405162461bcd60e51b815260206004820152601860248201527f4d69736d617463682063757272656e74207369676e65727300000000000000006044820152606401610be9565b87516020808a0191909120604080517f19457468657265756d205369676e6564204d6573736167653a0a33320000000081850152603c8082019390935281518082039093018352605c019052805191012061185e908888888888886130a7565b5050505050505050565b3361187b6000546001600160a01b031690565b6001600160a01b0316146118bf5760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b610fce816133dc565b611321336133dc565b6002600554036119235760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be9565b600260055560065460ff161561196e5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b8034146119af5760405162461bcd60e51b815260206004820152600f60248201526e082dadeeadce840dad2e6dac2e8c6d608b1b6044820152606401610be9565b6013546001600160a01b0316611a075760405162461bcd60e51b815260206004820152601360248201527f4e61746976652077726170206e6f7420736574000000000000000000000000006044820152606401610be9565b6013546001600160a01b03166000908152601160205260409020548111611a635760405162461bcd60e51b815260206004820152601060248201526f185b5bdd5b9d081d1bdbc81cdb585b1b60821b6044820152606401610be9565b6010805460019190600090611a8390849067ffffffffffffffff16614ed7565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550601360009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015611af957600080fd5b505af1158015611b0d573d6000803e3d6000fd5b50506010546013546040805167ffffffffffffffff90931683523360208401526001600160a01b0390911690820152606081018590527fd5d28426c3248963b1719df49aa4c665120372e02c8249bbea03d019c39ce76493506080019150611b729050565b60405180910390a1506001600555565b33611b956000546001600160a01b031690565b6001600160a01b031614611bd95760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b610fce81613495565b3360009081526007602052604090205460ff16611c415760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206973206e6f74207061757365720000000000000000000000006044820152606401610be9565b611321613552565b3360009081526008602052604090205460ff16611ca15760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b828114611ce25760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d3157828282818110611cff57611cff614e7f565b9050602002013560176000878785818110611d1c57611d1c614e7f565b9050602002016020810190611d3191906149dc565b6001600160a01b031681526020810191909152604001600020557f4f12d1a5bfb3ccd3719255d4d299d808d50cdca9a0a5c2b3a5aaa7edde73052c858583818110611d7e57611d7e614e7f565b9050602002016020810190611d9391906149dc565b848484818110611da557611da5614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180611dd881614eab565b915050611ce5565b60065460ff1615611e265760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b6000611e31826135cd565b9050611e4a816000015182602001518360400151613792565b5050565b33611e616000546001600160a01b031690565b6001600160a01b031614611ea55760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b601380546001600160a01b0319166001600160a01b0392909216919091179055565b60065460ff1615611f0d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b60004630604051602001611f6392919091825260601b6bffffffffffffffffffffffff191660208201527f57697468647261774d73670000000000000000000000000000000000000000006034820152603f0190565b604051602081830303815290604052805190602001209050611fad818a8a604051602001611f9393929190614f88565b60405160208183030381529060405288888888888861177c565b6000611fee8a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506138c492505050565b905060008160000151826020015183604001518460600151856080015160405160200161206795949392919060c095861b6001600160c01b031990811682529490951b9093166008850152606091821b6bffffffffffffffffffffffff199081166010860152911b166024830152603882015260580190565b60408051601f1981840301815291815281516020928301206000818152601290935291205490915060ff16156120df5760405162461bcd60e51b815260206004820152601a60248201527f776974686472617720616c7265616479207375636365656465640000000000006044820152606401610be9565b6000818152601260205260409020805460ff191660011790556060820151608083015161210c9190613a1e565b60608201516001600160a01b03166000908152600e6020526040902054801580159061213b5750808360800151115b1561215d5761215882846040015185606001518660800151613b3c565b612174565b612174836040015184606001518560800151613792565b7f48a1ab26f3aa7b62bb6b6e8eed182f292b84eb7b006c0254386b268af20774be8284602001518560400151866060015187608001518860a001516040516121f89695949392919095865267ffffffffffffffff9490941660208601526001600160a01b03928316604086015291166060840152608083015260a082015260c00190565b60405180910390a1505050505050505050505050565b6002600554036122605760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be9565b600260055560065460ff16156122ab5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b60006122bb878787878787612d45565b90506122d26001600160a01b03871633308861300f565b604080518281523360208201526001600160a01b0389811682840152881660608201526080810187905267ffffffffffffffff86811660a0830152851660c082015263ffffffff841660e082015290517f89d8051e597ab4178a863a5190407b98abfeff406aa8db90c59af76612e58f01918190036101000190a1505060016005555050505050565b3361236e6000546001600160a01b031690565b6001600160a01b0316146123b25760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b60035442116124035760405162461bcd60e51b815260206004820152601460248201527f6e6f742072656163682072657365742074696d650000000000000000000000006044820152606401610be9565b60001960035561241584848484613c4f565b50505050565b6002548b1161246c5760405162461bcd60e51b815260206004820152601e60248201527f547269676765722074696d65206973206e6f7420696e6372656173696e6700006044820152606401610be9565b61247842610e10614ec4565b8b106124c65760405162461bcd60e51b815260206004820152601960248201527f547269676765722074696d6520697320746f6f206c61726765000000000000006044820152606401610be9565b6000463060405160200161251c92919091825260601b6bffffffffffffffffffffffff191660208201527f5570646174655369676e65727300000000000000000000000000000000000000603482015260410190565b604051602081830303815290604052805190602001209050612552818d8d8d8d8d604051602001611f9396959493929190614fa2565b61255e8b8b8b8b613c4f565b5050506002989098555050505050505050565b60065460ff16156125b75760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b6000463060405160200161260d92919091825260601b6bffffffffffffffffffffffff191660208201527f52656c6179000000000000000000000000000000000000000000000000000000603482015260390190565b60405160208183030381529060405280519060200120905061263d818a8a604051602001611f9393929190614f88565b600061267e8a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613df992505050565b8051602080830151604080850151606080870151608088015160a089015160c0808b015187519a861b6bffffffffffffffffffffffff199081168c8c015298861b891660348c01529590941b9096166048890152605c880191909152811b6001600160c01b0319908116607c88015293901b9092166084850152608c808501929092528051808503909201825260ac909301835280519082012060008181526015909252919020549192509060ff161561276c5760405162461bcd60e51b815260206004820152600f60248201526e7472616e736665722065786973747360881b6044820152606401610be9565b60008181526015602052604090819020805460ff1916600117905582015160608301516127999190613a1e565b6040808301516001600160a01b03166000908152600e602052205480158015906127c65750808360600151115b156127e8576127e382846020015185604001518660600151613b3c565b6127ff565b6127ff836020015184604001518560600151613792565b7f79fa08de5149d912dce8e5e8da7a7c17ccdf23dd5d3bfe196802e6eb86347c7c82846000015185602001518660400151876060015188608001518960c001516040516121f897969594939291909687526001600160a01b0395861660208801529385166040870152919093166060850152608084019290925267ffffffffffffffff9190911660a083015260c082015260e00190565b3360009081526008602052604090205460ff166128ee5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b601455565b61132133613f6a565b3360009081526008602052604090205460ff166129545760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b8281146129955760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d31578282828181106129b2576129b2614e7f565b90506020020135601160008787858181106129cf576129cf614e7f565b90506020020160208101906129e491906149dc565b6001600160a01b031681526020810191909152604001600020557fc56b0d14c4940515800d94ebbd0f3f5d8cc58ba1109c12536bd993b72e466e4f858583818110612a3157612a31614e7f565b9050602002016020810190612a4691906149dc565b848484818110612a5857612a58614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180612a8b81614eab565b915050612998565b33612aa66000546001600160a01b031690565b6001600160a01b031614612aea5760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b610fce81613f6a565b33612b066000546001600160a01b031690565b6001600160a01b031614612b4a5760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b6004548111612ba75760405162461bcd60e51b815260206004820152602360248201527f6e6f7469636520706572696f642063616e206f6e6c7920626520696e637265616044820152621cd95960ea1b6064820152608401610be9565b600455565b33612bbf6000546001600160a01b031690565b6001600160a01b031614612c035760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b6001600160a01b038116612c7f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610be9565b610fce81614023565b6001600160a01b03811660009081526008602052604090205460ff1615612cf15760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920676f7665726e6f7200000000006044820152606401610be9565b6001600160a01b038116600081815260086020908152604091829020805460ff1916600117905590519182527fdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b5910161105a565b6001600160a01b0385166000908152601660205260408120548511612d9f5760405162461bcd60e51b815260206004820152601060248201526f185b5bdd5b9d081d1bdbc81cdb585b1b60821b6044820152606401610be9565b6001600160a01b0386166000908152601760205260409020541580612ddc57506001600160a01b0386166000908152601760205260409020548511155b612e285760405162461bcd60e51b815260206004820152601060248201527f616d6f756e7420746f6f206c61726765000000000000000000000000000000006044820152606401610be9565b60185463ffffffff90811690831611612e835760405162461bcd60e51b815260206004820152601660248201527f6d617820736c69707061676520746f6f20736d616c6c000000000000000000006044820152606401610be9565b6040516bffffffffffffffffffffffff1933606090811b8216602084015289811b8216603484015288901b166048820152605c81018690526001600160c01b031960c086811b8216607c84015285811b8216608484015246901b16608c82015260009060940160408051601f1981840301815291815281516020928301206000818152601590935291205490915060ff1615612f535760405162461bcd60e51b815260206004820152600f60248201526e7472616e736665722065786973747360881b6044820152606401610be9565b6000818152601560205260409020805460ff1916600117905590509695505050505050565b60065460ff16612fca5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610be9565b6006805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001610f64565b6040516001600160a01b03808516602483015283166044820152606481018290526124159085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152614073565b8281146131025760405162461bcd60e51b815260206004820152602360248201527f7369676e65727320616e6420706f77657273206c656e677468206e6f74206d616044820152620e8c6d60eb1b6064820152608401610be9565b6000805b848110156131465783838281811061312057613120614e7f565b90506020020135826131329190614ec4565b91508061313e81614eab565b915050613106565b5060006003613156836002614fca565b6131609190614fe1565b61316b906001614ec4565b905060008080805b8a81101561338a5760006131f68d8d8481811061319257613192614e7f565b90506020028101906131a49190615003565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508f61415890919063ffffffff16565b9050836001600160a01b0316816001600160a01b0316116132595760405162461bcd60e51b815260206004820152601e60248201527f7369676e657273206e6f7420696e20617363656e64696e67206f7264657200006044820152606401610be9565b8093505b8a8a8481811061326f5761326f614e7f565b905060200201602081019061328491906149dc565b6001600160a01b0316816001600160a01b031611156132fe576132a8600184614ec4565b92508983106132f95760405162461bcd60e51b815260206004820152601060248201527f7369676e6572206e6f7420666f756e64000000000000000000000000000000006044820152606401610be9565b61325d565b8a8a8481811061331057613310614e7f565b905060200201602081019061332591906149dc565b6001600160a01b0316816001600160a01b0316036133645788888481811061334f5761334f614e7f565b90506020020135856133619190614ec4565b94505b85851061337757505050505050506133d3565b508061338281614eab565b915050613173565b5060405162461bcd60e51b815260206004820152601260248201527f71756f72756d206e6f74207265616368656400000000000000000000000000006044820152606401610be9565b50505050505050565b6001600160a01b03811660009081526007602052604090205460ff166134445760405162461bcd60e51b815260206004820152601560248201527f4163636f756e74206973206e6f742070617573657200000000000000000000006044820152606401610be9565b6001600160a01b038116600081815260076020908152604091829020805460ff1916905590519182527fcd265ebaf09df2871cc7bd4133404a235ba12eff2041bb89d9c714a2621c7c7e910161105a565b6001600160a01b03811660009081526007602052604090205460ff16156134fe5760405162461bcd60e51b815260206004820152601960248201527f4163636f756e7420697320616c726561647920706175736572000000000000006044820152606401610be9565b6001600160a01b038116600081815260076020908152604091829020805460ff1916600117905590519182527f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f8910161105a565b60065460ff16156135985760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b6006805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612ff73390565b6040805160808101825260008082526020820181905291810182905260608101919091526000828152600d6020908152604091829020825160808101845281546001600160a01b039081168252600183015416928101929092526002810154928201929092526003909101546060820181905261368c5760405162461bcd60e51b815260206004820152601a60248201527f64656c61796564207472616e73666572206e6f742065786973740000000000006044820152606401610be9565b600f54816060015161369e9190614ec4565b42116136ec5760405162461bcd60e51b815260206004820152601d60248201527f64656c61796564207472616e73666572207374696c6c206c6f636b65640000006044820152606401610be9565b6000838152600d6020908152604080832080546001600160a01b03199081168255600182018054909116905560028101849055600301929092558251908301518383015192517f3b40e5089937425d14cdd96947e5661868357e224af59bd8b24a4b8a330d44269361378493889390929091909384526001600160a01b03928316602085015291166040830152606082015260800190565b60405180910390a192915050565b6013546001600160a01b03908116908316036138ab57601354604051632e1a7d4d60e01b8152600481018390526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b1580156137ee57600080fd5b505af1158015613802573d6000803e3d6000fd5b5050601454604051600093506001600160a01b0387169250849084818181858888f193505050503d8060008114613855576040519150601f19603f3d011682016040523d82523d6000602084013e61385a565b606091505b50509050806124155760405162461bcd60e51b815260206004820152601b60248201527f6661696c656420746f2073656e64206e617469766520746f6b656e00000000006044820152606401610be9565b6138bf6001600160a01b038316848361417e565b505050565b6040805160c08101825260008082526020808301829052828401829052606083018290526080830182905260a0830182905283518085019094528184528301849052909190805b60208301515183511015613a1657613922836141ae565b90925090508160010361394957613938836141e8565b67ffffffffffffffff16845261390b565b8160020361396e5761395a836141e8565b67ffffffffffffffff16602085015261390b565b8160030361399a5761398761398284614263565b614320565b6001600160a01b0316604085015261390b565b816004036139c1576139ae61398284614263565b6001600160a01b0316606085015261390b565b816005036139e4576139da6139d584614263565b61432b565b608085015261390b565b81600603613a07576139fd6139f884614263565b614362565b60a085015261390b565b613a11838261437a565b61390b565b505050919050565b600954600003613a2c575050565b6001600160a01b0382166000908152600b602052604081205490819003613a5257505050565b6001600160a01b0383166000908152600a602052604081205460095490914291613a7c8184614fe1565b613a869190614fca565b6001600160a01b0387166000908152600c6020526040902054909150811115613ab157849250613abe565b613abb8584614ec4565b92505b83831115613b0e5760405162461bcd60e51b815260206004820152601260248201527f766f6c756d6520657863656564732063617000000000000000000000000000006044820152606401610be9565b506001600160a01b039094166000908152600a6020908152604080832093909355600c905220929092555050565b6000848152600d602052604090206003015415613b9b5760405162461bcd60e51b815260206004820152601f60248201527f64656c61796564207472616e7366657220616c726561647920657869737473006044820152606401610be9565b604080516080810182526001600160a01b0380861682528481166020808401918252838501868152426060860190815260008b8152600d90935291869020945185549085166001600160a01b031991821617865592516001860180549190951693169290921790925551600283015551600390910155517fcbcfffe5102114216a85d3aceb14ad4b81a3935b1b5c468fadf3889eb9c5dce690613c419086815260200190565b60405180910390a150505050565b828114613caa5760405162461bcd60e51b815260206004820152602360248201527f7369676e65727320616e6420706f77657273206c656e677468206e6f74206d616044820152620e8c6d60eb1b6064820152608401610be9565b6000805b84811015613d8357816001600160a01b0316868683818110613cd257613cd2614e7f565b9050602002016020810190613ce791906149dc565b6001600160a01b031611613d485760405162461bcd60e51b815260206004820152602260248201527f4e6577207369676e657273206e6f7420696e20617363656e64696e67206f726460448201526132b960f11b6064820152608401610be9565b858582818110613d5a57613d5a614e7f565b9050602002016020810190613d6f91906149dc565b915080613d7b81614eab565b915050613cae565b5084848484604051602001613d9b9493929190614f67565b60408051601f198184030181529082905280516020909101206001557ff126123539a68393c55697f617e7d1148e371988daed246c2f41da99965a23f890613dea90879087908790879061504a565b60405180910390a15050505050565b6040805160e08101825260008082526020808301829052828401829052606083018290526080830182905260a0830182905260c0830182905283518085019094528184528301849052909190805b60208301515183511015613a1657613e5e836141ae565b909250905081600103613e8757613e7761398284614263565b6001600160a01b03168452613e47565b81600203613eae57613e9b61398284614263565b6001600160a01b03166020850152613e47565b81600303613ed557613ec261398284614263565b6001600160a01b03166040850152613e47565b81600403613ef357613ee96139d584614263565b6060850152613e47565b81600503613f1857613f04836141e8565b67ffffffffffffffff166080850152613e47565b81600603613f3d57613f29836141e8565b67ffffffffffffffff1660a0850152613e47565b81600703613f5b57613f516139f884614263565b60c0850152613e47565b613f65838261437a565b613e47565b6001600160a01b03811660009081526008602052604090205460ff16613fd25760405162461bcd60e51b815260206004820152601760248201527f4163636f756e74206973206e6f7420676f7665726e6f720000000000000000006044820152606401610be9565b6001600160a01b038116600081815260086020908152604091829020805460ff1916905590519182527f1ebe834e73d60a5fec822c1e1727d34bc79f2ad977ed504581cc1822fe20fb5b910161105a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006140c8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166143ea9092919063ffffffff16565b8051909150156138bf57808060200190518101906140e691906150c6565b6138bf5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610be9565b60008060006141678585614403565b9150915061417481614471565b5090505b92915050565b6040516001600160a01b0383166024820152604481018290526138bf90849063a9059cbb60e01b90606401613043565b60008060006141bc846141e8565b90506141c9600882614fe1565b92508060071660058111156141e0576141e06150e8565b915050915091565b602080820151825181019091015160009182805b600a8110156103815783811a9150614215816007614fca565b82607f16901b851794508160801660000361425157614235816001614ec4565b86518790614244908390614ec4565b9052509395945050505050565b8061425b81614eab565b9150506141fc565b60606000614270836141e8565b905060008184600001516142849190614ec4565b905083602001515181111561429857600080fd5b8167ffffffffffffffff8111156142b1576142b1614adf565b6040519080825280601f01601f1916602001820160405280156142db576020820181803683370190505b50602080860151865192955091818601919083010160005b8581101561431557818101518382015261430e602082614ec4565b90506142f3565b505050935250919050565b600061417882614627565b600060208251111561433c57600080fd5b602082015190508151602061435191906150fe565b61435c906008614fca565b1c919050565b6000815160201461437257600080fd5b506020015190565b600081600581111561438e5761438e6150e8565b0361439c576138bf826141e8565b60028160058111156143b0576143b06150e8565b036103815760006143c0836141e8565b905080836000018181516143d49190614ec4565b905250602083015151835111156138bf57600080fd5b60606143f9848460008561464f565b90505b9392505050565b60008082516041036144395760208301516040840151606085015160001a61442d87828585614797565b9450945050505061446a565b82516040036144625760208301516040840151614457868383614884565b93509350505061446a565b506000905060025b9250929050565b6000816004811115614485576144856150e8565b0361448d5750565b60018160048111156144a1576144a16150e8565b036144ee5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610be9565b6002816004811115614502576145026150e8565b0361454f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610be9565b6003816004811115614563576145636150e8565b036145bb5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610be9565b60048160048111156145cf576145cf6150e8565b03610fce5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610be9565b6000815160141461463757600080fd5b50602001516c01000000000000000000000000900490565b6060824710156146c75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610be9565b6001600160a01b0385163b61471e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610be9565b600080866001600160a01b0316858760405161473a9190615135565b60006040518083038185875af1925050503d8060008114614777576040519150601f19603f3d011682016040523d82523d6000602084013e61477c565b606091505b509150915061478c8282866148d6565b979650505050505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156147ce575060009050600361487b565b8460ff16601b141580156147e657508460ff16601c14155b156147f7575060009050600461487b565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561484b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166148745760006001925092505061487b565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8316816148ba60ff86901c601b614ec4565b90506148c887828885614797565b935093505050935093915050565b606083156148e55750816143fc565b8251156148f55782518084602001fd5b8160405162461bcd60e51b8152600401610be99190615151565b60008083601f84011261492157600080fd5b50813567ffffffffffffffff81111561493957600080fd5b6020830191508360208260051b850101111561446a57600080fd5b6000806000806040858703121561496a57600080fd5b843567ffffffffffffffff8082111561498257600080fd5b61498e8883890161490f565b909650945060208701359150808211156149a757600080fd5b506149b48782880161490f565b95989497509550505050565b80356001600160a01b03811681146149d757600080fd5b919050565b6000602082840312156149ee57600080fd5b6143fc826149c0565b600060208284031215614a0957600080fd5b5035919050565b803567ffffffffffffffff811681146149d757600080fd5b803563ffffffff811681146149d757600080fd5b600080600080600060a08688031215614a5457600080fd5b614a5d866149c0565b945060208601359350614a7260408701614a10565b9250614a8060608701614a10565b9150614a8e60808701614a28565b90509295509295909350565b600060208284031215614aac57600080fd5b6143fc82614a28565b60008060408385031215614ac857600080fd5b614ad1836149c0565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60008060008060008060006080888a031215614b1057600080fd5b873567ffffffffffffffff80821115614b2857600080fd5b818a0191508a601f830112614b3c57600080fd5b813581811115614b4e57614b4e614adf565b604051601f8201601f19908116603f01168101908382118183101715614b7657614b76614adf565b816040528281528d6020848701011115614b8f57600080fd5b82602086016020830137600094508460208483010152809b5050505060208a013581811115614bbc578283fd5b614bc88c828d0161490f565b90995097505060408a013581811115614bdf578283fd5b614beb8c828d0161490f565b90975095505060608a013581811115614c02578283fd5b614c0e8c828d0161490f565b9a9d999c50979a509598949794955050505050565b6000806000806000806000806080898b031215614c3f57600080fd5b883567ffffffffffffffff80821115614c5757600080fd5b818b0191508b601f830112614c6b57600080fd5b813581811115614c7a57600080fd5b8c6020828501011115614c8c57600080fd5b60209283019a509850908a01359080821115614ca757600080fd5b614cb38c838d0161490f565b909850965060408b0135915080821115614ccc57600080fd5b614cd88c838d0161490f565b909650945060608b0135915080821115614cf157600080fd5b50614cfe8b828c0161490f565b999c989b5096995094979396929594505050565b60008060008060008060c08789031215614d2b57600080fd5b614d34876149c0565b9550614d42602088016149c0565b945060408701359350614d5760608801614a10565b9250614d6560808801614a10565b9150614d7360a08801614a28565b90509295509295509295565b600080600080600080600080600080600060c08c8e031215614da057600080fd5b8b359a5067ffffffffffffffff8060208e01351115614dbe57600080fd5b614dce8e60208f01358f0161490f565b909b50995060408d0135811015614de457600080fd5b614df48e60408f01358f0161490f565b909950975060608d0135811015614e0a57600080fd5b614e1a8e60608f01358f0161490f565b909750955060808d0135811015614e3057600080fd5b614e408e60808f01358f0161490f565b909550935060a08d0135811015614e5657600080fd5b50614e678d60a08e01358e0161490f565b81935080925050509295989b509295989b9093969950565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201614ebd57614ebd614e95565b5060010190565b8082018082111561417857614178614e95565b67ffffffffffffffff818116838216019080821115614ef857614ef8614e95565b5092915050565b60008160005b84811015614f34576001600160a01b03614f1e836149c0565b1686526020958601959190910190600101614f05565b5093949350505050565b60006001600160fb1b03831115614f5457600080fd5b8260051b80838637939093019392505050565b6000614f7e614f77838789614eff565b8486614f3e565b9695505050505050565b838152818360208301376000910160200190815292915050565b8681528560208201526000614fbe614f77604084018789614eff565b98975050505050505050565b808202811582820484141761417857614178614e95565b600082614ffe57634e487b7160e01b600052601260045260246000fd5b500490565b6000808335601e1984360301811261501a57600080fd5b83018035915067ffffffffffffffff82111561503557600080fd5b60200191503681900382131561446a57600080fd5b6040808252810184905260008560608301825b8781101561508b576001600160a01b03615076846149c0565b1682526020928301929091019060010161505d565b5083810360208501528481526001600160fb1b038511156150ab57600080fd5b8460051b915081866020830137016020019695505050505050565b6000602082840312156150d857600080fd5b815180151581146143fc57600080fd5b634e487b7160e01b600052602160045260246000fd5b8181038181111561417857614178614e95565b60005b8381101561512c578181015183820152602001615114565b50506000910152565b60008251615147818460208701615111565b9190910192915050565b6020815260008251806020840152615170816040850160208701615111565b601f01601f1916919091016040019291505056fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212201f580448276626679dfbd08ead02b1321fa261434071f9e38f43db7adf29f45264736f6c63430008110033", + "deployedBytecode": "0x60806040526004361061037a5760003560e01c80638456cb59116101d1578063ba2cb25c11610102578063e3eece26116100a0578063f20c922a1161006f578063f20c922a14610afb578063f2fde38b14610b1b578063f832138314610b3b578063f8b30d7d14610b6857600080fd5b8063e3eece2614610a52578063e43581b814610a82578063e999e5f414610abb578063eecdac8814610adb57600080fd5b8063cefe0df5116100dc578063cefe0df5146109d7578063d0790da9146109f7578063e026049c14610a0d578063e09ab42814610a2257600080fd5b8063ba2cb25c1461096a578063ccde517a1461098a578063cdd1b25d146109b757600080fd5b8063a21a92801161016f578063adc0d57f11610149578063adc0d57f14610897578063b1c94d9414610911578063b517b55014610927578063b5f2bc471461093d57600080fd5b8063a21a928014610837578063a5977fbb14610857578063a7bdf45a1461087757600080fd5b80638da5cb5b116101ab5780638da5cb5b146107c35780639b14d4c6146107e15780639e25fc5c146107f75780639ff9001a1461081757600080fd5b80638456cb5914610754578063878fe1ce1461076957806389e391271461078957600080fd5b806352532faa116102ab57806365a114f1116102495780636ef8d66d116102235780636ef8d66d146106dc5780637044c89e146106f157806380f51c121461070457806382dc1ec41461073457600080fd5b806365a114f114610686578063682dbc221461069c5780636b2c0f55146106bc57600080fd5b806357d775f81161028557806357d775f8146105fe5780635c975abb1461061457806360216b001461062c578063618ee0551461065957600080fd5b806352532faa1461059157806354eea796146105be57806356688700146105de57600080fd5b80633d57210711610318578063457bfa2f116102f2578063457bfa2f146104e057806346fbf68e1461051857806347b16c6c14610551578063482341261461057157600080fd5b80633d572107146104985780633f2e5fc3146104b85780633f4ba83a146104cb57600080fd5b80632fd1b0a4116103545780632fd1b0a4146103dd578063370fb47b146104145780633c4a25d0146104385780633c64f04b1461045857600080fd5b8063089927411461038657806317bdbae5146103a857806325c38b9f146103c857600080fd5b3661038157005b600080fd5b34801561039257600080fd5b506103a66103a1366004614954565b610b95565b005b3480156103b457600080fd5b506103a66103c3366004614954565b610d38565b3480156103d457600080fd5b506103a6610ecf565b3480156103e957600080fd5b506018546103fa9063ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b34801561042057600080fd5b5061042a60025481565b60405190815260200161040b565b34801561044457600080fd5b506103a66104533660046149dc565b610f6e565b34801561046457600080fd5b506104886104733660046149f7565b60156020526000908152604090205460ff1681565b604051901515815260200161040b565b3480156104a457600080fd5b506103a66104b33660046149f7565b610fd1565b6103a66104c6366004614a3c565b611065565b3480156104d757600080fd5b506103a66112ba565b3480156104ec57600080fd5b50601354610500906001600160a01b031681565b6040516001600160a01b03909116815260200161040b565b34801561052457600080fd5b506104886105333660046149dc565b6001600160a01b031660009081526007602052604090205460ff1690565b34801561055d57600080fd5b506103a661056c366004614954565b611323565b34801561057d57600080fd5b506103a661058c366004614a9a565b6114ba565b34801561059d57600080fd5b5061042a6105ac3660046149dc565b600e6020526000908152604090205481565b3480156105ca57600080fd5b506103a66105d93660046149f7565b61152e565b3480156105ea57600080fd5b506103a66105f9366004614ab5565b6115bb565b34801561060a57600080fd5b5061042a60095481565b34801561062057600080fd5b5060065460ff16610488565b34801561063857600080fd5b5061042a6106473660046149dc565b600a6020526000908152604090205481565b34801561066557600080fd5b5061042a6106743660046149dc565b60176020526000908152604090205481565b34801561069257600080fd5b5061042a60035481565b3480156106a857600080fd5b506103a66106b7366004614af5565b61177c565b3480156106c857600080fd5b506103a66106d73660046149dc565b611868565b3480156106e857600080fd5b506103a66118c8565b6103a66106ff3660046149f7565b6118d1565b34801561071057600080fd5b5061048861071f3660046149dc565b60076020526000908152604090205460ff1681565b34801561074057600080fd5b506103a661074f3660046149dc565b611b82565b34801561076057600080fd5b506103a6611be2565b34801561077557600080fd5b506103a6610784366004614954565b611c49565b34801561079557600080fd5b506010546107aa9067ffffffffffffffff1681565b60405167ffffffffffffffff909116815260200161040b565b3480156107cf57600080fd5b506000546001600160a01b0316610500565b3480156107ed57600080fd5b5061042a60045481565b34801561080357600080fd5b506103a66108123660046149f7565b611de0565b34801561082357600080fd5b506103a66108323660046149dc565b611e4e565b34801561084357600080fd5b506103a6610852366004614c23565b611ec7565b34801561086357600080fd5b506103a6610872366004614d12565b61220e565b34801561088357600080fd5b506103a6610892366004614954565b61235b565b3480156108a357600080fd5b506108e66108b23660046149f7565b600d6020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b604080516001600160a01b03958616815294909316602085015291830152606082015260800161040b565b34801561091d57600080fd5b5061042a600f5481565b34801561093357600080fd5b5061042a60145481565b34801561094957600080fd5b5061042a6109583660046149dc565b600b6020526000908152604090205481565b34801561097657600080fd5b506103a6610985366004614d7f565b61241b565b34801561099657600080fd5b5061042a6109a53660046149dc565b60116020526000908152604090205481565b3480156109c357600080fd5b506103a66109d2366004614c23565b612571565b3480156109e357600080fd5b506103a66109f23660046149f7565b612896565b348015610a0357600080fd5b5061042a60015481565b348015610a1957600080fd5b506103a66128f3565b348015610a2e57600080fd5b50610488610a3d3660046149f7565b60126020526000908152604090205460ff1681565b348015610a5e57600080fd5b50610488610a6d3660046149dc565b60086020526000908152604090205460ff1681565b348015610a8e57600080fd5b50610488610a9d3660046149dc565b6001600160a01b031660009081526008602052604090205460ff1690565b348015610ac757600080fd5b506103a6610ad6366004614954565b6128fc565b348015610ae757600080fd5b506103a6610af63660046149dc565b612a93565b348015610b0757600080fd5b506103a6610b163660046149f7565b612af3565b348015610b2757600080fd5b506103a6610b363660046149dc565b612bac565b348015610b4757600080fd5b5061042a610b563660046149dc565b600c6020526000908152604090205481565b348015610b7457600080fd5b5061042a610b833660046149dc565b60166020526000908152604090205481565b3360009081526008602052604090205460ff16610bf25760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b60448201526064015b60405180910390fd5b828114610c335760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d3157828282818110610c5057610c50614e7f565b9050602002013560166000878785818110610c6d57610c6d614e7f565b9050602002016020810190610c8291906149dc565b6001600160a01b031681526020810191909152604001600020557f8b59d386e660418a48d742213ad5ce7c4dd51ae81f30e4e2c387f17d907010c9858583818110610ccf57610ccf614e7f565b9050602002016020810190610ce491906149dc565b848484818110610cf657610cf6614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180610d2981614eab565b915050610c36565b5050505050565b3360009081526008602052604090205460ff16610d905760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b828114610dd15760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d3157828282818110610dee57610dee614e7f565b90506020020135600e6000878785818110610e0b57610e0b614e7f565b9050602002016020810190610e2091906149dc565b6001600160a01b031681526020810191909152604001600020557fceaad6533bfb481492fb3e08ef19297f46611b8fa9de5ef4cf8dc23a56ad09ce858583818110610e6d57610e6d614e7f565b9050602002016020810190610e8291906149dc565b848484818110610e9457610e94614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180610ec781614eab565b915050610dd4565b33610ee26000546001600160a01b031690565b6001600160a01b031614610f265760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b600454610f339042614ec4565b60038190556040519081527f68e825132f7d4bc837dea2d64ac9fc19912bf0224b67f9317d8f1a917f5304a1906020015b60405180910390a1565b33610f816000546001600160a01b031690565b6001600160a01b031614610fc55760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b610fce81612c88565b50565b3360009081526008602052604090205460ff166110295760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b600f8190556040518181527fc0a39f234199b125fb93713c4d067bdcebbf691087f87b79c0feb92b156ba8b6906020015b60405180910390a150565b6002600554036110b75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be9565b600260055560065460ff16156111025760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b8334146111435760405162461bcd60e51b815260206004820152600f60248201526e082dadeeadce840dad2e6dac2e8c6d608b1b6044820152606401610be9565b6013546001600160a01b031661119b5760405162461bcd60e51b815260206004820152601360248201527f4e61746976652077726170206e6f7420736574000000000000000000000000006044820152606401610be9565b6013546000906111b99087906001600160a01b031687878787612d45565b9050601360009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004016000604051808303818588803b15801561120b57600080fd5b505af115801561121f573d6000803e3d6000fd5b5050601354604080518681523360208201526001600160a01b03808d1692820192909252911660608201526080810189905267ffffffffffffffff80891660a0830152871660c082015263ffffffff861660e08201527f89d8051e597ab4178a863a5190407b98abfeff406aa8db90c59af76612e58f0193506101000191506112a59050565b60405180910390a15050600160055550505050565b3360009081526007602052604090205460ff166113195760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206973206e6f74207061757365720000000000000000000000006044820152606401610be9565b611321612f78565b565b3360009081526008602052604090205460ff1661137b5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b8281146113bc5760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d31578282828181106113d9576113d9614e7f565b90506020020135600b60008787858181106113f6576113f6614e7f565b905060200201602081019061140b91906149dc565b6001600160a01b031681526020810191909152604001600020557f608e49c22994f20b5d3496dca088b88dfd81b4a3e8cc3809ea1e10a320107e8985858381811061145857611458614e7f565b905060200201602081019061146d91906149dc565b84848481811061147f5761147f614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a1806114b281614eab565b9150506113bf565b3360009081526008602052604090205460ff166115125760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b6018805463ffffffff191663ffffffff92909216919091179055565b3360009081526008602052604090205460ff166115865760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b60098190556040518181527f2664fec2ff76486ac58ed087310855b648b15b9d19f3de8529e95f7c46b7d6b39060200161105a565b60026005540361160d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be9565b600260055560065460ff16156116585760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b6001600160a01b03821660009081526011602052604090205481116116b25760405162461bcd60e51b815260206004820152601060248201526f185b5bdd5b9d081d1bdbc81cdb585b1b60821b6044820152606401610be9565b60108054600191906000906116d290849067ffffffffffffffff16614ed7565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550611718333083856001600160a01b031661300f909392919063ffffffff16565b6010546040805167ffffffffffffffff90921682523360208301526001600160a01b0384168282015260608201839052517fd5d28426c3248963b1719df49aa4c665120372e02c8249bbea03d019c39ce7649181900360800190a150506001600555565b6000848484846040516020016117959493929190614f67565b60405160208183030381529060405280519060200120905080600154146117fe5760405162461bcd60e51b815260206004820152601860248201527f4d69736d617463682063757272656e74207369676e65727300000000000000006044820152606401610be9565b87516020808a0191909120604080517f19457468657265756d205369676e6564204d6573736167653a0a33320000000081850152603c8082019390935281518082039093018352605c019052805191012061185e908888888888886130a7565b5050505050505050565b3361187b6000546001600160a01b031690565b6001600160a01b0316146118bf5760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b610fce816133dc565b611321336133dc565b6002600554036119235760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be9565b600260055560065460ff161561196e5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b8034146119af5760405162461bcd60e51b815260206004820152600f60248201526e082dadeeadce840dad2e6dac2e8c6d608b1b6044820152606401610be9565b6013546001600160a01b0316611a075760405162461bcd60e51b815260206004820152601360248201527f4e61746976652077726170206e6f7420736574000000000000000000000000006044820152606401610be9565b6013546001600160a01b03166000908152601160205260409020548111611a635760405162461bcd60e51b815260206004820152601060248201526f185b5bdd5b9d081d1bdbc81cdb585b1b60821b6044820152606401610be9565b6010805460019190600090611a8390849067ffffffffffffffff16614ed7565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550601360009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015611af957600080fd5b505af1158015611b0d573d6000803e3d6000fd5b50506010546013546040805167ffffffffffffffff90931683523360208401526001600160a01b0390911690820152606081018590527fd5d28426c3248963b1719df49aa4c665120372e02c8249bbea03d019c39ce76493506080019150611b729050565b60405180910390a1506001600555565b33611b956000546001600160a01b031690565b6001600160a01b031614611bd95760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b610fce81613495565b3360009081526007602052604090205460ff16611c415760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206973206e6f74207061757365720000000000000000000000006044820152606401610be9565b611321613552565b3360009081526008602052604090205460ff16611ca15760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b828114611ce25760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d3157828282818110611cff57611cff614e7f565b9050602002013560176000878785818110611d1c57611d1c614e7f565b9050602002016020810190611d3191906149dc565b6001600160a01b031681526020810191909152604001600020557f4f12d1a5bfb3ccd3719255d4d299d808d50cdca9a0a5c2b3a5aaa7edde73052c858583818110611d7e57611d7e614e7f565b9050602002016020810190611d9391906149dc565b848484818110611da557611da5614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180611dd881614eab565b915050611ce5565b60065460ff1615611e265760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b6000611e31826135cd565b9050611e4a816000015182602001518360400151613792565b5050565b33611e616000546001600160a01b031690565b6001600160a01b031614611ea55760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b601380546001600160a01b0319166001600160a01b0392909216919091179055565b60065460ff1615611f0d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b60004630604051602001611f6392919091825260601b6bffffffffffffffffffffffff191660208201527f57697468647261774d73670000000000000000000000000000000000000000006034820152603f0190565b604051602081830303815290604052805190602001209050611fad818a8a604051602001611f9393929190614f88565b60405160208183030381529060405288888888888861177c565b6000611fee8a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506138c492505050565b905060008160000151826020015183604001518460600151856080015160405160200161206795949392919060c095861b6001600160c01b031990811682529490951b9093166008850152606091821b6bffffffffffffffffffffffff199081166010860152911b166024830152603882015260580190565b60408051601f1981840301815291815281516020928301206000818152601290935291205490915060ff16156120df5760405162461bcd60e51b815260206004820152601a60248201527f776974686472617720616c7265616479207375636365656465640000000000006044820152606401610be9565b6000818152601260205260409020805460ff191660011790556060820151608083015161210c9190613a1e565b60608201516001600160a01b03166000908152600e6020526040902054801580159061213b5750808360800151115b1561215d5761215882846040015185606001518660800151613b3c565b612174565b612174836040015184606001518560800151613792565b7f48a1ab26f3aa7b62bb6b6e8eed182f292b84eb7b006c0254386b268af20774be8284602001518560400151866060015187608001518860a001516040516121f89695949392919095865267ffffffffffffffff9490941660208601526001600160a01b03928316604086015291166060840152608083015260a082015260c00190565b60405180910390a1505050505050505050505050565b6002600554036122605760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610be9565b600260055560065460ff16156122ab5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b60006122bb878787878787612d45565b90506122d26001600160a01b03871633308861300f565b604080518281523360208201526001600160a01b0389811682840152881660608201526080810187905267ffffffffffffffff86811660a0830152851660c082015263ffffffff841660e082015290517f89d8051e597ab4178a863a5190407b98abfeff406aa8db90c59af76612e58f01918190036101000190a1505060016005555050505050565b3361236e6000546001600160a01b031690565b6001600160a01b0316146123b25760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b60035442116124035760405162461bcd60e51b815260206004820152601460248201527f6e6f742072656163682072657365742074696d650000000000000000000000006044820152606401610be9565b60001960035561241584848484613c4f565b50505050565b6002548b1161246c5760405162461bcd60e51b815260206004820152601e60248201527f547269676765722074696d65206973206e6f7420696e6372656173696e6700006044820152606401610be9565b61247842610e10614ec4565b8b106124c65760405162461bcd60e51b815260206004820152601960248201527f547269676765722074696d6520697320746f6f206c61726765000000000000006044820152606401610be9565b6000463060405160200161251c92919091825260601b6bffffffffffffffffffffffff191660208201527f5570646174655369676e65727300000000000000000000000000000000000000603482015260410190565b604051602081830303815290604052805190602001209050612552818d8d8d8d8d604051602001611f9396959493929190614fa2565b61255e8b8b8b8b613c4f565b5050506002989098555050505050505050565b60065460ff16156125b75760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b6000463060405160200161260d92919091825260601b6bffffffffffffffffffffffff191660208201527f52656c6179000000000000000000000000000000000000000000000000000000603482015260390190565b60405160208183030381529060405280519060200120905061263d818a8a604051602001611f9393929190614f88565b600061267e8a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613df992505050565b8051602080830151604080850151606080870151608088015160a089015160c0808b015187519a861b6bffffffffffffffffffffffff199081168c8c015298861b891660348c01529590941b9096166048890152605c880191909152811b6001600160c01b0319908116607c88015293901b9092166084850152608c808501929092528051808503909201825260ac909301835280519082012060008181526015909252919020549192509060ff161561276c5760405162461bcd60e51b815260206004820152600f60248201526e7472616e736665722065786973747360881b6044820152606401610be9565b60008181526015602052604090819020805460ff1916600117905582015160608301516127999190613a1e565b6040808301516001600160a01b03166000908152600e602052205480158015906127c65750808360600151115b156127e8576127e382846020015185604001518660600151613b3c565b6127ff565b6127ff836020015184604001518560600151613792565b7f79fa08de5149d912dce8e5e8da7a7c17ccdf23dd5d3bfe196802e6eb86347c7c82846000015185602001518660400151876060015188608001518960c001516040516121f897969594939291909687526001600160a01b0395861660208801529385166040870152919093166060850152608084019290925267ffffffffffffffff9190911660a083015260c082015260e00190565b3360009081526008602052604090205460ff166128ee5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b601455565b61132133613f6a565b3360009081526008602052604090205460ff166129545760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b6044820152606401610be9565b8281146129955760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610be9565b60005b83811015610d31578282828181106129b2576129b2614e7f565b90506020020135601160008787858181106129cf576129cf614e7f565b90506020020160208101906129e491906149dc565b6001600160a01b031681526020810191909152604001600020557fc56b0d14c4940515800d94ebbd0f3f5d8cc58ba1109c12536bd993b72e466e4f858583818110612a3157612a31614e7f565b9050602002016020810190612a4691906149dc565b848484818110612a5857612a58614e7f565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180612a8b81614eab565b915050612998565b33612aa66000546001600160a01b031690565b6001600160a01b031614612aea5760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b610fce81613f6a565b33612b066000546001600160a01b031690565b6001600160a01b031614612b4a5760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b6004548111612ba75760405162461bcd60e51b815260206004820152602360248201527f6e6f7469636520706572696f642063616e206f6e6c7920626520696e637265616044820152621cd95960ea1b6064820152608401610be9565b600455565b33612bbf6000546001600160a01b031690565b6001600160a01b031614612c035760405162461bcd60e51b815260206004820181905260248201526000805160206151858339815191526044820152606401610be9565b6001600160a01b038116612c7f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610be9565b610fce81614023565b6001600160a01b03811660009081526008602052604090205460ff1615612cf15760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920676f7665726e6f7200000000006044820152606401610be9565b6001600160a01b038116600081815260086020908152604091829020805460ff1916600117905590519182527fdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b5910161105a565b6001600160a01b0385166000908152601660205260408120548511612d9f5760405162461bcd60e51b815260206004820152601060248201526f185b5bdd5b9d081d1bdbc81cdb585b1b60821b6044820152606401610be9565b6001600160a01b0386166000908152601760205260409020541580612ddc57506001600160a01b0386166000908152601760205260409020548511155b612e285760405162461bcd60e51b815260206004820152601060248201527f616d6f756e7420746f6f206c61726765000000000000000000000000000000006044820152606401610be9565b60185463ffffffff90811690831611612e835760405162461bcd60e51b815260206004820152601660248201527f6d617820736c69707061676520746f6f20736d616c6c000000000000000000006044820152606401610be9565b6040516bffffffffffffffffffffffff1933606090811b8216602084015289811b8216603484015288901b166048820152605c81018690526001600160c01b031960c086811b8216607c84015285811b8216608484015246901b16608c82015260009060940160408051601f1981840301815291815281516020928301206000818152601590935291205490915060ff1615612f535760405162461bcd60e51b815260206004820152600f60248201526e7472616e736665722065786973747360881b6044820152606401610be9565b6000818152601560205260409020805460ff1916600117905590509695505050505050565b60065460ff16612fca5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610be9565b6006805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001610f64565b6040516001600160a01b03808516602483015283166044820152606481018290526124159085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152614073565b8281146131025760405162461bcd60e51b815260206004820152602360248201527f7369676e65727320616e6420706f77657273206c656e677468206e6f74206d616044820152620e8c6d60eb1b6064820152608401610be9565b6000805b848110156131465783838281811061312057613120614e7f565b90506020020135826131329190614ec4565b91508061313e81614eab565b915050613106565b5060006003613156836002614fca565b6131609190614fe1565b61316b906001614ec4565b905060008080805b8a81101561338a5760006131f68d8d8481811061319257613192614e7f565b90506020028101906131a49190615003565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508f61415890919063ffffffff16565b9050836001600160a01b0316816001600160a01b0316116132595760405162461bcd60e51b815260206004820152601e60248201527f7369676e657273206e6f7420696e20617363656e64696e67206f7264657200006044820152606401610be9565b8093505b8a8a8481811061326f5761326f614e7f565b905060200201602081019061328491906149dc565b6001600160a01b0316816001600160a01b031611156132fe576132a8600184614ec4565b92508983106132f95760405162461bcd60e51b815260206004820152601060248201527f7369676e6572206e6f7420666f756e64000000000000000000000000000000006044820152606401610be9565b61325d565b8a8a8481811061331057613310614e7f565b905060200201602081019061332591906149dc565b6001600160a01b0316816001600160a01b0316036133645788888481811061334f5761334f614e7f565b90506020020135856133619190614ec4565b94505b85851061337757505050505050506133d3565b508061338281614eab565b915050613173565b5060405162461bcd60e51b815260206004820152601260248201527f71756f72756d206e6f74207265616368656400000000000000000000000000006044820152606401610be9565b50505050505050565b6001600160a01b03811660009081526007602052604090205460ff166134445760405162461bcd60e51b815260206004820152601560248201527f4163636f756e74206973206e6f742070617573657200000000000000000000006044820152606401610be9565b6001600160a01b038116600081815260076020908152604091829020805460ff1916905590519182527fcd265ebaf09df2871cc7bd4133404a235ba12eff2041bb89d9c714a2621c7c7e910161105a565b6001600160a01b03811660009081526007602052604090205460ff16156134fe5760405162461bcd60e51b815260206004820152601960248201527f4163636f756e7420697320616c726561647920706175736572000000000000006044820152606401610be9565b6001600160a01b038116600081815260076020908152604091829020805460ff1916600117905590519182527f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f8910161105a565b60065460ff16156135985760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610be9565b6006805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612ff73390565b6040805160808101825260008082526020820181905291810182905260608101919091526000828152600d6020908152604091829020825160808101845281546001600160a01b039081168252600183015416928101929092526002810154928201929092526003909101546060820181905261368c5760405162461bcd60e51b815260206004820152601a60248201527f64656c61796564207472616e73666572206e6f742065786973740000000000006044820152606401610be9565b600f54816060015161369e9190614ec4565b42116136ec5760405162461bcd60e51b815260206004820152601d60248201527f64656c61796564207472616e73666572207374696c6c206c6f636b65640000006044820152606401610be9565b6000838152600d6020908152604080832080546001600160a01b03199081168255600182018054909116905560028101849055600301929092558251908301518383015192517f3b40e5089937425d14cdd96947e5661868357e224af59bd8b24a4b8a330d44269361378493889390929091909384526001600160a01b03928316602085015291166040830152606082015260800190565b60405180910390a192915050565b6013546001600160a01b03908116908316036138ab57601354604051632e1a7d4d60e01b8152600481018390526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b1580156137ee57600080fd5b505af1158015613802573d6000803e3d6000fd5b5050601454604051600093506001600160a01b0387169250849084818181858888f193505050503d8060008114613855576040519150601f19603f3d011682016040523d82523d6000602084013e61385a565b606091505b50509050806124155760405162461bcd60e51b815260206004820152601b60248201527f6661696c656420746f2073656e64206e617469766520746f6b656e00000000006044820152606401610be9565b6138bf6001600160a01b038316848361417e565b505050565b6040805160c08101825260008082526020808301829052828401829052606083018290526080830182905260a0830182905283518085019094528184528301849052909190805b60208301515183511015613a1657613922836141ae565b90925090508160010361394957613938836141e8565b67ffffffffffffffff16845261390b565b8160020361396e5761395a836141e8565b67ffffffffffffffff16602085015261390b565b8160030361399a5761398761398284614263565b614320565b6001600160a01b0316604085015261390b565b816004036139c1576139ae61398284614263565b6001600160a01b0316606085015261390b565b816005036139e4576139da6139d584614263565b61432b565b608085015261390b565b81600603613a07576139fd6139f884614263565b614362565b60a085015261390b565b613a11838261437a565b61390b565b505050919050565b600954600003613a2c575050565b6001600160a01b0382166000908152600b602052604081205490819003613a5257505050565b6001600160a01b0383166000908152600a602052604081205460095490914291613a7c8184614fe1565b613a869190614fca565b6001600160a01b0387166000908152600c6020526040902054909150811115613ab157849250613abe565b613abb8584614ec4565b92505b83831115613b0e5760405162461bcd60e51b815260206004820152601260248201527f766f6c756d6520657863656564732063617000000000000000000000000000006044820152606401610be9565b506001600160a01b039094166000908152600a6020908152604080832093909355600c905220929092555050565b6000848152600d602052604090206003015415613b9b5760405162461bcd60e51b815260206004820152601f60248201527f64656c61796564207472616e7366657220616c726561647920657869737473006044820152606401610be9565b604080516080810182526001600160a01b0380861682528481166020808401918252838501868152426060860190815260008b8152600d90935291869020945185549085166001600160a01b031991821617865592516001860180549190951693169290921790925551600283015551600390910155517fcbcfffe5102114216a85d3aceb14ad4b81a3935b1b5c468fadf3889eb9c5dce690613c419086815260200190565b60405180910390a150505050565b828114613caa5760405162461bcd60e51b815260206004820152602360248201527f7369676e65727320616e6420706f77657273206c656e677468206e6f74206d616044820152620e8c6d60eb1b6064820152608401610be9565b6000805b84811015613d8357816001600160a01b0316868683818110613cd257613cd2614e7f565b9050602002016020810190613ce791906149dc565b6001600160a01b031611613d485760405162461bcd60e51b815260206004820152602260248201527f4e6577207369676e657273206e6f7420696e20617363656e64696e67206f726460448201526132b960f11b6064820152608401610be9565b858582818110613d5a57613d5a614e7f565b9050602002016020810190613d6f91906149dc565b915080613d7b81614eab565b915050613cae565b5084848484604051602001613d9b9493929190614f67565b60408051601f198184030181529082905280516020909101206001557ff126123539a68393c55697f617e7d1148e371988daed246c2f41da99965a23f890613dea90879087908790879061504a565b60405180910390a15050505050565b6040805160e08101825260008082526020808301829052828401829052606083018290526080830182905260a0830182905260c0830182905283518085019094528184528301849052909190805b60208301515183511015613a1657613e5e836141ae565b909250905081600103613e8757613e7761398284614263565b6001600160a01b03168452613e47565b81600203613eae57613e9b61398284614263565b6001600160a01b03166020850152613e47565b81600303613ed557613ec261398284614263565b6001600160a01b03166040850152613e47565b81600403613ef357613ee96139d584614263565b6060850152613e47565b81600503613f1857613f04836141e8565b67ffffffffffffffff166080850152613e47565b81600603613f3d57613f29836141e8565b67ffffffffffffffff1660a0850152613e47565b81600703613f5b57613f516139f884614263565b60c0850152613e47565b613f65838261437a565b613e47565b6001600160a01b03811660009081526008602052604090205460ff16613fd25760405162461bcd60e51b815260206004820152601760248201527f4163636f756e74206973206e6f7420676f7665726e6f720000000000000000006044820152606401610be9565b6001600160a01b038116600081815260086020908152604091829020805460ff1916905590519182527f1ebe834e73d60a5fec822c1e1727d34bc79f2ad977ed504581cc1822fe20fb5b910161105a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006140c8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166143ea9092919063ffffffff16565b8051909150156138bf57808060200190518101906140e691906150c6565b6138bf5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610be9565b60008060006141678585614403565b9150915061417481614471565b5090505b92915050565b6040516001600160a01b0383166024820152604481018290526138bf90849063a9059cbb60e01b90606401613043565b60008060006141bc846141e8565b90506141c9600882614fe1565b92508060071660058111156141e0576141e06150e8565b915050915091565b602080820151825181019091015160009182805b600a8110156103815783811a9150614215816007614fca565b82607f16901b851794508160801660000361425157614235816001614ec4565b86518790614244908390614ec4565b9052509395945050505050565b8061425b81614eab565b9150506141fc565b60606000614270836141e8565b905060008184600001516142849190614ec4565b905083602001515181111561429857600080fd5b8167ffffffffffffffff8111156142b1576142b1614adf565b6040519080825280601f01601f1916602001820160405280156142db576020820181803683370190505b50602080860151865192955091818601919083010160005b8581101561431557818101518382015261430e602082614ec4565b90506142f3565b505050935250919050565b600061417882614627565b600060208251111561433c57600080fd5b602082015190508151602061435191906150fe565b61435c906008614fca565b1c919050565b6000815160201461437257600080fd5b506020015190565b600081600581111561438e5761438e6150e8565b0361439c576138bf826141e8565b60028160058111156143b0576143b06150e8565b036103815760006143c0836141e8565b905080836000018181516143d49190614ec4565b905250602083015151835111156138bf57600080fd5b60606143f9848460008561464f565b90505b9392505050565b60008082516041036144395760208301516040840151606085015160001a61442d87828585614797565b9450945050505061446a565b82516040036144625760208301516040840151614457868383614884565b93509350505061446a565b506000905060025b9250929050565b6000816004811115614485576144856150e8565b0361448d5750565b60018160048111156144a1576144a16150e8565b036144ee5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610be9565b6002816004811115614502576145026150e8565b0361454f5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610be9565b6003816004811115614563576145636150e8565b036145bb5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610be9565b60048160048111156145cf576145cf6150e8565b03610fce5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610be9565b6000815160141461463757600080fd5b50602001516c01000000000000000000000000900490565b6060824710156146c75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610be9565b6001600160a01b0385163b61471e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610be9565b600080866001600160a01b0316858760405161473a9190615135565b60006040518083038185875af1925050503d8060008114614777576040519150601f19603f3d011682016040523d82523d6000602084013e61477c565b606091505b509150915061478c8282866148d6565b979650505050505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156147ce575060009050600361487b565b8460ff16601b141580156147e657508460ff16601c14155b156147f7575060009050600461487b565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561484b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166148745760006001925092505061487b565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8316816148ba60ff86901c601b614ec4565b90506148c887828885614797565b935093505050935093915050565b606083156148e55750816143fc565b8251156148f55782518084602001fd5b8160405162461bcd60e51b8152600401610be99190615151565b60008083601f84011261492157600080fd5b50813567ffffffffffffffff81111561493957600080fd5b6020830191508360208260051b850101111561446a57600080fd5b6000806000806040858703121561496a57600080fd5b843567ffffffffffffffff8082111561498257600080fd5b61498e8883890161490f565b909650945060208701359150808211156149a757600080fd5b506149b48782880161490f565b95989497509550505050565b80356001600160a01b03811681146149d757600080fd5b919050565b6000602082840312156149ee57600080fd5b6143fc826149c0565b600060208284031215614a0957600080fd5b5035919050565b803567ffffffffffffffff811681146149d757600080fd5b803563ffffffff811681146149d757600080fd5b600080600080600060a08688031215614a5457600080fd5b614a5d866149c0565b945060208601359350614a7260408701614a10565b9250614a8060608701614a10565b9150614a8e60808701614a28565b90509295509295909350565b600060208284031215614aac57600080fd5b6143fc82614a28565b60008060408385031215614ac857600080fd5b614ad1836149c0565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60008060008060008060006080888a031215614b1057600080fd5b873567ffffffffffffffff80821115614b2857600080fd5b818a0191508a601f830112614b3c57600080fd5b813581811115614b4e57614b4e614adf565b604051601f8201601f19908116603f01168101908382118183101715614b7657614b76614adf565b816040528281528d6020848701011115614b8f57600080fd5b82602086016020830137600094508460208483010152809b5050505060208a013581811115614bbc578283fd5b614bc88c828d0161490f565b90995097505060408a013581811115614bdf578283fd5b614beb8c828d0161490f565b90975095505060608a013581811115614c02578283fd5b614c0e8c828d0161490f565b9a9d999c50979a509598949794955050505050565b6000806000806000806000806080898b031215614c3f57600080fd5b883567ffffffffffffffff80821115614c5757600080fd5b818b0191508b601f830112614c6b57600080fd5b813581811115614c7a57600080fd5b8c6020828501011115614c8c57600080fd5b60209283019a509850908a01359080821115614ca757600080fd5b614cb38c838d0161490f565b909850965060408b0135915080821115614ccc57600080fd5b614cd88c838d0161490f565b909650945060608b0135915080821115614cf157600080fd5b50614cfe8b828c0161490f565b999c989b5096995094979396929594505050565b60008060008060008060c08789031215614d2b57600080fd5b614d34876149c0565b9550614d42602088016149c0565b945060408701359350614d5760608801614a10565b9250614d6560808801614a10565b9150614d7360a08801614a28565b90509295509295509295565b600080600080600080600080600080600060c08c8e031215614da057600080fd5b8b359a5067ffffffffffffffff8060208e01351115614dbe57600080fd5b614dce8e60208f01358f0161490f565b909b50995060408d0135811015614de457600080fd5b614df48e60408f01358f0161490f565b909950975060608d0135811015614e0a57600080fd5b614e1a8e60608f01358f0161490f565b909750955060808d0135811015614e3057600080fd5b614e408e60808f01358f0161490f565b909550935060a08d0135811015614e5657600080fd5b50614e678d60a08e01358e0161490f565b81935080925050509295989b509295989b9093969950565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201614ebd57614ebd614e95565b5060010190565b8082018082111561417857614178614e95565b67ffffffffffffffff818116838216019080821115614ef857614ef8614e95565b5092915050565b60008160005b84811015614f34576001600160a01b03614f1e836149c0565b1686526020958601959190910190600101614f05565b5093949350505050565b60006001600160fb1b03831115614f5457600080fd5b8260051b80838637939093019392505050565b6000614f7e614f77838789614eff565b8486614f3e565b9695505050505050565b838152818360208301376000910160200190815292915050565b8681528560208201526000614fbe614f77604084018789614eff565b98975050505050505050565b808202811582820484141761417857614178614e95565b600082614ffe57634e487b7160e01b600052601260045260246000fd5b500490565b6000808335601e1984360301811261501a57600080fd5b83018035915067ffffffffffffffff82111561503557600080fd5b60200191503681900382131561446a57600080fd5b6040808252810184905260008560608301825b8781101561508b576001600160a01b03615076846149c0565b1682526020928301929091019060010161505d565b5083810360208501528481526001600160fb1b038511156150ab57600080fd5b8460051b915081866020830137016020019695505050505050565b6000602082840312156150d857600080fd5b815180151581146143fc57600080fd5b634e487b7160e01b600052602160045260246000fd5b8181038181111561417857614178614e95565b60005b8381101561512c578181015183820152602001615114565b50506000910152565b60008251615147818460208701615111565b9190910192915050565b6020815260008251806020840152615170816040850160208701615111565b601f01601f1916919091016040019291505056fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212201f580448276626679dfbd08ead02b1321fa261434071f9e38f43db7adf29f45264736f6c63430008110033", + "devdoc": { + "kind": "dev", + "methods": { + "addLiquidity(address,uint256)": { + "params": { + "_amount": "The amount to add.", + "_token": "The address of the token." + } + }, + "addNativeLiquidity(uint256)": { + "params": { + "_amount": "The amount to add." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "relay(bytes,bytes[],address[],uint256[])": { + "params": { + "_powers": "The signing powers of the signers.", + "_relayRequest": "The serialized Relay protobuf.", + "_signers": "The sorted list of signers.", + "_sigs": "The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by +2/3 of the bridge's current signing power to be delivered." + } + }, + "send(address,address,uint256,uint64,uint64,uint32)": { + "params": { + "_amount": "The amount of the transfer.", + "_dstChainId": "The destination chain ID.", + "_maxSlippage": "The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%. Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the transfer can be refunded.", + "_nonce": "A number input to guarantee uniqueness of transferId. Can be timestamp in practice.", + "_receiver": "The address of the receiver.", + "_token": "The address of the token." + } + }, + "sendNative(address,uint256,uint64,uint64,uint32)": { + "params": { + "_amount": "The amount of the transfer.", + "_dstChainId": "The destination chain ID.", + "_maxSlippage": "The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%. Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the transfer can be refunded.", + "_nonce": "A unique number. Can be timestamp in practice.", + "_receiver": "The address of the receiver." + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "updateSigners(uint256,address[],uint256[],bytes[],address[],uint256[])": { + "params": { + "_curPowers": "powers of current signers", + "_curSigners": "sorted list of current signers", + "_newSigners": "sorted list of new signers", + "_sigs": "list of signatures sorted by signer addresses in ascending order" + } + }, + "verifySigs(bytes,bytes[],address[],uint256[])": { + "params": { + "_msg": "signed message", + "_powers": "powers of current signers", + "_signers": "sorted list of current signers", + "_sigs": "list of signatures sorted by signer addresses in ascending order" + } + }, + "withdraw(bytes,bytes[],address[],uint256[])": { + "params": { + "_powers": "The signing powers of the signers.", + "_signers": "The sorted list of signers.", + "_sigs": "The list of signatures sorted by signing addresses in ascending order. A withdrawal must be signed-off by +2/3 of the bridge's current signing power to be delivered.", + "_wdmsg": "The serialized Withdraw protobuf." + } + } + }, + "title": "The liquidity-pool based bridge.", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "addLiquidity(address,uint256)": { + "notice": "Add liquidity to the pool-based bridge. NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens." + }, + "addNativeLiquidity(uint256)": { + "notice": "Add native token liquidity to the pool-based bridge." + }, + "relay(bytes,bytes[],address[],uint256[])": { + "notice": "Relay a cross-chain transfer sent from a liquidity pool-based bridge on another chain." + }, + "resetSigners(address[],uint256[])": { + "notice": "reset signers, only used for init setup and emergency recovery" + }, + "send(address,address,uint256,uint64,uint64,uint32)": { + "notice": "Send a cross-chain transfer via the liquidity pool-based bridge. NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens." + }, + "sendNative(address,uint256,uint64,uint64,uint32)": { + "notice": "Send a cross-chain transfer via the liquidity pool-based bridge using the native token." + }, + "updateSigners(uint256,address[],uint256[],bytes[],address[],uint256[])": { + "notice": "Update new signers." + }, + "verifySigs(bytes,bytes[],address[],uint256[])": { + "notice": "Verifies that a message is signed by a quorum among the signers The sigs must be sorted by signer addresses in ascending order." + }, + "withdraw(bytes,bytes[],address[],uint256[])": { + "notice": "Withdraw funds from the bridge pool." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 33210, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 15465, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "ssHash", + "offset": 0, + "slot": "1", + "type": "t_bytes32" + }, + { + "astId": 15467, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "triggerTime", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 15469, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "resetTime", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 15471, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "noticePeriod", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 739, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "_status", + "offset": 0, + "slot": "5", + "type": "t_uint256" + }, + { + "astId": 654, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "_paused", + "offset": 0, + "slot": "6", + "type": "t_bool" + }, + { + "astId": 33324, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "pausers", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 33083, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "governors", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 33471, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "epochLength", + "offset": 0, + "slot": "9", + "type": "t_uint256" + }, + { + "astId": 33475, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "epochVolumes", + "offset": 0, + "slot": "10", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 33479, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "epochVolumeCaps", + "offset": 0, + "slot": "11", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 33483, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "lastOpTimestamps", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 32884, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "delayedTransfers", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_bytes32,t_struct(delayedTransfer)32879_storage)" + }, + { + "astId": 32888, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "delayThresholds", + "offset": 0, + "slot": "14", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 32890, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "delayPeriod", + "offset": 0, + "slot": "15", + "type": "t_uint256" + }, + { + "astId": 15009, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "addseq", + "offset": 0, + "slot": "16", + "type": "t_uint64" + }, + { + "astId": 15013, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "minAdd", + "offset": 0, + "slot": "17", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 15017, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "withdraws", + "offset": 0, + "slot": "18", + "type": "t_mapping(t_bytes32,t_bool)" + }, + { + "astId": 15019, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "nativeWrap", + "offset": 0, + "slot": "19", + "type": "t_address" + }, + { + "astId": 15022, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "nativeTokenTransferGas", + "offset": 0, + "slot": "20", + "type": "t_uint256" + }, + { + "astId": 14242, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "transfers", + "offset": 0, + "slot": "21", + "type": "t_mapping(t_bytes32,t_bool)" + }, + { + "astId": 14246, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "minSend", + "offset": 0, + "slot": "22", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 14250, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "maxSend", + "offset": 0, + "slot": "23", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 14252, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "minimalMaxSlippage", + "offset": 0, + "slot": "24", + "type": "t_uint32" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes32,t_bool)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_bytes32,t_struct(delayedTransfer)32879_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct DelayedTransfer.delayedTransfer)", + "numberOfBytes": "32", + "value": "t_struct(delayedTransfer)32879_storage" + }, + "t_struct(delayedTransfer)32879_storage": { + "encoding": "inplace", + "label": "struct DelayedTransfer.delayedTransfer", + "members": [ + { + "astId": 32872, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "receiver", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 32874, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "token", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 32876, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "amount", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 32878, + "contract": "contracts/liquidity-bridge/Bridge.sol:Bridge", + "label": "timestamp", + "offset": 0, + "slot": "3", + "type": "t_uint256" + } + ], + "numberOfBytes": "128" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint32": { + "encoding": "inplace", + "label": "uint32", + "numberOfBytes": "4" + }, + "t_uint64": { + "encoding": "inplace", + "label": "uint64", + "numberOfBytes": "8" + } + } + } +} \ No newline at end of file diff --git a/deployments/linea/MultiBridgeToken.json b/deployments/linea/MultiBridgeToken.json new file mode 100644 index 000000000..8a142c0aa --- /dev/null +++ b/deployments/linea/MultiBridgeToken.json @@ -0,0 +1,767 @@ +{ + "address": "0x265B25e22bcd7f10a5bD6E6410F10537Cc7567e8", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name_", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol_", + "type": "string" + }, + { + "internalType": "uint8", + "name": "decimals_", + "type": "uint8" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "bridge", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + } + ], + "name": "BridgeSupplyCapUpdated", + "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": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "bridges", + "outputs": [ + { + "internalType": "uint256", + "name": "cap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "total", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_bridge", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_cap", + "type": "uint256" + } + ], + "name": "updateBridgeSupplyCap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x452d7e50ff414689818073d4a4f92483e25ac30956f564de3ff455f06f670e2b", + "receipt": { + "to": null, + "from": "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1", + "contractAddress": "0x265B25e22bcd7f10a5bD6E6410F10537Cc7567e8", + "transactionIndex": 0, + "gasUsed": "1067818", + "logsBloom": "0x00000000000000000000000000000080000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000802000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000400000000000000000000040000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x1216b63b2be1996a72472c23e1c9f4ca2f27eedd507789f25ac128986f16f869", + "transactionHash": "0x452d7e50ff414689818073d4a4f92483e25ac30956f564de3ff455f06f670e2b", + "logs": [ + { + "transactionIndex": 0, + "blockNumber": 533, + "transactionHash": "0x452d7e50ff414689818073d4a4f92483e25ac30956f564de3ff455f06f670e2b", + "address": "0x265B25e22bcd7f10a5bD6E6410F10537Cc7567e8", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000058b529f9084d7eaa598eb3477fe36064c5b7bbc1" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x1216b63b2be1996a72472c23e1c9f4ca2f27eedd507789f25ac128986f16f869" + } + ], + "blockNumber": 533, + "cumulativeGasUsed": "1067818", + "status": 1, + "byzantium": true + }, + "args": [ + "Matic Token", + "MATIC", + "18" + ], + "numDeployments": 4, + "solcInputHash": "63e7586ecff740f5cf7af58b7e60f225", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"decimals_\",\"type\":\"uint8\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bridge\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"supplyCap\",\"type\":\"uint256\"}],\"name\":\"BridgeSupplyCapUpdated\",\"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\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"bridges\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"burnFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_bridge\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_cap\",\"type\":\"uint256\"}],\"name\":\"updateBridgeSupplyCap\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"See {IERC20-allowance}.\"},\"approve(address,uint256)\":{\"details\":\"See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address.\"},\"balanceOf(address)\":{\"details\":\"See {IERC20-balanceOf}.\"},\"burn(address,uint256)\":{\"params\":{\"_amount\":\"The amount to burn.\",\"_from\":\"The address to burn tokens from.\"}},\"burn(uint256)\":{\"params\":{\"_amount\":\"The amount to burn.\"}},\"burnFrom(address,uint256)\":{\"params\":{\"_amount\":\"The amount to burn.\",\"_from\":\"The address to burn tokens from.\"}},\"decreaseAllowance(address,uint256)\":{\"details\":\"Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`.\"},\"increaseAllowance(address,uint256)\":{\"details\":\"Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.\"},\"mint(address,uint256)\":{\"params\":{\"_amount\":\"The amount to mint.\",\"_to\":\"The address to mint tokens to.\"}},\"name()\":{\"details\":\"Returns the name of the token.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"symbol()\":{\"details\":\"Returns the symbol of the token, usually a shorter version of the name.\"},\"totalSupply()\":{\"details\":\"See {IERC20-totalSupply}.\"},\"transfer(address,uint256)\":{\"details\":\"See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"updateBridgeSupplyCap(address,uint256)\":{\"params\":{\"_bridge\":\"The bridge address.\",\"_cap\":\"The new supply cap.\"}}},\"title\":\"Example Multi-Bridge Pegged ERC20 token\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"burn(address,uint256)\":{\"notice\":\"Burns tokens from an address. Decreases total amount minted if called by a bridge. Alternative to {burnFrom} for compatibility with some bridge implementations. See {_burnFrom}.\"},\"burn(uint256)\":{\"notice\":\"Burns tokens for msg.sender.\"},\"burnFrom(address,uint256)\":{\"notice\":\"Burns tokens from an address. Decreases total amount minted if called by a bridge. See {_burnFrom}.\"},\"decimals()\":{\"notice\":\"Returns the decimals of the token.\"},\"getOwner()\":{\"notice\":\"Returns the owner address. Required by BEP20.\"},\"mint(address,uint256)\":{\"notice\":\"Mints tokens to an address. Increases total amount minted by the calling bridge.\"},\"updateBridgeSupplyCap(address,uint256)\":{\"notice\":\"Updates the supply cap for a bridge.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/pegged-bridge/tokens/MultiBridgeToken.sol\":\"MultiBridgeToken\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":800},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/ERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"./IERC20.sol\\\";\\nimport \\\"./extensions/IERC20Metadata.sol\\\";\\nimport \\\"../../utils/Context.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 * For a generic mechanism see {ERC20PresetMinterPauser}.\\n *\\n * TIP: For a detailed writeup see our guide\\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\\n * to implement supply mechanisms].\\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 *\\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\\n * functions have been added to mitigate the well-known issues around setting\\n * allowances. See {IERC20-approve}.\\n */\\ncontract ERC20 is Context, IERC20, IERC20Metadata {\\n mapping(address => uint256) private _balances;\\n\\n mapping(address => mapping(address => 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 * The default value of {decimals} is 18. To select a different value for\\n * {decimals} you should overload it.\\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 override 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 override 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 value {ERC20} uses, unless this function is\\n * 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 override returns (uint8) {\\n return 18;\\n }\\n\\n /**\\n * @dev See {IERC20-totalSupply}.\\n */\\n function totalSupply() public view virtual override returns (uint256) {\\n return _totalSupply;\\n }\\n\\n /**\\n * @dev See {IERC20-balanceOf}.\\n */\\n function balanceOf(address account) public view virtual override 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 `amount`.\\n */\\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _transfer(owner, to, amount);\\n return true;\\n }\\n\\n /**\\n * @dev See {IERC20-allowance}.\\n */\\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\\n return _allowances[owner][spender];\\n }\\n\\n /**\\n * @dev See {IERC20-approve}.\\n *\\n * NOTE: If `amount` 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 amount) public virtual override returns (bool) {\\n address owner = _msgSender();\\n _approve(owner, spender, amount);\\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 `amount`.\\n * - the caller must have allowance for ``from``'s tokens of at least\\n * `amount`.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) public virtual override returns (bool) {\\n address spender = _msgSender();\\n _spendAllowance(from, spender, amount);\\n _transfer(from, to, amount);\\n return true;\\n }\\n\\n /**\\n * @dev Atomically increases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n */\\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\\n address owner = _msgSender();\\n _approve(owner, spender, _allowances[owner][spender] + addedValue);\\n return true;\\n }\\n\\n /**\\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\\n *\\n * This is an alternative to {approve} that can be used as a mitigation for\\n * problems described in {IERC20-approve}.\\n *\\n * Emits an {Approval} event indicating the updated allowance.\\n *\\n * Requirements:\\n *\\n * - `spender` cannot be the zero address.\\n * - `spender` must have allowance for the caller of at least\\n * `subtractedValue`.\\n */\\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\\n address owner = _msgSender();\\n uint256 currentAllowance = _allowances[owner][spender];\\n require(currentAllowance >= subtractedValue, \\\"ERC20: decreased allowance below zero\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - subtractedValue);\\n }\\n\\n return true;\\n }\\n\\n /**\\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\\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 * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `from` must have a balance of at least `amount`.\\n */\\n function _transfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {\\n require(from != address(0), \\\"ERC20: transfer from the zero address\\\");\\n require(to != address(0), \\\"ERC20: transfer to the zero address\\\");\\n\\n _beforeTokenTransfer(from, to, amount);\\n\\n uint256 fromBalance = _balances[from];\\n require(fromBalance >= amount, \\\"ERC20: transfer amount exceeds balance\\\");\\n unchecked {\\n _balances[from] = fromBalance - amount;\\n }\\n _balances[to] += amount;\\n\\n emit Transfer(from, to, amount);\\n\\n _afterTokenTransfer(from, to, amount);\\n }\\n\\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\\n * the total supply.\\n *\\n * Emits a {Transfer} event with `from` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n */\\n function _mint(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: mint to the zero address\\\");\\n\\n _beforeTokenTransfer(address(0), account, amount);\\n\\n _totalSupply += amount;\\n _balances[account] += amount;\\n emit Transfer(address(0), account, amount);\\n\\n _afterTokenTransfer(address(0), account, amount);\\n }\\n\\n /**\\n * @dev Destroys `amount` tokens from `account`, reducing the\\n * total supply.\\n *\\n * Emits a {Transfer} event with `to` set to the zero address.\\n *\\n * Requirements:\\n *\\n * - `account` cannot be the zero address.\\n * - `account` must have at least `amount` tokens.\\n */\\n function _burn(address account, uint256 amount) internal virtual {\\n require(account != address(0), \\\"ERC20: burn from the zero address\\\");\\n\\n _beforeTokenTransfer(account, address(0), amount);\\n\\n uint256 accountBalance = _balances[account];\\n require(accountBalance >= amount, \\\"ERC20: burn amount exceeds balance\\\");\\n unchecked {\\n _balances[account] = accountBalance - amount;\\n }\\n _totalSupply -= amount;\\n\\n emit Transfer(account, address(0), amount);\\n\\n _afterTokenTransfer(account, address(0), amount);\\n }\\n\\n /**\\n * @dev Sets `amount` 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 function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n require(owner != address(0), \\\"ERC20: approve from the zero address\\\");\\n require(spender != address(0), \\\"ERC20: approve to the zero address\\\");\\n\\n _allowances[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n /**\\n * @dev Spend `amount` form the allowance of `owner` toward `spender`.\\n *\\n * Does not update the allowance amount in case of infinite allowance.\\n * Revert if not enough allowance is available.\\n *\\n * Might emit an {Approval} event.\\n */\\n function _spendAllowance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) internal virtual {\\n uint256 currentAllowance = allowance(owner, spender);\\n if (currentAllowance != type(uint256).max) {\\n require(currentAllowance >= amount, \\\"ERC20: insufficient allowance\\\");\\n unchecked {\\n _approve(owner, spender, currentAllowance - amount);\\n }\\n }\\n }\\n\\n /**\\n * @dev Hook that is called before any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * will be transferred to `to`.\\n * - when `from` is zero, `amount` tokens will be minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n /**\\n * @dev Hook that is called after any transfer of tokens. This includes\\n * minting and burning.\\n *\\n * Calling conditions:\\n *\\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\\n * has been transferred to `to`.\\n * - when `from` is zero, `amount` tokens have been minted for `to`.\\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\\n * - `from` and `to` are never both zero.\\n *\\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\\n */\\n function _afterTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n}\\n\",\"keccak256\":\"0xdadd41acb749920eccf40aeaa8d291adf9751399a7343561bad13e7a8d99be0b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` 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(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n\\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\",\"keccak256\":\"0xbbc8ac883ac3c0078ce5ad3e288fbb3ffcc8a30c3a98c0fda0114d64fc44fca2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\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\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/pegged-bridge/tokens/MultiBridgeToken.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/ERC20.sol\\\";\\nimport \\\"../../safeguard/Ownable.sol\\\";\\n\\n/**\\n * @title Example Multi-Bridge Pegged ERC20 token\\n */\\ncontract MultiBridgeToken is ERC20, Ownable {\\n struct Supply {\\n uint256 cap;\\n uint256 total;\\n }\\n mapping(address => Supply) public bridges; // bridge address -> supply\\n\\n uint8 private immutable _decimals;\\n\\n event BridgeSupplyCapUpdated(address bridge, uint256 supplyCap);\\n\\n constructor(\\n string memory name_,\\n string memory symbol_,\\n uint8 decimals_\\n ) ERC20(name_, symbol_) {\\n _decimals = decimals_;\\n }\\n\\n /**\\n * @notice Mints tokens to an address. Increases total amount minted by the calling bridge.\\n * @param _to The address to mint tokens to.\\n * @param _amount The amount to mint.\\n */\\n function mint(address _to, uint256 _amount) external returns (bool) {\\n Supply storage b = bridges[msg.sender];\\n require(b.cap > 0, \\\"invalid caller\\\");\\n b.total += _amount;\\n require(b.total <= b.cap, \\\"exceeds bridge supply cap\\\");\\n _mint(_to, _amount);\\n return true;\\n }\\n\\n /**\\n * @notice Burns tokens for msg.sender.\\n * @param _amount The amount to burn.\\n */\\n function burn(uint256 _amount) external returns (bool) {\\n _burn(msg.sender, _amount);\\n return true;\\n }\\n\\n /**\\n * @notice Burns tokens from an address. Decreases total amount minted if called by a bridge.\\n * Alternative to {burnFrom} for compatibility with some bridge implementations.\\n * See {_burnFrom}.\\n * @param _from The address to burn tokens from.\\n * @param _amount The amount to burn.\\n */\\n function burn(address _from, uint256 _amount) external returns (bool) {\\n return _burnFrom(_from, _amount);\\n }\\n\\n /**\\n * @notice Burns tokens from an address. Decreases total amount minted if called by a bridge.\\n * See {_burnFrom}.\\n * @param _from The address to burn tokens from.\\n * @param _amount The amount to burn.\\n */\\n function burnFrom(address _from, uint256 _amount) external returns (bool) {\\n return _burnFrom(_from, _amount);\\n }\\n\\n /**\\n * @dev Burns tokens from an address, deducting from the caller's allowance.\\n * Decreases total amount minted if called by a bridge.\\n * @param _from The address to burn tokens from.\\n * @param _amount The amount to burn.\\n */\\n function _burnFrom(address _from, uint256 _amount) internal returns (bool) {\\n Supply storage b = bridges[msg.sender];\\n if (b.cap > 0 || b.total > 0) {\\n // set cap to 1 would effectively disable a deprecated bridge's ability to burn\\n require(b.total >= _amount, \\\"exceeds bridge minted amount\\\");\\n unchecked {\\n b.total -= _amount;\\n }\\n }\\n _spendAllowance(_from, msg.sender, _amount);\\n _burn(_from, _amount);\\n return true;\\n }\\n\\n /**\\n * @notice Returns the decimals of the token.\\n */\\n function decimals() public view virtual override returns (uint8) {\\n return _decimals;\\n }\\n\\n /**\\n * @notice Updates the supply cap for a bridge.\\n * @param _bridge The bridge address.\\n * @param _cap The new supply cap.\\n */\\n function updateBridgeSupplyCap(address _bridge, uint256 _cap) external onlyOwner {\\n // cap == 0 means revoking bridge role\\n bridges[_bridge].cap = _cap;\\n emit BridgeSupplyCapUpdated(_bridge, _cap);\\n }\\n\\n /**\\n * @notice Returns the owner address. Required by BEP20.\\n */\\n function getOwner() external view returns (address) {\\n return owner();\\n }\\n}\\n\",\"keccak256\":\"0x01c04425aad1d6ecca616cdbc4b7018e1325438e9a3b5a0b4ab87f5378864f58\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity ^0.8.0;\\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 * By default, the owner account will be the one that deploys the contract. This\\n * can 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 *\\n * This adds a normal func that setOwner if _owner is address(0). So we can't allow\\n * renounceOwnership. So we can support Proxy based upgradable contract\\n */\\nabstract contract Ownable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _setOwner(msg.sender);\\n }\\n\\n /**\\n * @dev Only to be called by inherit contracts, in their init func called by Proxy\\n * we require _owner == address(0), which is only possible when it's a delegateCall\\n * because constructor sets _owner in contract state.\\n */\\n function initOwner() internal {\\n require(_owner == address(0), \\\"owner already set\\\");\\n _setOwner(msg.sender);\\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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == msg.sender, \\\"Ownable: caller is not the owner\\\");\\n _;\\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 require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _setOwner(newOwner);\\n }\\n\\n function _setOwner(address newOwner) private {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x2a92103195b8dce0f34fdf9bf7f94ddf38bf8edf0c0fd4be21323c47016687e9\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b50604051620014663803806200146683398101604081905262000034916200018d565b82826003620000448382620002a1565b506004620000538282620002a1565b50505062000067336200007660201b60201c565b60ff16608052506200036d9050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620000f057600080fd5b81516001600160401b03808211156200010d576200010d620000c8565b604051601f8301601f19908116603f01168101908282118183101715620001385762000138620000c8565b816040528381526020925086838588010111156200015557600080fd5b600091505b838210156200017957858201830151818301840152908201906200015a565b600093810190920192909252949350505050565b600080600060608486031215620001a357600080fd5b83516001600160401b0380821115620001bb57600080fd5b620001c987838801620000de565b94506020860151915080821115620001e057600080fd5b50620001ef86828701620000de565b925050604084015160ff811681146200020757600080fd5b809150509250925092565b600181811c908216806200022757607f821691505b6020821081036200024857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200029c57600081815260208120601f850160051c81016020861015620002775750805b601f850160051c820191505b81811015620002985782815560010162000283565b5050505b505050565b81516001600160401b03811115620002bd57620002bd620000c8565b620002d581620002ce845462000212565b846200024e565b602080601f8311600181146200030d5760008415620002f45750858301515b600019600386901b1c1916600185901b17855562000298565b600085815260208120601f198616915b828110156200033e578886015182559484019460019091019084016200031d565b50858210156200035d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6080516110dd6200038960003960006101de01526110dd6000f3fe608060405234801561001057600080fd5b506004361061016c5760003560e01c806379cc6790116100cd578063a457c2d711610081578063ced67f0c11610066578063ced67f0c146102f1578063dd62ed3e1461032d578063f2fde38b1461036657600080fd5b8063a457c2d7146102cb578063a9059cbb146102de57600080fd5b80638da5cb5b116100b25780638da5cb5b146102b257806395d89b41146102c35780639dc29fac1461027f57600080fd5b806379cc67901461027f578063893d20e81461029257600080fd5b8063395093511161012457806342966c681161010957806342966c681461022e5780634ce2f71a1461024157806370a082311461025657600080fd5b8063395093511461020857806340c10f191461021b57600080fd5b806318160ddd1161015557806318160ddd146101b257806323b872dd146101c4578063313ce567146101d757600080fd5b806306fdde0314610171578063095ea7b31461018f575b600080fd5b610179610379565b6040516101869190610efa565b60405180910390f35b6101a261019d366004610f64565b61040b565b6040519015158152602001610186565b6002545b604051908152602001610186565b6101a26101d2366004610f8e565b610425565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610186565b6101a2610216366004610f64565b610449565b6101a2610229366004610f64565b610488565b6101a261023c366004610fca565b610562565b61025461024f366004610f64565b610576565b005b6101b6610264366004610fe3565b6001600160a01b031660009081526020819052604090205490565b6101a261028d366004610f64565b610637565b61029a61064a565b6040516001600160a01b039091168152602001610186565b6005546001600160a01b031661029a565b610179610663565b6101a26102d9366004610f64565b610672565b6101a26102ec366004610f64565b61071c565b6103186102ff366004610fe3565b6006602052600090815260409020805460019091015482565b60408051928352602083019190915201610186565b6101b661033b366004610ffe565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610254610374366004610fe3565b61072a565b60606003805461038890611031565b80601f01602080910402602001604051908101604052809291908181526020018280546103b490611031565b80156104015780601f106103d657610100808354040283529160200191610401565b820191906000526020600020905b8154815290600101906020018083116103e457829003601f168201915b5050505050905090565b60003361041981858561081b565b60019150505b92915050565b600033610433858285610940565b61043e8585856109d2565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906104199082908690610483908790611081565b61081b565b33600090815260066020526040812080546104ea5760405162461bcd60e51b815260206004820152600e60248201527f696e76616c69642063616c6c657200000000000000000000000000000000000060448201526064015b60405180910390fd5b828160010160008282546104fe9190611081565b90915550508054600182015411156105585760405162461bcd60e51b815260206004820152601960248201527f657863656564732062726964676520737570706c79206361700000000000000060448201526064016104e1565b6104198484610bcf565b600061056e3383610cae565b506001919050565b336105896005546001600160a01b031690565b6001600160a01b0316146105df5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e1565b6001600160a01b038216600081815260066020908152604091829020849055815192835282018390527f59e1e4348943de408b89af8ab71e502ea722dd41efd1ff4a3548c60e83e91c60910160405180910390a15050565b60006106438383610df4565b9392505050565b600061065e6005546001600160a01b031690565b905090565b60606004805461038890611031565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091908381101561070f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016104e1565b61043e828686840361081b565b6000336104198185856109d2565b3361073d6005546001600160a01b031690565b6001600160a01b0316146107935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e1565b6001600160a01b03811661080f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104e1565b61081881610e90565b50565b6001600160a01b03831661087d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016104e1565b6001600160a01b0382166108de5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016104e1565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383811660009081526001602090815260408083209386168352929052205460001981146109cc57818110156109bf5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016104e1565b6109cc848484840361081b565b50505050565b6001600160a01b038316610a4e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016104e1565b6001600160a01b038216610ab05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016104e1565b6001600160a01b03831660009081526020819052604090205481811015610b3f5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016104e1565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290610b76908490611081565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610bc291815260200190565b60405180910390a36109cc565b6001600160a01b038216610c255760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016104e1565b8060026000828254610c379190611081565b90915550506001600160a01b03821660009081526020819052604081208054839290610c64908490611081565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038216610d0e5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016104e1565b6001600160a01b03821660009081526020819052604090205481811015610d825760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016104e1565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610db1908490611094565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610933565b3360009081526006602052604081208054151580610e16575060008160010154115b15610e7b578281600101541015610e6f5760405162461bcd60e51b815260206004820152601c60248201527f6578636565647320627269646765206d696e74656420616d6f756e740000000060448201526064016104e1565b60018101805484900390555b610e86843385610940565b6104198484610cae565b600580546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600060208083528351808285015260005b81811015610f2757858101830151858201604001528201610f0b565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610f5f57600080fd5b919050565b60008060408385031215610f7757600080fd5b610f8083610f48565b946020939093013593505050565b600080600060608486031215610fa357600080fd5b610fac84610f48565b9250610fba60208501610f48565b9150604084013590509250925092565b600060208284031215610fdc57600080fd5b5035919050565b600060208284031215610ff557600080fd5b61064382610f48565b6000806040838503121561101157600080fd5b61101a83610f48565b915061102860208401610f48565b90509250929050565b600181811c9082168061104557607f821691505b60208210810361106557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561041f5761041f61106b565b8181038181111561041f5761041f61106b56fea2646970667358221220f0061d6652c3cdec3d7ea07b04ec46693ddd7cf01d385cc2b9bcb27f6f7c5f5164736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061016c5760003560e01c806379cc6790116100cd578063a457c2d711610081578063ced67f0c11610066578063ced67f0c146102f1578063dd62ed3e1461032d578063f2fde38b1461036657600080fd5b8063a457c2d7146102cb578063a9059cbb146102de57600080fd5b80638da5cb5b116100b25780638da5cb5b146102b257806395d89b41146102c35780639dc29fac1461027f57600080fd5b806379cc67901461027f578063893d20e81461029257600080fd5b8063395093511161012457806342966c681161010957806342966c681461022e5780634ce2f71a1461024157806370a082311461025657600080fd5b8063395093511461020857806340c10f191461021b57600080fd5b806318160ddd1161015557806318160ddd146101b257806323b872dd146101c4578063313ce567146101d757600080fd5b806306fdde0314610171578063095ea7b31461018f575b600080fd5b610179610379565b6040516101869190610efa565b60405180910390f35b6101a261019d366004610f64565b61040b565b6040519015158152602001610186565b6002545b604051908152602001610186565b6101a26101d2366004610f8e565b610425565b60405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152602001610186565b6101a2610216366004610f64565b610449565b6101a2610229366004610f64565b610488565b6101a261023c366004610fca565b610562565b61025461024f366004610f64565b610576565b005b6101b6610264366004610fe3565b6001600160a01b031660009081526020819052604090205490565b6101a261028d366004610f64565b610637565b61029a61064a565b6040516001600160a01b039091168152602001610186565b6005546001600160a01b031661029a565b610179610663565b6101a26102d9366004610f64565b610672565b6101a26102ec366004610f64565b61071c565b6103186102ff366004610fe3565b6006602052600090815260409020805460019091015482565b60408051928352602083019190915201610186565b6101b661033b366004610ffe565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b610254610374366004610fe3565b61072a565b60606003805461038890611031565b80601f01602080910402602001604051908101604052809291908181526020018280546103b490611031565b80156104015780601f106103d657610100808354040283529160200191610401565b820191906000526020600020905b8154815290600101906020018083116103e457829003601f168201915b5050505050905090565b60003361041981858561081b565b60019150505b92915050565b600033610433858285610940565b61043e8585856109d2565b506001949350505050565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091906104199082908690610483908790611081565b61081b565b33600090815260066020526040812080546104ea5760405162461bcd60e51b815260206004820152600e60248201527f696e76616c69642063616c6c657200000000000000000000000000000000000060448201526064015b60405180910390fd5b828160010160008282546104fe9190611081565b90915550508054600182015411156105585760405162461bcd60e51b815260206004820152601960248201527f657863656564732062726964676520737570706c79206361700000000000000060448201526064016104e1565b6104198484610bcf565b600061056e3383610cae565b506001919050565b336105896005546001600160a01b031690565b6001600160a01b0316146105df5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e1565b6001600160a01b038216600081815260066020908152604091829020849055815192835282018390527f59e1e4348943de408b89af8ab71e502ea722dd41efd1ff4a3548c60e83e91c60910160405180910390a15050565b60006106438383610df4565b9392505050565b600061065e6005546001600160a01b031690565b905090565b60606004805461038890611031565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091908381101561070f5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016104e1565b61043e828686840361081b565b6000336104198185856109d2565b3361073d6005546001600160a01b031690565b6001600160a01b0316146107935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104e1565b6001600160a01b03811661080f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104e1565b61081881610e90565b50565b6001600160a01b03831661087d5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016104e1565b6001600160a01b0382166108de5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016104e1565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383811660009081526001602090815260408083209386168352929052205460001981146109cc57818110156109bf5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016104e1565b6109cc848484840361081b565b50505050565b6001600160a01b038316610a4e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016104e1565b6001600160a01b038216610ab05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016104e1565b6001600160a01b03831660009081526020819052604090205481811015610b3f5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016104e1565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290610b76908490611081565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610bc291815260200190565b60405180910390a36109cc565b6001600160a01b038216610c255760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016104e1565b8060026000828254610c379190611081565b90915550506001600160a01b03821660009081526020819052604081208054839290610c64908490611081565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6001600160a01b038216610d0e5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016104e1565b6001600160a01b03821660009081526020819052604090205481811015610d825760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016104e1565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610db1908490611094565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610933565b3360009081526006602052604081208054151580610e16575060008160010154115b15610e7b578281600101541015610e6f5760405162461bcd60e51b815260206004820152601c60248201527f6578636565647320627269646765206d696e74656420616d6f756e740000000060448201526064016104e1565b60018101805484900390555b610e86843385610940565b6104198484610cae565b600580546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600060208083528351808285015260005b81811015610f2757858101830151858201604001528201610f0b565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610f5f57600080fd5b919050565b60008060408385031215610f7757600080fd5b610f8083610f48565b946020939093013593505050565b600080600060608486031215610fa357600080fd5b610fac84610f48565b9250610fba60208501610f48565b9150604084013590509250925092565b600060208284031215610fdc57600080fd5b5035919050565b600060208284031215610ff557600080fd5b61064382610f48565b6000806040838503121561101157600080fd5b61101a83610f48565b915061102860208401610f48565b90509250929050565b600181811c9082168061104557607f821691505b60208210810361106557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561041f5761041f61106b565b8181038181111561041f5761041f61106b56fea2646970667358221220f0061d6652c3cdec3d7ea07b04ec46693ddd7cf01d385cc2b9bcb27f6f7c5f5164736f6c63430008110033", + "devdoc": { + "kind": "dev", + "methods": { + "allowance(address,address)": { + "details": "See {IERC20-allowance}." + }, + "approve(address,uint256)": { + "details": "See {IERC20-approve}. NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on `transferFrom`. This is semantically equivalent to an infinite approval. Requirements: - `spender` cannot be the zero address." + }, + "balanceOf(address)": { + "details": "See {IERC20-balanceOf}." + }, + "burn(address,uint256)": { + "params": { + "_amount": "The amount to burn.", + "_from": "The address to burn tokens from." + } + }, + "burn(uint256)": { + "params": { + "_amount": "The amount to burn." + } + }, + "burnFrom(address,uint256)": { + "params": { + "_amount": "The amount to burn.", + "_from": "The address to burn tokens from." + } + }, + "decreaseAllowance(address,uint256)": { + "details": "Atomically decreases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. - `spender` must have allowance for the caller of at least `subtractedValue`." + }, + "increaseAllowance(address,uint256)": { + "details": "Atomically increases the allowance granted to `spender` by the caller. This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address." + }, + "mint(address,uint256)": { + "params": { + "_amount": "The amount to mint.", + "_to": "The address to mint tokens to." + } + }, + "name()": { + "details": "Returns the name of the token." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "symbol()": { + "details": "Returns the symbol of the token, usually a shorter version of the name." + }, + "totalSupply()": { + "details": "See {IERC20-totalSupply}." + }, + "transfer(address,uint256)": { + "details": "See {IERC20-transfer}. Requirements: - `to` cannot be the zero address. - the caller must have a balance of at least `amount`." + }, + "transferFrom(address,address,uint256)": { + "details": "See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20}. NOTE: Does not update the allowance if the current allowance is the maximum `uint256`. Requirements: - `from` and `to` cannot be the zero address. - `from` must have a balance of at least `amount`. - the caller must have allowance for ``from``'s tokens of at least `amount`." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "updateBridgeSupplyCap(address,uint256)": { + "params": { + "_bridge": "The bridge address.", + "_cap": "The new supply cap." + } + } + }, + "title": "Example Multi-Bridge Pegged ERC20 token", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "burn(address,uint256)": { + "notice": "Burns tokens from an address. Decreases total amount minted if called by a bridge. Alternative to {burnFrom} for compatibility with some bridge implementations. See {_burnFrom}." + }, + "burn(uint256)": { + "notice": "Burns tokens for msg.sender." + }, + "burnFrom(address,uint256)": { + "notice": "Burns tokens from an address. Decreases total amount minted if called by a bridge. See {_burnFrom}." + }, + "decimals()": { + "notice": "Returns the decimals of the token." + }, + "getOwner()": { + "notice": "Returns the owner address. Required by BEP20." + }, + "mint(address,uint256)": { + "notice": "Mints tokens to an address. Increases total amount minted by the calling bridge." + }, + "updateBridgeSupplyCap(address,uint256)": { + "notice": "Updates the supply cap for a bridge." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 784, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "_balances", + "offset": 0, + "slot": "0", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 790, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "_allowances", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 792, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "_totalSupply", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 794, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "_name", + "offset": 0, + "slot": "3", + "type": "t_string_storage" + }, + { + "astId": 796, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "_symbol", + "offset": 0, + "slot": "4", + "type": "t_string_storage" + }, + { + "astId": 33210, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "_owner", + "offset": 0, + "slot": "5", + "type": "t_address" + }, + { + "astId": 29730, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "bridges", + "offset": 0, + "slot": "6", + "type": "t_mapping(t_address,t_struct(Supply)29725_storage)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_struct(Supply)29725_storage)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => struct MultiBridgeToken.Supply)", + "numberOfBytes": "32", + "value": "t_struct(Supply)29725_storage" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(Supply)29725_storage": { + "encoding": "inplace", + "label": "struct MultiBridgeToken.Supply", + "members": [ + { + "astId": 29722, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "cap", + "offset": 0, + "slot": "0", + "type": "t_uint256" + }, + { + "astId": 29724, + "contract": "contracts/pegged-bridge/tokens/MultiBridgeToken.sol:MultiBridgeToken", + "label": "total", + "offset": 0, + "slot": "1", + "type": "t_uint256" + } + ], + "numberOfBytes": "64" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/deployments/linea/PeggedTokenBridgeV2.json b/deployments/linea/PeggedTokenBridgeV2.json new file mode 100644 index 000000000..f460f4d37 --- /dev/null +++ b/deployments/linea/PeggedTokenBridgeV2.json @@ -0,0 +1,1395 @@ +{ + "address": "0x9Bb46D5100d2Db4608112026951c9C965b233f4D", + "abi": [ + { + "inputs": [ + { + "internalType": "contract ISigsVerifier", + "name": "_sigsVerifier", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "burnId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "toChainId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "address", + "name": "toAccount", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "nonce", + "type": "uint64" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "period", + "type": "uint256" + } + ], + "name": "DelayPeriodUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "threshold", + "type": "uint256" + } + ], + "name": "DelayThresholdUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "name": "DelayedTransferAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "DelayedTransferExecuted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "EpochLengthUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cap", + "type": "uint256" + } + ], + "name": "EpochVolumeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "GovernorAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "GovernorRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "MaxBurnUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "MinBurnUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "mintId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "refChainId", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "refId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "depositor", + "type": "address" + } + ], + "name": "Mint", + "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": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "PauserAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "PauserRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "supply", + "type": "uint256" + } + ], + "name": "SupplyUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "addGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "addPauser", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "_toChainId", + "type": "uint64" + }, + { + "internalType": "address", + "name": "_toAccount", + "type": "address" + }, + { + "internalType": "uint64", + "name": "_nonce", + "type": "uint64" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "_toChainId", + "type": "uint64" + }, + { + "internalType": "address", + "name": "_toAccount", + "type": "address" + }, + { + "internalType": "uint64", + "name": "_nonce", + "type": "uint64" + } + ], + "name": "burnFrom", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_delta", + "type": "uint256" + } + ], + "name": "decreaseSupply", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "delayPeriod", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "delayThresholds", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "delayedTransfers", + "outputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "epochLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "epochVolumeCaps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "epochVolumes", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "id", + "type": "bytes32" + } + ], + "name": "executeDelayedTransfer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "governors", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_delta", + "type": "uint256" + } + ], + "name": "increaseSupply", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "isGovernor", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "isPauser", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "lastOpTimestamps", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "maxBurn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "minBurn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "_request", + "type": "bytes" + }, + { + "internalType": "bytes[]", + "name": "_sigs", + "type": "bytes[]" + }, + { + "internalType": "address[]", + "name": "_signers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_powers", + "type": "uint256[]" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pausers", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "records", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_account", + "type": "address" + } + ], + "name": "removeGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "removePauser", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceGovernor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renouncePauser", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_period", + "type": "uint256" + } + ], + "name": "setDelayPeriod", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_thresholds", + "type": "uint256[]" + } + ], + "name": "setDelayThresholds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_length", + "type": "uint256" + } + ], + "name": "setEpochLength", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_caps", + "type": "uint256[]" + } + ], + "name": "setEpochVolumeCaps", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_amounts", + "type": "uint256[]" + } + ], + "name": "setMaxBurn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_amounts", + "type": "uint256[]" + } + ], + "name": "setMinBurn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_supply", + "type": "uint256" + } + ], + "name": "setSupply", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "sigsVerifier", + "outputs": [ + { + "internalType": "contract ISigsVerifier", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "supplies", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x4e5c348c6a415870ff90a0004ac2297956f8c8241e1b26fc7a1a1c687176d25d", + "receipt": { + "to": null, + "from": "0x58b529F9084D7eAA598EB3477Fe36064C5B7bbC1", + "contractAddress": "0x9Bb46D5100d2Db4608112026951c9C965b233f4D", + "transactionIndex": 1, + "gasUsed": "2746510", + "logsBloom": "0x00000000002000000000000000000000000000000000000000800000000000000000010002000000000000000000000000000000000000000000000000000000000000000080000001000000000000000001000000000000000000000000000000802000020000000000000000000800000000000000000000000000000000400000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000010020000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000020000000000000000040000000000000000000000000000000000000000000000000", + "blockHash": "0x8e45c73c939097146b4e91996382db9b2c1409c92dc9c7713b4e7d6aa1f7e479", + "transactionHash": "0x4e5c348c6a415870ff90a0004ac2297956f8c8241e1b26fc7a1a1c687176d25d", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 455, + "transactionHash": "0x4e5c348c6a415870ff90a0004ac2297956f8c8241e1b26fc7a1a1c687176d25d", + "address": "0x9Bb46D5100d2Db4608112026951c9C965b233f4D", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000058b529f9084d7eaa598eb3477fe36064c5b7bbc1" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x8e45c73c939097146b4e91996382db9b2c1409c92dc9c7713b4e7d6aa1f7e479" + }, + { + "transactionIndex": 1, + "blockNumber": 455, + "transactionHash": "0x4e5c348c6a415870ff90a0004ac2297956f8c8241e1b26fc7a1a1c687176d25d", + "address": "0x9Bb46D5100d2Db4608112026951c9C965b233f4D", + "topics": [ + "0x6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f8" + ], + "data": "0x00000000000000000000000058b529f9084d7eaa598eb3477fe36064c5b7bbc1", + "logIndex": 1, + "blockHash": "0x8e45c73c939097146b4e91996382db9b2c1409c92dc9c7713b4e7d6aa1f7e479" + }, + { + "transactionIndex": 1, + "blockNumber": 455, + "transactionHash": "0x4e5c348c6a415870ff90a0004ac2297956f8c8241e1b26fc7a1a1c687176d25d", + "address": "0x9Bb46D5100d2Db4608112026951c9C965b233f4D", + "topics": [ + "0xdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b5" + ], + "data": "0x00000000000000000000000058b529f9084d7eaa598eb3477fe36064c5b7bbc1", + "logIndex": 2, + "blockHash": "0x8e45c73c939097146b4e91996382db9b2c1409c92dc9c7713b4e7d6aa1f7e479" + } + ], + "blockNumber": 455, + "cumulativeGasUsed": "6934659", + "status": 1, + "byzantium": true + }, + "args": [ + "0x9B36f165baB9ebe611d491180418d8De4b8f3a1f" + ], + "numDeployments": 1, + "solcInputHash": "63e7586ecff740f5cf7af58b7e60f225", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract ISigsVerifier\",\"name\":\"_sigsVerifier\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"burnId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"toChainId\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"toAccount\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"nonce\",\"type\":\"uint64\"}],\"name\":\"Burn\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"period\",\"type\":\"uint256\"}],\"name\":\"DelayPeriodUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"threshold\",\"type\":\"uint256\"}],\"name\":\"DelayThresholdUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"DelayedTransferAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"DelayedTransferExecuted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"EpochLengthUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"cap\",\"type\":\"uint256\"}],\"name\":\"EpochVolumeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"GovernorAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"GovernorRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MaxBurnUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"MinBurnUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"mintId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"refChainId\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"refId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"}],\"name\":\"Mint\",\"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\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Paused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"PauserAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"PauserRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"supply\",\"type\":\"uint256\"}],\"name\":\"SupplyUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"Unpaused\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"addGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"addPauser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"_toChainId\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"_toAccount\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"}],\"name\":\"burn\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"_toChainId\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"_toAccount\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"_nonce\",\"type\":\"uint64\"}],\"name\":\"burnFrom\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_delta\",\"type\":\"uint256\"}],\"name\":\"decreaseSupply\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"delayPeriod\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"delayThresholds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"delayedTransfers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"epochLength\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"epochVolumeCaps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"epochVolumes\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"executeDelayedTransfer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"governors\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_delta\",\"type\":\"uint256\"}],\"name\":\"increaseSupply\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"isGovernor\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"isPauser\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastOpTimestamps\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"maxBurn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"minBurn\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_request\",\"type\":\"bytes\"},{\"internalType\":\"bytes[]\",\"name\":\"_sigs\",\"type\":\"bytes[]\"},{\"internalType\":\"address[]\",\"name\":\"_signers\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_powers\",\"type\":\"uint256[]\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"paused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pausers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"records\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_account\",\"type\":\"address\"}],\"name\":\"removeGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"removePauser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceGovernor\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renouncePauser\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_period\",\"type\":\"uint256\"}],\"name\":\"setDelayPeriod\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_thresholds\",\"type\":\"uint256[]\"}],\"name\":\"setDelayThresholds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_length\",\"type\":\"uint256\"}],\"name\":\"setEpochLength\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_caps\",\"type\":\"uint256[]\"}],\"name\":\"setEpochVolumeCaps\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"setMaxBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"_amounts\",\"type\":\"uint256[]\"}],\"name\":\"setMinBurn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_supply\",\"type\":\"uint256\"}],\"name\":\"setSupply\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sigsVerifier\",\"outputs\":[{\"internalType\":\"contract ISigsVerifier\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"supplies\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpause\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Work together with OriginalTokenVault deployed at remote chains.\",\"kind\":\"dev\",\"methods\":{\"burn(address,uint256,uint64,address,uint64)\":{\"params\":{\"_amount\":\"The amount to burn.\",\"_nonce\":\"A number to guarantee unique depositId. Can be timestamp in practice.\",\"_toAccount\":\"The account to receive tokens on the remote chain\",\"_toChainId\":\"If zero, withdraw from original vault; otherwise, the remote chain to mint tokens.\",\"_token\":\"The pegged token address.\"}},\"mint(bytes,bytes[],address[],uint256[])\":{\"params\":{\"_powers\":\"The signing powers of the signers.\",\"_request\":\"The serialized Mint protobuf.\",\"_signers\":\"The sorted list of signers.\",\"_sigs\":\"The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by +2/3 of the sigsVerifier's current signing power to be delivered.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"paused()\":{\"details\":\"Returns true if the contract is paused, and false otherwise.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"The bridge contract to mint and burn pegged tokens\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"burn(address,uint256,uint64,address,uint64)\":{\"notice\":\"Burn pegged tokens to trigger a cross-chain withdrawal of the original tokens at a remote chain's OriginalTokenVault, or mint at another remote chain NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\"},\"mint(bytes,bytes[],address[],uint256[])\":{\"notice\":\"Mint tokens triggered by deposit at a remote chain's OriginalTokenVault.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/pegged-bridge/PeggedTokenBridgeV2.sol\":\"PeggedTokenBridgeV2\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":800},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/security/Pausable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which allows children to implement an emergency stop\\n * mechanism that can be triggered by an authorized account.\\n *\\n * This module is used through inheritance. It will make available the\\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\\n * the functions of your contract. Note that they will not be pausable by\\n * simply including this module, only once the modifiers are put in place.\\n */\\nabstract contract Pausable is Context {\\n /**\\n * @dev Emitted when the pause is triggered by `account`.\\n */\\n event Paused(address account);\\n\\n /**\\n * @dev Emitted when the pause is lifted by `account`.\\n */\\n event Unpaused(address account);\\n\\n bool private _paused;\\n\\n /**\\n * @dev Initializes the contract in unpaused state.\\n */\\n constructor() {\\n _paused = false;\\n }\\n\\n /**\\n * @dev Returns true if the contract is paused, and false otherwise.\\n */\\n function paused() public view virtual returns (bool) {\\n return _paused;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is not paused.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n modifier whenNotPaused() {\\n require(!paused(), \\\"Pausable: paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Modifier to make a function callable only when the contract is paused.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n modifier whenPaused() {\\n require(paused(), \\\"Pausable: not paused\\\");\\n _;\\n }\\n\\n /**\\n * @dev Triggers stopped state.\\n *\\n * Requirements:\\n *\\n * - The contract must not be paused.\\n */\\n function _pause() internal virtual whenNotPaused {\\n _paused = true;\\n emit Paused(_msgSender());\\n }\\n\\n /**\\n * @dev Returns to normal state.\\n *\\n * Requirements:\\n *\\n * - The contract must be paused.\\n */\\n function _unpause() internal virtual whenPaused {\\n _paused = false;\\n emit Unpaused(_msgSender());\\n }\\n}\\n\",\"keccak256\":\"0xe68ed7fb8766ed1e888291f881e36b616037f852b37d96877045319ad298ba87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\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\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/interfaces/IPeggedToken.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity >=0.8.0;\\n\\ninterface IPeggedToken {\\n function mint(address _to, uint256 _amount) external;\\n\\n function burn(address _from, uint256 _amount) external;\\n}\\n\",\"keccak256\":\"0x14a27012c894926c3dc62bda579d150fdf02d299f36c7f4d9593184d222d047b\",\"license\":\"GPL-3.0-only\"},\"contracts/interfaces/IPeggedTokenBurnFrom.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity >=0.8.0;\\n\\n// used for pegged token with openzeppelin ERC20Burnable interface\\n// only compatible with PeggedTokenBridgeV2\\ninterface IPeggedTokenBurnFrom {\\n function mint(address _to, uint256 _amount) external;\\n\\n function burnFrom(address _from, uint256 _amount) external;\\n}\\n\",\"keccak256\":\"0x82c946321ec62caa905f0d83e3bfde49a370148736e5c3b150ce8478c552b96a\",\"license\":\"GPL-3.0-only\"},\"contracts/interfaces/ISigsVerifier.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity >=0.8.0;\\n\\ninterface ISigsVerifier {\\n /**\\n * @notice Verifies that a message is signed by a quorum among the signers.\\n * @param _msg signed message\\n * @param _sigs list of signatures sorted by signer addresses in ascending order\\n * @param _signers sorted list of current signers\\n * @param _powers powers of current signers\\n */\\n function verifySigs(\\n bytes memory _msg,\\n bytes[] calldata _sigs,\\n address[] calldata _signers,\\n uint256[] calldata _powers\\n ) external view;\\n}\\n\",\"keccak256\":\"0x0d0b090d078a5f50ea7b751331614785e536fc09bcff28bfe08a60613ebca1ae\",\"license\":\"GPL-3.0-only\"},\"contracts/libraries/Pb.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\n// runtime proto sol library\\nlibrary Pb {\\n enum WireType {\\n Varint,\\n Fixed64,\\n LengthDelim,\\n StartGroup,\\n EndGroup,\\n Fixed32\\n }\\n\\n struct Buffer {\\n uint256 idx; // the start index of next read. when idx=b.length, we're done\\n bytes b; // hold serialized proto msg, readonly\\n }\\n\\n // create a new in-memory Buffer object from raw msg bytes\\n function fromBytes(bytes memory raw) internal pure returns (Buffer memory buf) {\\n buf.b = raw;\\n buf.idx = 0;\\n }\\n\\n // whether there are unread bytes\\n function hasMore(Buffer memory buf) internal pure returns (bool) {\\n return buf.idx < buf.b.length;\\n }\\n\\n // decode current field number and wiretype\\n function decKey(Buffer memory buf) internal pure returns (uint256 tag, WireType wiretype) {\\n uint256 v = decVarint(buf);\\n tag = v / 8;\\n wiretype = WireType(v & 7);\\n }\\n\\n // count tag occurrences, return an array due to no memory map support\\n // have to create array for (maxtag+1) size. cnts[tag] = occurrences\\n // should keep buf.idx unchanged because this is only a count function\\n function cntTags(Buffer memory buf, uint256 maxtag) internal pure returns (uint256[] memory cnts) {\\n uint256 originalIdx = buf.idx;\\n cnts = new uint256[](maxtag + 1); // protobuf's tags are from 1 rather than 0\\n uint256 tag;\\n WireType wire;\\n while (hasMore(buf)) {\\n (tag, wire) = decKey(buf);\\n cnts[tag] += 1;\\n skipValue(buf, wire);\\n }\\n buf.idx = originalIdx;\\n }\\n\\n // read varint from current buf idx, move buf.idx to next read, return the int value\\n function decVarint(Buffer memory buf) internal pure returns (uint256 v) {\\n bytes10 tmp; // proto int is at most 10 bytes (7 bits can be used per byte)\\n bytes memory bb = buf.b; // get buf.b mem addr to use in assembly\\n v = buf.idx; // use v to save one additional uint variable\\n assembly {\\n tmp := mload(add(add(bb, 32), v)) // load 10 bytes from buf.b[buf.idx] to tmp\\n }\\n uint256 b; // store current byte content\\n v = 0; // reset to 0 for return value\\n for (uint256 i = 0; i < 10; i++) {\\n assembly {\\n b := byte(i, tmp) // don't use tmp[i] because it does bound check and costs extra\\n }\\n v |= (b & 0x7F) << (i * 7);\\n if (b & 0x80 == 0) {\\n buf.idx += i + 1;\\n return v;\\n }\\n }\\n revert(); // i=10, invalid varint stream\\n }\\n\\n // read length delimited field and return bytes\\n function decBytes(Buffer memory buf) internal pure returns (bytes memory b) {\\n uint256 len = decVarint(buf);\\n uint256 end = buf.idx + len;\\n require(end <= buf.b.length); // avoid overflow\\n b = new bytes(len);\\n bytes memory bufB = buf.b; // get buf.b mem addr to use in assembly\\n uint256 bStart;\\n uint256 bufBStart = buf.idx;\\n assembly {\\n bStart := add(b, 32)\\n bufBStart := add(add(bufB, 32), bufBStart)\\n }\\n for (uint256 i = 0; i < len; i += 32) {\\n assembly {\\n mstore(add(bStart, i), mload(add(bufBStart, i)))\\n }\\n }\\n buf.idx = end;\\n }\\n\\n // return packed ints\\n function decPacked(Buffer memory buf) internal pure returns (uint256[] memory t) {\\n uint256 len = decVarint(buf);\\n uint256 end = buf.idx + len;\\n require(end <= buf.b.length); // avoid overflow\\n // array in memory must be init w/ known length\\n // so we have to create a tmp array w/ max possible len first\\n uint256[] memory tmp = new uint256[](len);\\n uint256 i = 0; // count how many ints are there\\n while (buf.idx < end) {\\n tmp[i] = decVarint(buf);\\n i++;\\n }\\n t = new uint256[](i); // init t with correct length\\n for (uint256 j = 0; j < i; j++) {\\n t[j] = tmp[j];\\n }\\n return t;\\n }\\n\\n // move idx pass current value field, to beginning of next tag or msg end\\n function skipValue(Buffer memory buf, WireType wire) internal pure {\\n if (wire == WireType.Varint) {\\n decVarint(buf);\\n } else if (wire == WireType.LengthDelim) {\\n uint256 len = decVarint(buf);\\n buf.idx += len; // skip len bytes value data\\n require(buf.idx <= buf.b.length); // avoid overflow\\n } else {\\n revert();\\n } // unsupported wiretype\\n }\\n\\n // type conversion help utils\\n function _bool(uint256 x) internal pure returns (bool v) {\\n return x != 0;\\n }\\n\\n function _uint256(bytes memory b) internal pure returns (uint256 v) {\\n require(b.length <= 32); // b's length must be smaller than or equal to 32\\n assembly {\\n v := mload(add(b, 32))\\n } // load all 32bytes to v\\n v = v >> (8 * (32 - b.length)); // only first b.length is valid\\n }\\n\\n function _address(bytes memory b) internal pure returns (address v) {\\n v = _addressPayable(b);\\n }\\n\\n function _addressPayable(bytes memory b) internal pure returns (address payable v) {\\n require(b.length == 20);\\n //load 32bytes then shift right 12 bytes\\n assembly {\\n v := div(mload(add(b, 32)), 0x1000000000000000000000000)\\n }\\n }\\n\\n function _bytes32(bytes memory b) internal pure returns (bytes32 v) {\\n require(b.length == 32);\\n assembly {\\n v := mload(add(b, 32))\\n }\\n }\\n\\n // uint[] to uint8[]\\n function uint8s(uint256[] memory arr) internal pure returns (uint8[] memory t) {\\n t = new uint8[](arr.length);\\n for (uint256 i = 0; i < t.length; i++) {\\n t[i] = uint8(arr[i]);\\n }\\n }\\n\\n function uint32s(uint256[] memory arr) internal pure returns (uint32[] memory t) {\\n t = new uint32[](arr.length);\\n for (uint256 i = 0; i < t.length; i++) {\\n t[i] = uint32(arr[i]);\\n }\\n }\\n\\n function uint64s(uint256[] memory arr) internal pure returns (uint64[] memory t) {\\n t = new uint64[](arr.length);\\n for (uint256 i = 0; i < t.length; i++) {\\n t[i] = uint64(arr[i]);\\n }\\n }\\n\\n function bools(uint256[] memory arr) internal pure returns (bool[] memory t) {\\n t = new bool[](arr.length);\\n for (uint256 i = 0; i < t.length; i++) {\\n t[i] = arr[i] != 0;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xf8c5573d5b5a9bed5ed42254fadce2feeb64bbf81cc0aa4b30b80769c26ad149\",\"license\":\"GPL-3.0-only\"},\"contracts/libraries/PbPegged.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// Code generated by protoc-gen-sol. DO NOT EDIT.\\n// source: contracts/libraries/proto/pegged.proto\\npragma solidity 0.8.17;\\nimport \\\"./Pb.sol\\\";\\n\\nlibrary PbPegged {\\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\\n\\n struct Mint {\\n address token; // tag: 1\\n address account; // tag: 2\\n uint256 amount; // tag: 3\\n address depositor; // tag: 4\\n uint64 refChainId; // tag: 5\\n bytes32 refId; // tag: 6\\n } // end struct Mint\\n\\n function decMint(bytes memory raw) internal pure returns (Mint memory m) {\\n Pb.Buffer memory buf = Pb.fromBytes(raw);\\n\\n uint256 tag;\\n Pb.WireType wire;\\n while (buf.hasMore()) {\\n (tag, wire) = buf.decKey();\\n if (false) {}\\n // solidity has no switch/case\\n else if (tag == 1) {\\n m.token = Pb._address(buf.decBytes());\\n } else if (tag == 2) {\\n m.account = Pb._address(buf.decBytes());\\n } else if (tag == 3) {\\n m.amount = Pb._uint256(buf.decBytes());\\n } else if (tag == 4) {\\n m.depositor = Pb._address(buf.decBytes());\\n } else if (tag == 5) {\\n m.refChainId = uint64(buf.decVarint());\\n } else if (tag == 6) {\\n m.refId = Pb._bytes32(buf.decBytes());\\n } else {\\n buf.skipValue(wire);\\n } // skip value of unknown tag\\n }\\n } // end decoder Mint\\n\\n struct Withdraw {\\n address token; // tag: 1\\n address receiver; // tag: 2\\n uint256 amount; // tag: 3\\n address burnAccount; // tag: 4\\n uint64 refChainId; // tag: 5\\n bytes32 refId; // tag: 6\\n } // end struct Withdraw\\n\\n function decWithdraw(bytes memory raw) internal pure returns (Withdraw memory m) {\\n Pb.Buffer memory buf = Pb.fromBytes(raw);\\n\\n uint256 tag;\\n Pb.WireType wire;\\n while (buf.hasMore()) {\\n (tag, wire) = buf.decKey();\\n if (false) {}\\n // solidity has no switch/case\\n else if (tag == 1) {\\n m.token = Pb._address(buf.decBytes());\\n } else if (tag == 2) {\\n m.receiver = Pb._address(buf.decBytes());\\n } else if (tag == 3) {\\n m.amount = Pb._uint256(buf.decBytes());\\n } else if (tag == 4) {\\n m.burnAccount = Pb._address(buf.decBytes());\\n } else if (tag == 5) {\\n m.refChainId = uint64(buf.decVarint());\\n } else if (tag == 6) {\\n m.refId = Pb._bytes32(buf.decBytes());\\n } else {\\n buf.skipValue(wire);\\n } // skip value of unknown tag\\n }\\n } // end decoder Withdraw\\n}\\n\",\"keccak256\":\"0x2984ca398be79d388f95b2d184445b2be235e56a2fd63019c1a9015dcb2e98e4\",\"license\":\"GPL-3.0-only\"},\"contracts/pegged-bridge/PeggedTokenBridgeV2.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"../interfaces/ISigsVerifier.sol\\\";\\nimport \\\"../interfaces/IPeggedToken.sol\\\";\\nimport \\\"../interfaces/IPeggedTokenBurnFrom.sol\\\";\\nimport \\\"../libraries/PbPegged.sol\\\";\\nimport \\\"../safeguard/Pauser.sol\\\";\\nimport \\\"../safeguard/VolumeControl.sol\\\";\\nimport \\\"../safeguard/DelayedTransfer.sol\\\";\\n\\n/**\\n * @title The bridge contract to mint and burn pegged tokens\\n * @dev Work together with OriginalTokenVault deployed at remote chains.\\n */\\ncontract PeggedTokenBridgeV2 is Pauser, VolumeControl, DelayedTransfer {\\n ISigsVerifier public immutable sigsVerifier;\\n\\n mapping(bytes32 => bool) public records;\\n mapping(address => uint256) public supplies;\\n\\n mapping(address => uint256) public minBurn;\\n mapping(address => uint256) public maxBurn;\\n\\n event Mint(\\n bytes32 mintId,\\n address token,\\n address account,\\n uint256 amount,\\n // ref_chain_id defines the reference chain ID, taking values of:\\n // 1. The common case: the chain ID on which the remote corresponding deposit or burn happened;\\n // 2. Refund for wrong burn: this chain ID on which the burn happened\\n uint64 refChainId,\\n // ref_id defines a unique reference ID, taking values of:\\n // 1. The common case of deposit/burn-mint: the deposit or burn ID on the remote chain;\\n // 2. Refund for wrong burn: the burn ID on this chain\\n bytes32 refId,\\n address depositor\\n );\\n event Burn(\\n bytes32 burnId,\\n address token,\\n address account,\\n uint256 amount,\\n uint64 toChainId,\\n address toAccount,\\n uint64 nonce\\n );\\n event MinBurnUpdated(address token, uint256 amount);\\n event MaxBurnUpdated(address token, uint256 amount);\\n event SupplyUpdated(address token, uint256 supply);\\n\\n constructor(ISigsVerifier _sigsVerifier) {\\n sigsVerifier = _sigsVerifier;\\n }\\n\\n /**\\n * @notice Mint tokens triggered by deposit at a remote chain's OriginalTokenVault.\\n * @param _request The serialized Mint protobuf.\\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\\n * +2/3 of the sigsVerifier's current signing power to be delivered.\\n * @param _signers The sorted list of signers.\\n * @param _powers The signing powers of the signers.\\n */\\n function mint(\\n bytes calldata _request,\\n bytes[] calldata _sigs,\\n address[] calldata _signers,\\n uint256[] calldata _powers\\n ) external whenNotPaused returns (bytes32) {\\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \\\"Mint\\\"));\\n sigsVerifier.verifySigs(abi.encodePacked(domain, _request), _sigs, _signers, _powers);\\n PbPegged.Mint memory request = PbPegged.decMint(_request);\\n bytes32 mintId = keccak256(\\n // len = 20 + 20 + 32 + 20 + 8 + 32 + 20 = 152\\n abi.encodePacked(\\n request.account,\\n request.token,\\n request.amount,\\n request.depositor,\\n request.refChainId,\\n request.refId,\\n address(this)\\n )\\n );\\n require(records[mintId] == false, \\\"record exists\\\");\\n records[mintId] = true;\\n _updateVolume(request.token, request.amount);\\n uint256 delayThreshold = delayThresholds[request.token];\\n if (delayThreshold > 0 && request.amount > delayThreshold) {\\n _addDelayedTransfer(mintId, request.account, request.token, request.amount);\\n } else {\\n IPeggedToken(request.token).mint(request.account, request.amount);\\n }\\n supplies[request.token] += request.amount;\\n emit Mint(\\n mintId,\\n request.token,\\n request.account,\\n request.amount,\\n request.refChainId,\\n request.refId,\\n request.depositor\\n );\\n return mintId;\\n }\\n\\n /**\\n * @notice Burn pegged tokens to trigger a cross-chain withdrawal of the original tokens at a remote chain's\\n * OriginalTokenVault, or mint at another remote chain\\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\\n * @param _token The pegged token address.\\n * @param _amount The amount to burn.\\n * @param _toChainId If zero, withdraw from original vault; otherwise, the remote chain to mint tokens.\\n * @param _toAccount The account to receive tokens on the remote chain\\n * @param _nonce A number to guarantee unique depositId. Can be timestamp in practice.\\n */\\n function burn(\\n address _token,\\n uint256 _amount,\\n uint64 _toChainId,\\n address _toAccount,\\n uint64 _nonce\\n ) external whenNotPaused returns (bytes32) {\\n bytes32 burnId = _burn(_token, _amount, _toChainId, _toAccount, _nonce);\\n IPeggedToken(_token).burn(msg.sender, _amount);\\n return burnId;\\n }\\n\\n // same with `burn` above, use openzeppelin ERC20Burnable interface\\n function burnFrom(\\n address _token,\\n uint256 _amount,\\n uint64 _toChainId,\\n address _toAccount,\\n uint64 _nonce\\n ) external whenNotPaused returns (bytes32) {\\n bytes32 burnId = _burn(_token, _amount, _toChainId, _toAccount, _nonce);\\n IPeggedTokenBurnFrom(_token).burnFrom(msg.sender, _amount);\\n return burnId;\\n }\\n\\n function _burn(\\n address _token,\\n uint256 _amount,\\n uint64 _toChainId,\\n address _toAccount,\\n uint64 _nonce\\n ) internal returns (bytes32) {\\n require(_amount > minBurn[_token], \\\"amount too small\\\");\\n require(maxBurn[_token] == 0 || _amount <= maxBurn[_token], \\\"amount too large\\\");\\n supplies[_token] -= _amount;\\n bytes32 burnId = keccak256(\\n // len = 20 + 20 + 32 + 8 + 20 + 8 + 8 + 20 = 136\\n abi.encodePacked(\\n msg.sender,\\n _token,\\n _amount,\\n _toChainId,\\n _toAccount,\\n _nonce,\\n uint64(block.chainid),\\n address(this)\\n )\\n );\\n require(records[burnId] == false, \\\"record exists\\\");\\n records[burnId] = true;\\n emit Burn(burnId, _token, msg.sender, _amount, _toChainId, _toAccount, _nonce);\\n return burnId;\\n }\\n\\n function executeDelayedTransfer(bytes32 id) external whenNotPaused {\\n delayedTransfer memory transfer = _executeDelayedTransfer(id);\\n IPeggedToken(transfer.token).mint(transfer.receiver, transfer.amount);\\n }\\n\\n function setMinBurn(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\\n require(_tokens.length == _amounts.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n minBurn[_tokens[i]] = _amounts[i];\\n emit MinBurnUpdated(_tokens[i], _amounts[i]);\\n }\\n }\\n\\n function setMaxBurn(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\\n require(_tokens.length == _amounts.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n maxBurn[_tokens[i]] = _amounts[i];\\n emit MaxBurnUpdated(_tokens[i], _amounts[i]);\\n }\\n }\\n\\n function setSupply(address _token, uint256 _supply) external onlyOwner {\\n supplies[_token] = _supply;\\n emit SupplyUpdated(_token, _supply);\\n }\\n\\n function increaseSupply(address _token, uint256 _delta) external onlyOwner {\\n supplies[_token] += _delta;\\n emit SupplyUpdated(_token, supplies[_token]);\\n }\\n\\n function decreaseSupply(address _token, uint256 _delta) external onlyOwner {\\n supplies[_token] -= _delta;\\n emit SupplyUpdated(_token, supplies[_token]);\\n }\\n}\\n\",\"keccak256\":\"0x8ad6f6fd794f9a91e31720358c41b848e55e117180d2d2c06b7b98408a0e7e45\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/DelayedTransfer.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"./Governor.sol\\\";\\n\\nabstract contract DelayedTransfer is Governor {\\n struct delayedTransfer {\\n address receiver;\\n address token;\\n uint256 amount;\\n uint256 timestamp;\\n }\\n mapping(bytes32 => delayedTransfer) public delayedTransfers;\\n mapping(address => uint256) public delayThresholds;\\n uint256 public delayPeriod; // in seconds\\n\\n event DelayedTransferAdded(bytes32 id);\\n event DelayedTransferExecuted(bytes32 id, address receiver, address token, uint256 amount);\\n\\n event DelayPeriodUpdated(uint256 period);\\n event DelayThresholdUpdated(address token, uint256 threshold);\\n\\n function setDelayThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external onlyGovernor {\\n require(_tokens.length == _thresholds.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n delayThresholds[_tokens[i]] = _thresholds[i];\\n emit DelayThresholdUpdated(_tokens[i], _thresholds[i]);\\n }\\n }\\n\\n function setDelayPeriod(uint256 _period) external onlyGovernor {\\n delayPeriod = _period;\\n emit DelayPeriodUpdated(_period);\\n }\\n\\n function _addDelayedTransfer(\\n bytes32 id,\\n address receiver,\\n address token,\\n uint256 amount\\n ) internal {\\n require(delayedTransfers[id].timestamp == 0, \\\"delayed transfer already exists\\\");\\n delayedTransfers[id] = delayedTransfer({\\n receiver: receiver,\\n token: token,\\n amount: amount,\\n timestamp: block.timestamp\\n });\\n emit DelayedTransferAdded(id);\\n }\\n\\n // caller needs to do the actual token transfer\\n function _executeDelayedTransfer(bytes32 id) internal returns (delayedTransfer memory) {\\n delayedTransfer memory transfer = delayedTransfers[id];\\n require(transfer.timestamp > 0, \\\"delayed transfer not exist\\\");\\n require(block.timestamp > transfer.timestamp + delayPeriod, \\\"delayed transfer still locked\\\");\\n delete delayedTransfers[id];\\n emit DelayedTransferExecuted(id, transfer.receiver, transfer.token, transfer.amount);\\n return transfer;\\n }\\n}\\n\",\"keccak256\":\"0xabc30b51461760fca2280c892430e2890a3dca109df98ce351c0964f1114eaa3\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/Governor.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"./Ownable.sol\\\";\\n\\nabstract contract Governor is Ownable {\\n mapping(address => bool) public governors;\\n\\n event GovernorAdded(address account);\\n event GovernorRemoved(address account);\\n\\n modifier onlyGovernor() {\\n require(isGovernor(msg.sender), \\\"Caller is not governor\\\");\\n _;\\n }\\n\\n constructor() {\\n _addGovernor(msg.sender);\\n }\\n\\n function isGovernor(address _account) public view returns (bool) {\\n return governors[_account];\\n }\\n\\n function addGovernor(address _account) public onlyOwner {\\n _addGovernor(_account);\\n }\\n\\n function removeGovernor(address _account) public onlyOwner {\\n _removeGovernor(_account);\\n }\\n\\n function renounceGovernor() public {\\n _removeGovernor(msg.sender);\\n }\\n\\n function _addGovernor(address _account) private {\\n require(!isGovernor(_account), \\\"Account is already governor\\\");\\n governors[_account] = true;\\n emit GovernorAdded(_account);\\n }\\n\\n function _removeGovernor(address _account) private {\\n require(isGovernor(_account), \\\"Account is not governor\\\");\\n governors[_account] = false;\\n emit GovernorRemoved(_account);\\n }\\n}\\n\",\"keccak256\":\"0x2c05629097c488feb0f1cc9d832397c7d4c419cdd00545465f83f3b58aea0c48\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity ^0.8.0;\\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 * By default, the owner account will be the one that deploys the contract. This\\n * can 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 *\\n * This adds a normal func that setOwner if _owner is address(0). So we can't allow\\n * renounceOwnership. So we can support Proxy based upgradable contract\\n */\\nabstract contract Ownable {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _setOwner(msg.sender);\\n }\\n\\n /**\\n * @dev Only to be called by inherit contracts, in their init func called by Proxy\\n * we require _owner == address(0), which is only possible when it's a delegateCall\\n * because constructor sets _owner in contract state.\\n */\\n function initOwner() internal {\\n require(_owner == address(0), \\\"owner already set\\\");\\n _setOwner(msg.sender);\\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 called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == msg.sender, \\\"Ownable: caller is not the owner\\\");\\n _;\\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 require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _setOwner(newOwner);\\n }\\n\\n function _setOwner(address newOwner) private {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x2a92103195b8dce0f34fdf9bf7f94ddf38bf8edf0c0fd4be21323c47016687e9\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/Pauser.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/security/Pausable.sol\\\";\\nimport \\\"./Ownable.sol\\\";\\n\\nabstract contract Pauser is Ownable, Pausable {\\n mapping(address => bool) public pausers;\\n\\n event PauserAdded(address account);\\n event PauserRemoved(address account);\\n\\n constructor() {\\n _addPauser(msg.sender);\\n }\\n\\n modifier onlyPauser() {\\n require(isPauser(msg.sender), \\\"Caller is not pauser\\\");\\n _;\\n }\\n\\n function pause() public onlyPauser {\\n _pause();\\n }\\n\\n function unpause() public onlyPauser {\\n _unpause();\\n }\\n\\n function isPauser(address account) public view returns (bool) {\\n return pausers[account];\\n }\\n\\n function addPauser(address account) public onlyOwner {\\n _addPauser(account);\\n }\\n\\n function removePauser(address account) public onlyOwner {\\n _removePauser(account);\\n }\\n\\n function renouncePauser() public {\\n _removePauser(msg.sender);\\n }\\n\\n function _addPauser(address account) private {\\n require(!isPauser(account), \\\"Account is already pauser\\\");\\n pausers[account] = true;\\n emit PauserAdded(account);\\n }\\n\\n function _removePauser(address account) private {\\n require(isPauser(account), \\\"Account is not pauser\\\");\\n pausers[account] = false;\\n emit PauserRemoved(account);\\n }\\n}\\n\",\"keccak256\":\"0xe260d8e1780ca5f7ee0bedb8d1f7415bfd1e42b2b5f6d191a8e3e741ab0af5fd\",\"license\":\"GPL-3.0-only\"},\"contracts/safeguard/VolumeControl.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"./Governor.sol\\\";\\n\\nabstract contract VolumeControl is Governor {\\n uint256 public epochLength; // seconds\\n mapping(address => uint256) public epochVolumes; // key is token\\n mapping(address => uint256) public epochVolumeCaps; // key is token\\n mapping(address => uint256) public lastOpTimestamps; // key is token\\n\\n event EpochLengthUpdated(uint256 length);\\n event EpochVolumeUpdated(address token, uint256 cap);\\n\\n function setEpochLength(uint256 _length) external onlyGovernor {\\n epochLength = _length;\\n emit EpochLengthUpdated(_length);\\n }\\n\\n function setEpochVolumeCaps(address[] calldata _tokens, uint256[] calldata _caps) external onlyGovernor {\\n require(_tokens.length == _caps.length, \\\"length mismatch\\\");\\n for (uint256 i = 0; i < _tokens.length; i++) {\\n epochVolumeCaps[_tokens[i]] = _caps[i];\\n emit EpochVolumeUpdated(_tokens[i], _caps[i]);\\n }\\n }\\n\\n function _updateVolume(address _token, uint256 _amount) internal {\\n if (epochLength == 0) {\\n return;\\n }\\n uint256 cap = epochVolumeCaps[_token];\\n if (cap == 0) {\\n return;\\n }\\n uint256 volume = epochVolumes[_token];\\n uint256 timestamp = block.timestamp;\\n uint256 epochStartTime = (timestamp / epochLength) * epochLength;\\n if (lastOpTimestamps[_token] < epochStartTime) {\\n volume = _amount;\\n } else {\\n volume += _amount;\\n }\\n require(volume <= cap, \\\"volume exceeds cap\\\");\\n epochVolumes[_token] = volume;\\n lastOpTimestamps[_token] = timestamp;\\n }\\n}\\n\",\"keccak256\":\"0xe66e0543c641d3f0a38fa35a5f39c3cfe289b08a95bb77d3fbcaf3426479cb4d\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b50604051620031ec380380620031ec83398101604081905262000034916200024f565b6200003f3362000074565b6000805460ff60a01b191690556200005733620000c4565b62000062336200018f565b6001600160a01b031660805262000281565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811660009081526001602052604090205460ff1615620001335760405162461bcd60e51b815260206004820152601960248201527f4163636f756e7420697320616c7265616479207061757365720000000000000060448201526064015b60405180910390fd5b6001600160a01b038116600081815260016020818152604092839020805460ff191690921790915590519182527f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f891015b60405180910390a150565b6001600160a01b03811660009081526002602052604090205460ff1615620001fa5760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920676f7665726e6f72000000000060448201526064016200012a565b6001600160a01b038116600081815260026020908152604091829020805460ff1916600117905590519182527fdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b5910162000184565b6000602082840312156200026257600080fd5b81516001600160a01b03811681146200027a57600080fd5b9392505050565b608051612f48620002a460003960008181610601015261157b0152612f486000f3fe608060405234801561001057600080fd5b50600436106102c85760003560e01c806382dc1ec41161017b578063bf4816f0116100d8578063eecdac881161008c578063f832138311610071578063f8321383146106a0578063f8734302146106c0578063f9a8ea08146106d357600080fd5b8063eecdac881461067a578063f2fde38b1461068d57600080fd5b8063e026049c116100bd578063e026049c14610623578063e3eece261461062b578063e43581b81461064e57600080fd5b8063bf4816f0146105e9578063ccf2683b146105fc57600080fd5b8063a00293011161012f578063b1c94d9411610114578063b1c94d94146105ad578063b4d8cedc146105b6578063b5f2bc47146105c957600080fd5b8063a00293011461052d578063adc0d57f1461054057600080fd5b80638da5cb5b116101605780638da5cb5b146104e25780639e25fc5c146105075780639e422c331461051a57600080fd5b806382dc1ec4146104c75780638456cb59146104da57600080fd5b806352532faa116102295780636b2c0f55116101dd57806379fcd8ee116101c257806379fcd8ee146104715780637f8560131461048457806380f51c12146104a457600080fd5b80636b2c0f55146104565780636ef8d66d1461046957600080fd5b806357d775f81161020e57806357d775f81461041b5780635c975abb1461042457806360216b001461043657600080fd5b806352532faa146103e857806354eea7961461040857600080fd5b80633d5721071161028057806346fbf68e1161026557806346fbf68e1461038957806347b16c6c146103b5578063497bf3b2146103c857600080fd5b80633d5721071461036e5780633f4ba83a1461038157600080fd5b806317bdbae5116102b157806317bdbae51461031a578063274cee311461032d5780633c4a25d01461035b57600080fd5b806301e64725146102cd57806315d0975c14610305575b600080fd5b6102f06102db3660046129ab565b600a6020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6103186103133660046129e0565b6106e6565b005b610318610328366004612a56565b6107d7565b61034d61033b366004612ac2565b600b6020526000908152604090205481565b6040519081526020016102fc565b610318610369366004612ac2565b610975565b61031861037c3660046129ab565b6109ea565b610318610a7e565b6102f0610397366004612ac2565b6001600160a01b031660009081526001602052604090205460ff1690565b6103186103c3366004612a56565b610ae7565b61034d6103d6366004612ac2565b600d6020526000908152604090205481565b61034d6103f6366004612ac2565b60086020526000908152604090205481565b6103186104163660046129ab565b610c7e565b61034d60035481565b600054600160a01b900460ff166102f0565b61034d610444366004612ac2565b60046020526000908152604090205481565b610318610464366004612ac2565b610d0b565b610318610d7d565b61031861047f3660046129e0565b610d86565b61034d610492366004612ac2565b600c6020526000908152604090205481565b6102f06104b2366004612ac2565b60016020526000908152604090205460ff1681565b6103186104d5366004612ac2565b610e17565b610318610e89565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016102fc565b6103186105153660046129ab565b610ef0565b61034d610528366004612afc565b610fbd565b61034d61053b366004612afc565b611089565b61058261054e3660046129ab565b60076020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b604080516001600160a01b0395861681529490931660208501529183015260608201526080016102fc565b61034d60095481565b6103186105c43660046129e0565b61111c565b61034d6105d7366004612ac2565b60056020526000908152604090205481565b6103186105f7366004612a56565b6111d6565b6104ef7f000000000000000000000000000000000000000000000000000000000000000081565b61031861136d565b6102f0610639366004612ac2565b60026020526000908152604090205460ff1681565b6102f061065c366004612ac2565b6001600160a01b031660009081526002602052604090205460ff1690565b610318610688366004612ac2565b611376565b61031861069b366004612ac2565b6113e8565b61034d6106ae366004612ac2565b60066020526000908152604090205481565b61034d6106ce366004612b5a565b6114d6565b6103186106e1366004612a56565b611921565b336106f96000546001600160a01b031690565b6001600160a01b0316146107545760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6001600160a01b0382166000908152600b60205260408120805483929061077c908490612c5f565b90915550506001600160a01b0382166000818152600b6020908152604091829020548251938452908301527feb2f7272b55acd6dea98f5742868e8d2221ad82acb36b2d0cdd00150290e949991015b60405180910390a15050565b3360009081526002602052604090205460ff1661082f5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b8281146108705760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604482015260640161074b565b60005b8381101561096e5782828281811061088d5761088d612c72565b90506020020135600860008787858181106108aa576108aa612c72565b90506020020160208101906108bf9190612ac2565b6001600160a01b031681526020810191909152604001600020557fceaad6533bfb481492fb3e08ef19297f46611b8fa9de5ef4cf8dc23a56ad09ce85858381811061090c5761090c612c72565b90506020020160208101906109219190612ac2565b84848481811061093357610933612c72565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a18061096681612c88565b915050610873565b5050505050565b336109886000546001600160a01b031690565b6001600160a01b0316146109de5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6109e781611ab8565b50565b3360009081526002602052604090205460ff16610a425760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b60098190556040518181527fc0a39f234199b125fb93713c4d067bdcebbf691087f87b79c0feb92b156ba8b6906020015b60405180910390a150565b3360009081526001602052604090205460ff16610add5760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206973206e6f7420706175736572000000000000000000000000604482015260640161074b565b610ae5611b75565b565b3360009081526002602052604090205460ff16610b3f5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b828114610b805760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604482015260640161074b565b60005b8381101561096e57828282818110610b9d57610b9d612c72565b9050602002013560056000878785818110610bba57610bba612c72565b9050602002016020810190610bcf9190612ac2565b6001600160a01b031681526020810191909152604001600020557f608e49c22994f20b5d3496dca088b88dfd81b4a3e8cc3809ea1e10a320107e89858583818110610c1c57610c1c612c72565b9050602002016020810190610c319190612ac2565b848484818110610c4357610c43612c72565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180610c7681612c88565b915050610b83565b3360009081526002602052604090205460ff16610cd65760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b60038190556040518181527f2664fec2ff76486ac58ed087310855b648b15b9d19f3de8529e95f7c46b7d6b390602001610a73565b33610d1e6000546001600160a01b031690565b6001600160a01b031614610d745760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6109e781611c1b565b610ae533611c1b565b33610d996000546001600160a01b031690565b6001600160a01b031614610def5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6001600160a01b0382166000908152600b60205260408120805483929061077c908490612ca1565b33610e2a6000546001600160a01b031690565b6001600160a01b031614610e805760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6109e781611cd4565b3360009081526001602052604090205460ff16610ee85760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206973206e6f7420706175736572000000000000000000000000604482015260640161074b565b610ae5611d92565b600054600160a01b900460ff1615610f3d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b6000610f4882611e1a565b6020810151815160408084015190516340c10f1960e01b81526001600160a01b039283166004820152602481019190915292935016906340c10f1990604401600060405180830381600087803b158015610fa157600080fd5b505af1158015610fb5573d6000803e3d6000fd5b505050505050565b60008054600160a01b900460ff161561100b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b600061101a8787878787611fec565b60405163079cc67960e41b8152336004820152602481018890529091506001600160a01b038816906379cc6790906044015b600060405180830381600087803b15801561106657600080fd5b505af115801561107a573d6000803e3d6000fd5b50929998505050505050505050565b60008054600160a01b900460ff16156110d75760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b60006110e68787878787611fec565b604051632770a7eb60e21b8152336004820152602481018890529091506001600160a01b03881690639dc29fac9060440161104c565b3361112f6000546001600160a01b031690565b6001600160a01b0316146111855760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6001600160a01b0382166000818152600b6020908152604091829020849055815192835282018390527feb2f7272b55acd6dea98f5742868e8d2221ad82acb36b2d0cdd00150290e949991016107cb565b3360009081526002602052604090205460ff1661122e5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b82811461126f5760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604482015260640161074b565b60005b8381101561096e5782828281811061128c5761128c612c72565b90506020020135600c60008787858181106112a9576112a9612c72565b90506020020160208101906112be9190612ac2565b6001600160a01b031681526020810191909152604001600020557f3796cd0b17a8734f8da819920625598e9a18be490f686725282e5383f1d0668385858381811061130b5761130b612c72565b90506020020160208101906113209190612ac2565b84848481811061133257611332612c72565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a18061136581612c88565b915050611272565b610ae53361228c565b336113896000546001600160a01b031690565b6001600160a01b0316146113df5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6109e78161228c565b336113fb6000546001600160a01b031690565b6001600160a01b0316146114515760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6001600160a01b0381166114cd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161074b565b6109e781612345565b60008054600160a01b900460ff16156115245760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b6000463060405160200161156192919091825260601b6bffffffffffffffffffffffff1916602082015263135a5b9d60e21b603482015260380190565b6040516020818303038152906040528051906020012090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663682dbc22828c8c6040516020016115bd93929190612cb4565b6040516020818303038152906040528a8a8a8a8a8a6040518863ffffffff1660e01b81526004016115f49796959493929190612e18565b60006040518083038186803b15801561160c57600080fd5b505afa158015611620573d6000803e3d6000fd5b5050505060006116658b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506123a292505050565b6020818101518251604080850151606080870151608088015160a089015185516bffffffffffffffffffffffff1998851b8916818b015296841b88166034880152604887019490945290821b8616606886015277ffffffffffffffffffffffffffffffffffffffffffffffff1960c09190911b16607c850152608484019190915230901b90921660a48201528151808203609801815260b890910182528051908301206000818152600a9093529120549192509060ff16156117595760405162461bcd60e51b815260206004820152600d60248201526c7265636f72642065786973747360981b604482015260640161074b565b6000818152600a602052604090819020805460ff1916600117905582519083015161178491906124fe565b81516001600160a01b031660009081526008602052604090205480158015906117b05750808360400151115b156117d2576117cd8284602001518560000151866040015161261c565b611842565b8251602084015160408086015190516340c10f1960e01b81526001600160a01b03928316600482015260248101919091529116906340c10f1990604401600060405180830381600087803b15801561182957600080fd5b505af115801561183d573d6000803e3d6000fd5b505050505b60408084015184516001600160a01b03166000908152600b602052918220805491929091611871908490612ca1565b925050819055507f5bc84ecccfced5bb04bfc7f3efcdbe7f5cd21949ef146811b4d1967fe41f777a8284600001518560200151866040015187608001518860a00151896060015160405161190997969594939291909687526001600160a01b0395861660208801529385166040870152606086019290925267ffffffffffffffff16608085015260a08401521660c082015260e00190565b60405180910390a1509b9a5050505050505050505050565b3360009081526002602052604090205460ff166119795760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b8281146119ba5760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604482015260640161074b565b60005b8381101561096e578282828181106119d7576119d7612c72565b90506020020135600d60008787858181106119f4576119f4612c72565b9050602002016020810190611a099190612ac2565b6001600160a01b031681526020810191909152604001600020557fa3181379f6db47d9037efc6b6e8e3efe8c55ddb090b4f0512c152f97c4e47da5858583818110611a5657611a56612c72565b9050602002016020810190611a6b9190612ac2565b848484818110611a7d57611a7d612c72565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180611ab081612c88565b9150506119bd565b6001600160a01b03811660009081526002602052604090205460ff1615611b215760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920676f7665726e6f720000000000604482015260640161074b565b6001600160a01b038116600081815260026020908152604091829020805460ff1916600117905590519182527fdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b59101610a73565b600054600160a01b900460ff16611bce5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161074b565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b03811660009081526001602052604090205460ff16611c835760405162461bcd60e51b815260206004820152601560248201527f4163636f756e74206973206e6f74207061757365720000000000000000000000604482015260640161074b565b6001600160a01b038116600081815260016020908152604091829020805460ff1916905590519182527fcd265ebaf09df2871cc7bd4133404a235ba12eff2041bb89d9c714a2621c7c7e9101610a73565b6001600160a01b03811660009081526001602052604090205460ff1615611d3d5760405162461bcd60e51b815260206004820152601960248201527f4163636f756e7420697320616c72656164792070617573657200000000000000604482015260640161074b565b6001600160a01b038116600081815260016020818152604092839020805460ff191690921790915590519182527f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f89101610a73565b600054600160a01b900460ff1615611ddf5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611bfe3390565b604080516080810182526000808252602082018190529181018290526060810191909152600082815260076020908152604091829020825160808101845281546001600160a01b0390811682526001830154169281019290925260028101549282019290925260039091015460608201819052611ed95760405162461bcd60e51b815260206004820152601a60248201527f64656c61796564207472616e73666572206e6f74206578697374000000000000604482015260640161074b565b6009548160600151611eeb9190612ca1565b4211611f395760405162461bcd60e51b815260206004820152601d60248201527f64656c61796564207472616e73666572207374696c6c206c6f636b6564000000604482015260640161074b565b6000838152600760209081526040808320805473ffffffffffffffffffffffffffffffffffffffff199081168255600182018054909116905560028101849055600301929092558251908301518383015192517f3b40e5089937425d14cdd96947e5661868357e224af59bd8b24a4b8a330d442693611fde93889390929091909384526001600160a01b03928316602085015291166040830152606082015260800190565b60405180910390a192915050565b6001600160a01b0385166000908152600c602052604081205485116120535760405162461bcd60e51b815260206004820152601060248201527f616d6f756e7420746f6f20736d616c6c00000000000000000000000000000000604482015260640161074b565b6001600160a01b0386166000908152600d6020526040902054158061209057506001600160a01b0386166000908152600d60205260409020548511155b6120dc5760405162461bcd60e51b815260206004820152601060248201527f616d6f756e7420746f6f206c6172676500000000000000000000000000000000604482015260640161074b565b6001600160a01b0386166000908152600b602052604081208054879290612104908490612c5f565b90915550506040516bffffffffffffffffffffffff1933606090811b8216602084015288811b821660348401526048830188905277ffffffffffffffffffffffffffffffffffffffffffffffff1960c088811b8216606886015287831b8416607086015286811b8216608486015246901b16608c84015230901b16609482015260009060a80160408051601f1981840301815291815281516020928301206000818152600a90935291205490915060ff16156121f25760405162461bcd60e51b815260206004820152600d60248201526c7265636f72642065786973747360981b604482015260640161074b565b6000818152600a6020908152604091829020805460ff1916600117905581518381526001600160a01b038a81169282019290925233928101929092526060820188905267ffffffffffffffff878116608084015290861660a0830152841660c08201527f6298d7b58f235730b3b399dc5c282f15dae8b022e5fbbf89cee21fd83c8810a39060e00160405180910390a19695505050505050565b6001600160a01b03811660009081526002602052604090205460ff166122f45760405162461bcd60e51b815260206004820152601760248201527f4163636f756e74206973206e6f7420676f7665726e6f72000000000000000000604482015260640161074b565b6001600160a01b038116600081815260026020908152604091829020805460ff1916905590519182527f1ebe834e73d60a5fec822c1e1727d34bc79f2ad977ed504581cc1822fe20fb5b9101610a73565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805160c08101825260008082526020808301829052828401829052606083018290526080830182905260a0830182905283518085019094528184528301849052909190805b602083015151835110156124f6576124008361273c565b90925090508160010361242e5761241e61241984612776565b612833565b6001600160a01b031684526123e9565b816002036124555761244261241984612776565b6001600160a01b031660208501526123e9565b816003036124785761246e61246984612776565b612844565b60408501526123e9565b8160040361249f5761248c61241984612776565b6001600160a01b031660608501526123e9565b816005036124c4576124b08361287b565b67ffffffffffffffff1660808501526123e9565b816006036124e7576124dd6124d884612776565b6128f6565b60a08501526123e9565b6124f1838261290e565b6123e9565b505050919050565b60035460000361250c575050565b6001600160a01b0382166000908152600560205260408120549081900361253257505050565b6001600160a01b0383166000908152600460205260408120546003549091429161255c8184612ead565b6125669190612ecf565b6001600160a01b0387166000908152600660205260409020549091508111156125915784925061259e565b61259b8584612ca1565b92505b838311156125ee5760405162461bcd60e51b815260206004820152601260248201527f766f6c756d652065786365656473206361700000000000000000000000000000604482015260640161074b565b506001600160a01b039094166000908152600460209081526040808320939093556006905220929092555050565b6000848152600760205260409020600301541561267b5760405162461bcd60e51b815260206004820152601f60248201527f64656c61796564207472616e7366657220616c72656164792065786973747300604482015260640161074b565b604080516080810182526001600160a01b0380861682528481166020808401918252838501868152426060860190815260008b81526007909352918690209451855490851673ffffffffffffffffffffffffffffffffffffffff1991821617865592516001860180549190951693169290921790925551600283015551600390910155517fcbcfffe5102114216a85d3aceb14ad4b81a3935b1b5c468fadf3889eb9c5dce69061272e9086815260200190565b60405180910390a150505050565b600080600061274a8461287b565b9050612757600882612ead565b925080600716600581111561276e5761276e612ee6565b915050915091565b606060006127838361287b565b905060008184600001516127979190612ca1565b90508360200151518111156127ab57600080fd5b8167ffffffffffffffff8111156127c4576127c4612efc565b6040519080825280601f01601f1916602001820160405280156127ee576020820181803683370190505b50602080860151865192955091818601919083010160005b85811015612828578181015183820152612821602082612ca1565b9050612806565b505050935250919050565b600061283e82612983565b92915050565b600060208251111561285557600080fd5b602082015190508151602061286a9190612c5f565b612875906008612ecf565b1c919050565b602080820151825181019091015160009182805b600a8110156102c85783811a91506128a8816007612ecf565b82607f16901b85179450816080166000036128e4576128c8816001612ca1565b865187906128d7908390612ca1565b9052509395945050505050565b806128ee81612c88565b91505061288f565b6000815160201461290657600080fd5b506020015190565b600081600581111561292257612922612ee6565b03612935576129308261287b565b505050565b600281600581111561294957612949612ee6565b036102c85760006129598361287b565b9050808360000181815161296d9190612ca1565b9052506020830151518351111561293057600080fd5b6000815160141461299357600080fd5b50602001516c01000000000000000000000000900490565b6000602082840312156129bd57600080fd5b5035919050565b80356001600160a01b03811681146129db57600080fd5b919050565b600080604083850312156129f357600080fd5b6129fc836129c4565b946020939093013593505050565b60008083601f840112612a1c57600080fd5b50813567ffffffffffffffff811115612a3457600080fd5b6020830191508360208260051b8501011115612a4f57600080fd5b9250929050565b60008060008060408587031215612a6c57600080fd5b843567ffffffffffffffff80821115612a8457600080fd5b612a9088838901612a0a565b90965094506020870135915080821115612aa957600080fd5b50612ab687828801612a0a565b95989497509550505050565b600060208284031215612ad457600080fd5b612add826129c4565b9392505050565b803567ffffffffffffffff811681146129db57600080fd5b600080600080600060a08688031215612b1457600080fd5b612b1d866129c4565b945060208601359350612b3260408701612ae4565b9250612b40606087016129c4565b9150612b4e60808701612ae4565b90509295509295909350565b6000806000806000806000806080898b031215612b7657600080fd5b883567ffffffffffffffff80821115612b8e57600080fd5b818b0191508b601f830112612ba257600080fd5b813581811115612bb157600080fd5b8c6020828501011115612bc357600080fd5b60209283019a509850908a01359080821115612bde57600080fd5b612bea8c838d01612a0a565b909850965060408b0135915080821115612c0357600080fd5b612c0f8c838d01612a0a565b909650945060608b0135915080821115612c2857600080fd5b50612c358b828c01612a0a565b999c989b5096995094979396929594505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561283e5761283e612c49565b634e487b7160e01b600052603260045260246000fd5b600060018201612c9a57612c9a612c49565b5060010190565b8082018082111561283e5761283e612c49565b838152818360208301376000910160200190815292915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b818352600060208085019450848460051b86018460005b87811015612d795783830389528135601e19883603018112612d2f57600080fd5b8701858101903567ffffffffffffffff811115612d4b57600080fd5b803603821315612d5a57600080fd5b612d65858284612cce565b9a87019a9450505090840190600101612d0e565b5090979650505050505050565b8183526000602080850194508260005b85811015612dc2576001600160a01b03612daf836129c4565b1687529582019590820190600101612d96565b509495945050505050565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115612dff57600080fd5b8260051b80836020870137939093016020019392505050565b608081526000885180608084015260005b81811015612e46576020818c0181015160a0868401015201612e29565b50600060a08285010152601f19601f8201168301905060a0838203016020840152612e7560a08201898b612cf7565b90508281036040840152612e8a818789612d86565b90508281036060840152612e9f818587612dcd565b9a9950505050505050505050565b600082612eca57634e487b7160e01b600052601260045260246000fd5b500490565b808202811582820484141761283e5761283e612c49565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220e5b9f12e5c6d24cbc73614f3dcf66e5a438a61e936f8addfa2d161b6415d958264736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106102c85760003560e01c806382dc1ec41161017b578063bf4816f0116100d8578063eecdac881161008c578063f832138311610071578063f8321383146106a0578063f8734302146106c0578063f9a8ea08146106d357600080fd5b8063eecdac881461067a578063f2fde38b1461068d57600080fd5b8063e026049c116100bd578063e026049c14610623578063e3eece261461062b578063e43581b81461064e57600080fd5b8063bf4816f0146105e9578063ccf2683b146105fc57600080fd5b8063a00293011161012f578063b1c94d9411610114578063b1c94d94146105ad578063b4d8cedc146105b6578063b5f2bc47146105c957600080fd5b8063a00293011461052d578063adc0d57f1461054057600080fd5b80638da5cb5b116101605780638da5cb5b146104e25780639e25fc5c146105075780639e422c331461051a57600080fd5b806382dc1ec4146104c75780638456cb59146104da57600080fd5b806352532faa116102295780636b2c0f55116101dd57806379fcd8ee116101c257806379fcd8ee146104715780637f8560131461048457806380f51c12146104a457600080fd5b80636b2c0f55146104565780636ef8d66d1461046957600080fd5b806357d775f81161020e57806357d775f81461041b5780635c975abb1461042457806360216b001461043657600080fd5b806352532faa146103e857806354eea7961461040857600080fd5b80633d5721071161028057806346fbf68e1161026557806346fbf68e1461038957806347b16c6c146103b5578063497bf3b2146103c857600080fd5b80633d5721071461036e5780633f4ba83a1461038157600080fd5b806317bdbae5116102b157806317bdbae51461031a578063274cee311461032d5780633c4a25d01461035b57600080fd5b806301e64725146102cd57806315d0975c14610305575b600080fd5b6102f06102db3660046129ab565b600a6020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6103186103133660046129e0565b6106e6565b005b610318610328366004612a56565b6107d7565b61034d61033b366004612ac2565b600b6020526000908152604090205481565b6040519081526020016102fc565b610318610369366004612ac2565b610975565b61031861037c3660046129ab565b6109ea565b610318610a7e565b6102f0610397366004612ac2565b6001600160a01b031660009081526001602052604090205460ff1690565b6103186103c3366004612a56565b610ae7565b61034d6103d6366004612ac2565b600d6020526000908152604090205481565b61034d6103f6366004612ac2565b60086020526000908152604090205481565b6103186104163660046129ab565b610c7e565b61034d60035481565b600054600160a01b900460ff166102f0565b61034d610444366004612ac2565b60046020526000908152604090205481565b610318610464366004612ac2565b610d0b565b610318610d7d565b61031861047f3660046129e0565b610d86565b61034d610492366004612ac2565b600c6020526000908152604090205481565b6102f06104b2366004612ac2565b60016020526000908152604090205460ff1681565b6103186104d5366004612ac2565b610e17565b610318610e89565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016102fc565b6103186105153660046129ab565b610ef0565b61034d610528366004612afc565b610fbd565b61034d61053b366004612afc565b611089565b61058261054e3660046129ab565b60076020526000908152604090208054600182015460028301546003909301546001600160a01b0392831693919092169184565b604080516001600160a01b0395861681529490931660208501529183015260608201526080016102fc565b61034d60095481565b6103186105c43660046129e0565b61111c565b61034d6105d7366004612ac2565b60056020526000908152604090205481565b6103186105f7366004612a56565b6111d6565b6104ef7f000000000000000000000000000000000000000000000000000000000000000081565b61031861136d565b6102f0610639366004612ac2565b60026020526000908152604090205460ff1681565b6102f061065c366004612ac2565b6001600160a01b031660009081526002602052604090205460ff1690565b610318610688366004612ac2565b611376565b61031861069b366004612ac2565b6113e8565b61034d6106ae366004612ac2565b60066020526000908152604090205481565b61034d6106ce366004612b5a565b6114d6565b6103186106e1366004612a56565b611921565b336106f96000546001600160a01b031690565b6001600160a01b0316146107545760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6001600160a01b0382166000908152600b60205260408120805483929061077c908490612c5f565b90915550506001600160a01b0382166000818152600b6020908152604091829020548251938452908301527feb2f7272b55acd6dea98f5742868e8d2221ad82acb36b2d0cdd00150290e949991015b60405180910390a15050565b3360009081526002602052604090205460ff1661082f5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b8281146108705760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604482015260640161074b565b60005b8381101561096e5782828281811061088d5761088d612c72565b90506020020135600860008787858181106108aa576108aa612c72565b90506020020160208101906108bf9190612ac2565b6001600160a01b031681526020810191909152604001600020557fceaad6533bfb481492fb3e08ef19297f46611b8fa9de5ef4cf8dc23a56ad09ce85858381811061090c5761090c612c72565b90506020020160208101906109219190612ac2565b84848481811061093357610933612c72565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a18061096681612c88565b915050610873565b5050505050565b336109886000546001600160a01b031690565b6001600160a01b0316146109de5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6109e781611ab8565b50565b3360009081526002602052604090205460ff16610a425760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b60098190556040518181527fc0a39f234199b125fb93713c4d067bdcebbf691087f87b79c0feb92b156ba8b6906020015b60405180910390a150565b3360009081526001602052604090205460ff16610add5760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206973206e6f7420706175736572000000000000000000000000604482015260640161074b565b610ae5611b75565b565b3360009081526002602052604090205460ff16610b3f5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b828114610b805760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604482015260640161074b565b60005b8381101561096e57828282818110610b9d57610b9d612c72565b9050602002013560056000878785818110610bba57610bba612c72565b9050602002016020810190610bcf9190612ac2565b6001600160a01b031681526020810191909152604001600020557f608e49c22994f20b5d3496dca088b88dfd81b4a3e8cc3809ea1e10a320107e89858583818110610c1c57610c1c612c72565b9050602002016020810190610c319190612ac2565b848484818110610c4357610c43612c72565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180610c7681612c88565b915050610b83565b3360009081526002602052604090205460ff16610cd65760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b60038190556040518181527f2664fec2ff76486ac58ed087310855b648b15b9d19f3de8529e95f7c46b7d6b390602001610a73565b33610d1e6000546001600160a01b031690565b6001600160a01b031614610d745760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6109e781611c1b565b610ae533611c1b565b33610d996000546001600160a01b031690565b6001600160a01b031614610def5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6001600160a01b0382166000908152600b60205260408120805483929061077c908490612ca1565b33610e2a6000546001600160a01b031690565b6001600160a01b031614610e805760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6109e781611cd4565b3360009081526001602052604090205460ff16610ee85760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206973206e6f7420706175736572000000000000000000000000604482015260640161074b565b610ae5611d92565b600054600160a01b900460ff1615610f3d5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b6000610f4882611e1a565b6020810151815160408084015190516340c10f1960e01b81526001600160a01b039283166004820152602481019190915292935016906340c10f1990604401600060405180830381600087803b158015610fa157600080fd5b505af1158015610fb5573d6000803e3d6000fd5b505050505050565b60008054600160a01b900460ff161561100b5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b600061101a8787878787611fec565b60405163079cc67960e41b8152336004820152602481018890529091506001600160a01b038816906379cc6790906044015b600060405180830381600087803b15801561106657600080fd5b505af115801561107a573d6000803e3d6000fd5b50929998505050505050505050565b60008054600160a01b900460ff16156110d75760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b60006110e68787878787611fec565b604051632770a7eb60e21b8152336004820152602481018890529091506001600160a01b03881690639dc29fac9060440161104c565b3361112f6000546001600160a01b031690565b6001600160a01b0316146111855760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6001600160a01b0382166000818152600b6020908152604091829020849055815192835282018390527feb2f7272b55acd6dea98f5742868e8d2221ad82acb36b2d0cdd00150290e949991016107cb565b3360009081526002602052604090205460ff1661122e5760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b82811461126f5760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604482015260640161074b565b60005b8381101561096e5782828281811061128c5761128c612c72565b90506020020135600c60008787858181106112a9576112a9612c72565b90506020020160208101906112be9190612ac2565b6001600160a01b031681526020810191909152604001600020557f3796cd0b17a8734f8da819920625598e9a18be490f686725282e5383f1d0668385858381811061130b5761130b612c72565b90506020020160208101906113209190612ac2565b84848481811061133257611332612c72565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a18061136581612c88565b915050611272565b610ae53361228c565b336113896000546001600160a01b031690565b6001600160a01b0316146113df5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6109e78161228c565b336113fb6000546001600160a01b031690565b6001600160a01b0316146114515760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161074b565b6001600160a01b0381166114cd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161074b565b6109e781612345565b60008054600160a01b900460ff16156115245760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b6000463060405160200161156192919091825260601b6bffffffffffffffffffffffff1916602082015263135a5b9d60e21b603482015260380190565b6040516020818303038152906040528051906020012090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663682dbc22828c8c6040516020016115bd93929190612cb4565b6040516020818303038152906040528a8a8a8a8a8a6040518863ffffffff1660e01b81526004016115f49796959493929190612e18565b60006040518083038186803b15801561160c57600080fd5b505afa158015611620573d6000803e3d6000fd5b5050505060006116658b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506123a292505050565b6020818101518251604080850151606080870151608088015160a089015185516bffffffffffffffffffffffff1998851b8916818b015296841b88166034880152604887019490945290821b8616606886015277ffffffffffffffffffffffffffffffffffffffffffffffff1960c09190911b16607c850152608484019190915230901b90921660a48201528151808203609801815260b890910182528051908301206000818152600a9093529120549192509060ff16156117595760405162461bcd60e51b815260206004820152600d60248201526c7265636f72642065786973747360981b604482015260640161074b565b6000818152600a602052604090819020805460ff1916600117905582519083015161178491906124fe565b81516001600160a01b031660009081526008602052604090205480158015906117b05750808360400151115b156117d2576117cd8284602001518560000151866040015161261c565b611842565b8251602084015160408086015190516340c10f1960e01b81526001600160a01b03928316600482015260248101919091529116906340c10f1990604401600060405180830381600087803b15801561182957600080fd5b505af115801561183d573d6000803e3d6000fd5b505050505b60408084015184516001600160a01b03166000908152600b602052918220805491929091611871908490612ca1565b925050819055507f5bc84ecccfced5bb04bfc7f3efcdbe7f5cd21949ef146811b4d1967fe41f777a8284600001518560200151866040015187608001518860a00151896060015160405161190997969594939291909687526001600160a01b0395861660208801529385166040870152606086019290925267ffffffffffffffff16608085015260a08401521660c082015260e00190565b60405180910390a1509b9a5050505050505050505050565b3360009081526002602052604090205460ff166119795760405162461bcd60e51b815260206004820152601660248201527521b0b63632b91034b9903737ba1033b7bb32b93737b960511b604482015260640161074b565b8281146119ba5760405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b604482015260640161074b565b60005b8381101561096e578282828181106119d7576119d7612c72565b90506020020135600d60008787858181106119f4576119f4612c72565b9050602002016020810190611a099190612ac2565b6001600160a01b031681526020810191909152604001600020557fa3181379f6db47d9037efc6b6e8e3efe8c55ddb090b4f0512c152f97c4e47da5858583818110611a5657611a56612c72565b9050602002016020810190611a6b9190612ac2565b848484818110611a7d57611a7d612c72565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a180611ab081612c88565b9150506119bd565b6001600160a01b03811660009081526002602052604090205460ff1615611b215760405162461bcd60e51b815260206004820152601b60248201527f4163636f756e7420697320616c726561647920676f7665726e6f720000000000604482015260640161074b565b6001600160a01b038116600081815260026020908152604091829020805460ff1916600117905590519182527fdc5a48d79e2e147530ff63ecdbed5a5a66adb9d5cf339384d5d076da197c40b59101610a73565b600054600160a01b900460ff16611bce5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161074b565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6001600160a01b03811660009081526001602052604090205460ff16611c835760405162461bcd60e51b815260206004820152601560248201527f4163636f756e74206973206e6f74207061757365720000000000000000000000604482015260640161074b565b6001600160a01b038116600081815260016020908152604091829020805460ff1916905590519182527fcd265ebaf09df2871cc7bd4133404a235ba12eff2041bb89d9c714a2621c7c7e9101610a73565b6001600160a01b03811660009081526001602052604090205460ff1615611d3d5760405162461bcd60e51b815260206004820152601960248201527f4163636f756e7420697320616c72656164792070617573657200000000000000604482015260640161074b565b6001600160a01b038116600081815260016020818152604092839020805460ff191690921790915590519182527f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f89101610a73565b600054600160a01b900460ff1615611ddf5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015260640161074b565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611bfe3390565b604080516080810182526000808252602082018190529181018290526060810191909152600082815260076020908152604091829020825160808101845281546001600160a01b0390811682526001830154169281019290925260028101549282019290925260039091015460608201819052611ed95760405162461bcd60e51b815260206004820152601a60248201527f64656c61796564207472616e73666572206e6f74206578697374000000000000604482015260640161074b565b6009548160600151611eeb9190612ca1565b4211611f395760405162461bcd60e51b815260206004820152601d60248201527f64656c61796564207472616e73666572207374696c6c206c6f636b6564000000604482015260640161074b565b6000838152600760209081526040808320805473ffffffffffffffffffffffffffffffffffffffff199081168255600182018054909116905560028101849055600301929092558251908301518383015192517f3b40e5089937425d14cdd96947e5661868357e224af59bd8b24a4b8a330d442693611fde93889390929091909384526001600160a01b03928316602085015291166040830152606082015260800190565b60405180910390a192915050565b6001600160a01b0385166000908152600c602052604081205485116120535760405162461bcd60e51b815260206004820152601060248201527f616d6f756e7420746f6f20736d616c6c00000000000000000000000000000000604482015260640161074b565b6001600160a01b0386166000908152600d6020526040902054158061209057506001600160a01b0386166000908152600d60205260409020548511155b6120dc5760405162461bcd60e51b815260206004820152601060248201527f616d6f756e7420746f6f206c6172676500000000000000000000000000000000604482015260640161074b565b6001600160a01b0386166000908152600b602052604081208054879290612104908490612c5f565b90915550506040516bffffffffffffffffffffffff1933606090811b8216602084015288811b821660348401526048830188905277ffffffffffffffffffffffffffffffffffffffffffffffff1960c088811b8216606886015287831b8416607086015286811b8216608486015246901b16608c84015230901b16609482015260009060a80160408051601f1981840301815291815281516020928301206000818152600a90935291205490915060ff16156121f25760405162461bcd60e51b815260206004820152600d60248201526c7265636f72642065786973747360981b604482015260640161074b565b6000818152600a6020908152604091829020805460ff1916600117905581518381526001600160a01b038a81169282019290925233928101929092526060820188905267ffffffffffffffff878116608084015290861660a0830152841660c08201527f6298d7b58f235730b3b399dc5c282f15dae8b022e5fbbf89cee21fd83c8810a39060e00160405180910390a19695505050505050565b6001600160a01b03811660009081526002602052604090205460ff166122f45760405162461bcd60e51b815260206004820152601760248201527f4163636f756e74206973206e6f7420676f7665726e6f72000000000000000000604482015260640161074b565b6001600160a01b038116600081815260026020908152604091829020805460ff1916905590519182527f1ebe834e73d60a5fec822c1e1727d34bc79f2ad977ed504581cc1822fe20fb5b9101610a73565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805160c08101825260008082526020808301829052828401829052606083018290526080830182905260a0830182905283518085019094528184528301849052909190805b602083015151835110156124f6576124008361273c565b90925090508160010361242e5761241e61241984612776565b612833565b6001600160a01b031684526123e9565b816002036124555761244261241984612776565b6001600160a01b031660208501526123e9565b816003036124785761246e61246984612776565b612844565b60408501526123e9565b8160040361249f5761248c61241984612776565b6001600160a01b031660608501526123e9565b816005036124c4576124b08361287b565b67ffffffffffffffff1660808501526123e9565b816006036124e7576124dd6124d884612776565b6128f6565b60a08501526123e9565b6124f1838261290e565b6123e9565b505050919050565b60035460000361250c575050565b6001600160a01b0382166000908152600560205260408120549081900361253257505050565b6001600160a01b0383166000908152600460205260408120546003549091429161255c8184612ead565b6125669190612ecf565b6001600160a01b0387166000908152600660205260409020549091508111156125915784925061259e565b61259b8584612ca1565b92505b838311156125ee5760405162461bcd60e51b815260206004820152601260248201527f766f6c756d652065786365656473206361700000000000000000000000000000604482015260640161074b565b506001600160a01b039094166000908152600460209081526040808320939093556006905220929092555050565b6000848152600760205260409020600301541561267b5760405162461bcd60e51b815260206004820152601f60248201527f64656c61796564207472616e7366657220616c72656164792065786973747300604482015260640161074b565b604080516080810182526001600160a01b0380861682528481166020808401918252838501868152426060860190815260008b81526007909352918690209451855490851673ffffffffffffffffffffffffffffffffffffffff1991821617865592516001860180549190951693169290921790925551600283015551600390910155517fcbcfffe5102114216a85d3aceb14ad4b81a3935b1b5c468fadf3889eb9c5dce69061272e9086815260200190565b60405180910390a150505050565b600080600061274a8461287b565b9050612757600882612ead565b925080600716600581111561276e5761276e612ee6565b915050915091565b606060006127838361287b565b905060008184600001516127979190612ca1565b90508360200151518111156127ab57600080fd5b8167ffffffffffffffff8111156127c4576127c4612efc565b6040519080825280601f01601f1916602001820160405280156127ee576020820181803683370190505b50602080860151865192955091818601919083010160005b85811015612828578181015183820152612821602082612ca1565b9050612806565b505050935250919050565b600061283e82612983565b92915050565b600060208251111561285557600080fd5b602082015190508151602061286a9190612c5f565b612875906008612ecf565b1c919050565b602080820151825181019091015160009182805b600a8110156102c85783811a91506128a8816007612ecf565b82607f16901b85179450816080166000036128e4576128c8816001612ca1565b865187906128d7908390612ca1565b9052509395945050505050565b806128ee81612c88565b91505061288f565b6000815160201461290657600080fd5b506020015190565b600081600581111561292257612922612ee6565b03612935576129308261287b565b505050565b600281600581111561294957612949612ee6565b036102c85760006129598361287b565b9050808360000181815161296d9190612ca1565b9052506020830151518351111561293057600080fd5b6000815160141461299357600080fd5b50602001516c01000000000000000000000000900490565b6000602082840312156129bd57600080fd5b5035919050565b80356001600160a01b03811681146129db57600080fd5b919050565b600080604083850312156129f357600080fd5b6129fc836129c4565b946020939093013593505050565b60008083601f840112612a1c57600080fd5b50813567ffffffffffffffff811115612a3457600080fd5b6020830191508360208260051b8501011115612a4f57600080fd5b9250929050565b60008060008060408587031215612a6c57600080fd5b843567ffffffffffffffff80821115612a8457600080fd5b612a9088838901612a0a565b90965094506020870135915080821115612aa957600080fd5b50612ab687828801612a0a565b95989497509550505050565b600060208284031215612ad457600080fd5b612add826129c4565b9392505050565b803567ffffffffffffffff811681146129db57600080fd5b600080600080600060a08688031215612b1457600080fd5b612b1d866129c4565b945060208601359350612b3260408701612ae4565b9250612b40606087016129c4565b9150612b4e60808701612ae4565b90509295509295909350565b6000806000806000806000806080898b031215612b7657600080fd5b883567ffffffffffffffff80821115612b8e57600080fd5b818b0191508b601f830112612ba257600080fd5b813581811115612bb157600080fd5b8c6020828501011115612bc357600080fd5b60209283019a509850908a01359080821115612bde57600080fd5b612bea8c838d01612a0a565b909850965060408b0135915080821115612c0357600080fd5b612c0f8c838d01612a0a565b909650945060608b0135915080821115612c2857600080fd5b50612c358b828c01612a0a565b999c989b5096995094979396929594505050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561283e5761283e612c49565b634e487b7160e01b600052603260045260246000fd5b600060018201612c9a57612c9a612c49565b5060010190565b8082018082111561283e5761283e612c49565b838152818360208301376000910160200190815292915050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b818352600060208085019450848460051b86018460005b87811015612d795783830389528135601e19883603018112612d2f57600080fd5b8701858101903567ffffffffffffffff811115612d4b57600080fd5b803603821315612d5a57600080fd5b612d65858284612cce565b9a87019a9450505090840190600101612d0e565b5090979650505050505050565b8183526000602080850194508260005b85811015612dc2576001600160a01b03612daf836129c4565b1687529582019590820190600101612d96565b509495945050505050565b81835260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115612dff57600080fd5b8260051b80836020870137939093016020019392505050565b608081526000885180608084015260005b81811015612e46576020818c0181015160a0868401015201612e29565b50600060a08285010152601f19601f8201168301905060a0838203016020840152612e7560a08201898b612cf7565b90508281036040840152612e8a818789612d86565b90508281036060840152612e9f818587612dcd565b9a9950505050505050505050565b600082612eca57634e487b7160e01b600052601260045260246000fd5b500490565b808202811582820484141761283e5761283e612c49565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220e5b9f12e5c6d24cbc73614f3dcf66e5a438a61e936f8addfa2d161b6415d958264736f6c63430008110033", + "devdoc": { + "details": "Work together with OriginalTokenVault deployed at remote chains.", + "kind": "dev", + "methods": { + "burn(address,uint256,uint64,address,uint64)": { + "params": { + "_amount": "The amount to burn.", + "_nonce": "A number to guarantee unique depositId. Can be timestamp in practice.", + "_toAccount": "The account to receive tokens on the remote chain", + "_toChainId": "If zero, withdraw from original vault; otherwise, the remote chain to mint tokens.", + "_token": "The pegged token address." + } + }, + "mint(bytes,bytes[],address[],uint256[])": { + "params": { + "_powers": "The signing powers of the signers.", + "_request": "The serialized Mint protobuf.", + "_signers": "The sorted list of signers.", + "_sigs": "The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by +2/3 of the sigsVerifier's current signing power to be delivered." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "paused()": { + "details": "Returns true if the contract is paused, and false otherwise." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "title": "The bridge contract to mint and burn pegged tokens", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "burn(address,uint256,uint64,address,uint64)": { + "notice": "Burn pegged tokens to trigger a cross-chain withdrawal of the original tokens at a remote chain's OriginalTokenVault, or mint at another remote chain NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens." + }, + "mint(bytes,bytes[],address[],uint256[])": { + "notice": "Mint tokens triggered by deposit at a remote chain's OriginalTokenVault." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 33210, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 654, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "_paused", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 33324, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "pausers", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 33083, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "governors", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 33471, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "epochLength", + "offset": 0, + "slot": "3", + "type": "t_uint256" + }, + { + "astId": 33475, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "epochVolumes", + "offset": 0, + "slot": "4", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 33479, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "epochVolumeCaps", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 33483, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "lastOpTimestamps", + "offset": 0, + "slot": "6", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 32884, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "delayedTransfers", + "offset": 0, + "slot": "7", + "type": "t_mapping(t_bytes32,t_struct(delayedTransfer)32879_storage)" + }, + { + "astId": 32888, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "delayThresholds", + "offset": 0, + "slot": "8", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 32890, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "delayPeriod", + "offset": 0, + "slot": "9", + "type": "t_uint256" + }, + { + "astId": 28259, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "records", + "offset": 0, + "slot": "10", + "type": "t_mapping(t_bytes32,t_bool)" + }, + { + "astId": 28263, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "supplies", + "offset": 0, + "slot": "11", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 28267, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "minBurn", + "offset": 0, + "slot": "12", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 28271, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "maxBurn", + "offset": 0, + "slot": "13", + "type": "t_mapping(t_address,t_uint256)" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "encoding": "inplace", + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_bytes32,t_bool)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_bytes32,t_struct(delayedTransfer)32879_storage)": { + "encoding": "mapping", + "key": "t_bytes32", + "label": "mapping(bytes32 => struct DelayedTransfer.delayedTransfer)", + "numberOfBytes": "32", + "value": "t_struct(delayedTransfer)32879_storage" + }, + "t_struct(delayedTransfer)32879_storage": { + "encoding": "inplace", + "label": "struct DelayedTransfer.delayedTransfer", + "members": [ + { + "astId": 32872, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "receiver", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 32874, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "token", + "offset": 0, + "slot": "1", + "type": "t_address" + }, + { + "astId": 32876, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "amount", + "offset": 0, + "slot": "2", + "type": "t_uint256" + }, + { + "astId": 32878, + "contract": "contracts/pegged-bridge/PeggedTokenBridgeV2.sol:PeggedTokenBridgeV2", + "label": "timestamp", + "offset": 0, + "slot": "3", + "type": "t_uint256" + } + ], + "numberOfBytes": "128" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} \ No newline at end of file diff --git a/deployments/linea/solcInputs/63e7586ecff740f5cf7af58b7e60f225.json b/deployments/linea/solcInputs/63e7586ecff740f5cf7af58b7e60f225.json new file mode 100644 index 000000000..54d0fc2fd --- /dev/null +++ b/deployments/linea/solcInputs/63e7586ecff740f5cf7af58b7e60f225.json @@ -0,0 +1,473 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/access/AccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```\n * function foo() public {\n * require(hasRole(MY_ROLE, msg.sender));\n * ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n struct RoleData {\n mapping(address => bool) members;\n bytes32 adminRole;\n }\n\n mapping(bytes32 => RoleData) private _roles;\n\n bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n /**\n * @dev Modifier that checks that an account has a specific role. Reverts\n * with a standardized message including the required role.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n *\n * _Available since v4.1._\n */\n modifier onlyRole(bytes32 role) {\n _checkRole(role, _msgSender());\n _;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n return _roles[role].members[account];\n }\n\n /**\n * @dev Revert with a standard message if `account` is missing `role`.\n *\n * The format of the revert reason is given by the following regular expression:\n *\n * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n */\n function _checkRole(bytes32 role, address account) internal view virtual {\n if (!hasRole(role, account)) {\n revert(\n string(\n abi.encodePacked(\n \"AccessControl: account \",\n Strings.toHexString(uint160(account), 20),\n \" is missing role \",\n Strings.toHexString(uint256(role), 32)\n )\n )\n );\n }\n }\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n return _roles[role].adminRole;\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _grantRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n _revokeRole(role, account);\n }\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been revoked `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) public virtual override {\n require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n _revokeRole(role, account);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event. Note that unlike {grantRole}, this function doesn't perform any\n * checks on the calling account.\n *\n * [WARNING]\n * ====\n * This function should only be called from the constructor when setting\n * up the initial roles for the system.\n *\n * Using this function in any other way is effectively circumventing the admin\n * system imposed by {AccessControl}.\n * ====\n *\n * NOTE: This function is deprecated in favor of {_grantRole}.\n */\n function _setupRole(bytes32 role, address account) internal virtual {\n _grantRole(role, account);\n }\n\n /**\n * @dev Sets `adminRole` as ``role``'s admin role.\n *\n * Emits a {RoleAdminChanged} event.\n */\n function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n bytes32 previousAdminRole = getRoleAdmin(role);\n _roles[role].adminRole = adminRole;\n emit RoleAdminChanged(role, previousAdminRole, adminRole);\n }\n\n /**\n * @dev Grants `role` to `account`.\n *\n * Internal function without access restriction.\n */\n function _grantRole(bytes32 role, address account) internal virtual {\n if (!hasRole(role, account)) {\n _roles[role].members[account] = true;\n emit RoleGranted(role, account, _msgSender());\n }\n }\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * Internal function without access restriction.\n */\n function _revokeRole(bytes32 role, address account) internal virtual {\n if (hasRole(role, account)) {\n _roles[role].members[account] = false;\n emit RoleRevoked(role, account, _msgSender());\n }\n }\n}\n" + }, + "@openzeppelin/contracts/access/AccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControlEnumerable.sol\";\nimport \"./AccessControl.sol\";\nimport \"../utils/structs/EnumerableSet.sol\";\n\n/**\n * @dev Extension of {AccessControl} that allows enumerating the members of each role.\n */\nabstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {\n using EnumerableSet for EnumerableSet.AddressSet;\n\n mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {\n return _roleMembers[role].at(index);\n }\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {\n return _roleMembers[role].length();\n }\n\n /**\n * @dev Overload {_grantRole} to track enumerable memberships\n */\n function _grantRole(bytes32 role, address account) internal virtual override {\n super._grantRole(role, account);\n _roleMembers[role].add(account);\n }\n\n /**\n * @dev Overload {_revokeRole} to track enumerable memberships\n */\n function _revokeRole(bytes32 role, address account) internal virtual override {\n super._revokeRole(role, account);\n _roleMembers[role].remove(account);\n }\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControl.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n /**\n * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n *\n * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n * {RoleAdminChanged} not being emitted signaling this.\n *\n * _Available since v3.1._\n */\n event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n /**\n * @dev Emitted when `account` is granted `role`.\n *\n * `sender` is the account that originated the contract call, an admin role\n * bearer except when using {AccessControl-_setupRole}.\n */\n event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Emitted when `account` is revoked `role`.\n *\n * `sender` is the account that originated the contract call:\n * - if using `revokeRole`, it is the admin role bearer\n * - if using `renounceRole`, it is the role bearer (i.e. `account`)\n */\n event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n /**\n * @dev Returns `true` if `account` has been granted `role`.\n */\n function hasRole(bytes32 role, address account) external view returns (bool);\n\n /**\n * @dev Returns the admin role that controls `role`. See {grantRole} and\n * {revokeRole}.\n *\n * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n */\n function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n /**\n * @dev Grants `role` to `account`.\n *\n * If `account` had not been already granted `role`, emits a {RoleGranted}\n * event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function grantRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from `account`.\n *\n * If `account` had been granted `role`, emits a {RoleRevoked} event.\n *\n * Requirements:\n *\n * - the caller must have ``role``'s admin role.\n */\n function revokeRole(bytes32 role, address account) external;\n\n /**\n * @dev Revokes `role` from the calling account.\n *\n * Roles are often managed via {grantRole} and {revokeRole}: this function's\n * purpose is to provide a mechanism for accounts to lose their privileges\n * if they are compromised (such as when a trusted device is misplaced).\n *\n * If the calling account had been granted `role`, emits a {RoleRevoked}\n * event.\n *\n * Requirements:\n *\n * - the caller must be `account`.\n */\n function renounceRole(bytes32 role, address account) external;\n}\n" + }, + "@openzeppelin/contracts/access/IAccessControlEnumerable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\n\n/**\n * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.\n */\ninterface IAccessControlEnumerable is IAccessControl {\n /**\n * @dev Returns one of the accounts that have `role`. `index` must be a\n * value between 0 and {getRoleMemberCount}, non-inclusive.\n *\n * Role bearers are not sorted in any particular way, and their ordering may\n * change at any point.\n *\n * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure\n * you perform all queries on the same block. See the following\n * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]\n * for more information.\n */\n function getRoleMember(bytes32 role, uint256 index) external view returns (address);\n\n /**\n * @dev Returns the number of accounts that have `role`. Can be used\n * together with {getRoleMember} to enumerate all bearers of a role.\n */\n function getRoleMemberCount(bytes32 role) external view returns (uint256);\n}\n" + }, + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\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 called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing 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 require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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/security/Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n" + }, + "@openzeppelin/contracts/security/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/ERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.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 * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\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 *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n mapping(address => uint256) private _balances;\n\n mapping(address => mapping(address => 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 * The default value of {decimals} is 18. To select a different value for\n * {decimals} you should overload it.\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 override 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 override 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 value {ERC20} uses, unless this function is\n * 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 override returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual override 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 `amount`.\n */\n function transfer(address to, uint256 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual override returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` 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 amount) public virtual override returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, amount);\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 `amount`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `amount`.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual override returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, amount);\n _transfer(from, to, amount);\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, _allowances[owner][spender] + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n address owner = _msgSender();\n uint256 currentAllowance = _allowances[owner][spender];\n require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n unchecked {\n _approve(owner, spender, currentAllowance - subtractedValue);\n }\n\n return true;\n }\n\n /**\n * @dev Moves `amount` of tokens from `sender` to `recipient`.\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 * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `from` must have a balance of at least `amount`.\n */\n function _transfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {\n require(from != address(0), \"ERC20: transfer from the zero address\");\n require(to != address(0), \"ERC20: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, amount);\n\n uint256 fromBalance = _balances[from];\n require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n unchecked {\n _balances[from] = fromBalance - amount;\n }\n _balances[to] += amount;\n\n emit Transfer(from, to, amount);\n\n _afterTokenTransfer(from, to, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: mint to the zero address\");\n\n _beforeTokenTransfer(address(0), account, amount);\n\n _totalSupply += amount;\n _balances[account] += amount;\n emit Transfer(address(0), account, amount);\n\n _afterTokenTransfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n require(account != address(0), \"ERC20: burn from the zero address\");\n\n _beforeTokenTransfer(account, address(0), amount);\n\n uint256 accountBalance = _balances[account];\n require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n unchecked {\n _balances[account] = accountBalance - amount;\n }\n _totalSupply -= amount;\n\n emit Transfer(account, address(0), amount);\n\n _afterTokenTransfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` 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 function _approve(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n require(owner != address(0), \"ERC20: approve from the zero address\");\n require(spender != address(0), \"ERC20: approve to the zero address\");\n\n _allowances[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n\n /**\n * @dev Spend `amount` form the allowance of `owner` toward `spender`.\n *\n * Does not update the allowance amount in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Might emit an {Approval} event.\n */\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n }\n\n /**\n * @dev Hook that is called before any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * will be transferred to `to`.\n * - when `from` is zero, `amount` tokens will be minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n * has been transferred to `to`.\n * - when `from` is zero, `amount` tokens have been minted for `to`.\n * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./draft-IERC20Permit.sol\";\nimport \"../ERC20.sol\";\nimport \"../../../utils/cryptography/draft-EIP712.sol\";\nimport \"../../../utils/cryptography/ECDSA.sol\";\nimport \"../../../utils/Counters.sol\";\n\n/**\n * @dev Implementation 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 * _Available since v3.4._\n */\nabstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {\n using Counters for Counters.Counter;\n\n mapping(address => Counters.Counter) private _nonces;\n\n // solhint-disable-next-line var-name-mixedcase\n bytes32 private immutable _PERMIT_TYPEHASH =\n keccak256(\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\");\n\n /**\n * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `\"1\"`.\n *\n * It's a good idea to use the same `name` that is defined as the ERC20 token name.\n */\n constructor(string memory name) EIP712(name, \"1\") {}\n\n /**\n * @dev See {IERC20Permit-permit}.\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 ) public virtual override {\n require(block.timestamp <= deadline, \"ERC20Permit: expired deadline\");\n\n bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));\n\n bytes32 hash = _hashTypedDataV4(structHash);\n\n address signer = ECDSA.recover(hash, v, r, s);\n require(signer == owner, \"ERC20Permit: invalid signature\");\n\n _approve(owner, spender, value);\n }\n\n /**\n * @dev See {IERC20Permit-nonces}.\n */\n function nonces(address owner) public view virtual override returns (uint256) {\n return _nonces[owner].current();\n }\n\n /**\n * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view override returns (bytes32) {\n return _domainSeparatorV4();\n }\n\n /**\n * @dev \"Consume a nonce\": return the current value and increment.\n *\n * _Available since v4.1._\n */\n function _useNonce(address owner) internal virtual returns (uint256 current) {\n Counters.Counter storage nonce = _nonces[owner];\n current = nonce.current();\n nonce.increment();\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\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 */\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 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/extensions/ERC20Burnable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/extensions/ERC20Burnable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../utils/Context.sol\";\n\n/**\n * @dev Extension of {ERC20} that allows token holders to destroy both their own\n * tokens and those that they have an allowance for, in a way that can be\n * recognized off-chain (via event analysis).\n */\nabstract contract ERC20Burnable is Context, ERC20 {\n /**\n * @dev Destroys `amount` tokens from the caller.\n *\n * See {ERC20-_burn}.\n */\n function burn(uint256 amount) public virtual {\n _burn(_msgSender(), amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) public virtual {\n _spendAllowance(account, _msgSender(), amount);\n _burn(account, amount);\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../../../security/Pausable.sol\";\n\n/**\n * @dev ERC20 token with pausable token transfers, minting and burning.\n *\n * Useful for scenarios such as preventing trades until the end of an evaluation\n * period, or having an emergency switch for freezing all token transfers in the\n * event of a large bug.\n */\nabstract contract ERC20Pausable is ERC20, Pausable {\n /**\n * @dev See {ERC20-_beforeTokenTransfer}.\n *\n * Requirements:\n *\n * - the contract must not be paused.\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n\n require(!paused(), \"ERC20Pausable: token transfer while paused\");\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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/IERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` 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 amount) 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 `amount` as the allowance of `spender` over the 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 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` 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(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n\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" + }, + "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../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 function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\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, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/ERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n using Address for address;\n using Strings for uint256;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to owner address\n mapping(uint256 => address) private _owners;\n\n // Mapping owner address to token count\n mapping(address => uint256) private _balances;\n\n // Mapping from token ID to approved address\n mapping(uint256 => address) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n /**\n * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return\n interfaceId == type(IERC721).interfaceId ||\n interfaceId == type(IERC721Metadata).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev See {IERC721-balanceOf}.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n require(owner != address(0), \"ERC721: balance query for the zero address\");\n return _balances[owner];\n }\n\n /**\n * @dev See {IERC721-ownerOf}.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n address owner = _owners[tokenId];\n require(owner != address(0), \"ERC721: owner query for nonexistent token\");\n return owner;\n }\n\n /**\n * @dev See {IERC721Metadata-name}.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev See {IERC721Metadata-symbol}.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, can be overriden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n /**\n * @dev See {IERC721-approve}.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ERC721.ownerOf(tokenId);\n require(to != owner, \"ERC721: approval to current owner\");\n\n require(\n _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n \"ERC721: approve caller is not owner nor approved for all\"\n );\n\n _approve(to, tokenId);\n }\n\n /**\n * @dev See {IERC721-getApproved}.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n require(_exists(tokenId), \"ERC721: approved query for nonexistent token\");\n\n return _tokenApprovals[tokenId];\n }\n\n /**\n * @dev See {IERC721-setApprovalForAll}.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _setApprovalForAll(_msgSender(), operator, approved);\n }\n\n /**\n * @dev See {IERC721-isApprovedForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev See {IERC721-transferFrom}.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n //solhint-disable-next-line max-line-length\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n\n _transfer(from, to, tokenId);\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev See {IERC721-safeTransferFrom}.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public virtual override {\n require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: transfer caller is not owner nor approved\");\n _safeTransfer(from, to, tokenId, _data);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * `_data` is additional data, it has no specified format and it is sent in call to `to`.\n *\n * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n * implement alternative mechanisms to perform token transfer, such as signature-based.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeTransfer(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) internal virtual {\n _transfer(from, to, tokenId);\n require(_checkOnERC721Received(from, to, tokenId, _data), \"ERC721: transfer to non ERC721Receiver implementer\");\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted (`_mint`),\n * and stop existing when they are burned (`_burn`).\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return _owners[tokenId] != address(0);\n }\n\n /**\n * @dev Returns whether `spender` is allowed to manage `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n require(_exists(tokenId), \"ERC721: operator query for nonexistent token\");\n address owner = ERC721.ownerOf(tokenId);\n return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));\n }\n\n /**\n * @dev Safely mints `tokenId` and transfers it to `to`.\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function _safeMint(address to, uint256 tokenId) internal virtual {\n _safeMint(to, tokenId, \"\");\n }\n\n /**\n * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n */\n function _safeMint(\n address to,\n uint256 tokenId,\n bytes memory _data\n ) internal virtual {\n _mint(to, tokenId);\n require(\n _checkOnERC721Received(address(0), to, tokenId, _data),\n \"ERC721: transfer to non ERC721Receiver implementer\"\n );\n }\n\n /**\n * @dev Mints `tokenId` and transfers it to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n *\n * Requirements:\n *\n * - `tokenId` must not exist.\n * - `to` cannot be the zero address.\n *\n * Emits a {Transfer} event.\n */\n function _mint(address to, uint256 tokenId) internal virtual {\n require(to != address(0), \"ERC721: mint to the zero address\");\n require(!_exists(tokenId), \"ERC721: token already minted\");\n\n _beforeTokenTransfer(address(0), to, tokenId);\n\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(address(0), to, tokenId);\n\n _afterTokenTransfer(address(0), to, tokenId);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual {\n address owner = ERC721.ownerOf(tokenId);\n\n _beforeTokenTransfer(owner, address(0), tokenId);\n\n // Clear approvals\n _approve(address(0), tokenId);\n\n _balances[owner] -= 1;\n delete _owners[tokenId];\n\n emit Transfer(owner, address(0), tokenId);\n\n _afterTokenTransfer(owner, address(0), tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n *\n * Emits a {Transfer} event.\n */\n function _transfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {\n require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n require(to != address(0), \"ERC721: transfer to the zero address\");\n\n _beforeTokenTransfer(from, to, tokenId);\n\n // Clear approvals from the previous owner\n _approve(address(0), tokenId);\n\n _balances[from] -= 1;\n _balances[to] += 1;\n _owners[tokenId] = to;\n\n emit Transfer(from, to, tokenId);\n\n _afterTokenTransfer(from, to, tokenId);\n }\n\n /**\n * @dev Approve `to` to operate on `tokenId`\n *\n * Emits a {Approval} event.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _tokenApprovals[tokenId] = to;\n emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n }\n\n /**\n * @dev Approve `operator` to operate on all of `owner` tokens\n *\n * Emits a {ApprovalForAll} event.\n */\n function _setApprovalForAll(\n address owner,\n address operator,\n bool approved\n ) internal virtual {\n require(owner != operator, \"ERC721: approve to caller\");\n _operatorApprovals[owner][operator] = approved;\n emit ApprovalForAll(owner, operator, approved);\n }\n\n /**\n * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n * The call is not executed if the target address is not a contract.\n *\n * @param from address representing the previous owner of the given token ID\n * @param to target address that will receive the tokens\n * @param tokenId uint256 ID of the token to be transferred\n * @param _data bytes optional data to send along with the call\n * @return bool whether the call correctly returned the expected magic value\n */\n function _checkOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) private returns (bool) {\n if (to.isContract()) {\n try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {\n return retval == IERC721Receiver.onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n } else {\n return true;\n }\n }\n\n /**\n * @dev Hook that is called before any token transfer. This includes minting\n * and burning.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, ``from``'s `tokenId` will be burned.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after any transfer of tokens. This includes\n * minting and burning.\n *\n * Calling conditions:\n *\n * - when `from` and `to` are both non-zero.\n * - `from` and `to` are never both zero.\n *\n * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n */\n function _afterTokenTransfer(\n address from,\n address to,\n uint256 tokenId\n ) internal virtual {}\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721URIStorage.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\n\n/**\n * @dev ERC721 token with storage based token URI management.\n */\nabstract contract ERC721URIStorage is ERC721 {\n using Strings for uint256;\n\n // Optional mapping for token URIs\n mapping(uint256 => string) private _tokenURIs;\n\n /**\n * @dev See {IERC721Metadata-tokenURI}.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n require(_exists(tokenId), \"ERC721URIStorage: URI query for nonexistent token\");\n\n string memory _tokenURI = _tokenURIs[tokenId];\n string memory base = _baseURI();\n\n // If there is no base URI, return the token URI.\n if (bytes(base).length == 0) {\n return _tokenURI;\n }\n // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\n if (bytes(_tokenURI).length > 0) {\n return string(abi.encodePacked(base, _tokenURI));\n }\n\n return super.tokenURI(tokenId);\n }\n\n /**\n * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {\n require(_exists(tokenId), \"ERC721URIStorage: URI set of nonexistent token\");\n _tokenURIs[tokenId] = _tokenURI;\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId) internal virtual override {\n super._burn(tokenId);\n\n if (bytes(_tokenURIs[tokenId]).length != 0) {\n delete _tokenURIs[tokenId];\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\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\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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/Counters.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary Counters {\n struct Counter {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n // this feature: see https://github.com/ethereum/solidity/issues/4637\n uint256 _value; // default: 0\n }\n\n function current(Counter storage counter) internal view returns (uint256) {\n return counter._value;\n }\n\n function increment(Counter storage counter) internal {\n unchecked {\n counter._value += 1;\n }\n }\n\n function decrement(Counter storage counter) internal {\n uint256 value = counter._value;\n require(value > 0, \"Counter: decrement overflow\");\n unchecked {\n counter._value = value - 1;\n }\n }\n\n function reset(Counter storage counter) internal {\n counter._value = 0;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712 {\n /* solhint-disable var-name-mixedcase */\n // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to\n // invalidate the cached domain separator if the chain id changes.\n bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;\n uint256 private immutable _CACHED_CHAIN_ID;\n address private immutable _CACHED_THIS;\n\n bytes32 private immutable _HASHED_NAME;\n bytes32 private immutable _HASHED_VERSION;\n bytes32 private immutable _TYPE_HASH;\n\n /* solhint-enable var-name-mixedcase */\n\n /**\n * @dev Initializes the domain separator and parameter caches.\n *\n * The meaning of `name` and `version` is specified in\n * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n *\n * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n * - `version`: the current major version of the signing domain.\n *\n * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n * contract upgrade].\n */\n constructor(string memory name, string memory version) {\n bytes32 hashedName = keccak256(bytes(name));\n bytes32 hashedVersion = keccak256(bytes(version));\n bytes32 typeHash = keccak256(\n \"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"\n );\n _HASHED_NAME = hashedName;\n _HASHED_VERSION = hashedVersion;\n _CACHED_CHAIN_ID = block.chainid;\n _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);\n _CACHED_THIS = address(this);\n _TYPE_HASH = typeHash;\n }\n\n /**\n * @dev Returns the domain separator for the current chain.\n */\n function _domainSeparatorV4() internal view returns (bytes32) {\n if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {\n return _CACHED_DOMAIN_SEPARATOR;\n } else {\n return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);\n }\n }\n\n function _buildDomainSeparator(\n bytes32 typeHash,\n bytes32 nameHash,\n bytes32 versionHash\n ) private view returns (bytes32) {\n return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));\n }\n\n /**\n * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n * function returns the hash of the fully encoded EIP712 message for this domain.\n *\n * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n *\n * ```solidity\n * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n * keccak256(\"Mail(address to,string contents)\"),\n * mailTo,\n * keccak256(bytes(mailContents))\n * )));\n * address signer = ECDSA.recover(digest, signature);\n * ```\n */\n function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS,\n InvalidSignatureV\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n } else if (error == RecoverError.InvalidSignatureV) {\n revert(\"ECDSA: invalid signature 'v' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n *\n * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n // Check the signature length\n // - case 65: r,s,v signature (standard)\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else if (signature.length == 64) {\n bytes32 r;\n bytes32 vs;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n assembly {\n r := mload(add(signature, 0x20))\n vs := mload(add(signature, 0x40))\n }\n return tryRecover(hash, r, vs);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength);\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n *\n * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS);\n }\n if (v != 27 && v != 28) {\n return (address(0), RecoverError.InvalidSignatureV);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/ERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n" + }, + "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n" + }, + "contracts/circle-usdc/CircleBridgeProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"./FeeOperator.sol\";\nimport \"../interfaces/ICircleBridge.sol\";\nimport \"../safeguard/Governor.sol\";\nimport \"../safeguard/Pauser.sol\";\n\ncontract CircleBridgeProxy is FeeOperator, Governor, Pauser, ReentrancyGuard {\n using SafeERC20 for IERC20;\n\n address public immutable circleBridge;\n\n uint32 public feePercGlobal; //in 1e6\n // chainId => feePercOverride, support override fee perc by dst chain\n mapping(uint64 => uint32) public feePercOverride;\n /// per dest chain id executor fee in this chain's USDC token\n mapping(uint64 => uint256) public dstTxFee;\n\n // 0 is regarded as not registered. Set to a negative value if target domain is actually 0.\n mapping(uint64 => int32) public chidToDomain;\n\n event FeePercUpdated(uint64[] chainIds, uint32[] feePercs);\n event TxFeeUpdated(uint64[] chainIds, uint256[] fees);\n event ChidToDomainUpdated(uint64[] chainIds, int32[] domains);\n event Deposited(\n address sender,\n bytes32 recipient,\n uint64 dstChid,\n uint256 amount,\n uint256 txFee,\n uint256 percFee,\n uint64 nonce\n );\n\n constructor(address _circleBridge, address _feeCollector) FeeOperator(_feeCollector) {\n circleBridge = _circleBridge;\n }\n\n function depositForBurn(\n uint256 _amount,\n uint64 _dstChid,\n bytes32 _mintRecipient,\n address _burnToken\n ) external nonReentrant whenNotPaused returns (uint64 _nonce) {\n int32 dstDomain = chidToDomain[_dstChid];\n require(dstDomain != 0, \"dst domain not registered\");\n if (dstDomain < 0) {\n dstDomain = 0; // a negative value indicates the target domain is 0 actually.\n }\n (uint256 fee, uint256 txFee, uint256 percFee) = totalFee(_amount, _dstChid);\n require(_amount > fee, \"fee not covered\");\n\n IERC20(_burnToken).safeTransferFrom(msg.sender, address(this), _amount);\n uint256 bridgeAmt = _amount - fee;\n IERC20(_burnToken).safeIncreaseAllowance(circleBridge, bridgeAmt);\n _nonce = ICircleBridge(circleBridge).depositForBurn(bridgeAmt, uint32(dstDomain), _mintRecipient, _burnToken);\n IERC20(_burnToken).safeApprove(circleBridge, 0);\n emit Deposited(msg.sender, _mintRecipient, _dstChid, _amount, txFee, percFee, _nonce);\n }\n\n function totalFee(uint256 _amount, uint64 _dstChid)\n public\n view\n returns (\n uint256 _fee,\n uint256 _txFee,\n uint256 _percFee\n )\n {\n uint32 feePerc = feePercOverride[_dstChid];\n if (feePerc == 0) {\n feePerc = feePercGlobal;\n }\n _txFee = dstTxFee[_dstChid];\n _percFee = (_amount * feePerc) / 1e6;\n _fee = _txFee + _percFee;\n }\n\n function setFeePerc(uint64[] calldata _chainIds, uint32[] calldata _feePercs) external onlyGovernor {\n require(_chainIds.length == _feePercs.length, \"length mismatch\");\n for (uint256 i = 0; i < _chainIds.length; i++) {\n require(_feePercs[i] < 1e6, \"fee percentage too large\");\n if (_chainIds[i] == 0) {\n feePercGlobal = _feePercs[i];\n } else {\n feePercOverride[_chainIds[i]] = _feePercs[i];\n }\n }\n emit FeePercUpdated(_chainIds, _feePercs);\n }\n\n function setTxFee(uint64[] calldata _chainIds, uint256[] calldata _fees) external onlyGovernor {\n require(_chainIds.length == _fees.length, \"length mismatch\");\n for (uint256 i = 0; i < _chainIds.length; i++) {\n dstTxFee[_chainIds[i]] = _fees[i];\n }\n emit TxFeeUpdated(_chainIds, _fees);\n }\n\n function setChidToDomain(uint64[] calldata _chainIds, int32[] calldata _domains) external onlyGovernor {\n require(_chainIds.length == _domains.length, \"length mismatch\");\n for (uint256 i = 0; i < _chainIds.length; i++) {\n chidToDomain[_chainIds[i]] = _domains[i];\n }\n emit ChidToDomainUpdated(_chainIds, _domains);\n }\n}\n" + }, + "contracts/circle-usdc/FeeOperator.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../safeguard/Ownable.sol\";\n\nabstract contract FeeOperator is Ownable {\n using SafeERC20 for IERC20;\n\n address public feeCollector;\n\n event FeeCollectorUpdated(address from, address to);\n\n modifier onlyFeeCollector() {\n require(msg.sender == feeCollector, \"not fee collector\");\n _;\n }\n\n constructor(address _feeCollector) {\n feeCollector = _feeCollector;\n }\n\n function collectFee(address[] calldata _tokens, address _to) external onlyFeeCollector {\n for (uint256 i = 0; i < _tokens.length; i++) {\n // use zero address to denote native token\n if (_tokens[i] == address(0)) {\n uint256 bal = address(this).balance;\n (bool sent, ) = _to.call{value: bal, gas: 50000}(\"\");\n require(sent, \"send native failed\");\n } else {\n uint256 balance = IERC20(_tokens[i]).balanceOf(address(this));\n IERC20(_tokens[i]).safeTransfer(_to, balance);\n }\n }\n }\n\n function setFeeCollector(address _feeCollector) external onlyOwner {\n address oldFeeCollector = feeCollector;\n feeCollector = _feeCollector;\n emit FeeCollectorUpdated(oldFeeCollector, _feeCollector);\n }\n}\n" + }, + "contracts/governed-owner/customized/MessageBusOwner.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"../../libraries/Utils.sol\";\nimport \"../interfaces/IMessageOwner.sol\";\n\n// only allow set MsgFee and PreExecuteMessageGasUsage\n// disable contract upgrade or token bridge address updates\ncontract MessageBusOwner {\n uint256 public constant THRESHOLD_DECIMAL = 100;\n uint256 public constant MIN_ACTIVE_PERIOD = 3600; // one hour\n uint256 public constant MAX_ACTIVE_PERIOD = 2419200; // four weeks\n\n enum ParamName {\n ActivePeriod,\n QuorumThreshold // threshold for votes to pass\n }\n\n enum ProposalType {\n External,\n InternalParamChange,\n InternalVoterUpdate\n }\n\n enum MsgFeeType {\n PerByte,\n Base\n }\n\n mapping(ParamName => uint256) public params;\n\n struct Proposal {\n bytes32 dataHash; // hash(proposalType, targetAddress, calldata)\n uint256 deadline;\n mapping(address => bool) votes;\n }\n\n mapping(uint256 => Proposal) public proposals;\n uint256 public nextProposalId;\n\n address[] public voters;\n mapping(address => uint256) public voterPowers; // voter addr -> voting power\n\n event Initiated(address[] voters, uint256[] powers, uint256 activePeriod, uint256 quorumThreshold);\n\n event ProposalCreated(\n uint256 proposalId,\n ProposalType proposalType,\n address target,\n bytes data,\n uint256 deadline,\n address proposer\n );\n event ParamChangeProposalCreated(uint256 proposalId, ParamName name, uint256 value);\n event VoterUpdateProposalCreated(uint256 proposalId, address[] voters, uint256[] powers);\n event SetMsgFeeProposalCreated(uint256 proposalId, address target, MsgFeeType feeType, uint256 fee);\n event SetPreExecuteMessageGasUsageProposalCreated(uint256 proposalId, address target, uint256 usage);\n\n event ProposalVoted(uint256 proposalId, address voter, bool vote);\n event ProposalExecuted(uint256 proposalId);\n\n constructor(\n address[] memory _voters,\n uint256[] memory _powers,\n uint256 _activePeriod,\n uint256 _quorumThreshold\n ) {\n require(_voters.length > 0 && _voters.length == _powers.length, \"invalid init voters\");\n require(_activePeriod <= MAX_ACTIVE_PERIOD && _activePeriod >= MIN_ACTIVE_PERIOD, \"invalid active period\");\n require(_quorumThreshold < THRESHOLD_DECIMAL, \"invalid init thresholds\");\n for (uint256 i = 0; i < _voters.length; i++) {\n _setVoter(_voters[i], _powers[i]);\n }\n params[ParamName.ActivePeriod] = _activePeriod;\n params[ParamName.QuorumThreshold] = _quorumThreshold;\n emit Initiated(_voters, _powers, _activePeriod, _quorumThreshold);\n }\n\n /*********************************\n * External and Public Functions *\n *********************************/\n\n function proposeParamChange(ParamName _name, uint256 _value) external returns (uint256) {\n bytes memory data = abi.encode(_name, _value);\n uint256 proposalId = _createProposal(msg.sender, address(0), data, ProposalType.InternalParamChange);\n emit ParamChangeProposalCreated(proposalId, _name, _value);\n return proposalId;\n }\n\n function proposeVoterUpdate(address[] calldata _voters, uint256[] calldata _powers) external returns (uint256) {\n require(_voters.length == _powers.length, \"voters and powers length not match\");\n bytes memory data = abi.encode(_voters, _powers);\n uint256 proposalId = _createProposal(msg.sender, address(0), data, ProposalType.InternalVoterUpdate);\n emit VoterUpdateProposalCreated(proposalId, _voters, _powers);\n return proposalId;\n }\n\n function proposeSetMsgFee(\n address _target,\n MsgFeeType _feeType,\n uint256 _fee\n ) external returns (uint256) {\n bytes4 selector;\n if (_feeType == MsgFeeType.PerByte) {\n selector = IMessageOwner.setFeePerByte.selector;\n } else if (_feeType == MsgFeeType.Base) {\n selector = IMessageOwner.setFeeBase.selector;\n } else {\n revert(\"invalid fee type\");\n }\n bytes memory data = abi.encodeWithSelector(selector, _fee);\n uint256 proposalId = _createProposal(msg.sender, _target, data, ProposalType.External);\n emit SetMsgFeeProposalCreated(proposalId, _target, _feeType, _fee);\n return proposalId;\n }\n\n function proposeSetPreExecuteMessageGasUsage(address _target, uint256 _usage) external {\n bytes memory data = abi.encodeWithSelector(IMessageOwner.setPreExecuteMessageGasUsage.selector, _usage);\n uint256 proposalId = _createProposal(msg.sender, _target, data, ProposalType.External);\n emit SetPreExecuteMessageGasUsageProposalCreated(proposalId, _target, _usage);\n }\n\n function voteProposal(uint256 _proposalId, bool _vote) external {\n require(voterPowers[msg.sender] > 0, \"invalid voter\");\n Proposal storage p = proposals[_proposalId];\n require(block.timestamp < p.deadline, \"deadline passed\");\n p.votes[msg.sender] = _vote;\n emit ProposalVoted(_proposalId, msg.sender, _vote);\n }\n\n function executeProposal(\n uint256 _proposalId,\n ProposalType _type,\n address _target,\n bytes calldata _data\n ) external {\n require(voterPowers[msg.sender] > 0, \"only voter can execute a proposal\");\n Proposal storage p = proposals[_proposalId];\n require(block.timestamp < p.deadline, \"deadline passed\");\n require(keccak256(abi.encodePacked(_type, _target, _data)) == p.dataHash, \"data hash not match\");\n p.deadline = 0;\n\n p.votes[msg.sender] = true;\n (, , bool pass) = countVotes(_proposalId);\n require(pass, \"not enough votes\");\n\n if (_type == ProposalType.External) {\n (bool success, bytes memory res) = _target.call(_data);\n require(success, Utils.getRevertMsg(res));\n } else if (_type == ProposalType.InternalParamChange) {\n (ParamName name, uint256 value) = abi.decode((_data), (ParamName, uint256));\n params[name] = value;\n if (name == ParamName.ActivePeriod) {\n require(value <= MAX_ACTIVE_PERIOD && value >= MIN_ACTIVE_PERIOD, \"invalid active period\");\n } else if (name == ParamName.QuorumThreshold) {\n require(value < THRESHOLD_DECIMAL && value > 0, \"invalid threshold\");\n }\n } else if (_type == ProposalType.InternalVoterUpdate) {\n (address[] memory addrs, uint256[] memory powers) = abi.decode((_data), (address[], uint256[]));\n for (uint256 i = 0; i < addrs.length; i++) {\n if (powers[i] > 0) {\n _setVoter(addrs[i], powers[i]);\n } else {\n _removeVoter(addrs[i]);\n }\n }\n }\n emit ProposalExecuted(_proposalId);\n }\n\n /**************************\n * Public View Functions *\n **************************/\n\n function getVoters() public view returns (address[] memory, uint256[] memory) {\n address[] memory addrs = new address[](voters.length);\n uint256[] memory powers = new uint256[](voters.length);\n for (uint32 i = 0; i < voters.length; i++) {\n addrs[i] = voters[i];\n powers[i] = voterPowers[voters[i]];\n }\n return (addrs, powers);\n }\n\n function getVote(uint256 _proposalId, address _voter) public view returns (bool) {\n return proposals[_proposalId].votes[_voter];\n }\n\n function countVotes(uint256 _proposalId)\n public\n view\n returns (\n uint256,\n uint256,\n bool\n )\n {\n uint256 yesVotes;\n uint256 totalPower;\n for (uint32 i = 0; i < voters.length; i++) {\n if (getVote(_proposalId, voters[i])) {\n yesVotes += voterPowers[voters[i]];\n }\n totalPower += voterPowers[voters[i]];\n }\n uint256 threshold = params[ParamName.QuorumThreshold];\n bool pass = (yesVotes >= (totalPower * threshold) / THRESHOLD_DECIMAL);\n return (totalPower, yesVotes, pass);\n }\n\n /**********************************\n * Internal and Private Functions *\n **********************************/\n\n // create a proposal and vote yes\n function _createProposal(\n address _proposer,\n address _target,\n bytes memory _data,\n ProposalType _type\n ) private returns (uint256) {\n require(voterPowers[_proposer] > 0, \"only voter can create a proposal\");\n uint256 proposalId = nextProposalId;\n nextProposalId += 1;\n Proposal storage p = proposals[proposalId];\n p.dataHash = keccak256(abi.encodePacked(_type, _target, _data));\n p.deadline = block.timestamp + params[ParamName.ActivePeriod];\n p.votes[_proposer] = true;\n emit ProposalCreated(proposalId, _type, _target, _data, p.deadline, _proposer);\n return proposalId;\n }\n\n function _setVoter(address _voter, uint256 _power) private {\n require(_power > 0, \"zero power\");\n if (voterPowers[_voter] == 0) {\n // add new voter\n voters.push(_voter);\n }\n voterPowers[_voter] = _power;\n }\n\n function _removeVoter(address _voter) private {\n require(voterPowers[_voter] > 0, \"not a voter\");\n uint256 lastIndex = voters.length - 1;\n for (uint256 i = 0; i < voters.length; i++) {\n if (voters[i] == _voter) {\n if (i < lastIndex) {\n voters[i] = voters[lastIndex];\n }\n voters.pop();\n voterPowers[_voter] = 0;\n return;\n }\n }\n revert(\"voter not found\"); // this should never happen\n }\n}\n" + }, + "contracts/governed-owner/GovernedOwnerProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./proxies/CommonOwnerProxy.sol\";\nimport \"./proxies/BridgeOwnerProxy.sol\";\nimport \"./proxies/MessageOwnerProxy.sol\";\nimport \"./proxies/SgnOwnerProxy.sol\";\nimport \"./proxies/UpgradeableOwnerProxy.sol\";\n\ncontract GovernedOwnerProxy is\n CommonOwnerProxy,\n BridgeOwnerProxy,\n MessageOwnerProxy,\n SgnOwnerProxy,\n UpgradeableOwnerProxy\n{\n constructor(address _initializer) OwnerProxyBase(_initializer) {}\n}\n" + }, + "contracts/governed-owner/interfaces/IBridgeOwner.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IBridgeOwner {\n // for bridges\n\n function resetSigners(address[] calldata _signers, uint256[] calldata _powers) external;\n\n function notifyResetSigners() external;\n\n function increaseNoticePeriod(uint256 _period) external;\n\n function setWrap(address _token) external;\n\n function setSupply(address _token, uint256 _supply) external;\n\n function increaseSupply(address _token, uint256 _delta) external;\n\n function decreaseSupply(address _token, uint256 _delta) external;\n\n function addGovernor(address _account) external;\n\n function removeGovernor(address _account) external;\n\n // for bridge tokens\n\n function updateBridge(address _bridge) external;\n\n function updateBridgeSupplyCap(address _bridge, uint256 _cap) external;\n\n function setBridgeTokenSwapCap(address _bridgeToken, uint256 _swapCap) external;\n}\n" + }, + "contracts/governed-owner/interfaces/ICommonOwner.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface ICommonOwner {\n function transferOwnership(address _newOwner) external;\n\n function addPauser(address _account) external;\n\n function removePauser(address _account) external;\n}\n" + }, + "contracts/governed-owner/interfaces/IMessageOwner.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IMessageOwner {\n function setFeePerByte(uint256 _fee) external;\n\n function setFeeBase(uint256 _fee) external;\n\n function setLiquidityBridge(address _addr) external;\n\n function setPegBridge(address _addr) external;\n\n function setPegVault(address _addr) external;\n\n function setPegBridgeV2(address _addr) external;\n\n function setPegVaultV2(address _addr) external;\n\n function setPreExecuteMessageGasUsage(uint256 _usage) external;\n}\n" + }, + "contracts/governed-owner/interfaces/ISgnOwner.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface ISgnOwner {\n function setWhitelistEnabled(bool _whitelistEnabled) external;\n\n function addWhitelisted(address _account) external;\n\n function removeWhitelisted(address _account) external;\n\n function setGovContract(address _addr) external;\n\n function setRewardContract(address _addr) external;\n\n function setMaxSlashFactor(uint256 _maxSlashFactor) external;\n}\n" + }, + "contracts/governed-owner/interfaces/IUpgradeableOwner.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IUpgradeableOwner {\n function changeProxyAdmin(address _proxy, address _newAdmin) external;\n\n function upgrade(address _proxy, address _implementation) external;\n\n function upgradeAndCall(\n address _proxy,\n address _implementation,\n bytes calldata _data\n ) external;\n\n function upgradeTo(address _implementation) external;\n\n function upgradeToAndCall(address _implementation, bytes calldata _data) external;\n}\n" + }, + "contracts/governed-owner/proxies/BridgeOwnerProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./OwnerProxyBase.sol\";\nimport \"../interfaces/IBridgeOwner.sol\";\nimport {SimpleGovernance as sg} from \"../SimpleGovernance.sol\";\nimport {OwnerDataTypes as dt} from \"./OwnerDataTypes.sol\";\n\nabstract contract BridgeOwnerProxy is OwnerProxyBase {\n // for bridges\n event ResetSignersProposalCreated(uint256 proposalId, address target, address[] signers, uint256[] powers);\n event NotifyResetSignersProposalCreated(uint256 proposalId, address target);\n event IncreaseNoticePeriodProposalCreated(uint256 proposalId, address target, uint256 period);\n event SetNativeWrapProposalCreated(uint256 proposalId, address target, address token);\n event UpdateSupplyProposalCreated(\n uint256 proposalId,\n address target,\n dt.Action action,\n address token,\n uint256 supply\n );\n event UpdateGovernorProposalCreated(uint256 proposalId, address target, dt.Action action, address account);\n\n // for bridge tokens\n event UpdateBridgeProposalCreated(uint256 proposalId, address target, address bridgeAddr);\n event UpdateBridgeSupplyCapProposalCreated(uint256 proposalId, address target, address bridge, uint256 cap);\n event SetBridgeTokenSwapCapProposalCreated(uint256 proposalId, address target, address bridgeToken, uint256 cap);\n\n function proposeResetSigners(\n address _target,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external {\n bytes memory data = abi.encodeWithSelector(IBridgeOwner.resetSigners.selector, _signers, _powers);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit ResetSignersProposalCreated(proposalId, _target, _signers, _powers);\n }\n\n function proposeNotifyResetSigners(address _target) external {\n bytes memory data = abi.encodeWithSelector(IBridgeOwner.notifyResetSigners.selector);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalFastPass);\n emit NotifyResetSignersProposalCreated(proposalId, _target);\n }\n\n function proposeIncreaseNoticePeriod(address _target, uint256 _period) external {\n bytes memory data = abi.encodeWithSelector(IBridgeOwner.increaseNoticePeriod.selector, _period);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit IncreaseNoticePeriodProposalCreated(proposalId, _target, _period);\n }\n\n function proposeSetNativeWrap(address _target, address _token) external {\n bytes memory data = abi.encodeWithSelector(IBridgeOwner.setWrap.selector, _token);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit SetNativeWrapProposalCreated(proposalId, _target, _token);\n }\n\n function proposeUpdateSupply(\n address _target,\n dt.Action _action,\n address _token,\n uint256 _supply\n ) external {\n bytes4 selector;\n if (_action == dt.Action.Set) {\n selector = IBridgeOwner.setSupply.selector;\n } else if (_action == dt.Action.Add) {\n selector = IBridgeOwner.increaseSupply.selector;\n } else if (_action == dt.Action.Remove) {\n selector = IBridgeOwner.decreaseSupply.selector;\n } else {\n revert(\"invalid action\");\n }\n bytes memory data = abi.encodeWithSelector(selector, _token, _supply);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalFastPass);\n emit UpdateSupplyProposalCreated(proposalId, _target, _action, _token, _supply);\n }\n\n function proposeUpdateGovernor(\n address _target,\n dt.Action _action,\n address _account\n ) external {\n bytes4 selector;\n if (_action == dt.Action.Add) {\n selector = IBridgeOwner.addGovernor.selector;\n } else if (_action == dt.Action.Remove) {\n selector = IBridgeOwner.removeGovernor.selector;\n } else {\n revert(\"invalid action\");\n }\n bytes memory data = abi.encodeWithSelector(selector, _account);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalFastPass);\n emit UpdateGovernorProposalCreated(proposalId, _target, _action, _account);\n }\n\n function proposeUpdateBridgeSupplyCap(\n address _target,\n address _bridge,\n uint256 _cap\n ) external {\n bytes memory data = abi.encodeWithSelector(IBridgeOwner.updateBridgeSupplyCap.selector, _bridge, _cap);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit UpdateBridgeSupplyCapProposalCreated(proposalId, _target, _bridge, _cap);\n }\n\n function proposeSetBridgeTokenSwapCap(\n address _target,\n address _bridgeToken,\n uint256 _swapCap\n ) external {\n bytes memory data = abi.encodeWithSelector(IBridgeOwner.setBridgeTokenSwapCap.selector, _bridgeToken, _swapCap);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit SetBridgeTokenSwapCapProposalCreated(proposalId, _target, _bridgeToken, _swapCap);\n }\n}\n" + }, + "contracts/governed-owner/proxies/CommonOwnerProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./OwnerProxyBase.sol\";\nimport \"../interfaces/ICommonOwner.sol\";\nimport {SimpleGovernance as sg} from \"../SimpleGovernance.sol\";\nimport {OwnerDataTypes as dt} from \"./OwnerDataTypes.sol\";\n\nabstract contract CommonOwnerProxy is OwnerProxyBase {\n event TransferOwnershipProposalCreated(uint256 proposalId, address target, address newOwner);\n event UpdatePauserProposalCreated(uint256 proposalId, address target, dt.Action action, address account);\n\n function proposeTransferOwnership(address _target, address _newOwner) external {\n bytes memory data = abi.encodeWithSelector(ICommonOwner.transferOwnership.selector, _newOwner);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit TransferOwnershipProposalCreated(proposalId, _target, _newOwner);\n }\n\n function proposeUpdatePauser(\n address _target,\n dt.Action _action,\n address _account\n ) external {\n bytes4 selector;\n if (_action == dt.Action.Add) {\n selector = ICommonOwner.addPauser.selector;\n } else if (_action == dt.Action.Remove) {\n selector = ICommonOwner.removePauser.selector;\n } else {\n revert(\"invalid action\");\n }\n bytes memory data = abi.encodeWithSelector(selector, _account);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalFastPass);\n emit UpdatePauserProposalCreated(proposalId, _target, _action, _account);\n }\n}\n" + }, + "contracts/governed-owner/proxies/MessageOwnerProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./OwnerProxyBase.sol\";\nimport \"../interfaces/IMessageOwner.sol\";\nimport {SimpleGovernance as sg} from \"../SimpleGovernance.sol\";\nimport {OwnerDataTypes as dt} from \"./OwnerDataTypes.sol\";\n\nabstract contract MessageOwnerProxy is OwnerProxyBase {\n event SetMsgFeeProposalCreated(uint256 proposalId, address target, dt.MsgFeeType feeType, uint256 fee);\n event SetBridgeAddressProposalCreated(\n uint256 proposalId,\n address target,\n dt.BridgeType bridgeType,\n address bridgeAddr\n );\n event SetPreExecuteMessageGasUsageProposalCreated(uint256 proposalId, address target, uint256 usage);\n\n function proposeSetMsgFee(\n address _target,\n dt.MsgFeeType _feeType,\n uint256 _fee\n ) external {\n bytes4 selector;\n if (_feeType == dt.MsgFeeType.PerByte) {\n selector = IMessageOwner.setFeePerByte.selector;\n } else if (_feeType == dt.MsgFeeType.Base) {\n selector = IMessageOwner.setFeeBase.selector;\n } else {\n revert(\"invalid fee type\");\n }\n bytes memory data = abi.encodeWithSelector(selector, _fee);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalFastPass);\n emit SetMsgFeeProposalCreated(proposalId, _target, _feeType, _fee);\n }\n\n function proposeSetBridgeAddress(\n address _target,\n dt.BridgeType _bridgeType,\n address _bridgeAddr\n ) external {\n bytes4 selector;\n if (_bridgeType == dt.BridgeType.Liquidity) {\n selector = IMessageOwner.setLiquidityBridge.selector;\n } else if (_bridgeType == dt.BridgeType.PegBridge) {\n selector = IMessageOwner.setPegBridge.selector;\n } else if (_bridgeType == dt.BridgeType.PegVault) {\n selector = IMessageOwner.setPegVault.selector;\n } else if (_bridgeType == dt.BridgeType.PegBridgeV2) {\n selector = IMessageOwner.setPegBridgeV2.selector;\n } else if (_bridgeType == dt.BridgeType.PegVaultV2) {\n selector = IMessageOwner.setPegVaultV2.selector;\n } else {\n revert(\"invalid bridge type\");\n }\n bytes memory data = abi.encodeWithSelector(selector, _bridgeAddr);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit SetBridgeAddressProposalCreated(proposalId, _target, _bridgeType, _bridgeAddr);\n }\n\n function proposeSetPreExecuteMessageGasUsage(address _target, uint256 _usage) external {\n bytes memory data = abi.encodeWithSelector(IMessageOwner.setPreExecuteMessageGasUsage.selector, _usage);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit SetPreExecuteMessageGasUsageProposalCreated(proposalId, _target, _usage);\n }\n}\n" + }, + "contracts/governed-owner/proxies/OwnerDataTypes.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nlibrary OwnerDataTypes {\n enum Action {\n Set,\n Add,\n Remove\n }\n\n enum MsgFeeType {\n PerByte,\n Base\n }\n\n enum BridgeType {\n Liquidity,\n PegBridge,\n PegVault,\n PegBridgeV2,\n PegVaultV2\n }\n}\n" + }, + "contracts/governed-owner/proxies/OwnerProxyBase.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"../SimpleGovernance.sol\";\n\nabstract contract OwnerProxyBase {\n SimpleGovernance public gov;\n address private initializer;\n\n constructor(address _initializer) {\n initializer = _initializer;\n }\n\n function initGov(SimpleGovernance _gov) public {\n require(msg.sender == initializer, \"only initializer can init\");\n require(address(gov) == address(0), \"gov addr already set\");\n gov = _gov;\n }\n}\n" + }, + "contracts/governed-owner/proxies/SgnOwnerProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./OwnerProxyBase.sol\";\nimport \"../interfaces/ISgnOwner.sol\";\nimport {SimpleGovernance as sg} from \"../SimpleGovernance.sol\";\nimport {OwnerDataTypes as dt} from \"./OwnerDataTypes.sol\";\n\nabstract contract SgnOwnerProxy is OwnerProxyBase {\n event SetWhitelistEnableProposalCreated(uint256 proposalId, address target, bool enabled);\n event UpdateWhitelistedProposalCreated(uint256 proposalId, address target, dt.Action action, address account);\n event SetGovContractProposalCreated(uint256 proposalId, address target, address addr);\n event SetRewardContractProposalCreated(uint256 proposalId, address target, address addr);\n event SetMaxSlashFactorProposalCreated(uint256 proposalId, address target, uint256 maxSlashFactor);\n event DrainTokenProposalCreated(uint256 proposalId, address target, address token, uint256 amount);\n\n function proposeSetWhitelistEnable(address _target, bool _enable) external {\n bytes memory data = abi.encodeWithSelector(ISgnOwner.setWhitelistEnabled.selector, _enable);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit SetWhitelistEnableProposalCreated(proposalId, _target, _enable);\n }\n\n function proposeUpdateWhitelisted(\n address _target,\n dt.Action _action,\n address _account\n ) external {\n bytes4 selector;\n if (_action == dt.Action.Add) {\n selector = ISgnOwner.addWhitelisted.selector;\n } else if (_action == dt.Action.Remove) {\n selector = ISgnOwner.removeWhitelisted.selector;\n } else {\n revert(\"invalid action\");\n }\n bytes memory data = abi.encodeWithSelector(selector, _account);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalFastPass);\n emit UpdateWhitelistedProposalCreated(proposalId, _target, _action, _account);\n }\n\n function proposeSetGovContract(address _target, address _addr) external {\n bytes memory data = abi.encodeWithSelector(ISgnOwner.setGovContract.selector, _addr);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit SetGovContractProposalCreated(proposalId, _target, _addr);\n }\n\n function proposeSetRewardContract(address _target, address _addr) external {\n bytes memory data = abi.encodeWithSelector(ISgnOwner.setRewardContract.selector, _addr);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit SetRewardContractProposalCreated(proposalId, _target, _addr);\n }\n\n function proposeSetMaxSlashFactor(address _target, uint256 _maxSlashFactor) external {\n bytes memory data = abi.encodeWithSelector(ISgnOwner.setMaxSlashFactor.selector, _maxSlashFactor);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit SetMaxSlashFactorProposalCreated(proposalId, _target, _maxSlashFactor);\n }\n\n function proposeDrainToken(\n address _target,\n address _token,\n uint256 _amount\n ) external {\n bytes memory data;\n if (_token == address(0)) {\n data = abi.encodeWithSelector(bytes4(keccak256(bytes(\"drainToken(uint256\"))), _amount);\n } else {\n data = abi.encodeWithSelector(bytes4(keccak256(bytes(\"drainToken(address,uint256\"))), _token, _amount);\n }\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit DrainTokenProposalCreated(proposalId, _target, _token, _amount);\n }\n}\n" + }, + "contracts/governed-owner/proxies/UpgradeableOwnerProxy.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./OwnerProxyBase.sol\";\nimport \"../interfaces/IUpgradeableOwner.sol\";\nimport {SimpleGovernance as sg} from \"../SimpleGovernance.sol\";\nimport {OwnerDataTypes as dt} from \"./OwnerDataTypes.sol\";\n\nabstract contract UpgradeableOwnerProxy is OwnerProxyBase {\n event ChangeProxyAdminProposalCreated(uint256 proposalId, address target, address proxy, address newAdmin);\n event UpgradeProposalCreated(uint256 proposalId, address target, address proxy, address implementation);\n event UpgradeAndCallProposalCreated(\n uint256 proposalId,\n address target,\n address proxy,\n address implementation,\n bytes data\n );\n event UpgradeToProposalCreated(uint256 proposalId, address target, address implementation);\n event UpgradeToAndCallProposalCreated(uint256 proposalId, address target, address implementation, bytes data);\n\n function proposeChangeProxyAdmin(\n address _target,\n address _proxy,\n address _newAdmin\n ) external {\n bytes memory data = abi.encodeWithSelector(IUpgradeableOwner.changeProxyAdmin.selector, _proxy, _newAdmin);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit ChangeProxyAdminProposalCreated(proposalId, _target, _proxy, _newAdmin);\n }\n\n function proposeUpgrade(\n address _target,\n address _proxy,\n address _implementation\n ) external {\n bytes memory data = abi.encodeWithSelector(IUpgradeableOwner.upgrade.selector, _proxy, _implementation);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit UpgradeProposalCreated(proposalId, _target, _proxy, _implementation);\n }\n\n function proposeUpgradeAndCall(\n address _target,\n address _proxy,\n address _implementation,\n bytes calldata _data\n ) external {\n bytes memory data = abi.encodeWithSelector(\n IUpgradeableOwner.upgradeAndCall.selector,\n _proxy,\n _implementation,\n _data\n );\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit UpgradeAndCallProposalCreated(proposalId, _target, _proxy, _implementation, _data);\n }\n\n function proposeUpgradeTo(address _target, address _implementation) external {\n bytes memory data = abi.encodeWithSelector(IUpgradeableOwner.upgradeTo.selector, _implementation);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit UpgradeToProposalCreated(proposalId, _target, _implementation);\n }\n\n function proposeUpgradeToAndCall(\n address _target,\n address _implementation,\n bytes calldata _data\n ) external {\n bytes memory data = abi.encodeWithSelector(IUpgradeableOwner.upgradeToAndCall.selector, _implementation, _data);\n uint256 proposalId = gov.createProposal(msg.sender, _target, data, sg.ProposalType.ExternalDefault);\n emit UpgradeToAndCallProposalCreated(proposalId, _target, _implementation, _data);\n }\n}\n" + }, + "contracts/governed-owner/SimpleGovernance.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../libraries/Utils.sol\";\n\n// mainly used for governed-owner to do infrequent sgn/cbridge owner operations,\n// relatively prefer easy-to-use over gas-efficiency\ncontract SimpleGovernance {\n uint256 public constant THRESHOLD_DECIMAL = 100;\n uint256 public constant MIN_ACTIVE_PERIOD = 3600; // one hour\n uint256 public constant MAX_ACTIVE_PERIOD = 2419200; // four weeks\n\n using SafeERC20 for IERC20;\n\n enum ParamName {\n ActivePeriod,\n QuorumThreshold, // default threshold for votes to pass\n FastPassThreshold // lower threshold for less critical operations\n }\n\n enum ProposalType {\n ExternalDefault,\n ExternalFastPass,\n InternalParamChange,\n InternalVoterUpdate,\n InternalProxyUpdate,\n InternalTransferToken\n }\n\n mapping(ParamName => uint256) public params;\n\n struct Proposal {\n bytes32 dataHash; // hash(proposalType, targetAddress, calldata)\n uint256 deadline;\n mapping(address => bool) votes;\n }\n\n mapping(uint256 => Proposal) public proposals;\n uint256 public nextProposalId;\n\n address[] public voters;\n mapping(address => uint256) public voterPowers; // voter addr -> voting power\n\n // NOTE: proxies must be audited open-source non-upgradable contracts with following requirements:\n // 1. Truthfully pass along tx sender who called the proxy function as the governance proposer.\n // 2. Do not allow arbitrary fastpass proposal with calldata constructed by the proxy callers.\n // See ./proxies/CommonOwnerProxy.sol for example.\n mapping(address => bool) public proposerProxies;\n\n event Initiated(\n address[] voters,\n uint256[] powers,\n address[] proxies,\n uint256 activePeriod,\n uint256 quorumThreshold,\n uint256 fastPassThreshold\n );\n\n event ProposalCreated(\n uint256 proposalId,\n ProposalType proposalType,\n address target,\n bytes data,\n uint256 deadline,\n address proposer\n );\n event ProposalVoted(uint256 proposalId, address voter, bool vote);\n event ProposalExecuted(uint256 proposalId);\n\n event ParamChangeProposalCreated(uint256 proposalId, ParamName name, uint256 value);\n event VoterUpdateProposalCreated(uint256 proposalId, address[] voters, uint256[] powers);\n event ProxyUpdateProposalCreated(uint256 proposalId, address[] addrs, bool[] ops);\n event TransferTokenProposalCreated(uint256 proposalId, address receiver, address token, uint256 amount);\n\n constructor(\n address[] memory _voters,\n uint256[] memory _powers,\n address[] memory _proxies,\n uint256 _activePeriod,\n uint256 _quorumThreshold,\n uint256 _fastPassThreshold\n ) {\n require(_voters.length > 0 && _voters.length == _powers.length, \"invalid init voters\");\n require(_activePeriod <= MAX_ACTIVE_PERIOD && _activePeriod >= MIN_ACTIVE_PERIOD, \"invalid active period\");\n require(\n _quorumThreshold < THRESHOLD_DECIMAL && _fastPassThreshold <= _quorumThreshold,\n \"invalid init thresholds\"\n );\n for (uint256 i = 0; i < _voters.length; i++) {\n _setVoter(_voters[i], _powers[i]);\n }\n for (uint256 i = 0; i < _proxies.length; i++) {\n proposerProxies[_proxies[i]] = true;\n }\n params[ParamName.ActivePeriod] = _activePeriod;\n params[ParamName.QuorumThreshold] = _quorumThreshold;\n params[ParamName.FastPassThreshold] = _fastPassThreshold;\n emit Initiated(_voters, _powers, _proxies, _activePeriod, _quorumThreshold, _fastPassThreshold);\n }\n\n /*********************************\n * External and Public Functions *\n *********************************/\n\n function createProposal(address _target, bytes memory _data) external returns (uint256) {\n return _createProposal(msg.sender, _target, _data, ProposalType.ExternalDefault);\n }\n\n // create proposal through proxy\n function createProposal(\n address _proposer,\n address _target,\n bytes memory _data,\n ProposalType _type\n ) external returns (uint256) {\n require(proposerProxies[msg.sender], \"sender is not a valid proxy\");\n require(_type == ProposalType.ExternalDefault || _type == ProposalType.ExternalFastPass, \"invalid type\");\n return _createProposal(_proposer, _target, _data, _type);\n }\n\n function createParamChangeProposal(ParamName _name, uint256 _value) external returns (uint256) {\n bytes memory data = abi.encode(_name, _value);\n uint256 proposalId = _createProposal(msg.sender, address(0), data, ProposalType.InternalParamChange);\n emit ParamChangeProposalCreated(proposalId, _name, _value);\n return proposalId;\n }\n\n function createVoterUpdateProposal(address[] calldata _voters, uint256[] calldata _powers)\n external\n returns (uint256)\n {\n require(_voters.length == _powers.length, \"voters and powers length not match\");\n bytes memory data = abi.encode(_voters, _powers);\n uint256 proposalId = _createProposal(msg.sender, address(0), data, ProposalType.InternalVoterUpdate);\n emit VoterUpdateProposalCreated(proposalId, _voters, _powers);\n return proposalId;\n }\n\n function createProxyUpdateProposal(address[] calldata _addrs, bool[] calldata _ops) external returns (uint256) {\n require(_addrs.length == _ops.length, \"_addrs and _ops length not match\");\n bytes memory data = abi.encode(_addrs, _ops);\n uint256 proposalId = _createProposal(msg.sender, address(0), data, ProposalType.InternalProxyUpdate);\n emit ProxyUpdateProposalCreated(proposalId, _addrs, _ops);\n return proposalId;\n }\n\n function createTransferTokenProposal(\n address _receiver,\n address _token,\n uint256 _amount\n ) external returns (uint256) {\n bytes memory data = abi.encode(_receiver, _token, _amount);\n uint256 proposalId = _createProposal(msg.sender, address(0), data, ProposalType.InternalTransferToken);\n emit TransferTokenProposalCreated(proposalId, _receiver, _token, _amount);\n return proposalId;\n }\n\n function voteProposal(uint256 _proposalId, bool _vote) external {\n require(voterPowers[msg.sender] > 0, \"invalid voter\");\n Proposal storage p = proposals[_proposalId];\n require(block.timestamp < p.deadline, \"deadline passed\");\n p.votes[msg.sender] = _vote;\n emit ProposalVoted(_proposalId, msg.sender, _vote);\n }\n\n function executeProposal(\n uint256 _proposalId,\n ProposalType _type,\n address _target,\n bytes calldata _data\n ) external {\n require(voterPowers[msg.sender] > 0, \"only voter can execute a proposal\");\n Proposal storage p = proposals[_proposalId];\n require(block.timestamp < p.deadline, \"deadline passed\");\n require(keccak256(abi.encodePacked(_type, _target, _data)) == p.dataHash, \"data hash not match\");\n p.deadline = 0;\n\n p.votes[msg.sender] = true;\n (, , bool pass) = countVotes(_proposalId, _type);\n require(pass, \"not enough votes\");\n\n if (_type == ProposalType.ExternalDefault || _type == ProposalType.ExternalFastPass) {\n (bool success, bytes memory res) = _target.call(_data);\n require(success, Utils.getRevertMsg(res));\n } else if (_type == ProposalType.InternalParamChange) {\n (ParamName name, uint256 value) = abi.decode((_data), (ParamName, uint256));\n params[name] = value;\n if (name == ParamName.ActivePeriod) {\n require(value <= MAX_ACTIVE_PERIOD && value >= MIN_ACTIVE_PERIOD, \"invalid active period\");\n } else if (name == ParamName.QuorumThreshold || name == ParamName.FastPassThreshold) {\n require(\n params[ParamName.QuorumThreshold] >= params[ParamName.FastPassThreshold] &&\n value < THRESHOLD_DECIMAL &&\n value > 0,\n \"invalid threshold\"\n );\n }\n } else if (_type == ProposalType.InternalVoterUpdate) {\n (address[] memory addrs, uint256[] memory powers) = abi.decode((_data), (address[], uint256[]));\n for (uint256 i = 0; i < addrs.length; i++) {\n if (powers[i] > 0) {\n _setVoter(addrs[i], powers[i]);\n } else {\n _removeVoter(addrs[i]);\n }\n }\n } else if (_type == ProposalType.InternalProxyUpdate) {\n (address[] memory addrs, bool[] memory ops) = abi.decode((_data), (address[], bool[]));\n for (uint256 i = 0; i < addrs.length; i++) {\n if (ops[i]) {\n proposerProxies[addrs[i]] = true;\n } else {\n delete proposerProxies[addrs[i]];\n }\n }\n } else if (_type == ProposalType.InternalTransferToken) {\n (address receiver, address token, uint256 amount) = abi.decode((_data), (address, address, uint256));\n _transfer(receiver, token, amount);\n }\n emit ProposalExecuted(_proposalId);\n }\n\n receive() external payable {}\n\n /**************************\n * Public View Functions *\n **************************/\n\n function getVoters() public view returns (address[] memory, uint256[] memory) {\n address[] memory addrs = new address[](voters.length);\n uint256[] memory powers = new uint256[](voters.length);\n for (uint32 i = 0; i < voters.length; i++) {\n addrs[i] = voters[i];\n powers[i] = voterPowers[voters[i]];\n }\n return (addrs, powers);\n }\n\n function getVote(uint256 _proposalId, address _voter) public view returns (bool) {\n return proposals[_proposalId].votes[_voter];\n }\n\n function countVotes(uint256 _proposalId, ProposalType _type)\n public\n view\n returns (\n uint256,\n uint256,\n bool\n )\n {\n uint256 yesVotes;\n uint256 totalPower;\n for (uint32 i = 0; i < voters.length; i++) {\n if (getVote(_proposalId, voters[i])) {\n yesVotes += voterPowers[voters[i]];\n }\n totalPower += voterPowers[voters[i]];\n }\n uint256 threshold;\n if (_type == ProposalType.ExternalFastPass) {\n threshold = params[ParamName.FastPassThreshold];\n } else {\n threshold = params[ParamName.QuorumThreshold];\n }\n bool pass = (yesVotes >= (totalPower * threshold) / THRESHOLD_DECIMAL);\n return (totalPower, yesVotes, pass);\n }\n\n /**********************************\n * Internal and Private Functions *\n **********************************/\n\n // create a proposal and vote yes\n function _createProposal(\n address _proposer,\n address _target,\n bytes memory _data,\n ProposalType _type\n ) private returns (uint256) {\n require(voterPowers[_proposer] > 0, \"only voter can create a proposal\");\n uint256 proposalId = nextProposalId;\n nextProposalId += 1;\n Proposal storage p = proposals[proposalId];\n p.dataHash = keccak256(abi.encodePacked(_type, _target, _data));\n p.deadline = block.timestamp + params[ParamName.ActivePeriod];\n p.votes[_proposer] = true;\n emit ProposalCreated(proposalId, _type, _target, _data, p.deadline, _proposer);\n return proposalId;\n }\n\n function _setVoter(address _voter, uint256 _power) private {\n require(_power > 0, \"zero power\");\n if (voterPowers[_voter] == 0) {\n // add new voter\n voters.push(_voter);\n }\n voterPowers[_voter] = _power;\n }\n\n function _removeVoter(address _voter) private {\n require(voterPowers[_voter] > 0, \"not a voter\");\n uint256 lastIndex = voters.length - 1;\n for (uint256 i = 0; i < voters.length; i++) {\n if (voters[i] == _voter) {\n if (i < lastIndex) {\n voters[i] = voters[lastIndex];\n }\n voters.pop();\n voterPowers[_voter] = 0;\n return;\n }\n }\n revert(\"voter not found\"); // this should never happen\n }\n\n function _transfer(\n address _receiver,\n address _token,\n uint256 _amount\n ) private {\n if (_token == address(0)) {\n (bool sent, ) = _receiver.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"failed to send native token\");\n } else {\n IERC20(_token).safeTransfer(_receiver, _amount);\n }\n }\n}\n" + }, + "contracts/integration-examples/ContractAsLP.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/IPool.sol\";\nimport \"../interfaces/IWithdrawInbox.sol\";\nimport \"../safeguard/Pauser.sol\";\n\n/**\n * @title Example contract to provide liquidity to {Bridge}. Supports withdrawing liquidity via {WithdrawInbox}.\n */\ncontract ContractAsLP is ReentrancyGuard, Pauser {\n using SafeERC20 for IERC20;\n\n address public bridge;\n address public inbox;\n\n event Deposited(address depositor, address token, uint256 amount);\n\n constructor(address _bridge, address _inbox) {\n bridge = _bridge;\n inbox = _inbox;\n }\n\n /**\n * @notice Deposit tokens.\n * @param _token The deposited token address.\n * @param _amount The amount to deposit.\n */\n function deposit(address _token, uint256 _amount) external nonReentrant whenNotPaused onlyOwner {\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n emit Deposited(msg.sender, _token, _amount);\n }\n\n /**\n * @notice Add liquidity to the pool-based bridge.\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\n * @param _token The address of the token.\n * @param _amount The amount to add.\n */\n function addLiquidity(address _token, uint256 _amount) external whenNotPaused onlyOwner {\n require(IERC20(_token).balanceOf(address(this)) >= _amount, \"insufficient balance\");\n IERC20(_token).safeIncreaseAllowance(bridge, _amount);\n IPool(bridge).addLiquidity(_token, _amount);\n }\n\n /**\n * @notice Withdraw liquidity from the pool-based bridge.\n * NOTE: Each of your withdrawal request should have different _wdSeq.\n * NOTE: Tokens to withdraw within one withdrawal request should have the same symbol.\n * @param _wdSeq The unique sequence number to identify this withdrawal request.\n * @param _receiver The receiver address on _toChain.\n * @param _toChain The chain Id to receive the withdrawn tokens.\n * @param _fromChains The chain Ids to withdraw tokens.\n * @param _tokens The token to withdraw on each fromChain.\n * @param _ratios The withdrawal ratios of each token.\n * @param _slippages The max slippages of each token for cross-chain withdraw.\n */\n function withdraw(\n uint64 _wdSeq,\n address _receiver,\n uint64 _toChain,\n uint64[] calldata _fromChains,\n address[] calldata _tokens,\n uint32[] calldata _ratios,\n uint32[] calldata _slippages\n ) external whenNotPaused onlyOwner {\n IWithdrawInbox(inbox).withdraw(_wdSeq, _receiver, _toChain, _fromChains, _tokens, _ratios, _slippages);\n }\n}\n" + }, + "contracts/integration-examples/ContractAsSender.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"../libraries/BridgeTransferLib.sol\";\nimport \"../safeguard/Pauser.sol\";\n\n/**\n * @title Example contract to send cBridge transfers. Supports the liquidity pool-based {Bridge}, the {OriginalTokenVault} for pegged\n * deposit and the {PeggedTokenBridge} for pegged burn. Includes handling of refunds for failed transfers.\n * @notice For the bad Bridge.send/PeggedTokenBridge.deposit of native token(eg.ETH) or wrapped native token(eg.WETH),\n * its refund asset depends on whether the nativeWrap of Bridge/PeggedTokenBridge is set or not AT THE MOMENT OF REFUNDING.\n * If the nativeWrap is set, the refund asset would always be native token (eg.ETH), even though the original sending asset\n * is wrapped native token. If the nativeWrap isn't set, the refund asset would always be wrapped native token.\n */\ncontract ContractAsSender is ReentrancyGuard, Pauser {\n using SafeERC20 for IERC20;\n\n mapping(BridgeTransferLib.BridgeSendType => address) public bridges;\n mapping(bytes32 => address) public records;\n address public nativeWrap;\n\n event Deposited(address depositor, address token, uint256 amount);\n event BridgeUpdated(BridgeTransferLib.BridgeSendType bridgeSendType, address bridgeAddr);\n\n /**\n * @notice Send a cross-chain transfer either via liquidity pool-based bridge or in form of mint/burn.\n * @param _receiver The address of the receiver.\n * @param _token The address of the token.\n * @param _amount The amount of the transfer.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least\n * (100% - max slippage percentage) * amount or the transfer can be refunded.\n * Only applicable to the {BridgeSendType.Liquidity}.\n * @param _bridgeSendType The type of bridge used by this transfer. One of the {BridgeSendType} enum.\n */\n function transfer(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage, // slippage * 1M, eg. 0.5% -> 5000\n BridgeTransferLib.BridgeSendType _bridgeSendType\n ) external nonReentrant whenNotPaused onlyOwner returns (bytes32) {\n address _bridgeAddr = bridges[_bridgeSendType];\n require(_bridgeAddr != address(0), \"unknown bridge type\");\n bytes32 transferId = BridgeTransferLib.sendTransfer(\n _receiver,\n _token,\n _amount,\n _dstChainId,\n _nonce,\n _maxSlippage,\n _bridgeSendType,\n _bridgeAddr\n );\n require(records[transferId] == address(0), \"record exists\");\n records[transferId] = msg.sender;\n return transferId;\n }\n\n /**\n * @notice Refund a failed cross-chain transfer.\n * @param _request The serialized request protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n * @param _bridgeSendType The type of bridge used by this failed transfer. One of the {BridgeSendType} enum.\n */\n function refund(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n BridgeTransferLib.BridgeSendType _bridgeSendType\n ) external nonReentrant whenNotPaused onlyOwner returns (bytes32) {\n address _bridgeAddr = bridges[_bridgeSendType];\n require(_bridgeAddr != address(0), \"unknown bridge type\");\n BridgeTransferLib.ReceiveInfo memory refundInfo = BridgeTransferLib.receiveTransfer(\n _request,\n _sigs,\n _signers,\n _powers,\n BridgeTransferLib.bridgeRefundType(_bridgeSendType),\n _bridgeAddr\n );\n require(refundInfo.receiver == address(this), \"invalid refund\");\n address _receiver = records[refundInfo.refid];\n require(_receiver != address(0), \"unknown transfer id or already refunded\");\n delete records[refundInfo.refid];\n _sendToken(_receiver, refundInfo.token, refundInfo.amount);\n return refundInfo.transferId;\n }\n\n /**\n * @notice Send token to user. For native token and wrapped native token, this contract may not have enough _token to\n * send to _receiver. This may caused by others refund an original transfer that is sent from this contract via cBridge\n * contract right before you call refund function of this contract and then the nativeWrap of cBridge contract is\n * modified right after that the refund triggered by that guy completes.\n * As a consequence, native token and wrapped native token possessed by this contract are mixed. But don't worry,\n * the total sum of two tokens keeps correct. So in order to avoid deadlocking any token, we'd better have a\n * balance check before sending out native token or wrapped native token. If the balance of _token is not sufficient,\n * we change to sent the other token.\n */\n function _sendToken(\n address _receiver,\n address _token,\n uint256 _amount\n ) internal {\n if (_token == address(0)) {\n // refund asset is ETH\n if (address(this).balance >= _amount) {\n (bool sent, ) = _receiver.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"failed to send native token\");\n } else {\n // in case of refund asset is WETH\n IERC20(_token).safeTransfer(_receiver, _amount);\n }\n } else if (_token == nativeWrap) {\n // refund asset is WETH\n if (IERC20(_token).balanceOf(address(this)) >= _amount) {\n IERC20(_token).safeTransfer(_receiver, _amount);\n } else {\n // in case of refund asset is ETH\n (bool sent, ) = _receiver.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"failed to send native token\");\n }\n } else {\n IERC20(_token).safeTransfer(_receiver, _amount);\n }\n }\n\n // ----------------------Admin operation-----------------------\n\n /**\n * @notice Lock tokens.\n * @param _token The deposited token address.\n * @param _amount The amount to deposit.\n */\n function deposit(address _token, uint256 _amount) external nonReentrant whenNotPaused onlyOwner {\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n emit Deposited(msg.sender, _token, _amount);\n }\n\n function setBridgeAddress(BridgeTransferLib.BridgeSendType _bridgeSendType, address _addr) public onlyOwner {\n require(_addr != address(0), \"invalid address\");\n bridges[_bridgeSendType] = _addr;\n emit BridgeUpdated(_bridgeSendType, _addr);\n }\n\n // set nativeWrap\n function setWrap(address _weth) external onlyOwner {\n nativeWrap = _weth;\n }\n\n // This is needed to receive ETH if a refund asset is ETH\n receive() external payable {}\n}\n" + }, + "contracts/interfaces/IBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IBridge {\n function send(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external;\n\n function sendNative(\n address _receiver,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external payable;\n\n function relay(\n bytes calldata _relayRequest,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n\n function transfers(bytes32 transferId) external view returns (bool);\n\n function withdraws(bytes32 withdrawId) external view returns (bool);\n\n function withdraw(\n bytes calldata _wdmsg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n\n /**\n * @notice Verifies that a message is signed by a quorum among the signers.\n * @param _msg signed message\n * @param _sigs list of signatures sorted by signer addresses in ascending order\n * @param _signers sorted list of current signers\n * @param _powers powers of current signers\n */\n function verifySigs(\n bytes memory _msg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external view;\n}\n" + }, + "contracts/interfaces/ICircleBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface ICircleBridge {\n /**\n * @notice Deposits and burns tokens from sender to be minted on destination domain.\n * Emits a `DepositForBurn` event.\n * @dev reverts if:\n * - given burnToken is not supported\n * - given destinationDomain has no CircleBridge registered\n * - transferFrom() reverts. For example, if sender's burnToken balance or approved allowance\n * to this contract is less than `amount`.\n * - burn() reverts. For example, if `amount` is 0.\n * - MessageTransmitter returns false or reverts.\n * @param _amount amount of tokens to burn\n * @param _destinationDomain destination domain (ETH = 0, AVAX = 1)\n * @param _mintRecipient address of mint recipient on destination domain\n * @param _burnToken address of contract to burn deposited tokens, on local domain\n * @return _nonce unique nonce reserved by message\n */\n function depositForBurn(\n uint256 _amount,\n uint32 _destinationDomain,\n bytes32 _mintRecipient,\n address _burnToken\n ) external returns (uint64 _nonce);\n}\n" + }, + "contracts/interfaces/IDelayedTransfer.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\ninterface IDelayedTransfer {\n struct delayedTransfer {\n address receiver;\n address token;\n uint256 amount;\n uint256 timestamp;\n }\n\n function delayedTransfers(bytes32 transferId) external view returns (delayedTransfer memory);\n}\n" + }, + "contracts/interfaces/IOriginalTokenVault.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IOriginalTokenVault {\n /**\n * @notice Lock original tokens to trigger mint at a remote chain's PeggedTokenBridge\n * @param _token local token address\n * @param _amount locked token amount\n * @param _mintChainId destination chainId to mint tokens\n * @param _mintAccount destination account to receive minted tokens\n * @param _nonce user input to guarantee unique depositId\n */\n function deposit(\n address _token,\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) external;\n\n /**\n * @notice Lock native token as original token to trigger mint at a remote chain's PeggedTokenBridge\n * @param _amount locked token amount\n * @param _mintChainId destination chainId to mint tokens\n * @param _mintAccount destination account to receive minted tokens\n * @param _nonce user input to guarantee unique depositId\n */\n function depositNative(\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) external payable;\n\n /**\n * @notice Withdraw locked original tokens triggered by a burn at a remote chain's PeggedTokenBridge.\n * @param _request The serialized Withdraw protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the bridge's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function withdraw(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n\n function records(bytes32 recordId) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IOriginalTokenVaultV2.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IOriginalTokenVaultV2 {\n /**\n * @notice Lock original tokens to trigger mint at a remote chain's PeggedTokenBridge\n * @param _token local token address\n * @param _amount locked token amount\n * @param _mintChainId destination chainId to mint tokens\n * @param _mintAccount destination account to receive minted tokens\n * @param _nonce user input to guarantee unique depositId\n */\n function deposit(\n address _token,\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) external returns (bytes32);\n\n /**\n * @notice Lock native token as original token to trigger mint at a remote chain's PeggedTokenBridge\n * @param _amount locked token amount\n * @param _mintChainId destination chainId to mint tokens\n * @param _mintAccount destination account to receive minted tokens\n * @param _nonce user input to guarantee unique depositId\n */\n function depositNative(\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) external payable returns (bytes32);\n\n /**\n * @notice Withdraw locked original tokens triggered by a burn at a remote chain's PeggedTokenBridge.\n * @param _request The serialized Withdraw protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the bridge's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function withdraw(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external returns (bytes32);\n\n function records(bytes32 recordId) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IPeggedToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IPeggedToken {\n function mint(address _to, uint256 _amount) external;\n\n function burn(address _from, uint256 _amount) external;\n}\n" + }, + "contracts/interfaces/IPeggedTokenBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IPeggedTokenBridge {\n /**\n * @notice Burn tokens to trigger withdrawal at a remote chain's OriginalTokenVault\n * @param _token local token address\n * @param _amount locked token amount\n * @param _withdrawAccount account who withdraw original tokens on the remote chain\n * @param _nonce user input to guarantee unique depositId\n */\n function burn(\n address _token,\n uint256 _amount,\n address _withdrawAccount,\n uint64 _nonce\n ) external;\n\n /**\n * @notice Mint tokens triggered by deposit at a remote chain's OriginalTokenVault.\n * @param _request The serialized Mint protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function mint(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n\n function records(bytes32 recordId) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IPeggedTokenBridgeV2.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IPeggedTokenBridgeV2 {\n /**\n * @notice Burn pegged tokens to trigger a cross-chain withdrawal of the original tokens at a remote chain's\n * OriginalTokenVault, or mint at another remote chain\n * @param _token The pegged token address.\n * @param _amount The amount to burn.\n * @param _toChainId If zero, withdraw from original vault; otherwise, the remote chain to mint tokens.\n * @param _toAccount The account to receive tokens on the remote chain\n * @param _nonce A number to guarantee unique depositId. Can be timestamp in practice.\n */\n function burn(\n address _token,\n uint256 _amount,\n uint64 _toChainId,\n address _toAccount,\n uint64 _nonce\n ) external returns (bytes32);\n\n // same with `burn` above, use openzeppelin ERC20Burnable interface\n function burnFrom(\n address _token,\n uint256 _amount,\n uint64 _toChainId,\n address _toAccount,\n uint64 _nonce\n ) external returns (bytes32);\n\n /**\n * @notice Mint tokens triggered by deposit at a remote chain's OriginalTokenVault.\n * @param _request The serialized Mint protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function mint(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external returns (bytes32);\n\n function records(bytes32 recordId) external view returns (bool);\n}\n" + }, + "contracts/interfaces/IPeggedTokenBurnFrom.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\n// used for pegged token with openzeppelin ERC20Burnable interface\n// only compatible with PeggedTokenBridgeV2\ninterface IPeggedTokenBurnFrom {\n function mint(address _to, uint256 _amount) external;\n\n function burnFrom(address _from, uint256 _amount) external;\n}\n" + }, + "contracts/interfaces/IPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IPool {\n function addLiquidity(address _token, uint256 _amount) external;\n\n function withdraws(bytes32 withdrawId) external view returns (bool);\n\n function withdraw(\n bytes calldata _wdmsg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n}\n" + }, + "contracts/interfaces/ISigsVerifier.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface ISigsVerifier {\n /**\n * @notice Verifies that a message is signed by a quorum among the signers.\n * @param _msg signed message\n * @param _sigs list of signatures sorted by signer addresses in ascending order\n * @param _signers sorted list of current signers\n * @param _powers powers of current signers\n */\n function verifySigs(\n bytes memory _msg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external view;\n}\n" + }, + "contracts/interfaces/IUniswapV2.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IUniswapV2 {\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n}\n" + }, + "contracts/interfaces/IWETH.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IWETH {\n function deposit() external payable;\n\n function withdraw(uint256) external;\n}\n" + }, + "contracts/interfaces/IWithdrawInbox.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IWithdrawInbox {\n function withdraw(\n uint64 _wdSeq,\n address _receiver,\n uint64 _toChain,\n uint64[] calldata _fromChains,\n address[] calldata _tokens,\n uint32[] calldata _ratios,\n uint32[] calldata _slippages\n ) external;\n}\n" + }, + "contracts/libraries/BridgeTransferLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"./PbBridge.sol\";\nimport \"./PbPegged.sol\";\nimport \"./PbPool.sol\";\nimport \"../interfaces/IBridge.sol\";\nimport \"../interfaces/IOriginalTokenVault.sol\";\nimport \"../interfaces/IOriginalTokenVaultV2.sol\";\nimport \"../interfaces/IPeggedTokenBridge.sol\";\nimport \"../interfaces/IPeggedTokenBridgeV2.sol\";\n\ninterface INativeWrap {\n function nativeWrap() external view returns (address);\n}\n\nlibrary BridgeTransferLib {\n using SafeERC20 for IERC20;\n\n enum BridgeSendType {\n Null,\n Liquidity,\n PegDeposit,\n PegBurn,\n PegV2Deposit,\n PegV2Burn,\n PegV2BurnFrom\n }\n\n enum BridgeReceiveType {\n Null,\n LqRelay,\n LqWithdraw,\n PegMint,\n PegWithdraw,\n PegV2Mint,\n PegV2Withdraw\n }\n\n struct ReceiveInfo {\n bytes32 transferId;\n address receiver;\n address token; // 0 address for native token\n uint256 amount;\n bytes32 refid; // reference id, e.g., srcTransferId for refund\n }\n\n // ============== Internal library functions called by apps ==============\n\n /**\n * @notice Send a cross-chain transfer of ERC20 token either via liquidity pool-based bridge or in the form of pegged mint / burn.\n * @param _receiver The address of the receiver.\n * @param _token The address of the token.\n * @param _amount The amount of the transfer.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least\n * (100% - max slippage percentage) * amount or the transfer can be refunded.\n * Only applicable to the {BridgeSendType.Liquidity}.\n * @param _bridgeSendType The type of the bridge used by this transfer. One of the {BridgeSendType} enum.\n * @param _bridgeAddr The address of the bridge used.\n */\n function sendTransfer(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage, // slippage * 1M, eg. 0.5% -> 5000\n BridgeSendType _bridgeSendType,\n address _bridgeAddr\n ) internal returns (bytes32) {\n bytes32 transferId;\n IERC20(_token).safeIncreaseAllowance(_bridgeAddr, _amount);\n if (_bridgeSendType == BridgeSendType.Liquidity) {\n IBridge(_bridgeAddr).send(_receiver, _token, _amount, _dstChainId, _nonce, _maxSlippage);\n transferId = keccak256(\n abi.encodePacked(address(this), _receiver, _token, _amount, _dstChainId, _nonce, uint64(block.chainid))\n );\n } else if (_bridgeSendType == BridgeSendType.PegDeposit) {\n IOriginalTokenVault(_bridgeAddr).deposit(_token, _amount, _dstChainId, _receiver, _nonce);\n transferId = keccak256(\n abi.encodePacked(address(this), _token, _amount, _dstChainId, _receiver, _nonce, uint64(block.chainid))\n );\n } else if (_bridgeSendType == BridgeSendType.PegBurn) {\n IPeggedTokenBridge(_bridgeAddr).burn(_token, _amount, _receiver, _nonce);\n transferId = keccak256(\n abi.encodePacked(address(this), _token, _amount, _receiver, _nonce, uint64(block.chainid))\n );\n // handle cases where certain tokens do not spend allowance for role-based burn\n IERC20(_token).safeApprove(_bridgeAddr, 0);\n } else if (_bridgeSendType == BridgeSendType.PegV2Deposit) {\n transferId = IOriginalTokenVaultV2(_bridgeAddr).deposit(_token, _amount, _dstChainId, _receiver, _nonce);\n } else if (_bridgeSendType == BridgeSendType.PegV2Burn) {\n transferId = IPeggedTokenBridgeV2(_bridgeAddr).burn(_token, _amount, _dstChainId, _receiver, _nonce);\n // handle cases where certain tokens do not spend allowance for role-based burn\n IERC20(_token).safeApprove(_bridgeAddr, 0);\n } else if (_bridgeSendType == BridgeSendType.PegV2BurnFrom) {\n transferId = IPeggedTokenBridgeV2(_bridgeAddr).burnFrom(_token, _amount, _dstChainId, _receiver, _nonce);\n // handle cases where certain tokens do not spend allowance for role-based burn\n IERC20(_token).safeApprove(_bridgeAddr, 0);\n } else {\n revert(\"bridge send type not supported\");\n }\n return transferId;\n }\n\n /**\n * @notice Send a cross-chain transfer of native token either via liquidity pool-based bridge or in the form of pegged mint / burn.\n * @param _receiver The address of the receiver.\n * @param _amount The amount of the transfer.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least\n * (100% - max slippage percentage) * amount or the transfer can be refunded.\n * Only applicable to the {BridgeSendType.Liquidity}.\n * @param _bridgeSendType The type of the bridge used by this transfer. One of the {BridgeSendType} enum.\n * @param _bridgeAddr The address of the bridge used.\n */\n function sendNativeTransfer(\n address _receiver,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage, // slippage * 1M, eg. 0.5% -> 5000\n BridgeSendType _bridgeSendType,\n address _bridgeAddr\n ) internal returns (bytes32) {\n require(\n _bridgeSendType == BridgeSendType.Liquidity ||\n _bridgeSendType == BridgeSendType.PegDeposit ||\n _bridgeSendType == BridgeSendType.PegV2Deposit,\n \"Lib: invalid bridge send type\"\n );\n address _token = INativeWrap(_bridgeAddr).nativeWrap();\n bytes32 transferId;\n if (_bridgeSendType == BridgeSendType.Liquidity) {\n IBridge(_bridgeAddr).sendNative{value: msg.value}(_receiver, _amount, _dstChainId, _nonce, _maxSlippage);\n transferId = keccak256(\n abi.encodePacked(address(this), _receiver, _token, _amount, _dstChainId, _nonce, uint64(block.chainid))\n );\n } else if (_bridgeSendType == BridgeSendType.PegDeposit) {\n IOriginalTokenVault(_bridgeAddr).depositNative{value: msg.value}(_amount, _dstChainId, _receiver, _nonce);\n transferId = keccak256(\n abi.encodePacked(address(this), _token, _amount, _dstChainId, _receiver, _nonce, uint64(block.chainid))\n );\n } else {\n // _bridgeSendType == BridgeSendType.PegV2Deposit\n transferId = IOriginalTokenVaultV2(_bridgeAddr).depositNative{value: msg.value}(\n _amount,\n _dstChainId,\n _receiver,\n _nonce\n );\n }\n return transferId;\n }\n\n /**\n * @notice Receive a cross-chain transfer.\n * @param _request The serialized request protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n * @param _bridgeReceiveType The type of the received transfer. One of the {BridgeReceiveType} enum.\n * @param _bridgeAddr The address of the bridge used.\n */\n function receiveTransfer(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n BridgeReceiveType _bridgeReceiveType,\n address _bridgeAddr\n ) internal returns (ReceiveInfo memory) {\n if (_bridgeReceiveType == BridgeReceiveType.LqRelay) {\n return receiveLiquidityRelay(_request, _sigs, _signers, _powers, _bridgeAddr);\n } else if (_bridgeReceiveType == BridgeReceiveType.LqWithdraw) {\n return receiveLiquidityWithdraw(_request, _sigs, _signers, _powers, _bridgeAddr);\n } else if (_bridgeReceiveType == BridgeReceiveType.PegWithdraw) {\n return receivePegWithdraw(_request, _sigs, _signers, _powers, _bridgeAddr);\n } else if (_bridgeReceiveType == BridgeReceiveType.PegMint) {\n return receivePegMint(_request, _sigs, _signers, _powers, _bridgeAddr);\n } else if (_bridgeReceiveType == BridgeReceiveType.PegV2Withdraw) {\n return receivePegV2Withdraw(_request, _sigs, _signers, _powers, _bridgeAddr);\n } else if (_bridgeReceiveType == BridgeReceiveType.PegV2Mint) {\n return receivePegV2Mint(_request, _sigs, _signers, _powers, _bridgeAddr);\n } else {\n revert(\"bridge receive type not supported\");\n }\n }\n\n /**\n * @notice Receive a liquidity bridge relay.\n * @param _request The serialized request protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n * @param _bridgeAddr The address of liquidity bridge.\n */\n function receiveLiquidityRelay(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n address _bridgeAddr\n ) internal returns (ReceiveInfo memory) {\n ReceiveInfo memory recv;\n PbBridge.Relay memory request = PbBridge.decRelay(_request);\n recv.transferId = keccak256(\n abi.encodePacked(\n request.sender,\n request.receiver,\n request.token,\n request.amount,\n request.srcChainId,\n uint64(block.chainid),\n request.srcTransferId\n )\n );\n recv.refid = request.srcTransferId;\n recv.receiver = request.receiver;\n recv.token = request.token;\n recv.amount = request.amount;\n if (!IBridge(_bridgeAddr).transfers(recv.transferId)) {\n IBridge(_bridgeAddr).relay(_request, _sigs, _signers, _powers);\n }\n return recv;\n }\n\n /**\n * @notice Receive a liquidity bridge withdrawal.\n * @param _request The serialized request protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n * @param _bridgeAddr The address of liquidity bridge.\n */\n function receiveLiquidityWithdraw(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n address _bridgeAddr\n ) internal returns (ReceiveInfo memory) {\n ReceiveInfo memory recv;\n PbPool.WithdrawMsg memory request = PbPool.decWithdrawMsg(_request);\n recv.transferId = keccak256(\n abi.encodePacked(request.chainid, request.seqnum, request.receiver, request.token, request.amount)\n );\n recv.refid = request.refid;\n recv.receiver = request.receiver;\n if (INativeWrap(_bridgeAddr).nativeWrap() == request.token) {\n recv.token = address(0);\n } else {\n recv.token = request.token;\n }\n recv.amount = request.amount;\n if (!IBridge(_bridgeAddr).withdraws(recv.transferId)) {\n IBridge(_bridgeAddr).withdraw(_request, _sigs, _signers, _powers);\n }\n return recv;\n }\n\n /**\n * @notice Receive an OriginalTokenVault withdrawal.\n * @param _request The serialized request protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n * @param _bridgeAddr The address of OriginalTokenVault.\n */\n function receivePegWithdraw(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n address _bridgeAddr\n ) internal returns (ReceiveInfo memory) {\n ReceiveInfo memory recv;\n PbPegged.Withdraw memory request = PbPegged.decWithdraw(_request);\n recv.transferId = keccak256(\n abi.encodePacked(\n request.receiver,\n request.token,\n request.amount,\n request.burnAccount,\n request.refChainId,\n request.refId\n )\n );\n recv.refid = request.refId;\n recv.receiver = request.receiver;\n if (INativeWrap(_bridgeAddr).nativeWrap() == request.token) {\n recv.token = address(0);\n } else {\n recv.token = request.token;\n }\n recv.amount = request.amount;\n if (!IOriginalTokenVault(_bridgeAddr).records(recv.transferId)) {\n IOriginalTokenVault(_bridgeAddr).withdraw(_request, _sigs, _signers, _powers);\n }\n return recv;\n }\n\n /**\n * @notice Receive a PeggedTokenBridge mint.\n * @param _request The serialized request protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n * @param _bridgeAddr The address of PeggedTokenBridge.\n */\n function receivePegMint(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n address _bridgeAddr\n ) internal returns (ReceiveInfo memory) {\n ReceiveInfo memory recv;\n PbPegged.Mint memory request = PbPegged.decMint(_request);\n recv.transferId = keccak256(\n abi.encodePacked(\n request.account,\n request.token,\n request.amount,\n request.depositor,\n request.refChainId,\n request.refId\n )\n );\n recv.refid = request.refId;\n recv.receiver = request.account;\n recv.token = request.token;\n recv.amount = request.amount;\n if (!IPeggedTokenBridge(_bridgeAddr).records(recv.transferId)) {\n IPeggedTokenBridge(_bridgeAddr).mint(_request, _sigs, _signers, _powers);\n }\n return recv;\n }\n\n /**\n * @notice Receive an OriginalTokenVaultV2 withdrawal.\n * @param _request The serialized request protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A request must be signed-off by\n * +2/3 of the bridge's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n * @param _bridgeAddr The address of OriginalTokenVaultV2.\n */\n function receivePegV2Withdraw(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n address _bridgeAddr\n ) internal returns (ReceiveInfo memory) {\n ReceiveInfo memory recv;\n PbPegged.Withdraw memory request = PbPegged.decWithdraw(_request);\n if (IOriginalTokenVaultV2(_bridgeAddr).records(request.refId)) {\n recv.transferId = keccak256(\n abi.encodePacked(\n request.receiver,\n request.token,\n request.amount,\n request.burnAccount,\n request.refChainId,\n request.refId,\n _bridgeAddr\n )\n );\n } else {\n recv.transferId = IOriginalTokenVaultV2(_bridgeAddr).withdraw(_request, _sigs, _signers, _powers);\n }\n recv.refid = request.refId;\n recv.receiver = request.receiver;\n if (INativeWrap(_bridgeAddr).nativeWrap() == request.token) {\n recv.token = address(0);\n } else {\n recv.token = request.token;\n }\n recv.amount = request.amount;\n return recv;\n }\n\n /**\n * @notice Receive a PeggedTokenBridgeV2 mint.\n * @param _request The serialized request protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A request must be signed-off by\n * +2/3 of the bridge's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n * @param _bridgeAddr The address of PeggedTokenBridgeV2.\n */\n function receivePegV2Mint(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n address _bridgeAddr\n ) internal returns (ReceiveInfo memory) {\n ReceiveInfo memory recv;\n PbPegged.Mint memory request = PbPegged.decMint(_request);\n if (IPeggedTokenBridgeV2(_bridgeAddr).records(request.refId)) {\n recv.transferId = keccak256(\n abi.encodePacked(\n request.account,\n request.token,\n request.amount,\n request.depositor,\n request.refChainId,\n request.refId,\n _bridgeAddr\n )\n );\n } else {\n recv.transferId = IPeggedTokenBridgeV2(_bridgeAddr).mint(_request, _sigs, _signers, _powers);\n }\n recv.refid = request.refId;\n recv.receiver = request.account;\n recv.token = request.token;\n recv.amount = request.amount;\n return recv;\n }\n\n function bridgeRefundType(BridgeSendType _bridgeSendType) internal pure returns (BridgeReceiveType) {\n if (_bridgeSendType == BridgeSendType.Liquidity) {\n return BridgeReceiveType.LqWithdraw;\n }\n if (_bridgeSendType == BridgeSendType.PegDeposit) {\n return BridgeReceiveType.PegWithdraw;\n }\n if (_bridgeSendType == BridgeSendType.PegBurn) {\n return BridgeReceiveType.PegMint;\n }\n if (_bridgeSendType == BridgeSendType.PegV2Deposit) {\n return BridgeReceiveType.PegV2Withdraw;\n }\n if (_bridgeSendType == BridgeSendType.PegV2Burn || _bridgeSendType == BridgeSendType.PegV2BurnFrom) {\n return BridgeReceiveType.PegV2Mint;\n }\n return BridgeReceiveType.Null;\n }\n}\n" + }, + "contracts/libraries/Pb.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\n// runtime proto sol library\nlibrary Pb {\n enum WireType {\n Varint,\n Fixed64,\n LengthDelim,\n StartGroup,\n EndGroup,\n Fixed32\n }\n\n struct Buffer {\n uint256 idx; // the start index of next read. when idx=b.length, we're done\n bytes b; // hold serialized proto msg, readonly\n }\n\n // create a new in-memory Buffer object from raw msg bytes\n function fromBytes(bytes memory raw) internal pure returns (Buffer memory buf) {\n buf.b = raw;\n buf.idx = 0;\n }\n\n // whether there are unread bytes\n function hasMore(Buffer memory buf) internal pure returns (bool) {\n return buf.idx < buf.b.length;\n }\n\n // decode current field number and wiretype\n function decKey(Buffer memory buf) internal pure returns (uint256 tag, WireType wiretype) {\n uint256 v = decVarint(buf);\n tag = v / 8;\n wiretype = WireType(v & 7);\n }\n\n // count tag occurrences, return an array due to no memory map support\n // have to create array for (maxtag+1) size. cnts[tag] = occurrences\n // should keep buf.idx unchanged because this is only a count function\n function cntTags(Buffer memory buf, uint256 maxtag) internal pure returns (uint256[] memory cnts) {\n uint256 originalIdx = buf.idx;\n cnts = new uint256[](maxtag + 1); // protobuf's tags are from 1 rather than 0\n uint256 tag;\n WireType wire;\n while (hasMore(buf)) {\n (tag, wire) = decKey(buf);\n cnts[tag] += 1;\n skipValue(buf, wire);\n }\n buf.idx = originalIdx;\n }\n\n // read varint from current buf idx, move buf.idx to next read, return the int value\n function decVarint(Buffer memory buf) internal pure returns (uint256 v) {\n bytes10 tmp; // proto int is at most 10 bytes (7 bits can be used per byte)\n bytes memory bb = buf.b; // get buf.b mem addr to use in assembly\n v = buf.idx; // use v to save one additional uint variable\n assembly {\n tmp := mload(add(add(bb, 32), v)) // load 10 bytes from buf.b[buf.idx] to tmp\n }\n uint256 b; // store current byte content\n v = 0; // reset to 0 for return value\n for (uint256 i = 0; i < 10; i++) {\n assembly {\n b := byte(i, tmp) // don't use tmp[i] because it does bound check and costs extra\n }\n v |= (b & 0x7F) << (i * 7);\n if (b & 0x80 == 0) {\n buf.idx += i + 1;\n return v;\n }\n }\n revert(); // i=10, invalid varint stream\n }\n\n // read length delimited field and return bytes\n function decBytes(Buffer memory buf) internal pure returns (bytes memory b) {\n uint256 len = decVarint(buf);\n uint256 end = buf.idx + len;\n require(end <= buf.b.length); // avoid overflow\n b = new bytes(len);\n bytes memory bufB = buf.b; // get buf.b mem addr to use in assembly\n uint256 bStart;\n uint256 bufBStart = buf.idx;\n assembly {\n bStart := add(b, 32)\n bufBStart := add(add(bufB, 32), bufBStart)\n }\n for (uint256 i = 0; i < len; i += 32) {\n assembly {\n mstore(add(bStart, i), mload(add(bufBStart, i)))\n }\n }\n buf.idx = end;\n }\n\n // return packed ints\n function decPacked(Buffer memory buf) internal pure returns (uint256[] memory t) {\n uint256 len = decVarint(buf);\n uint256 end = buf.idx + len;\n require(end <= buf.b.length); // avoid overflow\n // array in memory must be init w/ known length\n // so we have to create a tmp array w/ max possible len first\n uint256[] memory tmp = new uint256[](len);\n uint256 i = 0; // count how many ints are there\n while (buf.idx < end) {\n tmp[i] = decVarint(buf);\n i++;\n }\n t = new uint256[](i); // init t with correct length\n for (uint256 j = 0; j < i; j++) {\n t[j] = tmp[j];\n }\n return t;\n }\n\n // move idx pass current value field, to beginning of next tag or msg end\n function skipValue(Buffer memory buf, WireType wire) internal pure {\n if (wire == WireType.Varint) {\n decVarint(buf);\n } else if (wire == WireType.LengthDelim) {\n uint256 len = decVarint(buf);\n buf.idx += len; // skip len bytes value data\n require(buf.idx <= buf.b.length); // avoid overflow\n } else {\n revert();\n } // unsupported wiretype\n }\n\n // type conversion help utils\n function _bool(uint256 x) internal pure returns (bool v) {\n return x != 0;\n }\n\n function _uint256(bytes memory b) internal pure returns (uint256 v) {\n require(b.length <= 32); // b's length must be smaller than or equal to 32\n assembly {\n v := mload(add(b, 32))\n } // load all 32bytes to v\n v = v >> (8 * (32 - b.length)); // only first b.length is valid\n }\n\n function _address(bytes memory b) internal pure returns (address v) {\n v = _addressPayable(b);\n }\n\n function _addressPayable(bytes memory b) internal pure returns (address payable v) {\n require(b.length == 20);\n //load 32bytes then shift right 12 bytes\n assembly {\n v := div(mload(add(b, 32)), 0x1000000000000000000000000)\n }\n }\n\n function _bytes32(bytes memory b) internal pure returns (bytes32 v) {\n require(b.length == 32);\n assembly {\n v := mload(add(b, 32))\n }\n }\n\n // uint[] to uint8[]\n function uint8s(uint256[] memory arr) internal pure returns (uint8[] memory t) {\n t = new uint8[](arr.length);\n for (uint256 i = 0; i < t.length; i++) {\n t[i] = uint8(arr[i]);\n }\n }\n\n function uint32s(uint256[] memory arr) internal pure returns (uint32[] memory t) {\n t = new uint32[](arr.length);\n for (uint256 i = 0; i < t.length; i++) {\n t[i] = uint32(arr[i]);\n }\n }\n\n function uint64s(uint256[] memory arr) internal pure returns (uint64[] memory t) {\n t = new uint64[](arr.length);\n for (uint256 i = 0; i < t.length; i++) {\n t[i] = uint64(arr[i]);\n }\n }\n\n function bools(uint256[] memory arr) internal pure returns (bool[] memory t) {\n t = new bool[](arr.length);\n for (uint256 i = 0; i < t.length; i++) {\n t[i] = arr[i] != 0;\n }\n }\n}\n" + }, + "contracts/libraries/PbBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// Code generated by protoc-gen-sol. DO NOT EDIT.\n// source: bridge.proto\npragma solidity 0.8.17;\nimport \"./Pb.sol\";\n\nlibrary PbBridge {\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\n\n struct Relay {\n address sender; // tag: 1\n address receiver; // tag: 2\n address token; // tag: 3\n uint256 amount; // tag: 4\n uint64 srcChainId; // tag: 5\n uint64 dstChainId; // tag: 6\n bytes32 srcTransferId; // tag: 7\n } // end struct Relay\n\n function decRelay(bytes memory raw) internal pure returns (Relay memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.sender = Pb._address(buf.decBytes());\n } else if (tag == 2) {\n m.receiver = Pb._address(buf.decBytes());\n } else if (tag == 3) {\n m.token = Pb._address(buf.decBytes());\n } else if (tag == 4) {\n m.amount = Pb._uint256(buf.decBytes());\n } else if (tag == 5) {\n m.srcChainId = uint64(buf.decVarint());\n } else if (tag == 6) {\n m.dstChainId = uint64(buf.decVarint());\n } else if (tag == 7) {\n m.srcTransferId = Pb._bytes32(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder Relay\n}\n" + }, + "contracts/libraries/PbFarming.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// Code generated by protoc-gen-sol. DO NOT EDIT.\n// source: contracts/libraries/proto/farming.proto\npragma solidity 0.8.17;\nimport \"./Pb.sol\";\n\nlibrary PbFarming {\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\n\n struct FarmingRewards {\n address recipient; // tag: 1\n address[] tokenAddresses; // tag: 2\n uint256[] cumulativeRewardAmounts; // tag: 3\n } // end struct FarmingRewards\n\n function decFarmingRewards(bytes memory raw) internal pure returns (FarmingRewards memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256[] memory cnts = buf.cntTags(3);\n m.tokenAddresses = new address[](cnts[2]);\n cnts[2] = 0; // reset counter for later use\n m.cumulativeRewardAmounts = new uint256[](cnts[3]);\n cnts[3] = 0; // reset counter for later use\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.recipient = Pb._address(buf.decBytes());\n } else if (tag == 2) {\n m.tokenAddresses[cnts[2]] = Pb._address(buf.decBytes());\n cnts[2]++;\n } else if (tag == 3) {\n m.cumulativeRewardAmounts[cnts[3]] = Pb._uint256(buf.decBytes());\n cnts[3]++;\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder FarmingRewards\n}\n" + }, + "contracts/libraries/PbPegged.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// Code generated by protoc-gen-sol. DO NOT EDIT.\n// source: contracts/libraries/proto/pegged.proto\npragma solidity 0.8.17;\nimport \"./Pb.sol\";\n\nlibrary PbPegged {\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\n\n struct Mint {\n address token; // tag: 1\n address account; // tag: 2\n uint256 amount; // tag: 3\n address depositor; // tag: 4\n uint64 refChainId; // tag: 5\n bytes32 refId; // tag: 6\n } // end struct Mint\n\n function decMint(bytes memory raw) internal pure returns (Mint memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.token = Pb._address(buf.decBytes());\n } else if (tag == 2) {\n m.account = Pb._address(buf.decBytes());\n } else if (tag == 3) {\n m.amount = Pb._uint256(buf.decBytes());\n } else if (tag == 4) {\n m.depositor = Pb._address(buf.decBytes());\n } else if (tag == 5) {\n m.refChainId = uint64(buf.decVarint());\n } else if (tag == 6) {\n m.refId = Pb._bytes32(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder Mint\n\n struct Withdraw {\n address token; // tag: 1\n address receiver; // tag: 2\n uint256 amount; // tag: 3\n address burnAccount; // tag: 4\n uint64 refChainId; // tag: 5\n bytes32 refId; // tag: 6\n } // end struct Withdraw\n\n function decWithdraw(bytes memory raw) internal pure returns (Withdraw memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.token = Pb._address(buf.decBytes());\n } else if (tag == 2) {\n m.receiver = Pb._address(buf.decBytes());\n } else if (tag == 3) {\n m.amount = Pb._uint256(buf.decBytes());\n } else if (tag == 4) {\n m.burnAccount = Pb._address(buf.decBytes());\n } else if (tag == 5) {\n m.refChainId = uint64(buf.decVarint());\n } else if (tag == 6) {\n m.refId = Pb._bytes32(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder Withdraw\n}\n" + }, + "contracts/libraries/PbPool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// Code generated by protoc-gen-sol. DO NOT EDIT.\n// source: contracts/libraries/proto/pool.proto\npragma solidity 0.8.17;\nimport \"./Pb.sol\";\n\nlibrary PbPool {\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\n\n struct WithdrawMsg {\n uint64 chainid; // tag: 1\n uint64 seqnum; // tag: 2\n address receiver; // tag: 3\n address token; // tag: 4\n uint256 amount; // tag: 5\n bytes32 refid; // tag: 6\n } // end struct WithdrawMsg\n\n function decWithdrawMsg(bytes memory raw) internal pure returns (WithdrawMsg memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.chainid = uint64(buf.decVarint());\n } else if (tag == 2) {\n m.seqnum = uint64(buf.decVarint());\n } else if (tag == 3) {\n m.receiver = Pb._address(buf.decBytes());\n } else if (tag == 4) {\n m.token = Pb._address(buf.decBytes());\n } else if (tag == 5) {\n m.amount = Pb._uint256(buf.decBytes());\n } else if (tag == 6) {\n m.refid = Pb._bytes32(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder WithdrawMsg\n}\n" + }, + "contracts/libraries/PbSgn.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// Code generated by protoc-gen-sol. DO NOT EDIT.\n// source: contracts/libraries/proto/sgn.proto\npragma solidity 0.8.17;\nimport \"./Pb.sol\";\n\nlibrary PbSgn {\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\n\n struct Withdrawal {\n address account; // tag: 1\n address token; // tag: 2\n uint256 cumulativeAmount; // tag: 3\n } // end struct Withdrawal\n\n function decWithdrawal(bytes memory raw) internal pure returns (Withdrawal memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.account = Pb._address(buf.decBytes());\n } else if (tag == 2) {\n m.token = Pb._address(buf.decBytes());\n } else if (tag == 3) {\n m.cumulativeAmount = Pb._uint256(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder Withdrawal\n}\n" + }, + "contracts/libraries/PbStaking.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\n// Code generated by protoc-gen-sol. DO NOT EDIT.\n// source: contracts/libraries/proto/staking.proto\npragma solidity 0.8.17;\nimport \"./Pb.sol\";\n\nlibrary PbStaking {\n using Pb for Pb.Buffer; // so we can call Pb funcs on Buffer obj\n\n struct StakingReward {\n address recipient; // tag: 1\n uint256 cumulativeRewardAmount; // tag: 2\n } // end struct StakingReward\n\n function decStakingReward(bytes memory raw) internal pure returns (StakingReward memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.recipient = Pb._address(buf.decBytes());\n } else if (tag == 2) {\n m.cumulativeRewardAmount = Pb._uint256(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder StakingReward\n\n struct Slash {\n address validator; // tag: 1\n uint64 nonce; // tag: 2\n uint64 slashFactor; // tag: 3\n uint64 expireTime; // tag: 4\n uint64 jailPeriod; // tag: 5\n AcctAmtPair[] collectors; // tag: 6\n } // end struct Slash\n\n function decSlash(bytes memory raw) internal pure returns (Slash memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256[] memory cnts = buf.cntTags(6);\n m.collectors = new AcctAmtPair[](cnts[6]);\n cnts[6] = 0; // reset counter for later use\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.validator = Pb._address(buf.decBytes());\n } else if (tag == 2) {\n m.nonce = uint64(buf.decVarint());\n } else if (tag == 3) {\n m.slashFactor = uint64(buf.decVarint());\n } else if (tag == 4) {\n m.expireTime = uint64(buf.decVarint());\n } else if (tag == 5) {\n m.jailPeriod = uint64(buf.decVarint());\n } else if (tag == 6) {\n m.collectors[cnts[6]] = decAcctAmtPair(buf.decBytes());\n cnts[6]++;\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder Slash\n\n struct AcctAmtPair {\n address account; // tag: 1\n uint256 amount; // tag: 2\n } // end struct AcctAmtPair\n\n function decAcctAmtPair(bytes memory raw) internal pure returns (AcctAmtPair memory m) {\n Pb.Buffer memory buf = Pb.fromBytes(raw);\n\n uint256 tag;\n Pb.WireType wire;\n while (buf.hasMore()) {\n (tag, wire) = buf.decKey();\n if (false) {}\n // solidity has no switch/case\n else if (tag == 1) {\n m.account = Pb._address(buf.decBytes());\n } else if (tag == 2) {\n m.amount = Pb._uint256(buf.decBytes());\n } else {\n buf.skipValue(wire);\n } // skip value of unknown tag\n }\n } // end decoder AcctAmtPair\n}\n" + }, + "contracts/libraries/Utils.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nlibrary Utils {\n // https://ethereum.stackexchange.com/a/83577\n // https://github.com/Uniswap/v3-periphery/blob/v1.0.0/contracts/base/Multicall.sol\n function getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {\n // If the _res length is less than 68, then the transaction failed silently (without a revert message)\n if (_returnData.length < 68) return \"Transaction reverted silently\";\n assembly {\n // Slice the sighash.\n _returnData := add(_returnData, 0x04)\n }\n return abi.decode(_returnData, (string)); // All that remains is the revert string\n }\n}\n" + }, + "contracts/liquidity-bridge/Bridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../libraries/PbBridge.sol\";\nimport \"./Pool.sol\";\n\n/**\n * @title The liquidity-pool based bridge.\n */\ncontract Bridge is Pool {\n using SafeERC20 for IERC20;\n\n // liquidity events\n event Send(\n bytes32 transferId,\n address sender,\n address receiver,\n address token,\n uint256 amount,\n uint64 dstChainId,\n uint64 nonce,\n uint32 maxSlippage\n );\n event Relay(\n bytes32 transferId,\n address sender,\n address receiver,\n address token,\n uint256 amount,\n uint64 srcChainId,\n bytes32 srcTransferId\n );\n // gov events\n event MinSendUpdated(address token, uint256 amount);\n event MaxSendUpdated(address token, uint256 amount);\n\n mapping(bytes32 => bool) public transfers;\n mapping(address => uint256) public minSend; // send _amount must > minSend\n mapping(address => uint256) public maxSend;\n\n // min allowed max slippage uint32 value is slippage * 1M, eg. 0.5% -> 5000\n uint32 public minimalMaxSlippage;\n\n /**\n * @notice Send a cross-chain transfer via the liquidity pool-based bridge.\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\n * @param _receiver The address of the receiver.\n * @param _token The address of the token.\n * @param _amount The amount of the transfer.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the\n * transfer can be refunded.\n */\n function send(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage // slippage * 1M, eg. 0.5% -> 5000\n ) external nonReentrant whenNotPaused {\n bytes32 transferId = _send(_receiver, _token, _amount, _dstChainId, _nonce, _maxSlippage);\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n emit Send(transferId, msg.sender, _receiver, _token, _amount, _dstChainId, _nonce, _maxSlippage);\n }\n\n /**\n * @notice Send a cross-chain transfer via the liquidity pool-based bridge using the native token.\n * @param _receiver The address of the receiver.\n * @param _amount The amount of the transfer.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A unique number. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the\n * transfer can be refunded.\n */\n function sendNative(\n address _receiver,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) external payable nonReentrant whenNotPaused {\n require(msg.value == _amount, \"Amount mismatch\");\n require(nativeWrap != address(0), \"Native wrap not set\");\n bytes32 transferId = _send(_receiver, nativeWrap, _amount, _dstChainId, _nonce, _maxSlippage);\n IWETH(nativeWrap).deposit{value: _amount}();\n emit Send(transferId, msg.sender, _receiver, nativeWrap, _amount, _dstChainId, _nonce, _maxSlippage);\n }\n\n function _send(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage\n ) private returns (bytes32) {\n require(_amount > minSend[_token], \"amount too small\");\n require(maxSend[_token] == 0 || _amount <= maxSend[_token], \"amount too large\");\n require(_maxSlippage > minimalMaxSlippage, \"max slippage too small\");\n bytes32 transferId = keccak256(\n // uint64(block.chainid) for consistency as entire system uses uint64 for chain id\n // len = 20 + 20 + 20 + 32 + 8 + 8 + 8 = 116\n abi.encodePacked(msg.sender, _receiver, _token, _amount, _dstChainId, _nonce, uint64(block.chainid))\n );\n require(transfers[transferId] == false, \"transfer exists\");\n transfers[transferId] = true;\n return transferId;\n }\n\n /**\n * @notice Relay a cross-chain transfer sent from a liquidity pool-based bridge on another chain.\n * @param _relayRequest The serialized Relay protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the bridge's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function relay(\n bytes calldata _relayRequest,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external whenNotPaused {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"Relay\"));\n verifySigs(abi.encodePacked(domain, _relayRequest), _sigs, _signers, _powers);\n PbBridge.Relay memory request = PbBridge.decRelay(_relayRequest);\n // len = 20 + 20 + 20 + 32 + 8 + 8 + 32 = 140\n bytes32 transferId = keccak256(\n abi.encodePacked(\n request.sender,\n request.receiver,\n request.token,\n request.amount,\n request.srcChainId,\n request.dstChainId,\n request.srcTransferId\n )\n );\n require(transfers[transferId] == false, \"transfer exists\");\n transfers[transferId] = true;\n _updateVolume(request.token, request.amount);\n uint256 delayThreshold = delayThresholds[request.token];\n if (delayThreshold > 0 && request.amount > delayThreshold) {\n _addDelayedTransfer(transferId, request.receiver, request.token, request.amount);\n } else {\n _sendToken(request.receiver, request.token, request.amount);\n }\n\n emit Relay(\n transferId,\n request.sender,\n request.receiver,\n request.token,\n request.amount,\n request.srcChainId,\n request.srcTransferId\n );\n }\n\n function setMinSend(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n minSend[_tokens[i]] = _amounts[i];\n emit MinSendUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setMaxSend(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n maxSend[_tokens[i]] = _amounts[i];\n emit MaxSendUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setMinimalMaxSlippage(uint32 _minimalMaxSlippage) external onlyGovernor {\n minimalMaxSlippage = _minimalMaxSlippage;\n }\n\n // This is needed to receive ETH when calling `IWETH.withdraw`\n receive() external payable {}\n}\n" + }, + "contracts/liquidity-bridge/FarmingRewards.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../interfaces/ISigsVerifier.sol\";\nimport \"../libraries/PbFarming.sol\";\nimport \"../safeguard/Pauser.sol\";\n\n/**\n * @title A contract to hold and distribute farming rewards.\n */\ncontract FarmingRewards is Pauser {\n using SafeERC20 for IERC20;\n\n ISigsVerifier public immutable sigsVerifier;\n\n // recipient => tokenAddress => amount\n mapping(address => mapping(address => uint256)) public claimedRewardAmounts;\n\n event FarmingRewardClaimed(address indexed recipient, address indexed token, uint256 reward);\n event FarmingRewardContributed(address indexed contributor, address indexed token, uint256 contribution);\n\n constructor(ISigsVerifier _sigsVerifier) {\n sigsVerifier = _sigsVerifier;\n }\n\n /**\n * @notice Claim rewards\n * @dev Here we use cumulative reward to make claim process idempotent\n * @param _rewardsRequest rewards request bytes coded in protobuf\n * @param _sigs list of signatures sorted by signer addresses in ascending order\n * @param _signers sorted list of current signers\n * @param _powers powers of current signers\n */\n function claimRewards(\n bytes calldata _rewardsRequest,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external whenNotPaused {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"FarmingRewards\"));\n sigsVerifier.verifySigs(abi.encodePacked(domain, _rewardsRequest), _sigs, _signers, _powers);\n PbFarming.FarmingRewards memory rewards = PbFarming.decFarmingRewards(_rewardsRequest);\n bool hasNewReward;\n for (uint256 i = 0; i < rewards.tokenAddresses.length; i++) {\n address token = rewards.tokenAddresses[i];\n uint256 cumulativeRewardAmount = rewards.cumulativeRewardAmounts[i];\n uint256 newReward = cumulativeRewardAmount - claimedRewardAmounts[rewards.recipient][token];\n if (newReward > 0) {\n hasNewReward = true;\n claimedRewardAmounts[rewards.recipient][token] = cumulativeRewardAmount;\n IERC20(token).safeTransfer(rewards.recipient, newReward);\n emit FarmingRewardClaimed(rewards.recipient, token, newReward);\n }\n }\n require(hasNewReward, \"No new reward\");\n }\n\n /**\n * @notice Contribute reward tokens to the reward pool\n * @param _token the address of the token to contribute\n * @param _amount the amount of the token to contribute\n */\n function contributeToRewardPool(address _token, uint256 _amount) external whenNotPaused {\n address contributor = msg.sender;\n IERC20(_token).safeTransferFrom(contributor, address(this), _amount);\n\n emit FarmingRewardContributed(contributor, _token, _amount);\n }\n\n /**\n * @notice Owner drains tokens when the contract is paused\n * @dev emergency use only\n * @param _token the address of the token to drain\n * @param _amount drained token amount\n */\n function drainToken(address _token, uint256 _amount) external whenPaused onlyOwner {\n IERC20(_token).safeTransfer(msg.sender, _amount);\n }\n}\n" + }, + "contracts/liquidity-bridge/Pool.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"../libraries/PbPool.sol\";\nimport \"../safeguard/Pauser.sol\";\nimport \"../safeguard/VolumeControl.sol\";\nimport \"../safeguard/DelayedTransfer.sol\";\nimport \"./Signers.sol\";\n\n/**\n * @title Liquidity pool functions for {Bridge}.\n */\ncontract Pool is Signers, ReentrancyGuard, Pauser, VolumeControl, DelayedTransfer {\n using SafeERC20 for IERC20;\n\n uint64 public addseq; // ensure unique LiquidityAdded event, start from 1\n mapping(address => uint256) public minAdd; // add _amount must > minAdd\n\n // map of successful withdraws, if true means already withdrew money or added to delayedTransfers\n mapping(bytes32 => bool) public withdraws;\n\n // erc20 wrap of gas token of this chain, eg. WETH, when relay ie. pay out,\n // if request.token equals this, will withdraw and send native token to receiver\n // note we don't check whether it's zero address. when this isn't set, and request.token\n // is all 0 address, guarantee fail\n address public nativeWrap;\n\n // when transfer native token after wrap, use this gas used config.\n uint256 public nativeTokenTransferGas = 50000;\n\n // liquidity events\n event LiquidityAdded(\n uint64 seqnum,\n address provider,\n address token,\n uint256 amount // how many tokens were added\n );\n event WithdrawDone(\n bytes32 withdrawId,\n uint64 seqnum,\n address receiver,\n address token,\n uint256 amount,\n bytes32 refid\n );\n event MinAddUpdated(address token, uint256 amount);\n\n /**\n * @notice Add liquidity to the pool-based bridge.\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\n * @param _token The address of the token.\n * @param _amount The amount to add.\n */\n function addLiquidity(address _token, uint256 _amount) external nonReentrant whenNotPaused {\n require(_amount > minAdd[_token], \"amount too small\");\n addseq += 1;\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n emit LiquidityAdded(addseq, msg.sender, _token, _amount);\n }\n\n /**\n * @notice Add native token liquidity to the pool-based bridge.\n * @param _amount The amount to add.\n */\n function addNativeLiquidity(uint256 _amount) external payable nonReentrant whenNotPaused {\n require(msg.value == _amount, \"Amount mismatch\");\n require(nativeWrap != address(0), \"Native wrap not set\");\n require(_amount > minAdd[nativeWrap], \"amount too small\");\n addseq += 1;\n IWETH(nativeWrap).deposit{value: _amount}();\n emit LiquidityAdded(addseq, msg.sender, nativeWrap, _amount);\n }\n\n /**\n * @notice Withdraw funds from the bridge pool.\n * @param _wdmsg The serialized Withdraw protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A withdrawal must be\n * signed-off by +2/3 of the bridge's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function withdraw(\n bytes calldata _wdmsg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external whenNotPaused {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"WithdrawMsg\"));\n verifySigs(abi.encodePacked(domain, _wdmsg), _sigs, _signers, _powers);\n // decode and check wdmsg\n PbPool.WithdrawMsg memory wdmsg = PbPool.decWithdrawMsg(_wdmsg);\n // len = 8 + 8 + 20 + 20 + 32 = 88\n bytes32 wdId = keccak256(\n abi.encodePacked(wdmsg.chainid, wdmsg.seqnum, wdmsg.receiver, wdmsg.token, wdmsg.amount)\n );\n require(withdraws[wdId] == false, \"withdraw already succeeded\");\n withdraws[wdId] = true;\n _updateVolume(wdmsg.token, wdmsg.amount);\n uint256 delayThreshold = delayThresholds[wdmsg.token];\n if (delayThreshold > 0 && wdmsg.amount > delayThreshold) {\n _addDelayedTransfer(wdId, wdmsg.receiver, wdmsg.token, wdmsg.amount);\n } else {\n _sendToken(wdmsg.receiver, wdmsg.token, wdmsg.amount);\n }\n emit WithdrawDone(wdId, wdmsg.seqnum, wdmsg.receiver, wdmsg.token, wdmsg.amount, wdmsg.refid);\n }\n\n function executeDelayedTransfer(bytes32 id) external whenNotPaused {\n delayedTransfer memory transfer = _executeDelayedTransfer(id);\n _sendToken(transfer.receiver, transfer.token, transfer.amount);\n }\n\n function setMinAdd(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n minAdd[_tokens[i]] = _amounts[i];\n emit MinAddUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function _sendToken(\n address _receiver,\n address _token,\n uint256 _amount\n ) internal {\n if (_token == nativeWrap) {\n // withdraw then transfer native to receiver\n IWETH(nativeWrap).withdraw(_amount);\n (bool sent, ) = _receiver.call{value: _amount, gas: nativeTokenTransferGas}(\"\");\n require(sent, \"failed to send native token\");\n } else {\n IERC20(_token).safeTransfer(_receiver, _amount);\n }\n }\n\n // set nativeWrap, for relay requests, if token == nativeWrap, will withdraw first then transfer native to receiver\n function setWrap(address _weth) external onlyOwner {\n nativeWrap = _weth;\n }\n\n // setNativeTransferGasUsed, native transfer will use this config.\n function setNativeTokenTransferGas(uint256 _gasUsed) external onlyGovernor {\n nativeTokenTransferGas = _gasUsed;\n }\n}\n" + }, + "contracts/liquidity-bridge/Signers.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"../safeguard/Ownable.sol\";\nimport \"../interfaces/ISigsVerifier.sol\";\n\n/**\n * @title Multi-sig verification and management functions for {Bridge}.\n */\ncontract Signers is Ownable, ISigsVerifier {\n using ECDSA for bytes32;\n\n bytes32 public ssHash;\n uint256 public triggerTime; // timestamp when last update was triggered\n\n // reset can be called by the owner address for emergency recovery\n uint256 public resetTime;\n uint256 public noticePeriod; // advance notice period as seconds for reset\n uint256 constant MAX_INT = 2**256 - 1;\n\n event SignersUpdated(address[] _signers, uint256[] _powers);\n\n event ResetNotification(uint256 resetTime);\n\n /**\n * @notice Verifies that a message is signed by a quorum among the signers\n * The sigs must be sorted by signer addresses in ascending order.\n * @param _msg signed message\n * @param _sigs list of signatures sorted by signer addresses in ascending order\n * @param _signers sorted list of current signers\n * @param _powers powers of current signers\n */\n function verifySigs(\n bytes memory _msg,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) public view override {\n bytes32 h = keccak256(abi.encodePacked(_signers, _powers));\n require(ssHash == h, \"Mismatch current signers\");\n _verifySignedPowers(keccak256(_msg).toEthSignedMessageHash(), _sigs, _signers, _powers);\n }\n\n /**\n * @notice Update new signers.\n * @param _newSigners sorted list of new signers\n * @param _curPowers powers of new signers\n * @param _sigs list of signatures sorted by signer addresses in ascending order\n * @param _curSigners sorted list of current signers\n * @param _curPowers powers of current signers\n */\n function updateSigners(\n uint256 _triggerTime,\n address[] calldata _newSigners,\n uint256[] calldata _newPowers,\n bytes[] calldata _sigs,\n address[] calldata _curSigners,\n uint256[] calldata _curPowers\n ) external {\n // use trigger time for nonce protection, must be ascending\n require(_triggerTime > triggerTime, \"Trigger time is not increasing\");\n // make sure triggerTime is not too large, as it cannot be decreased once set\n require(_triggerTime < block.timestamp + 3600, \"Trigger time is too large\");\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"UpdateSigners\"));\n verifySigs(abi.encodePacked(domain, _triggerTime, _newSigners, _newPowers), _sigs, _curSigners, _curPowers);\n _updateSigners(_newSigners, _newPowers);\n triggerTime = _triggerTime;\n }\n\n /**\n * @notice reset signers, only used for init setup and emergency recovery\n */\n function resetSigners(address[] calldata _signers, uint256[] calldata _powers) external onlyOwner {\n require(block.timestamp > resetTime, \"not reach reset time\");\n resetTime = MAX_INT;\n _updateSigners(_signers, _powers);\n }\n\n function notifyResetSigners() external onlyOwner {\n resetTime = block.timestamp + noticePeriod;\n emit ResetNotification(resetTime);\n }\n\n function increaseNoticePeriod(uint256 period) external onlyOwner {\n require(period > noticePeriod, \"notice period can only be increased\");\n noticePeriod = period;\n }\n\n // separate from verifySigs func to avoid \"stack too deep\" issue\n function _verifySignedPowers(\n bytes32 _hash,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) private pure {\n require(_signers.length == _powers.length, \"signers and powers length not match\");\n uint256 totalPower; // sum of all signer.power\n for (uint256 i = 0; i < _signers.length; i++) {\n totalPower += _powers[i];\n }\n uint256 quorum = (totalPower * 2) / 3 + 1;\n\n uint256 signedPower; // sum of signer powers who are in sigs\n address prev = address(0);\n uint256 index = 0;\n for (uint256 i = 0; i < _sigs.length; i++) {\n address signer = _hash.recover(_sigs[i]);\n require(signer > prev, \"signers not in ascending order\");\n prev = signer;\n // now find match signer add its power\n while (signer > _signers[index]) {\n index += 1;\n require(index < _signers.length, \"signer not found\");\n }\n if (signer == _signers[index]) {\n signedPower += _powers[index];\n }\n if (signedPower >= quorum) {\n // return early to save gas\n return;\n }\n }\n revert(\"quorum not reached\");\n }\n\n function _updateSigners(address[] calldata _signers, uint256[] calldata _powers) private {\n require(_signers.length == _powers.length, \"signers and powers length not match\");\n address prev = address(0);\n for (uint256 i = 0; i < _signers.length; i++) {\n require(_signers[i] > prev, \"New signers not in ascending order\");\n prev = _signers[i];\n }\n ssHash = keccak256(abi.encodePacked(_signers, _powers));\n emit SignersUpdated(_signers, _powers);\n }\n}\n" + }, + "contracts/liquidity-bridge/WithdrawInbox.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"../safeguard/Ownable.sol\";\n\n/**\n * @title A contract to initiate withdrawal requests for contracts tha provide liquidity to {Bridge}.\n */\ncontract WithdrawInbox is Ownable {\n // min allowed max slippage uint32 value is slippage * 1M, eg. 0.5% -> 5000\n uint32 public minimalMaxSlippage;\n // the period of time during which a withdrawal request is intended to be valid\n uint256 public validityPeriod;\n\n // contract LP withdrawal request\n event WithdrawalRequest(\n uint64 seqNum,\n address sender,\n address receiver,\n uint64 toChain,\n uint64[] fromChains,\n address[] tokens,\n uint32[] ratios,\n uint32[] slippages,\n uint256 deadline\n );\n\n constructor() {\n // default validityPeriod is 2 hours\n validityPeriod = 7200;\n }\n\n /**\n * @notice Withdraw liquidity from the pool-based bridge.\n * NOTE: Each of your withdrawal request should have different _wdSeq.\n * NOTE: Tokens to withdraw within one withdrawal request should have the same symbol.\n * @param _wdSeq The unique sequence number to identify this withdrawal request.\n * @param _receiver The receiver address on _toChain.\n * @param _toChain The chain Id to receive the withdrawn tokens.\n * @param _fromChains The chain Ids to withdraw tokens.\n * @param _tokens The token to withdraw on each fromChain.\n * @param _ratios The withdrawal ratios of each token.\n * @param _slippages The max slippages of each token for cross-chain withdraw.\n */\n function withdraw(\n uint64 _wdSeq,\n address _receiver,\n uint64 _toChain,\n uint64[] calldata _fromChains,\n address[] calldata _tokens,\n uint32[] calldata _ratios,\n uint32[] calldata _slippages\n ) external {\n require(_fromChains.length > 0, \"empty withdrawal request\");\n require(\n _tokens.length == _fromChains.length &&\n _ratios.length == _fromChains.length &&\n _slippages.length == _fromChains.length,\n \"length mismatch\"\n );\n for (uint256 i = 0; i < _ratios.length; i++) {\n require(_ratios[i] > 0 && _ratios[i] <= 1e8, \"invalid ratio\");\n require(_slippages[i] >= minimalMaxSlippage, \"slippage too small\");\n }\n uint256 _deadline = block.timestamp + validityPeriod;\n emit WithdrawalRequest(\n _wdSeq,\n msg.sender,\n _receiver,\n _toChain,\n _fromChains,\n _tokens,\n _ratios,\n _slippages,\n _deadline\n );\n }\n\n // ------------------------Admin operations--------------------------\n\n function setMinimalMaxSlippage(uint32 _minimalMaxSlippage) external onlyOwner {\n minimalMaxSlippage = _minimalMaxSlippage;\n }\n\n function setValidityPeriod(uint256 _validityPeriod) external onlyOwner {\n validityPeriod = _validityPeriod;\n }\n}\n" + }, + "contracts/message/apps/adapter/MessageReceiverAdapter.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"../../framework/MessageApp.sol\";\nimport \"../../safeguard/MessageAppPauser.sol\";\nimport \"../../safeguard/DelayedMessage.sol\";\nimport \"../../../libraries/Utils.sol\";\n\ncontract MessageReceiverAdapter is MessageApp, MessageAppPauser, DelayedMessage {\n event ExternalCall(address srcContract, uint64 srcChainId, address dstContract, bytes callData);\n event AllowedSenderUpdated(address dstContract, uint64 srcChainId, address srcContract, bool allowed);\n\n // dstContract => srcChainId => srcContract => allowed or not\n mapping(address => mapping(uint64 => mapping(address => bool))) public allowedSender;\n\n constructor(address _messageBus) MessageApp(_messageBus) {}\n\n // Called by MessageBus on destination chain to receive cross-chain messages.\n // The message is abi.encode of (dst_contract_address, dst_contract_calldata).\n // If a delayed period is configured, the message would be put in a delayed message queue,\n // otherwise, the external call to the dst contract will be executed immediately\n function executeMessage(\n address _srcContract,\n uint64 _srcChainId,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus whenNotMsgPaused returns (ExecutionStatus) {\n (address dstContract, bytes memory callData) = abi.decode(_message, (address, bytes));\n require(allowedSender[dstContract][_srcChainId][_srcContract], \"not allowed sender\");\n if (delayPeriod > 0) {\n _addDelayedMessage(_srcContract, _srcChainId, _message);\n } else {\n _externalCall(_srcContract, _srcChainId, dstContract, callData);\n }\n return ExecutionStatus.Success;\n }\n\n // execute external call to the dst contract after the message delay period is passed.\n function executeDelayedMessage(\n address _srcContract,\n uint64 _srcChainId,\n bytes calldata _message,\n uint32 _nonce\n ) external payable whenNotPaused {\n _executeDelayedMessage(_srcContract, _srcChainId, _message, _nonce);\n (address dstContract, bytes memory callData) = abi.decode(_message, (address, bytes));\n _externalCall(_srcContract, _srcChainId, dstContract, callData);\n }\n\n function _externalCall(\n address _srcContract,\n uint64 _srcChainId,\n address _dstContract,\n bytes memory _callData\n ) internal {\n (bool ok, bytes memory returnData) = _dstContract.call{value: msg.value}(_callData);\n if (!ok) {\n revert(Utils.getRevertMsg(returnData));\n }\n emit ExternalCall(_srcContract, _srcChainId, _dstContract, _callData);\n }\n\n function setAllowedSender(\n address _dstContract,\n uint64 _srcChainId,\n address[] calldata _srcContracts,\n bool[] calldata _alloweds\n ) external onlyOwner {\n require(_srcContracts.length == _alloweds.length, \"length mismatch\");\n for (uint256 i = 0; i < _srcContracts.length; i++) {\n allowedSender[_dstContract][_srcChainId][_srcContracts[i]] = _alloweds[i];\n emit AllowedSenderUpdated(_dstContract, _srcChainId, _srcContracts[i], _alloweds[i]);\n }\n }\n}\n" + }, + "contracts/message/apps/examples/BatchTransfer.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"../../framework/MessageApp.sol\";\n\n/** @title Sample app to test message passing flow, not for production use */\ncontract BatchTransfer is MessageApp {\n using SafeERC20 for IERC20;\n\n struct TransferRequest {\n uint64 nonce;\n address[] accounts;\n uint256[] amounts;\n address sender;\n }\n\n enum TransferStatus {\n Null,\n Success,\n Fail\n }\n\n struct TransferReceipt {\n uint64 nonce;\n TransferStatus status;\n }\n\n constructor(address _messageBus) MessageApp(_messageBus) {}\n\n // ============== functions and states on source chain ==============\n\n uint64 nonce;\n\n struct BatchTransferStatus {\n bytes32 h; // hash(receiver, dstChainId)\n TransferStatus status;\n }\n mapping(uint64 => BatchTransferStatus) public status; // nonce -> BatchTransferStatus\n\n modifier onlyEOA() {\n require(msg.sender == tx.origin, \"Not EOA\");\n _;\n }\n\n // called by sender on source chain to send tokens to a list of\n // <_accounts, _amounts> on the destination chain\n function batchTransfer(\n address _dstContract, // BatchTransfer contract address at the dst chain\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint32 _maxSlippage,\n MsgDataTypes.BridgeSendType _bridgeSendType,\n address[] calldata _accounts,\n uint256[] calldata _amounts\n ) external payable onlyEOA {\n uint256 totalAmt;\n for (uint256 i = 0; i < _amounts.length; i++) {\n totalAmt += _amounts[i];\n }\n // commented out the slippage check below to trigger failure case for handleFailedMessageWithTransfer testing\n // uint256 minRecv = _amount - (_amount * _maxSlippage) / 1e6;\n // require(minRecv > totalAmt, \"invalid maxSlippage\");\n nonce += 1;\n status[nonce] = BatchTransferStatus({\n h: keccak256(abi.encodePacked(_dstContract, _dstChainId)),\n status: TransferStatus.Null\n });\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n bytes memory message = abi.encode(\n TransferRequest({nonce: nonce, accounts: _accounts, amounts: _amounts, sender: msg.sender})\n );\n // send token and message to the destination chain\n sendMessageWithTransfer(\n _dstContract,\n _token,\n _amount,\n _dstChainId,\n nonce,\n _maxSlippage,\n message,\n _bridgeSendType,\n msg.value\n );\n }\n\n // called by MessageBus on source chain to handle message with token transfer failures (e.g., due to bad slippage).\n // the associated token transfer is guaranteed to have already been refunded\n function executeMessageWithTransferRefund(\n address _token,\n uint256 _amount,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n TransferRequest memory transfer = abi.decode((_message), (TransferRequest));\n IERC20(_token).safeTransfer(transfer.sender, _amount);\n return ExecutionStatus.Success;\n }\n\n // called by MessageBus on source chain to receive receipts\n function executeMessage(\n address _sender,\n uint64 _srcChainId,\n bytes memory _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n TransferReceipt memory receipt = abi.decode((_message), (TransferReceipt));\n require(status[receipt.nonce].h == keccak256(abi.encodePacked(_sender, _srcChainId)), \"invalid message\");\n status[receipt.nonce].status = receipt.status;\n return ExecutionStatus.Success;\n }\n\n // ============== functions on destination chain ==============\n\n // called by MessageBus on destination chain to handle batchTransfer message by\n // distributing tokens to receivers and sending receipt.\n // the lump sum token transfer associated with the message is guaranteed to have already been received.\n function executeMessageWithTransfer(\n address _srcContract,\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes memory _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n TransferRequest memory transfer = abi.decode((_message), (TransferRequest));\n uint256 totalAmt;\n for (uint256 i = 0; i < transfer.accounts.length; i++) {\n IERC20(_token).safeTransfer(transfer.accounts[i], transfer.amounts[i]);\n totalAmt += transfer.amounts[i];\n }\n uint256 remainder = _amount - totalAmt;\n if (_amount > totalAmt) {\n // transfer the remainder of the money to sender as fee for executing this transfer\n IERC20(_token).safeTransfer(transfer.sender, remainder);\n }\n bytes memory message = abi.encode(TransferReceipt({nonce: transfer.nonce, status: TransferStatus.Success}));\n // send receipt back to the source chain contract\n sendMessage(_srcContract, _srcChainId, message, msg.value);\n return ExecutionStatus.Success;\n }\n\n // called by MessageBus if handleMessageWithTransfer above got reverted\n function executeMessageWithTransferFallback(\n address _srcContract,\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes memory _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n TransferRequest memory transfer = abi.decode((_message), (TransferRequest));\n IERC20(_token).safeTransfer(transfer.sender, _amount);\n bytes memory message = abi.encode(TransferReceipt({nonce: transfer.nonce, status: TransferStatus.Fail}));\n // send receipt back to the source chain contract\n sendMessage(_srcContract, _srcChainId, message, msg.value);\n return ExecutionStatus.Success;\n }\n}\n" + }, + "contracts/message/apps/examples/MsgExampleBasic.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"../../framework/MessageApp.sol\";\n\n// A HelloWorld example for basic cross-chain message passing\ncontract MsgExampleBasic is MessageApp {\n event MessageReceived(address srcContract, uint64 srcChainId, address sender, bytes message);\n\n constructor(address _messageBus) MessageApp(_messageBus) {}\n\n // called by user on source chain to send cross-chain messages\n function sendMessage(\n address _dstContract,\n uint64 _dstChainId,\n bytes calldata _message\n ) external payable {\n bytes memory message = abi.encode(msg.sender, _message);\n sendMessage(_dstContract, _dstChainId, message, msg.value);\n }\n\n // called by MessageBus on destination chain to receive cross-chain messages\n function executeMessage(\n address _srcContract,\n uint64 _srcChainId,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n (address sender, bytes memory message) = abi.decode((_message), (address, bytes));\n emit MessageReceived(_srcContract, _srcChainId, sender, message);\n return ExecutionStatus.Success;\n }\n}\n" + }, + "contracts/message/apps/examples/MsgExampleBasicTransfer.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../../framework/MessageApp.sol\";\n\n// A HelloWorld example for basic cross-chain message passing with associate cross-chain token transfer\ncontract MsgExampleBasicTransfer is MessageApp {\n using SafeERC20 for IERC20;\n\n event MessageWithTransferReceived(address sender, address token, uint256 amount, uint64 srcChainId, bytes note);\n event MessageWithTransferRefunded(address sender, address token, uint256 amount, bytes note);\n\n // acccount, token -> balance\n mapping(address => mapping(address => uint256)) public balances;\n\n constructor(address _messageBus) MessageApp(_messageBus) {}\n\n // called by user on source chain to send token with note to destination chain\n function sendTokenWithNote(\n address _dstContract,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage,\n bytes calldata _note,\n MsgDataTypes.BridgeSendType _bridgeSendType\n ) external payable {\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n bytes memory message = abi.encode(msg.sender, _note);\n sendMessageWithTransfer(\n _dstContract,\n _token,\n _amount,\n _dstChainId,\n _nonce,\n _maxSlippage,\n message,\n _bridgeSendType,\n msg.value\n );\n }\n\n // called by MessageBus on destination chain to receive message, record and emit info.\n // the associated token transfer is guaranteed to have already been received\n function executeMessageWithTransfer(\n address, // srcContract\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes memory _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n (address sender, bytes memory note) = abi.decode((_message), (address, bytes));\n balances[sender][_token] += _amount;\n emit MessageWithTransferReceived(sender, _token, _amount, _srcChainId, note);\n return ExecutionStatus.Success;\n }\n\n // called by MessageBus on source chain to handle message with failed token transfer\n // the associated token transfer is guaranteed to have already been refunded\n function executeMessageWithTransferRefund(\n address _token,\n uint256 _amount,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n (address sender, bytes memory note) = abi.decode((_message), (address, bytes));\n IERC20(_token).safeTransfer(sender, _amount);\n emit MessageWithTransferRefunded(sender, _token, _amount, note);\n return ExecutionStatus.Success;\n }\n\n // called by user on destination chain to withdraw tokens\n function withdraw(address _token, uint256 _amount) external {\n balances[msg.sender][_token] -= _amount;\n IERC20(_token).safeTransfer(msg.sender, _amount);\n }\n}\n" + }, + "contracts/message/apps/examples/MsgExampleInOrder.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"../../framework/MessageApp.sol\";\n\n// a simple example to enforce in-order message delivery\ncontract MsgExampleInOrder is MessageApp {\n event MessageReceived(address srcContract, uint64 srcChainId, address sender, uint64 seq, bytes message);\n\n // map at source chain. (dstChainId, dstContract) -> seq\n mapping(uint64 => mapping(address => uint64)) public sendSeq;\n\n // map at destination chain (srcChainId, srcContract) -> seq\n mapping(uint64 => mapping(address => uint64)) public recvSeq;\n\n constructor(address _messageBus) MessageApp(_messageBus) {}\n\n // called by user on source chain to send cross-chain message\n function sendMessage(\n address _dstContract,\n uint64 _dstChainId,\n bytes calldata _message\n ) external payable {\n uint64 seq = sendSeq[_dstChainId][_dstContract];\n bytes memory message = abi.encode(msg.sender, seq, _message);\n sendMessage(_dstContract, _dstChainId, message, msg.value);\n sendSeq[_dstChainId][_dstContract] += 1;\n }\n\n // called by MessageBus on destination chain to receive message\n function executeMessage(\n address _srcContract,\n uint64 _srcChainId,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n (address sender, uint64 seq, bytes memory message) = abi.decode((_message), (address, uint64, bytes));\n uint64 expectedSeq = recvSeq[_srcChainId][_srcContract];\n if (seq != expectedSeq) {\n // sequence number not expected, let executor retry.\n // Note: cannot revert here, because once a message execute tx is reverted, it cannot be retried later.\n return ExecutionStatus.Retry;\n }\n emit MessageReceived(_srcContract, _srcChainId, sender, seq, message);\n recvSeq[_srcChainId][_srcContract] += 1;\n return ExecutionStatus.Success;\n }\n}\n" + }, + "contracts/message/apps/examples/MsgTest.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../../framework/MessageApp.sol\";\nimport \"../../../safeguard/Ownable.sol\";\n\n/** @title Application to test message with transfer refund flow */\ncontract MsgTest is MessageApp, Ownable {\n using SafeERC20 for IERC20;\n uint64 nonce;\n\n event MessageReceivedWithTransfer(\n address token,\n uint256 amount,\n address sender,\n uint64 srcChainId,\n address receiver,\n bytes message\n );\n event Refunded(address receiver, address token, uint256 amount, bytes message);\n event MessageReceived(address sender, uint64 srcChainId, uint64 nonce, bytes message);\n event Message2Received(bytes sender, uint64 srcChainId, uint64 nonce, bytes message);\n\n constructor(address _messageBus) MessageApp(_messageBus) {}\n\n function sendMessageWithTransfer(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint32 _maxSlippage,\n bytes calldata _message,\n MsgDataTypes.BridgeSendType _bridgeSendType\n ) external payable {\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n bytes memory message = abi.encode(msg.sender, _message);\n sendMessageWithTransfer(\n _receiver,\n _token,\n _amount,\n _dstChainId,\n nonce,\n _maxSlippage,\n message,\n _bridgeSendType,\n msg.value\n );\n nonce++;\n }\n\n function executeMessageWithTransfer(\n address _sender,\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes memory _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n (address receiver, bytes memory message) = abi.decode((_message), (address, bytes));\n IERC20(_token).safeTransfer(receiver, _amount);\n emit MessageReceivedWithTransfer(_token, _amount, _sender, _srcChainId, receiver, message);\n return ExecutionStatus.Success;\n }\n\n function executeMessageWithTransferRefund(\n address _token,\n uint256 _amount,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n (address receiver, bytes memory message) = abi.decode((_message), (address, bytes));\n IERC20(_token).safeTransfer(receiver, _amount);\n emit Refunded(receiver, _token, _amount, message);\n return ExecutionStatus.Success;\n }\n\n function sendMessage(\n address _receiver,\n uint64 _dstChainId,\n bytes calldata _message\n ) external payable {\n bytes memory message = abi.encode(nonce, _message);\n nonce++;\n sendMessage(_receiver, _dstChainId, message, msg.value);\n }\n\n function sendMessage(\n bytes calldata _receiver,\n uint64 _dstChainId,\n bytes calldata _message\n ) external payable {\n bytes memory message = abi.encode(nonce, _message);\n nonce++;\n sendMessage(_receiver, _dstChainId, message, msg.value);\n }\n\n function sendMessages(\n address _receiver,\n uint64 _dstChainId,\n bytes[] calldata _messages,\n uint256[] calldata _fees\n ) external payable {\n for (uint256 i = 0; i < _messages.length; i++) {\n bytes memory message = abi.encode(nonce, _messages[i]);\n nonce++;\n sendMessage(_receiver, _dstChainId, message, _fees[i]);\n }\n }\n\n function sendMessageWithNonce(\n address _receiver,\n uint64 _dstChainId,\n bytes calldata _message,\n uint64 _nonce\n ) external payable {\n bytes memory message = abi.encode(_nonce, _message);\n sendMessage(_receiver, _dstChainId, message, msg.value);\n }\n\n function executeMessage(\n address _sender,\n uint64 _srcChainId,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n (uint64 n, bytes memory message) = abi.decode((_message), (uint64, bytes));\n require(n != 100000000000001, \"invalid nonce\"); // test revert with reason\n if (n == 100000000000002) {\n // test revert without reason\n revert();\n } else if (n == 100000000000003) {\n return ExecutionStatus.Retry;\n }\n // test execution revert\n require(n != 100000000000004, _abortReason(\"invalid nonce\"));\n emit MessageReceived(_sender, _srcChainId, n, message);\n return ExecutionStatus.Success;\n }\n\n function executeMessage(\n bytes calldata _sender,\n uint64 _srcChainId,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n (uint64 n, bytes memory message) = abi.decode((_message), (uint64, bytes));\n emit Message2Received(_sender, _srcChainId, n, message);\n return ExecutionStatus.Success;\n }\n\n function drainToken(address _token, uint256 _amount) external onlyOwner {\n IERC20(_token).safeTransfer(msg.sender, _amount);\n }\n}\n" + }, + "contracts/message/apps/examples/TransferSwap.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"../../framework/MessageApp.sol\";\nimport \"../../../safeguard/Ownable.sol\";\nimport \"../../../interfaces/IWETH.sol\";\nimport \"../../../interfaces/IUniswapV2.sol\";\n\n/**\n * @title Demo application contract that facilitates swapping on a chain, transferring to another chain,\n * and swapping another time on the destination chain before sending the result tokens to a user\n */\ncontract TransferSwap is MessageApp, Ownable {\n using SafeERC20 for IERC20;\n\n modifier onlyEOA() {\n require(msg.sender == tx.origin, \"Not EOA\");\n _;\n }\n\n struct SwapInfo {\n // if this array has only one element, it means no need to swap\n address[] path;\n // the following fields are only needed if path.length > 1\n address dex; // the DEX to use for the swap\n uint256 deadline; // deadline for the swap\n uint256 minRecvAmt; // minimum receive amount for the swap\n }\n\n struct SwapRequest {\n SwapInfo swap;\n // the receiving party (the user) of the final output token\n address receiver;\n // this field is best to be per-user per-transaction unique so that\n // a nonce that is specified by the calling party (the user),\n uint64 nonce;\n // indicates whether the output token coming out of the swap on destination\n // chain should be unwrapped before sending to the user\n bool nativeOut;\n }\n\n enum SwapStatus {\n Null,\n Succeeded,\n Failed,\n Fallback\n }\n\n // emitted when requested dstChainId == srcChainId, no bridging\n event DirectSwap(\n bytes32 id,\n uint64 srcChainId,\n uint256 amountIn,\n address tokenIn,\n uint256 amountOut,\n address tokenOut\n );\n event SwapRequestSent(bytes32 id, uint64 dstChainId, uint256 srcAmount, address srcToken, address dstToken);\n event SwapRequestDone(bytes32 id, uint256 dstAmount, SwapStatus status);\n\n mapping(address => uint256) public minSwapAmounts;\n mapping(address => bool) supportedDex;\n\n // erc20 wrap of gas token of this chain, eg. WETH\n address public nativeWrap;\n\n constructor(\n address _messageBus,\n address _supportedDex,\n address _nativeWrap\n ) MessageApp(_messageBus) {\n supportedDex[_supportedDex] = true;\n nativeWrap = _nativeWrap;\n }\n\n function transferWithSwapNative(\n address _receiver,\n uint256 _amountIn,\n uint64 _dstChainId,\n SwapInfo calldata _srcSwap,\n SwapInfo calldata _dstSwap,\n uint32 _maxBridgeSlippage,\n uint64 _nonce,\n bool _nativeOut\n ) external payable onlyEOA {\n require(msg.value >= _amountIn, \"Amount insufficient\");\n require(_srcSwap.path[0] == nativeWrap, \"token mismatch\");\n IWETH(nativeWrap).deposit{value: _amountIn}();\n _transferWithSwap(\n _receiver,\n _amountIn,\n _dstChainId,\n _srcSwap,\n _dstSwap,\n _maxBridgeSlippage,\n _nonce,\n _nativeOut,\n msg.value - _amountIn\n );\n }\n\n function transferWithSwap(\n address _receiver,\n uint256 _amountIn,\n uint64 _dstChainId,\n SwapInfo calldata _srcSwap,\n SwapInfo calldata _dstSwap,\n uint32 _maxBridgeSlippage,\n uint64 _nonce\n ) external payable onlyEOA {\n IERC20(_srcSwap.path[0]).safeTransferFrom(msg.sender, address(this), _amountIn);\n _transferWithSwap(\n _receiver,\n _amountIn,\n _dstChainId,\n _srcSwap,\n _dstSwap,\n _maxBridgeSlippage,\n _nonce,\n false,\n msg.value\n );\n }\n\n /**\n * @notice Sends a cross-chain transfer via the liquidity pool-based bridge and sends a message specifying a wanted swap action on the\n destination chain via the message bus\n * @param _receiver the app contract that implements the MessageReceiver abstract contract\n * NOTE not to be confused with the receiver field in SwapInfo which is an EOA address of a user\n * @param _amountIn the input amount that the user wants to swap and/or bridge\n * @param _dstChainId destination chain ID\n * @param _srcSwap a struct containing swap related requirements\n * @param _dstSwap a struct containing swap related requirements\n * @param _maxBridgeSlippage the max acceptable slippage at bridge, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the\n * transfer can be refunded.\n * @param _fee the fee to pay to MessageBus.\n */\n function _transferWithSwap(\n address _receiver,\n uint256 _amountIn,\n uint64 _dstChainId,\n SwapInfo memory _srcSwap,\n SwapInfo memory _dstSwap,\n uint32 _maxBridgeSlippage,\n uint64 _nonce,\n bool _nativeOut,\n uint256 _fee\n ) private {\n require(_srcSwap.path.length > 0, \"empty src swap path\");\n address srcTokenOut = _srcSwap.path[_srcSwap.path.length - 1];\n\n require(_amountIn > minSwapAmounts[_srcSwap.path[0]], \"amount must be greater than min swap amount\");\n uint64 chainId = uint64(block.chainid);\n require(_srcSwap.path.length > 1 || _dstChainId != chainId, \"noop is not allowed\"); // revert early to save gas\n\n uint256 srcAmtOut = _amountIn;\n\n // swap source token for intermediate token on the source DEX\n if (_srcSwap.path.length > 1) {\n bool ok = true;\n (ok, srcAmtOut) = _trySwap(_srcSwap, _amountIn);\n if (!ok) revert(\"src swap failed\");\n }\n\n if (_dstChainId == chainId) {\n _directSend(_receiver, _amountIn, chainId, _srcSwap, _nonce, srcTokenOut, srcAmtOut);\n } else {\n _crossChainTransferWithSwap(\n _receiver,\n _amountIn,\n chainId,\n _dstChainId,\n _srcSwap,\n _dstSwap,\n _maxBridgeSlippage,\n _nonce,\n _nativeOut,\n _fee,\n srcTokenOut,\n srcAmtOut\n );\n }\n }\n\n function _directSend(\n address _receiver,\n uint256 _amountIn,\n uint64 _chainId,\n SwapInfo memory _srcSwap,\n uint64 _nonce,\n address srcTokenOut,\n uint256 srcAmtOut\n ) private {\n // no need to bridge, directly send the tokens to user\n IERC20(srcTokenOut).safeTransfer(_receiver, srcAmtOut);\n // use uint64 for chainid to be consistent with other components in the system\n bytes32 id = keccak256(abi.encode(msg.sender, _chainId, _receiver, _nonce, _srcSwap));\n emit DirectSwap(id, _chainId, _amountIn, _srcSwap.path[0], srcAmtOut, srcTokenOut);\n }\n\n function _crossChainTransferWithSwap(\n address _receiver,\n uint256 _amountIn,\n uint64 _chainId,\n uint64 _dstChainId,\n SwapInfo memory _srcSwap,\n SwapInfo memory _dstSwap,\n uint32 _maxBridgeSlippage,\n uint64 _nonce,\n bool _nativeOut,\n uint256 _fee,\n address srcTokenOut,\n uint256 srcAmtOut\n ) private {\n require(_dstSwap.path.length > 0, \"empty dst swap path\");\n bytes memory message = abi.encode(\n SwapRequest({swap: _dstSwap, receiver: msg.sender, nonce: _nonce, nativeOut: _nativeOut})\n );\n bytes32 id = _computeSwapRequestId(msg.sender, _chainId, _dstChainId, message);\n // bridge the intermediate token to destination chain along with the message\n // NOTE In production, it's better use a per-user per-transaction nonce so that it's less likely transferId collision\n // would happen at Bridge contract. Currently this nonce is a timestamp supplied by frontend\n sendMessageWithTransfer(\n _receiver,\n srcTokenOut,\n srcAmtOut,\n _dstChainId,\n _nonce,\n _maxBridgeSlippage,\n message,\n MsgDataTypes.BridgeSendType.Liquidity,\n _fee\n );\n emit SwapRequestSent(id, _dstChainId, _amountIn, _srcSwap.path[0], _dstSwap.path[_dstSwap.path.length - 1]);\n }\n\n /**\n * @notice called by MessageBus when the tokens are checked to be arrived at this contract's address.\n sends the amount received to the receiver. swaps beforehand if swap behavior is defined in message\n * NOTE: if the swap fails, it sends the tokens received directly to the receiver as fallback behavior\n * @param _token the address of the token sent through the bridge\n * @param _amount the amount of tokens received at this contract through the cross-chain bridge\n * @param _srcChainId source chain ID\n * @param _message SwapRequest message that defines the swap behavior on this destination chain\n */\n function executeMessageWithTransfer(\n address, // _sender\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes memory _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n SwapRequest memory m = abi.decode((_message), (SwapRequest));\n require(_token == m.swap.path[0], \"bridged token must be the same as the first token in destination swap path\");\n bytes32 id = _computeSwapRequestId(m.receiver, _srcChainId, uint64(block.chainid), _message);\n uint256 dstAmount;\n SwapStatus status = SwapStatus.Succeeded;\n\n if (m.swap.path.length > 1) {\n bool ok = true;\n (ok, dstAmount) = _trySwap(m.swap, _amount);\n if (ok) {\n _sendToken(m.swap.path[m.swap.path.length - 1], dstAmount, m.receiver, m.nativeOut);\n status = SwapStatus.Succeeded;\n } else {\n // handle swap failure, send the received token directly to receiver\n _sendToken(_token, _amount, m.receiver, false);\n dstAmount = _amount;\n status = SwapStatus.Fallback;\n }\n } else {\n // no need to swap, directly send the bridged token to user\n _sendToken(m.swap.path[0], _amount, m.receiver, m.nativeOut);\n dstAmount = _amount;\n status = SwapStatus.Succeeded;\n }\n emit SwapRequestDone(id, dstAmount, status);\n // always return success since swap failure is already handled in-place\n return ExecutionStatus.Success;\n }\n\n /**\n * @notice called by MessageBus when the executeMessageWithTransfer call fails. does nothing but emitting a \"fail\" event\n * @param _srcChainId source chain ID\n * @param _message SwapRequest message that defines the swap behavior on this destination chain\n */\n function executeMessageWithTransferFallback(\n address, // _sender\n address, // _token\n uint256, // _amount\n uint64 _srcChainId,\n bytes memory _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n SwapRequest memory m = abi.decode((_message), (SwapRequest));\n bytes32 id = _computeSwapRequestId(m.receiver, _srcChainId, uint64(block.chainid), _message);\n emit SwapRequestDone(id, 0, SwapStatus.Failed);\n // always return fail to mark this transfer as failed since if this function is called then there nothing more\n // we can do in this app as the swap failures are already handled in executeMessageWithTransfer\n return ExecutionStatus.Fail;\n }\n\n function _trySwap(SwapInfo memory _swap, uint256 _amount) private returns (bool ok, uint256 amountOut) {\n uint256 zero;\n if (!supportedDex[_swap.dex]) {\n return (false, zero);\n }\n IERC20(_swap.path[0]).safeIncreaseAllowance(_swap.dex, _amount);\n try\n IUniswapV2(_swap.dex).swapExactTokensForTokens(\n _amount,\n _swap.minRecvAmt,\n _swap.path,\n address(this),\n _swap.deadline\n )\n returns (uint256[] memory amounts) {\n return (true, amounts[amounts.length - 1]);\n } catch {\n return (false, zero);\n }\n }\n\n function _sendToken(\n address _token,\n uint256 _amount,\n address _receiver,\n bool _nativeOut\n ) private {\n if (_nativeOut) {\n require(_token == nativeWrap, \"token mismatch\");\n IWETH(nativeWrap).withdraw(_amount);\n (bool sent, ) = _receiver.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"failed to send native\");\n } else {\n IERC20(_token).safeTransfer(_receiver, _amount);\n }\n }\n\n function _computeSwapRequestId(\n address _sender,\n uint64 _srcChainId,\n uint64 _dstChainId,\n bytes memory _message\n ) private pure returns (bytes32) {\n return keccak256(abi.encodePacked(_sender, _srcChainId, _dstChainId, _message));\n }\n\n function setMinSwapAmount(address _token, uint256 _minSwapAmount) external onlyOwner {\n minSwapAmounts[_token] = _minSwapAmount;\n }\n\n function setSupportedDex(address _dex, bool _enabled) external onlyOwner {\n supportedDex[_dex] = _enabled;\n }\n\n function setNativeWrap(address _nativeWrap) external onlyOwner {\n nativeWrap = _nativeWrap;\n }\n\n function setMessageBus(address _messageBus) public onlyOwner {\n messageBus = _messageBus;\n }\n\n // This is needed to receive ETH when calling `IWETH.withdraw`\n receive() external payable {}\n}\n" + }, + "contracts/message/apps/examples/TransferSwapSendBack.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"../../framework/MessageApp.sol\";\n\ninterface ISwapToken {\n // function sellBase(address to) external returns (uint256);\n // uniswap v2\n function swapExactTokensForTokens(\n uint256,\n uint256,\n address[] calldata,\n address,\n uint256\n ) external returns (uint256[] memory);\n}\n\ncontract CrossChainSwap is MessageApp {\n using SafeERC20 for IERC20;\n\n address public dex; // needed on swap chain\n\n struct SwapInfo {\n address wantToken; // token user want to receive on dest chain\n address user;\n bool sendBack; // if true, send wantToken back to start chain\n uint32 cbrMaxSlippage; // _maxSlippage for cbridge send\n }\n\n constructor(address _messageBus, address dex_) MessageApp(_messageBus) {\n dex = dex_;\n }\n\n // ========== on start chain ==========\n\n uint64 nonce; // required by IBridge.send\n\n // this func could be called by a router contract\n function startCrossChainSwap(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n SwapInfo calldata swapInfo // wantToken on destChain and actual user address as receiver when send back\n ) external payable {\n nonce += 1;\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n bytes memory message = abi.encode(swapInfo);\n sendMessageWithTransfer(\n _receiver,\n _token,\n _amount,\n _dstChainId,\n nonce,\n swapInfo.cbrMaxSlippage,\n message,\n MsgDataTypes.BridgeSendType.Liquidity,\n msg.value\n );\n }\n\n // ========== on swap chain ==========\n // do dex, send received asset to src chain via bridge\n function executeMessageWithTransfer(\n address, // _sender\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes memory _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n SwapInfo memory swapInfo = abi.decode((_message), (SwapInfo));\n IERC20(_token).approve(dex, _amount);\n address[] memory path = new address[](2);\n path[0] = _token;\n path[1] = swapInfo.wantToken;\n if (swapInfo.sendBack) {\n nonce += 1;\n uint256[] memory swapReturn = ISwapToken(dex).swapExactTokensForTokens(\n _amount,\n 0,\n path,\n address(this),\n type(uint256).max\n );\n // send received token back to start chain. swapReturn[1] is amount of wantToken\n sendTokenTransfer(\n swapInfo.user,\n swapInfo.wantToken,\n swapReturn[1],\n _srcChainId,\n nonce,\n swapInfo.cbrMaxSlippage,\n MsgDataTypes.BridgeSendType.Liquidity\n );\n } else {\n // swap to wantToken and send to user\n ISwapToken(dex).swapExactTokensForTokens(_amount, 0, path, swapInfo.user, type(uint256).max);\n }\n // bytes memory notice; // send back to src chain to handleMessage\n // sendMessage(_sender, _srcChainId, notice);\n return ExecutionStatus.Success;\n }\n}\n" + }, + "contracts/message/apps/nft-bridge/MCNNFT.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol\";\nimport \"../../../safeguard/Pauser.sol\";\n\ninterface INFTBridge {\n function sendMsg(\n uint64 _dstChid,\n address _sender,\n address _receiver,\n uint256 _id,\n string calldata _uri\n ) external payable;\n\n function sendMsg(\n uint64 _dstChid,\n address _sender,\n bytes calldata _receiver,\n uint256 _id,\n string calldata _uri\n ) external payable;\n\n function totalFee(\n uint64 _dstChid,\n address _nft,\n uint256 _id\n ) external view returns (uint256);\n}\n\n// Multi-Chain Native NFT, same contract on all chains. User interacts with this directly.\ncontract MCNNFT is ERC721URIStorage, Pauser {\n event NFTBridgeUpdated(address);\n address public nftBridge;\n\n constructor(\n string memory name_,\n string memory symbol_,\n address _nftBridge\n ) ERC721(name_, symbol_) {\n nftBridge = _nftBridge;\n }\n\n modifier onlyNftBridge() {\n require(msg.sender == nftBridge, \"caller is not bridge\");\n _;\n }\n\n function bridgeMint(\n address to,\n uint256 id,\n string memory uri\n ) external onlyNftBridge {\n _mint(to, id);\n _setTokenURI(id, uri);\n }\n\n // calls nft bridge to get total fee for crossChain msg.Value\n function totalFee(uint64 _dstChid, uint256 _id) external view returns (uint256) {\n return INFTBridge(nftBridge).totalFee(_dstChid, address(this), _id);\n }\n\n // called by user, burn token on this chain and mint same id/uri on dest chain\n function crossChain(\n uint64 _dstChid,\n uint256 _id,\n address _receiver\n ) external payable whenNotPaused {\n require(msg.sender == ownerOf(_id), \"not token owner\");\n string memory _uri = tokenURI(_id);\n _burn(_id);\n INFTBridge(nftBridge).sendMsg{value: msg.value}(_dstChid, msg.sender, _receiver, _id, _uri);\n }\n\n // support chains using bytes for address\n function crossChain(\n uint64 _dstChid,\n uint256 _id,\n bytes calldata _receiver\n ) external payable whenNotPaused {\n require(msg.sender == ownerOf(_id), \"not token owner\");\n string memory _uri = tokenURI(_id);\n _burn(_id);\n INFTBridge(nftBridge).sendMsg{value: msg.value}(_dstChid, msg.sender, _receiver, _id, _uri);\n }\n\n // ===== only Owner\n function mint(\n address to,\n uint256 id,\n string memory uri\n ) external onlyOwner {\n _mint(to, id);\n _setTokenURI(id, uri);\n }\n\n function setNFTBridge(address _newBridge) public onlyOwner {\n nftBridge = _newBridge;\n emit NFTBridgeUpdated(_newBridge);\n }\n}\n" + }, + "contracts/message/apps/nft-bridge/NFTBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity 0.8.17;\n\nimport \"../../framework/MessageReceiverApp.sol\";\nimport \"../../interfaces/IMessageBus.sol\";\nimport \"../../../safeguard/Pauser.sol\";\n\n// interface for NFT contract, ERC721 and metadata, only funcs needed by NFTBridge\ninterface INFT {\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n // we do not support NFT that charges transfer fees\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n // impl by NFToken contract, mint an NFT with id and uri to user or burn\n function bridgeMint(\n address to,\n uint256 id,\n string memory uri\n ) external;\n\n function burn(uint256 id) external;\n}\n\n/** @title NFT Bridge */\ncontract NFTBridge is MessageReceiverApp, Pauser {\n /// per dest chain id executor fee in this chain's gas token\n mapping(uint64 => uint256) public destTxFee;\n /// per dest chain id NFTBridge address\n mapping(uint64 => address) public destBridge;\n /// first key is NFT address on this chain, 2nd key is dest chain id, value is address on dest chain\n mapping(address => mapping(uint64 => address)) public destNFTAddr;\n\n /// only set to true if NFT addr on this chain is the orig, so we will use deposit/withdraw instead of burn/mint.\n /// not applicable for mcn nft (always burn/mint)\n mapping(address => bool) public origNFT;\n\n /// only for non-evm chains and address can't fit 20bytes\n mapping(uint64 => bytes) public destBridge2;\n mapping(address => mapping(uint64 => bytes)) public destNFTAddr2;\n\n struct NFTMsg {\n address user; // receiver of minted or withdrawn NFT\n address nft; // NFT contract on mint/withdraw chain\n uint256 id; // token ID\n string uri; // tokenURI from source NFT\n }\n // for non-evm dst chain, address type is bytes\n struct NFTMsg2 {\n bytes user; // receiver of minted or withdrawn NFT\n bytes nft; // NFT contract on mint/withdraw chain\n uint256 id; // token ID\n string uri; // tokenURI from source NFT\n }\n // emit in deposit or burn\n event Sent(address sender, address srcNft, uint256 id, uint64 dstChid, address receiver, address dstNft);\n // bytes type for receiver and dstNft\n event Sent2(address sender, address srcNft, uint256 id, uint64 dstChid, bytes receiver, bytes dstNft);\n // emit for mint or withdraw message\n event Received(address receiver, address nft, uint256 id, uint64 srcChid);\n\n // emit when params change\n event SetDestNFT(address srcNft, uint64 dstChid, address dstNft);\n event SetTxFee(uint64 chid, uint256 fee);\n event SetDestBridge(uint64 dstChid, address dstNftBridge);\n event FeeClaimed(uint256 amount);\n event SetOrigNFT(address nft, bool isOrig);\n // emit if executeMessage calls nft transfer or bridgeMint returns error\n event ExtCallErr(bytes returnData);\n\n event SetDestNFT2(address srcNft, uint64 dstChid, bytes dstNft);\n event SetDestBridge2(uint64 dstChid, bytes dstNftBridge);\n\n constructor(address _msgBus) {\n messageBus = _msgBus;\n }\n\n // only to be called by Proxy via delegatecall and will modify Proxy state\n // initOwner will fail if owner is already set, so only delegateCall will work\n function init(address _msgBus) external {\n initOwner();\n messageBus = _msgBus;\n }\n\n /**\n * @notice totalFee returns gas token value to be set in user tx, includes both msg fee and executor fee for dest chain\n * @dev we assume if dst chain address are bytes, user and nft are same length, otherwise we need to add receiver to args\n * @param _dstChid dest chain ID\n * @param _nft address of source NFT contract\n * @param _id token ID to bridge (need to get accurate tokenURI length)\n * @return total fee needed for user tx\n */\n function totalFee(\n uint64 _dstChid,\n address _nft,\n uint256 _id\n ) external view returns (uint256) {\n string memory _uri = INFT(_nft).tokenURI(_id);\n bytes memory message;\n // try non-evm first\n bytes memory dstNft = destNFTAddr2[_nft][_dstChid];\n if (dstNft.length > 0) {\n message = abi.encode(NFTMsg2(dstNft, dstNft, _id, _uri));\n } else {\n // evm chains or not configured, assume to be evm, 20 bytes address\n message = abi.encode(NFTMsg(_nft, _nft, _id, _uri));\n }\n return IMessageBus(messageBus).calcFee(message) + destTxFee[_dstChid];\n }\n\n // ===== called by user\n /**\n * @notice locks or burn user's NFT in this contract and send message to mint (or withdraw) on dest chain\n * @param _nft address of source NFT contract\n * @param _id nft token ID to bridge\n * @param _dstChid dest chain ID\n * @param _receiver receiver address on dest chain\n */\n function sendTo(\n address _nft,\n uint256 _id,\n uint64 _dstChid,\n address _receiver\n ) external payable whenNotPaused {\n require(msg.sender == INFT(_nft).ownerOf(_id), \"not token owner\");\n // must save _uri before burn\n string memory _uri = INFT(_nft).tokenURI(_id);\n lockOrBurn(_nft, _id);\n (address _dstBridge, address _dstNft) = checkAddr(_nft, _dstChid);\n msgBus(_dstBridge, _dstChid, abi.encode(NFTMsg(_receiver, _dstNft, _id, _uri)));\n emit Sent(msg.sender, _nft, _id, _dstChid, _receiver, _dstNft);\n }\n\n /**\n * @notice locks or burn user's NFT in this contract and send message to mint (or withdraw) on dest chain\n * @param _nft address of source NFT contract\n * @param _id nft token ID to bridge\n * @param _dstChid dest chain ID\n * @param _receiver receiver address on dest chain, arbitrary bytes\n */\n function sendTo(\n address _nft,\n uint256 _id,\n uint64 _dstChid,\n bytes calldata _receiver\n ) external payable whenNotPaused {\n require(msg.sender == INFT(_nft).ownerOf(_id), \"not token owner\");\n // must save _uri before burn\n string memory _uri = INFT(_nft).tokenURI(_id);\n lockOrBurn(_nft, _id);\n (bytes memory _dstBridge, bytes memory _dstNft) = checkAddr2(_nft, _dstChid);\n msgBus(_dstBridge, _dstChid, abi.encode(NFTMsg2(_receiver, _dstNft, _id, _uri)));\n emit Sent2(msg.sender, _nft, _id, _dstChid, _receiver, _dstNft);\n }\n\n // ===== called by MCN NFT after NFT is burnt\n function sendMsg(\n uint64 _dstChid,\n address _sender,\n address _receiver,\n uint256 _id,\n string calldata _uri\n ) external payable whenNotPaused {\n address _nft = msg.sender;\n (address _dstBridge, address _dstNft) = checkAddr(_nft, _dstChid);\n msgBus(_dstBridge, _dstChid, abi.encode(NFTMsg(_receiver, _dstNft, _id, _uri)));\n emit Sent(_sender, _nft, _id, _dstChid, _receiver, _dstNft);\n }\n\n // for non-evm chains and address can't fit 20bytes or non-hex\n function sendMsg(\n uint64 _dstChid,\n address _sender,\n bytes calldata _receiver,\n uint256 _id,\n string calldata _uri\n ) external payable whenNotPaused {\n address _nft = msg.sender;\n (bytes memory _dstBridge, bytes memory _dstNft) = checkAddr2(_nft, _dstChid);\n msgBus(_dstBridge, _dstChid, abi.encode(NFTMsg2(_receiver, _dstNft, _id, _uri)));\n emit Sent2(_sender, _nft, _id, _dstChid, _receiver, _dstNft);\n }\n\n // ===== called by msgbus\n function executeMessage(\n address sender,\n uint64 srcChid,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n // Must check sender to ensure msg is from another nft bridge\n // but we allow retry later in case it's a temporary config error\n // risk is invalid sender will be retried but this can be easily filtered\n // in executor or require manual trigger for retry\n if (paused() || sender != destBridge[srcChid]) {\n return ExecutionStatus.Retry;\n }\n return xferOrMint(_message, srcChid);\n }\n\n function executeMessage(\n bytes calldata sender,\n uint64 srcChid,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n if (paused() || keccak256(sender) != keccak256(destBridge2[srcChid])) {\n return ExecutionStatus.Retry;\n }\n return xferOrMint(_message, srcChid);\n }\n\n // ===== internal utils\n // lockOrBurn on sender side\n function lockOrBurn(address _nft, uint256 _id) internal {\n if (origNFT[_nft] == true) {\n // deposit\n INFT(_nft).transferFrom(msg.sender, address(this), _id);\n require(INFT(_nft).ownerOf(_id) == address(this), \"transfer NFT failed\");\n } else {\n // burn\n INFT(_nft).burn(_id);\n }\n }\n\n // xferOrMint on receiver side, transfer or mint NFT to receiver\n function xferOrMint(bytes calldata _message, uint64 srcChid) internal returns (ExecutionStatus) {\n // withdraw original locked nft back to user, or mint new nft depending on if this is the orig chain of nft\n NFTMsg memory nftMsg = abi.decode((_message), (NFTMsg));\n // if we are on nft orig chain, use transfer, otherwise, use mint\n // we must never return fail because burnt nft will be lost forever\n if (origNFT[nftMsg.nft] == true) {\n try INFT(nftMsg.nft).transferFrom(address(this), nftMsg.user, nftMsg.id) {\n // do nothing here to move on to emit Received event and return success\n } catch (bytes memory returnData) {\n emit ExtCallErr(returnData);\n return ExecutionStatus.Retry;\n }\n } else {\n try INFT(nftMsg.nft).bridgeMint(nftMsg.user, nftMsg.id, nftMsg.uri) {\n // do nothing here to move on to emit Received event and return success\n } catch (bytes memory returnData) {\n emit ExtCallErr(returnData);\n return ExecutionStatus.Retry;\n }\n }\n emit Received(nftMsg.user, nftMsg.nft, nftMsg.id, srcChid);\n return ExecutionStatus.Success;\n }\n\n // check _nft and destChid are valid, return dstBridge and dstNft\n function checkAddr(address _nft, uint64 _dstChid) internal view returns (address dstBridge, address dstNft) {\n dstBridge = destBridge[_dstChid];\n require(dstBridge != address(0), \"dest NFT Bridge not found\");\n dstNft = destNFTAddr[_nft][_dstChid];\n require(dstNft != address(0), \"dest NFT not found\");\n }\n\n function checkAddr2(address _nft, uint64 _dstChid)\n internal\n view\n returns (bytes memory dstBridge, bytes memory dstNft)\n {\n dstBridge = destBridge2[_dstChid];\n require(dstBridge.length != 0, \"dest NFT Bridge not found\");\n dstNft = destNFTAddr2[_nft][_dstChid];\n require(dstNft.length != 0, \"dest NFT not found\");\n }\n\n // check fee and call msgbus sendMessage\n function msgBus(\n address _dstBridge,\n uint64 _dstChid,\n bytes memory message\n ) internal {\n uint256 fee = IMessageBus(messageBus).calcFee(message);\n require(msg.value >= fee + destTxFee[_dstChid], \"insufficient fee\");\n IMessageBus(messageBus).sendMessage{value: fee}(_dstBridge, _dstChid, message);\n }\n\n function msgBus(\n bytes memory _dstBridge,\n uint64 _dstChid,\n bytes memory message\n ) internal {\n uint256 fee = IMessageBus(messageBus).calcFee(message);\n require(msg.value >= fee + destTxFee[_dstChid], \"insufficient fee\");\n IMessageBus(messageBus).sendMessage{value: fee}(_dstBridge, _dstChid, message);\n }\n\n // only owner\n // set per NFT, per chain id, address\n function setDestNFT(\n address srcNft,\n uint64 dstChid,\n address dstNft\n ) external onlyOwner {\n destNFTAddr[srcNft][dstChid] = dstNft;\n emit SetDestNFT(srcNft, dstChid, dstNft);\n }\n\n // add to destNFTAddr2\n function setDestNFT(\n address srcNft,\n uint64 dstChid,\n bytes calldata dstNft\n ) external onlyOwner {\n destNFTAddr2[srcNft][dstChid] = dstNft;\n emit SetDestNFT2(srcNft, dstChid, dstNft);\n }\n\n // set all dest chains\n function setDestNFTs(\n address srcNft,\n uint64[] calldata dstChid,\n address[] calldata dstNft\n ) external onlyOwner {\n require(dstChid.length == dstNft.length, \"length mismatch\");\n for (uint256 i = 0; i < dstChid.length; i++) {\n destNFTAddr[srcNft][dstChid[i]] = dstNft[i];\n }\n }\n\n // set destTxFee\n function setTxFee(uint64 chid, uint256 fee) external onlyOwner {\n destTxFee[chid] = fee;\n emit SetTxFee(chid, fee);\n }\n\n // set per chain id, nft bridge address\n function setDestBridge(uint64 dstChid, address dstNftBridge) external onlyOwner {\n destBridge[dstChid] = dstNftBridge;\n emit SetDestBridge(dstChid, dstNftBridge);\n }\n\n function setDestBridge(uint64 dstChid, bytes calldata dstNftBridge) external onlyOwner {\n destBridge2[dstChid] = dstNftBridge;\n emit SetDestBridge2(dstChid, dstNftBridge);\n }\n\n // batch set nft bridge addresses for multiple chainids\n function setDestBridges(uint64[] calldata dstChid, address[] calldata dstNftBridge) external onlyOwner {\n for (uint256 i = 0; i < dstChid.length; i++) {\n destBridge[dstChid[i]] = dstNftBridge[i];\n }\n }\n\n // only called on NFT's orig chain, not applicable for mcn nft\n function setOrigNFT(address _nft) external onlyOwner {\n origNFT[_nft] = true;\n emit SetOrigNFT(_nft, true);\n }\n\n // remove origNFT entry\n function delOrigNFT(address _nft) external onlyOwner {\n delete origNFT[_nft];\n emit SetOrigNFT(_nft, false);\n }\n\n // send all gas token this contract has to owner\n function claimFee() external onlyOwner {\n uint256 amount = address(this).balance;\n payable(msg.sender).transfer(amount);\n emit FeeClaimed(amount);\n }\n}\n" + }, + "contracts/message/apps/nft-bridge/OrigNFT.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol\";\nimport \"../../../safeguard/Ownable.sol\";\n\ncontract OrigNFT is ERC721URIStorage, Ownable {\n constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {}\n\n function mint(\n address to,\n uint256 id,\n string memory uri\n ) external onlyOwner {\n _mint(to, id);\n _setTokenURI(id, uri);\n }\n}\n" + }, + "contracts/message/apps/nft-bridge/PegNFT.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol\";\n\ncontract PegNFT is ERC721URIStorage {\n address public immutable nftBridge;\n\n constructor(\n string memory name_,\n string memory symbol_,\n address _nftBridge\n ) ERC721(name_, symbol_) {\n nftBridge = _nftBridge;\n }\n\n modifier onlyNftBridge() {\n require(msg.sender == nftBridge, \"caller is not bridge\");\n _;\n }\n\n function bridgeMint(\n address to,\n uint256 id,\n string memory uri\n ) external onlyNftBridge {\n _mint(to, id);\n _setTokenURI(id, uri);\n }\n\n function burn(uint256 id) external onlyNftBridge {\n _burn(id);\n }\n}\n" + }, + "contracts/message/apps/RFQ.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"../framework/MessageSenderApp.sol\";\nimport \"../framework/MessageReceiverApp.sol\";\nimport \"../../safeguard/Pauser.sol\";\nimport \"../../safeguard/Governor.sol\";\nimport \"../../message/interfaces/IMessageBus.sol\";\nimport \"../../interfaces/IWETH.sol\";\n\n/** @title rfq contract */\ncontract RFQ is MessageSenderApp, MessageReceiverApp, Pauser, Governor {\n using SafeERC20 for IERC20;\n using ECDSA for bytes32;\n\n struct Quote {\n uint64 srcChainId;\n address srcToken;\n uint256 srcAmount;\n uint256 srcReleaseAmount;\n uint64 dstChainId;\n address dstToken;\n uint256 dstAmount;\n uint64 deadline;\n uint64 nonce;\n address sender;\n address receiver;\n address refundTo;\n address liquidityProvider;\n }\n\n enum QuoteStatus {\n Null,\n SrcDeposited, // sender deposited\n SrcReleased, // released ERC20 token to liquidity provider\n SrcReleasedNative, // released native token to liquidity provider\n SrcRefunded, // refunded ERC20 token to refundTo/sender\n SrcRefundedNative, // refunded native token to refundTo/sender\n DstRefundInitiated, // refund initiated\n DstTransferred, // transferred ERC20 token to receiver\n DstTransferredNative // transferred native token to reciever\n }\n\n enum MessageType {\n Null,\n Release,\n Refund\n }\n\n address public nativeWrap;\n mapping(uint64 => address) public remoteRfqContracts;\n // msg => bool\n mapping(bytes32 => bool) public unconsumedMsg;\n // quoteHash => QuoteStatus\n mapping(bytes32 => QuoteStatus) public quotes;\n\n address public treasuryAddr;\n uint32 public feePercGlobal;\n // chainId => feePercOverride, support override fee perc of this chain\n mapping(uint64 => uint32) public feePercOverride;\n // tokenAddr => feeBalance\n mapping(address => uint256) public protocolFee;\n\n // market maker => allowed signer\n mapping(address => address) public allowedSigner;\n\n event SrcDeposited(bytes32 quoteHash, Quote quote);\n event DstTransferred(bytes32 quoteHash, address receiver, address dstToken, uint256 amount);\n event RefundInitiated(bytes32 quoteHash);\n event SrcReleased(bytes32 quoteHash, address liquidityProvider, address srcToken, uint256 amount);\n event Refunded(bytes32 quoteHash, address refundTo, address srcToken, uint256 amount);\n event RfqContractsUpdated(uint64[] chainIds, address[] remoteRfqContracts);\n event FeePercUpdated(uint64[] chainIds, uint32[] feePercs);\n event TreasuryAddrUpdated(address treasuryAddr);\n event FeeCollected(address treasuryAddr, address token, uint256 amount);\n\n constructor(address _messageBus) {\n messageBus = _messageBus;\n }\n\n function srcDeposit(Quote calldata _quote, uint64 _submissionDeadline)\n external\n payable\n whenNotPaused\n returns (bytes32)\n {\n bytes32 quoteHash = _srcDeposit(_quote, _submissionDeadline, msg.value);\n IERC20(_quote.srcToken).safeTransferFrom(msg.sender, address(this), _quote.srcAmount);\n return quoteHash;\n }\n\n function srcDepositNative(Quote calldata _quote, uint64 _submissionDeadline)\n external\n payable\n whenNotPaused\n returns (bytes32)\n {\n require(nativeWrap != address(0), \"Rfq: native wrap not set\");\n require(_quote.srcToken == nativeWrap, \"Rfq: src token mismatch\");\n require(msg.value >= _quote.srcAmount, \"Rfq: insufficient amount\");\n bytes32 quoteHash = _srcDeposit(_quote, _submissionDeadline, msg.value - _quote.srcAmount);\n IWETH(nativeWrap).deposit{value: _quote.srcAmount}();\n return quoteHash;\n }\n\n function _srcDeposit(\n Quote calldata _quote,\n uint64 _submissionDeadline,\n uint256 _msgFee\n ) private returns (bytes32) {\n require(\n _submissionDeadline > block.timestamp && _quote.deadline > _submissionDeadline,\n \"Rfq: inappropriate deadline\"\n );\n require(\n _quote.receiver != address(0) && _quote.liquidityProvider != address(0),\n \"Rfq: invalid receiver or liquidityProvider\"\n );\n require(_quote.srcChainId == uint64(block.chainid), \"Rfq: src chainId mismatch\");\n require(_quote.sender == msg.sender, \"Rfq: sender mismatch\");\n bytes32 quoteHash = getQuoteHash(_quote);\n require(quotes[quoteHash] == QuoteStatus.Null, \"Rfq: quote hash exists\");\n uint256 rfqFee = getRfqFee(_quote.dstChainId, _quote.srcAmount);\n require(rfqFee <= _quote.srcAmount - _quote.srcReleaseAmount, \"Rfq: insufficient protocol fee\");\n\n quotes[quoteHash] = QuoteStatus.SrcDeposited;\n if (_quote.srcChainId != _quote.dstChainId) {\n address msgReceiver = remoteRfqContracts[_quote.dstChainId];\n require(msgReceiver != address(0), \"Rfq: dst contract not set\");\n bytes memory message = abi.encodePacked(quoteHash);\n sendMessage(msgReceiver, _quote.dstChainId, message, _msgFee);\n }\n emit SrcDeposited(quoteHash, _quote);\n return quoteHash;\n }\n\n function dstTransfer(Quote calldata _quote) external payable whenNotPaused {\n (bytes32 quoteHash, address msgReceiver) = _dstTransferCheck(_quote);\n quotes[quoteHash] = QuoteStatus.DstTransferred;\n bytes memory message = abi.encodePacked(keccak256(abi.encodePacked(quoteHash, MessageType.Release)));\n sendMessage(msgReceiver, _quote.srcChainId, message, msg.value);\n IERC20(_quote.dstToken).safeTransferFrom(msg.sender, _quote.receiver, _quote.dstAmount);\n emit DstTransferred(quoteHash, _quote.receiver, _quote.dstToken, _quote.dstAmount);\n }\n\n function dstTransferNative(Quote calldata _quote) external payable whenNotPaused {\n require(_quote.dstToken == nativeWrap, \"Rfq: dst token mismatch\");\n require(msg.value >= _quote.dstAmount, \"Rfq: insufficient amount\");\n (bytes32 quoteHash, address msgReceiver) = _dstTransferCheck(_quote);\n quotes[quoteHash] = QuoteStatus.DstTransferredNative;\n bytes memory message = abi.encodePacked(keccak256(abi.encodePacked(quoteHash, MessageType.Release)));\n sendMessage(msgReceiver, _quote.srcChainId, message, msg.value - _quote.dstAmount);\n _transferNativeToken(_quote.receiver, _quote.dstAmount);\n emit DstTransferred(quoteHash, _quote.receiver, _quote.dstToken, _quote.dstAmount);\n }\n\n // As transferFrom is not available for native token, dstTransferNativeWithSig is not supported\n function dstTransferWithSig(Quote calldata _quote, bytes calldata _sig) external payable whenNotPaused {\n (bytes32 quoteHash, address msgReceiver) = _dstTransferCheck(_quote);\n verifySigOfQuoteHash(_quote.liquidityProvider, quoteHash, _sig);\n quotes[quoteHash] = QuoteStatus.DstTransferred;\n bytes memory message = abi.encodePacked(keccak256(abi.encodePacked(quoteHash, MessageType.Release)));\n sendMessage(msgReceiver, _quote.srcChainId, message, msg.value);\n IERC20(_quote.dstToken).safeTransferFrom(_quote.liquidityProvider, _quote.receiver, _quote.dstAmount);\n emit DstTransferred(quoteHash, _quote.receiver, _quote.dstToken, _quote.dstAmount);\n }\n\n function sameChainTransfer(Quote calldata _quote, bool _releaseNative) external payable whenNotPaused {\n require(_quote.srcChainId == _quote.dstChainId, \"Rfq: not same chain swap\");\n (bytes32 quoteHash, ) = _dstTransferCheck(_quote);\n IERC20(_quote.dstToken).safeTransferFrom(msg.sender, _quote.receiver, _quote.dstAmount);\n _srcRelease(_quote, quoteHash, _releaseNative);\n emit DstTransferred(quoteHash, _quote.receiver, _quote.dstToken, _quote.dstAmount);\n }\n\n function sameChainTransferNative(Quote calldata _quote, bool _releaseNative) external payable whenNotPaused {\n require(_quote.srcChainId == _quote.dstChainId, \"Rfq: not same chain swap\");\n require(_quote.dstToken == nativeWrap, \"Rfq: dst token mismatch\");\n require(msg.value == _quote.dstAmount, \"Rfq: native token amount mismatch\");\n (bytes32 quoteHash, ) = _dstTransferCheck(_quote);\n _transferNativeToken(_quote.receiver, _quote.dstAmount);\n _srcRelease(_quote, quoteHash, _releaseNative);\n emit DstTransferred(quoteHash, _quote.receiver, _quote.dstToken, _quote.dstAmount);\n }\n\n // As transferFrom is not available for native token, sameChainTransferNativeWithSig is not supported\n function sameChainTransferWithSig(\n Quote calldata _quote,\n bool _releaseNative,\n bytes calldata _sig\n ) external payable whenNotPaused {\n require(_quote.srcChainId == _quote.dstChainId, \"Rfq: not same chain swap\");\n (bytes32 quoteHash, ) = _dstTransferCheck(_quote);\n verifySigOfQuoteHash(_quote.liquidityProvider, quoteHash, _sig);\n IERC20(_quote.dstToken).safeTransferFrom(_quote.liquidityProvider, _quote.receiver, _quote.dstAmount);\n _srcRelease(_quote, quoteHash, _releaseNative);\n emit DstTransferred(quoteHash, _quote.receiver, _quote.dstToken, _quote.dstAmount);\n }\n\n function _dstTransferCheck(Quote calldata _quote) private view returns (bytes32, address) {\n require(_quote.deadline > block.timestamp, \"Rfq: transfer deadline passed\");\n require(_quote.dstChainId == uint64(block.chainid), \"Rfq: dst chainId mismatch\");\n bytes32 quoteHash = getQuoteHash(_quote);\n address msgReceiver = remoteRfqContracts[_quote.srcChainId];\n if (_quote.srcChainId != _quote.dstChainId) {\n require(quotes[quoteHash] == QuoteStatus.Null, \"Rfq: quote already executed\");\n require(msgReceiver != address(0), \"Rfq: dst rfq contract not set\");\n } else {\n require(quotes[quoteHash] == QuoteStatus.SrcDeposited, \"Rfq: no deposit on same chain\");\n }\n return (quoteHash, msgReceiver);\n }\n\n function srcRelease(Quote calldata _quote, bytes calldata _execMsgCallData) external whenNotPaused {\n bytes32 quoteHash = _srcReleaseCheck(_quote, _execMsgCallData);\n _srcRelease(_quote, quoteHash, false);\n }\n\n function srcReleaseNative(Quote calldata _quote, bytes calldata _execMsgCallData) external whenNotPaused {\n require(_quote.srcToken == nativeWrap, \"Rfq: src token mismatch\");\n bytes32 quoteHash = _srcReleaseCheck(_quote, _execMsgCallData);\n _srcRelease(_quote, quoteHash, true);\n }\n\n function _srcReleaseCheck(Quote calldata _quote, bytes calldata _execMsgCallData) private returns (bytes32) {\n bytes32 quoteHash = getQuoteHash(_quote);\n require(quotes[quoteHash] == QuoteStatus.SrcDeposited, \"Rfq: incorrect quote hash\");\n _receiveMessage(_execMsgCallData, quoteHash, MessageType.Release);\n return quoteHash;\n }\n\n function _srcRelease(\n Quote calldata _quote,\n bytes32 _quoteHash,\n bool _releaseNative\n ) private {\n protocolFee[_quote.srcToken] += (_quote.srcAmount - _quote.srcReleaseAmount);\n if (_releaseNative) {\n quotes[_quoteHash] = QuoteStatus.SrcReleasedNative;\n _withdrawNativeToken(_quote.liquidityProvider, _quote.srcReleaseAmount);\n } else {\n quotes[_quoteHash] = QuoteStatus.SrcReleased;\n IERC20(_quote.srcToken).safeTransfer(_quote.liquidityProvider, _quote.srcReleaseAmount);\n }\n emit SrcReleased(_quoteHash, _quote.liquidityProvider, _quote.srcToken, _quote.srcReleaseAmount);\n }\n\n function requestRefund(Quote calldata _quote) external payable whenNotPaused {\n require(_quote.deadline < block.timestamp, \"Rfq: transfer deadline not passed\");\n require(_quote.dstChainId == uint64(block.chainid), \"Rfq: dst chainId mismatch\");\n address _receiver = remoteRfqContracts[_quote.srcChainId];\n require(_receiver != address(0), \"Rfq: src rfq contract not set\");\n bytes32 quoteHash = getQuoteHash(_quote);\n require(quotes[quoteHash] == QuoteStatus.Null, \"Rfq: quote already executed\");\n\n quotes[quoteHash] = QuoteStatus.DstRefundInitiated;\n bytes memory message = abi.encodePacked(keccak256(abi.encodePacked(quoteHash, MessageType.Refund)));\n sendMessage(_receiver, _quote.srcChainId, message, msg.value);\n emit RefundInitiated(quoteHash);\n }\n\n function executeRefund(Quote calldata _quote, bytes calldata _execMsgCallData) external whenNotPaused {\n (bytes32 quoteHash, address receiver) = _executeRefund(_quote, _execMsgCallData);\n quotes[quoteHash] = QuoteStatus.SrcRefunded;\n IERC20(_quote.srcToken).safeTransfer(receiver, _quote.srcAmount);\n emit Refunded(quoteHash, receiver, _quote.srcToken, _quote.srcAmount);\n }\n\n function executeRefundNative(Quote calldata _quote, bytes calldata _execMsgCallData) external whenNotPaused {\n require(_quote.srcToken == nativeWrap, \"Rfq: src token mismatch\");\n (bytes32 quoteHash, address receiver) = _executeRefund(_quote, _execMsgCallData);\n quotes[quoteHash] = QuoteStatus.SrcRefundedNative;\n _withdrawNativeToken(_quote.receiver, _quote.srcAmount);\n emit Refunded(quoteHash, receiver, _quote.srcToken, _quote.srcAmount);\n }\n\n function _executeRefund(Quote calldata _quote, bytes calldata _execMsgCallData) private returns (bytes32, address) {\n bytes32 quoteHash = getQuoteHash(_quote);\n require(quotes[quoteHash] == QuoteStatus.SrcDeposited, \"Rfq: incorrect quote hash\");\n if (_quote.srcChainId != _quote.dstChainId) {\n _receiveMessage(_execMsgCallData, quoteHash, MessageType.Refund);\n } else {\n require(_quote.deadline < block.timestamp, \"Rfq: transfer deadline not passed\");\n }\n address receiver = (_quote.refundTo == address(0)) ? _quote.sender : _quote.refundTo;\n return (quoteHash, receiver);\n }\n\n function executeMessage(\n address _sender,\n uint64 _srcChainId,\n bytes calldata _message,\n address // executor\n ) external payable override onlyMessageBus returns (ExecutionStatus) {\n require(_message.length == 32, \"Rfq: incorrect message length\");\n address expectedSender = remoteRfqContracts[_srcChainId];\n if (expectedSender != _sender) {\n return ExecutionStatus.Retry;\n }\n unconsumedMsg[bytes32(_message)] = true;\n return ExecutionStatus.Success;\n }\n\n function collectFee(address _token) external {\n require(treasuryAddr != address(0), \"Rfq: treasury address not set\");\n uint256 feeAmount = protocolFee[_token];\n protocolFee[_token] = 0;\n IERC20(_token).safeTransfer(treasuryAddr, feeAmount);\n emit FeeCollected(treasuryAddr, _token, feeAmount);\n }\n\n function registerAllowedSigner(address _signer) external {\n if (_signer == address(0)) {\n delete (allowedSigner[msg.sender]);\n } else {\n allowedSigner[msg.sender] = _signer;\n }\n }\n\n // This is needed to receive ETH\n receive() external payable {}\n\n //=========================== helper functions ==========================\n\n function getQuoteHash(Quote calldata _quote) public pure returns (bytes32) {\n return\n keccak256(\n abi.encodePacked(\n _quote.srcChainId,\n _quote.srcToken,\n _quote.srcAmount,\n _quote.srcReleaseAmount,\n _quote.dstChainId,\n _quote.dstToken,\n _quote.dstAmount,\n _quote.deadline,\n _quote.nonce,\n _quote.sender,\n _quote.receiver,\n _quote.refundTo,\n _quote.liquidityProvider\n )\n );\n }\n\n function getRfqFee(uint64 _chainId, uint256 _amount) public view returns (uint256) {\n uint32 feePerc = feePercOverride[_chainId];\n if (feePerc == 0) {\n feePerc = feePercGlobal;\n }\n return (_amount * feePerc) / 1e6;\n }\n\n function getMsgFee(bytes calldata _message) public view returns (uint256) {\n return IMessageBus(messageBus).calcFee(_message);\n }\n\n function getSignerOfQuoteHash(bytes32 _quoteHash, bytes calldata _sig) public view returns (address) {\n bytes32 msgHash = keccak256(abi.encodePacked(block.chainid, address(this), \"AllowedTransfer\", _quoteHash))\n .toEthSignedMessageHash();\n return msgHash.recover(_sig);\n }\n\n function verifySigOfQuoteHash(\n address _liquidityProvider,\n bytes32 _quoteHash,\n bytes calldata _sig\n ) public view {\n address signer = getSignerOfQuoteHash(_quoteHash, _sig);\n require(\n signer == _liquidityProvider ||\n (allowedSigner[_liquidityProvider] != address(0) && signer == allowedSigner[_liquidityProvider]),\n \"Rfq: not allowed signer\"\n );\n }\n\n function _receiveMessage(\n bytes calldata _execMsgCallData,\n bytes32 _quoteHash,\n MessageType _msgType\n ) private {\n bytes32 expectedMsg = keccak256(abi.encodePacked(_quoteHash, _msgType));\n if (!unconsumedMsg[expectedMsg]) {\n (bool success, ) = messageBus.call(_execMsgCallData);\n require(success, \"execute msg failed\");\n }\n require(unconsumedMsg[expectedMsg], \"Rfq: invalid msg\");\n delete unconsumedMsg[expectedMsg];\n }\n\n function _transferNativeToken(address _receiver, uint256 _amount) private {\n require(nativeWrap != address(0), \"Rfq: native wrap not set\");\n (bool sent, ) = _receiver.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"Rfq: failed to transfer native token\");\n }\n\n function _withdrawNativeToken(address _receiver, uint256 _amount) private {\n require(nativeWrap != address(0), \"Rfq: native wrap not set\");\n IWETH(nativeWrap).withdraw(_amount);\n (bool sent, ) = _receiver.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"Rfq: failed to withdraw native token\");\n }\n\n //=========================== admin operations ==========================\n\n function setRemoteRfqContracts(uint64[] calldata _chainIds, address[] calldata _remoteRfqContracts)\n external\n onlyOwner\n {\n require(_chainIds.length == _remoteRfqContracts.length, \"Rfq: length mismatch\");\n for (uint256 i = 0; i < _chainIds.length; i++) {\n remoteRfqContracts[_chainIds[i]] = _remoteRfqContracts[i];\n }\n emit RfqContractsUpdated(_chainIds, _remoteRfqContracts);\n }\n\n function setFeePerc(uint64[] calldata _chainIds, uint32[] calldata _feePercs) external onlyGovernor {\n require(_chainIds.length == _feePercs.length, \"Rfq: length mismatch\");\n for (uint256 i = 0; i < _chainIds.length; i++) {\n require(_feePercs[i] < 1e6, \"Rfq: fee percentage too large\");\n if (_chainIds[i] == 0) {\n feePercGlobal = _feePercs[i];\n } else {\n feePercOverride[_chainIds[i]] = _feePercs[i];\n }\n }\n emit FeePercUpdated(_chainIds, _feePercs);\n }\n\n function setTreasuryAddr(address _treasuryAddr) external onlyOwner {\n treasuryAddr = _treasuryAddr;\n emit TreasuryAddrUpdated(_treasuryAddr);\n }\n\n function setNativeWrap(address _nativeWrap) external onlyOwner {\n nativeWrap = _nativeWrap;\n }\n}\n" + }, + "contracts/message/framework/MessageApp.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"./MessageSenderApp.sol\";\nimport \"./MessageReceiverApp.sol\";\n\nabstract contract MessageApp is MessageSenderApp, MessageReceiverApp {\n constructor(address _messageBus) {\n messageBus = _messageBus;\n }\n}\n" + }, + "contracts/message/framework/MessageBusAddress.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nabstract contract MessageBusAddress {\n address public messageBus;\n}\n" + }, + "contracts/message/framework/MessageReceiverApp.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"../interfaces/IMessageReceiverApp.sol\";\nimport \"../libraries/MsgDataTypes.sol\";\nimport \"./MessageBusAddress.sol\";\n\nabstract contract MessageReceiverApp is IMessageReceiverApp, MessageBusAddress {\n modifier onlyMessageBus() {\n require(msg.sender == messageBus, \"caller is not message bus\");\n _;\n }\n\n // Add abort prefix in the reason string for require or revert.\n // This will abort (revert) the message execution without markig it as failed state,\n // making it possible to retry later.\n function _abortReason(string memory reason) internal pure returns (string memory) {\n return MsgDataTypes.abortReason(reason);\n }\n\n /**\n * @notice Called by MessageBus to execute a message\n * @param _sender The address of the source app contract\n * @param _srcChainId The source chain ID where the transfer is originated from\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _executor Address who called the MessageBus execution function\n */\n function executeMessage(\n address _sender,\n uint64 _srcChainId,\n bytes calldata _message,\n address _executor\n ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}\n\n // execute message from non-evm chain with bytes for sender address,\n // otherwise same as above.\n function executeMessage(\n bytes calldata _sender,\n uint64 _srcChainId,\n bytes calldata _message,\n address _executor\n ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}\n\n /**\n * @notice Called by MessageBus to execute a message with an associated token transfer.\n * The contract is guaranteed to have received the right amount of tokens before this function is called.\n * @param _sender The address of the source app contract\n * @param _token The address of the token that comes out of the bridge\n * @param _amount The amount of tokens received at this contract through the cross-chain bridge.\n * @param _srcChainId The source chain ID where the transfer is originated from\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _executor Address who called the MessageBus execution function\n */\n function executeMessageWithTransfer(\n address _sender,\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes calldata _message,\n address _executor\n ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}\n\n /**\n * @notice Only called by MessageBus if\n * 1. executeMessageWithTransfer reverts, or\n * 2. executeMessageWithTransfer returns ExecutionStatus.Fail\n * The contract is guaranteed to have received the right amount of tokens before this function is called.\n * @param _sender The address of the source app contract\n * @param _token The address of the token that comes out of the bridge\n * @param _amount The amount of tokens received at this contract through the cross-chain bridge.\n * @param _srcChainId The source chain ID where the transfer is originated from\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _executor Address who called the MessageBus execution function\n */\n function executeMessageWithTransferFallback(\n address _sender,\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes calldata _message,\n address _executor\n ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}\n\n /**\n * @notice Called by MessageBus to process refund of the original transfer from this contract.\n * The contract is guaranteed to have received the refund before this function is called.\n * @param _token The token address of the original transfer\n * @param _amount The amount of the original transfer\n * @param _message The same message associated with the original transfer\n * @param _executor Address who called the MessageBus execution function\n */\n function executeMessageWithTransferRefund(\n address _token,\n uint256 _amount,\n bytes calldata _message,\n address _executor\n ) external payable virtual override onlyMessageBus returns (ExecutionStatus) {}\n}\n" + }, + "contracts/message/framework/MessageSenderApp.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport \"../libraries/MsgDataTypes.sol\";\nimport \"../libraries/MessageSenderLib.sol\";\nimport \"../messagebus/MessageBus.sol\";\nimport \"./MessageBusAddress.sol\";\n\nabstract contract MessageSenderApp is MessageBusAddress {\n using SafeERC20 for IERC20;\n\n // ============== Utility functions called by apps ==============\n\n /**\n * @notice Sends a message to a contract on another chain.\n * Sender needs to make sure the uniqueness of the message Id, which is computed as\n * hash(type.MessageOnly, sender, receiver, srcChainId, srcTxHash, dstChainId, message).\n * If messages with the same Id are sent, only one of them will succeed at dst chain.\n * @param _receiver The address of the destination app contract.\n * @param _dstChainId The destination chain ID.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n * @param _fee The fee amount to pay to MessageBus.\n */\n function sendMessage(\n address _receiver,\n uint64 _dstChainId,\n bytes memory _message,\n uint256 _fee\n ) internal {\n MessageSenderLib.sendMessage(_receiver, _dstChainId, _message, messageBus, _fee);\n }\n\n // Send message to non-evm chain with bytes for receiver address,\n // otherwise same as above.\n function sendMessage(\n bytes calldata _receiver,\n uint64 _dstChainId,\n bytes memory _message,\n uint256 _fee\n ) internal {\n MessageSenderLib.sendMessage(_receiver, _dstChainId, _message, messageBus, _fee);\n }\n\n /**\n * @notice Sends a message associated with a transfer to a contract on another chain.\n * @param _receiver The address of the destination app contract.\n * @param _token The address of the token to be sent.\n * @param _amount The amount of tokens to be sent.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least\n * (100% - max slippage percentage) * amount or the transfer can be refunded.\n * Only applicable to the {MsgDataTypes.BridgeSendType.Liquidity}.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n * If message is empty, only the token transfer will be sent\n * @param _bridgeSendType One of the {BridgeSendType} enum.\n * @param _fee The fee amount to pay to MessageBus.\n * @return The transfer ID.\n */\n function sendMessageWithTransfer(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage,\n bytes memory _message,\n MsgDataTypes.BridgeSendType _bridgeSendType,\n uint256 _fee\n ) internal returns (bytes32) {\n return\n MessageSenderLib.sendMessageWithTransfer(\n _receiver,\n _token,\n _amount,\n _dstChainId,\n _nonce,\n _maxSlippage,\n _message,\n _bridgeSendType,\n messageBus,\n _fee\n );\n }\n\n /**\n * @notice Sends a token transfer via a bridge.\n * @dev sendMessageWithTransfer with empty message\n * @param _receiver The address of the destination app contract.\n * @param _token The address of the token to be sent.\n * @param _amount The amount of tokens to be sent.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least\n * (100% - max slippage percentage) * amount or the transfer can be refunded.\n * Only applicable to the {MsgDataTypes.BridgeSendType.Liquidity}.\n * @param _bridgeSendType One of the {BridgeSendType} enum.\n */\n function sendTokenTransfer(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage,\n MsgDataTypes.BridgeSendType _bridgeSendType\n ) internal returns (bytes32) {\n return\n MessageSenderLib.sendMessageWithTransfer(\n _receiver,\n _token,\n _amount,\n _dstChainId,\n _nonce,\n _maxSlippage,\n \"\", // empty message, which will not trigger sendMessage\n _bridgeSendType,\n messageBus,\n 0\n );\n }\n}\n" + }, + "contracts/message/interfaces/IMessageBus.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"../libraries/MsgDataTypes.sol\";\n\ninterface IMessageBus {\n /**\n * @notice Send a message to a contract on another chain.\n * Sender needs to make sure the uniqueness of the message Id, which is computed as\n * hash(type.MessageOnly, sender, receiver, srcChainId, srcTxHash, dstChainId, message).\n * If messages with the same Id are sent, only one of them will succeed at dst chain..\n * A fee is charged in the native gas token.\n * @param _receiver The address of the destination app contract.\n * @param _dstChainId The destination chain ID.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n */\n function sendMessage(\n address _receiver,\n uint256 _dstChainId,\n bytes calldata _message\n ) external payable;\n\n // same as above, except that receiver is an non-evm chain address,\n function sendMessage(\n bytes calldata _receiver,\n uint256 _dstChainId,\n bytes calldata _message\n ) external payable;\n\n /**\n * @notice Send a message associated with a token transfer to a contract on another chain.\n * If messages with the same srcTransferId are sent, only one of them will succeed at dst chain..\n * A fee is charged in the native token.\n * @param _receiver The address of the destination app contract.\n * @param _dstChainId The destination chain ID.\n * @param _srcBridge The bridge contract to send the transfer with.\n * @param _srcTransferId The transfer ID.\n * @param _dstChainId The destination chain ID.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n */\n function sendMessageWithTransfer(\n address _receiver,\n uint256 _dstChainId,\n address _srcBridge,\n bytes32 _srcTransferId,\n bytes calldata _message\n ) external payable;\n\n /**\n * @notice Execute a message not associated with a transfer.\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function executeMessage(\n bytes calldata _message,\n MsgDataTypes.RouteInfo calldata _route,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external payable;\n\n /**\n * @notice Execute a message with a successful transfer.\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _transfer The transfer info.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function executeMessageWithTransfer(\n bytes calldata _message,\n MsgDataTypes.TransferInfo calldata _transfer,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external payable;\n\n /**\n * @notice Execute a message with a refunded transfer.\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _transfer The transfer info.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function executeMessageWithTransferRefund(\n bytes calldata _message, // the same message associated with the original transfer\n MsgDataTypes.TransferInfo calldata _transfer,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external payable;\n\n /**\n * @notice Withdraws message fee in the form of native gas token.\n * @param _account The address receiving the fee.\n * @param _cumulativeFee The cumulative fee credited to the account. Tracked by SGN.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A withdrawal must be\n * signed-off by +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function withdrawFee(\n address _account,\n uint256 _cumulativeFee,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external;\n\n /**\n * @notice Calculates the required fee for the message.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n @ @return The required fee.\n */\n function calcFee(bytes calldata _message) external view returns (uint256);\n\n function liquidityBridge() external view returns (address);\n\n function pegBridge() external view returns (address);\n\n function pegBridgeV2() external view returns (address);\n\n function pegVault() external view returns (address);\n\n function pegVaultV2() external view returns (address);\n}\n" + }, + "contracts/message/interfaces/IMessageReceiverApp.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\ninterface IMessageReceiverApp {\n enum ExecutionStatus {\n Fail, // execution failed, finalized\n Success, // execution succeeded, finalized\n Retry // execution rejected, can retry later\n }\n\n /**\n * @notice Called by MessageBus to execute a message\n * @param _sender The address of the source app contract\n * @param _srcChainId The source chain ID where the transfer is originated from\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _executor Address who called the MessageBus execution function\n */\n function executeMessage(\n address _sender,\n uint64 _srcChainId,\n bytes calldata _message,\n address _executor\n ) external payable returns (ExecutionStatus);\n\n // same as above, except that sender is an non-evm chain address,\n // otherwise same as above.\n function executeMessage(\n bytes calldata _sender,\n uint64 _srcChainId,\n bytes calldata _message,\n address _executor\n ) external payable returns (ExecutionStatus);\n\n /**\n * @notice Called by MessageBus to execute a message with an associated token transfer.\n * The contract is guaranteed to have received the right amount of tokens before this function is called.\n * @param _sender The address of the source app contract\n * @param _token The address of the token that comes out of the bridge\n * @param _amount The amount of tokens received at this contract through the cross-chain bridge.\n * @param _srcChainId The source chain ID where the transfer is originated from\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _executor Address who called the MessageBus execution function\n */\n function executeMessageWithTransfer(\n address _sender,\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes calldata _message,\n address _executor\n ) external payable returns (ExecutionStatus);\n\n /**\n * @notice Only called by MessageBus if\n * 1. executeMessageWithTransfer reverts, or\n * 2. executeMessageWithTransfer returns ExecutionStatus.Fail\n * The contract is guaranteed to have received the right amount of tokens before this function is called.\n * @param _sender The address of the source app contract\n * @param _token The address of the token that comes out of the bridge\n * @param _amount The amount of tokens received at this contract through the cross-chain bridge.\n * @param _srcChainId The source chain ID where the transfer is originated from\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _executor Address who called the MessageBus execution function\n */\n function executeMessageWithTransferFallback(\n address _sender,\n address _token,\n uint256 _amount,\n uint64 _srcChainId,\n bytes calldata _message,\n address _executor\n ) external payable returns (ExecutionStatus);\n\n /**\n * @notice Called by MessageBus to process refund of the original transfer from this contract.\n * The contract is guaranteed to have received the refund before this function is called.\n * @param _token The token address of the original transfer\n * @param _amount The amount of the original transfer\n * @param _message The same message associated with the original transfer\n * @param _executor Address who called the MessageBus execution function\n */\n function executeMessageWithTransferRefund(\n address _token,\n uint256 _amount,\n bytes calldata _message,\n address _executor\n ) external payable returns (ExecutionStatus);\n}\n" + }, + "contracts/message/libraries/MessageSenderLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"../../interfaces/IBridge.sol\";\nimport \"../../interfaces/IOriginalTokenVault.sol\";\nimport \"../../interfaces/IOriginalTokenVaultV2.sol\";\nimport \"../../interfaces/IPeggedTokenBridge.sol\";\nimport \"../../interfaces/IPeggedTokenBridgeV2.sol\";\nimport \"../interfaces/IMessageBus.sol\";\nimport \"./MsgDataTypes.sol\";\n\nlibrary MessageSenderLib {\n using SafeERC20 for IERC20;\n\n // ============== Internal library functions called by apps ==============\n\n /**\n * @notice Sends a message to an app on another chain via MessageBus without an associated transfer.\n * @param _receiver The address of the destination app contract.\n * @param _dstChainId The destination chain ID.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n * @param _messageBus The address of the MessageBus on this chain.\n * @param _fee The fee amount to pay to MessageBus.\n */\n function sendMessage(\n address _receiver,\n uint64 _dstChainId,\n bytes memory _message,\n address _messageBus,\n uint256 _fee\n ) internal {\n IMessageBus(_messageBus).sendMessage{value: _fee}(_receiver, _dstChainId, _message);\n }\n\n // Send message to non-evm chain with bytes for receiver address,\n // otherwise same as above.\n function sendMessage(\n bytes calldata _receiver,\n uint64 _dstChainId,\n bytes memory _message,\n address _messageBus,\n uint256 _fee\n ) internal {\n IMessageBus(_messageBus).sendMessage{value: _fee}(_receiver, _dstChainId, _message);\n }\n\n /**\n * @notice Sends a message to an app on another chain via MessageBus with an associated transfer.\n * @param _receiver The address of the destination app contract.\n * @param _token The address of the token to be sent.\n * @param _amount The amount of tokens to be sent.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the\n * transfer can be refunded. Only applicable to the {MsgDataTypes.BridgeSendType.Liquidity}.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n * @param _bridgeSendType One of the {MsgDataTypes.BridgeSendType} enum.\n * @param _messageBus The address of the MessageBus on this chain.\n * @param _fee The fee amount to pay to MessageBus.\n * @return The transfer ID.\n */\n function sendMessageWithTransfer(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage,\n bytes memory _message,\n MsgDataTypes.BridgeSendType _bridgeSendType,\n address _messageBus,\n uint256 _fee\n ) internal returns (bytes32) {\n (bytes32 transferId, address bridge) = sendTokenTransfer(\n _receiver,\n _token,\n _amount,\n _dstChainId,\n _nonce,\n _maxSlippage,\n _bridgeSendType,\n _messageBus\n );\n if (_message.length > 0) {\n IMessageBus(_messageBus).sendMessageWithTransfer{value: _fee}(\n _receiver,\n _dstChainId,\n bridge,\n transferId,\n _message\n );\n }\n return transferId;\n }\n\n /**\n * @notice Sends a token transfer via a bridge.\n * @param _receiver The address of the destination app contract.\n * @param _token The address of the token to be sent.\n * @param _amount The amount of tokens to be sent.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least (100% - max slippage percentage) * amount or the\n * transfer can be refunded.\n * @param _bridgeSendType One of the {MsgDataTypes.BridgeSendType} enum.\n */\n function sendTokenTransfer(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage,\n MsgDataTypes.BridgeSendType _bridgeSendType,\n address _messageBus\n ) internal returns (bytes32 transferId, address bridge) {\n if (_bridgeSendType == MsgDataTypes.BridgeSendType.Liquidity) {\n bridge = IMessageBus(_messageBus).liquidityBridge();\n IERC20(_token).safeIncreaseAllowance(bridge, _amount);\n IBridge(bridge).send(_receiver, _token, _amount, _dstChainId, _nonce, _maxSlippage);\n transferId = computeLiqBridgeTransferId(_receiver, _token, _amount, _dstChainId, _nonce);\n } else if (_bridgeSendType == MsgDataTypes.BridgeSendType.PegDeposit) {\n bridge = IMessageBus(_messageBus).pegVault();\n IERC20(_token).safeIncreaseAllowance(bridge, _amount);\n IOriginalTokenVault(bridge).deposit(_token, _amount, _dstChainId, _receiver, _nonce);\n transferId = computePegV1DepositId(_receiver, _token, _amount, _dstChainId, _nonce);\n } else if (_bridgeSendType == MsgDataTypes.BridgeSendType.PegBurn) {\n bridge = IMessageBus(_messageBus).pegBridge();\n IERC20(_token).safeIncreaseAllowance(bridge, _amount);\n IPeggedTokenBridge(bridge).burn(_token, _amount, _receiver, _nonce);\n // handle cases where certain tokens do not spend allowance for role-based burn\n IERC20(_token).safeApprove(bridge, 0);\n transferId = computePegV1BurnId(_receiver, _token, _amount, _nonce);\n } else if (_bridgeSendType == MsgDataTypes.BridgeSendType.PegV2Deposit) {\n bridge = IMessageBus(_messageBus).pegVaultV2();\n IERC20(_token).safeIncreaseAllowance(bridge, _amount);\n transferId = IOriginalTokenVaultV2(bridge).deposit(_token, _amount, _dstChainId, _receiver, _nonce);\n } else if (_bridgeSendType == MsgDataTypes.BridgeSendType.PegV2Burn) {\n bridge = IMessageBus(_messageBus).pegBridgeV2();\n IERC20(_token).safeIncreaseAllowance(bridge, _amount);\n transferId = IPeggedTokenBridgeV2(bridge).burn(_token, _amount, _dstChainId, _receiver, _nonce);\n // handle cases where certain tokens do not spend allowance for role-based burn\n IERC20(_token).safeApprove(bridge, 0);\n } else if (_bridgeSendType == MsgDataTypes.BridgeSendType.PegV2BurnFrom) {\n bridge = IMessageBus(_messageBus).pegBridgeV2();\n IERC20(_token).safeIncreaseAllowance(bridge, _amount);\n transferId = IPeggedTokenBridgeV2(bridge).burnFrom(_token, _amount, _dstChainId, _receiver, _nonce);\n // handle cases where certain tokens do not spend allowance for role-based burn\n IERC20(_token).safeApprove(bridge, 0);\n } else {\n revert(\"bridge type not supported\");\n }\n }\n\n function computeLiqBridgeTransferId(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce\n ) internal view returns (bytes32) {\n return\n keccak256(\n abi.encodePacked(address(this), _receiver, _token, _amount, _dstChainId, _nonce, uint64(block.chainid))\n );\n }\n\n function computePegV1DepositId(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce\n ) internal view returns (bytes32) {\n return\n keccak256(\n abi.encodePacked(address(this), _token, _amount, _dstChainId, _receiver, _nonce, uint64(block.chainid))\n );\n }\n\n function computePegV1BurnId(\n address _receiver,\n address _token,\n uint256 _amount,\n uint64 _nonce\n ) internal view returns (bytes32) {\n return keccak256(abi.encodePacked(address(this), _token, _amount, _receiver, _nonce, uint64(block.chainid)));\n }\n}\n" + }, + "contracts/message/libraries/MsgDataTypes.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nlibrary MsgDataTypes {\n string constant ABORT_PREFIX = \"MSG::ABORT:\";\n\n // Add abort prefix in the reason string for require or revert.\n // This will abort (revert) the message execution without markig it as failed state,\n // making it possible to retry later.\n function abortReason(string memory reason) internal pure returns (string memory) {\n return string.concat(MsgDataTypes.ABORT_PREFIX, reason);\n }\n\n // bridge operation type at the sender side (src chain)\n enum BridgeSendType {\n Null,\n Liquidity,\n PegDeposit,\n PegBurn,\n PegV2Deposit,\n PegV2Burn,\n PegV2BurnFrom\n }\n\n // bridge operation type at the receiver side (dst chain)\n enum TransferType {\n Null,\n LqRelay, // relay through liquidity bridge\n LqWithdraw, // withdraw from liquidity bridge\n PegMint, // mint through pegged token bridge\n PegWithdraw, // withdraw from original token vault\n PegV2Mint, // mint through pegged token bridge v2\n PegV2Withdraw // withdraw from original token vault v2\n }\n\n enum MsgType {\n MessageWithTransfer,\n MessageOnly\n }\n\n enum TxStatus {\n Null,\n Success,\n Fail,\n Fallback,\n Pending // transient state within a transaction\n }\n\n struct TransferInfo {\n TransferType t;\n address sender;\n address receiver;\n address token;\n uint256 amount;\n uint64 wdseq; // only needed for LqWithdraw (refund)\n uint64 srcChainId;\n bytes32 refId;\n bytes32 srcTxHash; // src chain msg tx hash\n }\n\n struct RouteInfo {\n address sender;\n address receiver;\n uint64 srcChainId;\n bytes32 srcTxHash; // src chain msg tx hash\n }\n\n // used for msg from non-evm chains with longer-bytes address\n struct RouteInfo2 {\n bytes sender;\n address receiver;\n uint64 srcChainId;\n bytes32 srcTxHash;\n }\n\n // combination of RouteInfo and RouteInfo2 for easier processing\n struct Route {\n address sender; // from RouteInfo\n bytes senderBytes; // from RouteInfo2\n address receiver;\n uint64 srcChainId;\n bytes32 srcTxHash;\n }\n\n struct MsgWithTransferExecutionParams {\n bytes message;\n TransferInfo transfer;\n bytes[] sigs;\n address[] signers;\n uint256[] powers;\n }\n\n struct BridgeTransferParams {\n bytes request;\n bytes[] sigs;\n address[] signers;\n uint256[] powers;\n }\n}\n" + }, + "contracts/message/messagebus/MessageBus.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./MessageBusSender.sol\";\nimport \"./MessageBusReceiver.sol\";\n\ncontract MessageBus is MessageBusSender, MessageBusReceiver {\n constructor(\n ISigsVerifier _sigsVerifier,\n address _liquidityBridge,\n address _pegBridge,\n address _pegVault,\n address _pegBridgeV2,\n address _pegVaultV2\n )\n MessageBusSender(_sigsVerifier)\n MessageBusReceiver(_liquidityBridge, _pegBridge, _pegVault, _pegBridgeV2, _pegVaultV2)\n {}\n\n // this is only to be called by Proxy via delegateCall as initOwner will require _owner is 0.\n // so calling init on this contract directly will guarantee to fail\n function init(\n address _liquidityBridge,\n address _pegBridge,\n address _pegVault,\n address _pegBridgeV2,\n address _pegVaultV2\n ) external {\n // MUST manually call ownable init and must only call once\n initOwner();\n // we don't need sender init as _sigsVerifier is immutable so already in the deployed code\n initReceiver(_liquidityBridge, _pegBridge, _pegVault, _pegBridgeV2, _pegVaultV2);\n }\n}\n" + }, + "contracts/message/messagebus/MessageBusReceiver.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"../libraries/MsgDataTypes.sol\";\nimport \"../interfaces/IMessageReceiverApp.sol\";\nimport \"../../interfaces/IBridge.sol\";\nimport \"../../interfaces/IOriginalTokenVault.sol\";\nimport \"../../interfaces/IOriginalTokenVaultV2.sol\";\nimport \"../../interfaces/IPeggedTokenBridge.sol\";\nimport \"../../interfaces/IPeggedTokenBridgeV2.sol\";\nimport \"../../interfaces/IDelayedTransfer.sol\";\nimport \"../../safeguard/Ownable.sol\";\nimport \"../../libraries/Utils.sol\";\n\ncontract MessageBusReceiver is Ownable {\n mapping(bytes32 => MsgDataTypes.TxStatus) public executedMessages;\n\n address public liquidityBridge; // liquidity bridge address\n address public pegBridge; // peg bridge address\n address public pegVault; // peg original vault address\n address public pegBridgeV2; // peg bridge address\n address public pegVaultV2; // peg original vault address\n\n // minimum amount of gas needed by this contract before it tries to\n // deliver a message to the target contract.\n uint256 public preExecuteMessageGasUsage;\n\n event Executed(\n MsgDataTypes.MsgType msgType,\n bytes32 msgId,\n MsgDataTypes.TxStatus status,\n address indexed receiver,\n uint64 srcChainId,\n bytes32 srcTxHash\n );\n event NeedRetry(MsgDataTypes.MsgType msgType, bytes32 msgId, uint64 srcChainId, bytes32 srcTxHash);\n event CallReverted(string reason); // help debug\n\n event LiquidityBridgeUpdated(address liquidityBridge);\n event PegBridgeUpdated(address pegBridge);\n event PegVaultUpdated(address pegVault);\n event PegBridgeV2Updated(address pegBridgeV2);\n event PegVaultV2Updated(address pegVaultV2);\n\n constructor(\n address _liquidityBridge,\n address _pegBridge,\n address _pegVault,\n address _pegBridgeV2,\n address _pegVaultV2\n ) {\n liquidityBridge = _liquidityBridge;\n pegBridge = _pegBridge;\n pegVault = _pegVault;\n pegBridgeV2 = _pegBridgeV2;\n pegVaultV2 = _pegVaultV2;\n }\n\n function initReceiver(\n address _liquidityBridge,\n address _pegBridge,\n address _pegVault,\n address _pegBridgeV2,\n address _pegVaultV2\n ) internal {\n require(liquidityBridge == address(0), \"liquidityBridge already set\");\n liquidityBridge = _liquidityBridge;\n pegBridge = _pegBridge;\n pegVault = _pegVault;\n pegBridgeV2 = _pegBridgeV2;\n pegVaultV2 = _pegVaultV2;\n }\n\n // ============== functions called by executor ==============\n\n /**\n * @notice Execute a message with a successful transfer.\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _transfer The transfer info.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function executeMessageWithTransfer(\n bytes calldata _message,\n MsgDataTypes.TransferInfo calldata _transfer,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) public payable {\n // For message with token transfer, message Id is computed through transfer info\n // in order to guarantee that each transfer can only be used once.\n bytes32 messageId = verifyTransfer(_transfer);\n require(executedMessages[messageId] == MsgDataTypes.TxStatus.Null, \"transfer already executed\");\n executedMessages[messageId] = MsgDataTypes.TxStatus.Pending;\n\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"MessageWithTransfer\"));\n IBridge(liquidityBridge).verifySigs(\n abi.encodePacked(domain, messageId, _message, _transfer.srcTxHash),\n _sigs,\n _signers,\n _powers\n );\n MsgDataTypes.TxStatus status;\n IMessageReceiverApp.ExecutionStatus est = executeMessageWithTransfer(_transfer, _message);\n if (est == IMessageReceiverApp.ExecutionStatus.Success) {\n status = MsgDataTypes.TxStatus.Success;\n } else if (est == IMessageReceiverApp.ExecutionStatus.Retry) {\n executedMessages[messageId] = MsgDataTypes.TxStatus.Null;\n emit NeedRetry(\n MsgDataTypes.MsgType.MessageWithTransfer,\n messageId,\n _transfer.srcChainId,\n _transfer.srcTxHash\n );\n return;\n } else {\n est = executeMessageWithTransferFallback(_transfer, _message);\n if (est == IMessageReceiverApp.ExecutionStatus.Success) {\n status = MsgDataTypes.TxStatus.Fallback;\n } else {\n status = MsgDataTypes.TxStatus.Fail;\n }\n }\n executedMessages[messageId] = status;\n emitMessageWithTransferExecutedEvent(messageId, status, _transfer);\n }\n\n /**\n * @notice Execute a message with a refunded transfer.\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _transfer The transfer info.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function executeMessageWithTransferRefund(\n bytes calldata _message, // the same message associated with the original transfer\n MsgDataTypes.TransferInfo calldata _transfer,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) public payable {\n // similar to executeMessageWithTransfer\n bytes32 messageId = verifyTransfer(_transfer);\n require(executedMessages[messageId] == MsgDataTypes.TxStatus.Null, \"transfer already executed\");\n executedMessages[messageId] = MsgDataTypes.TxStatus.Pending;\n\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"MessageWithTransferRefund\"));\n IBridge(liquidityBridge).verifySigs(\n abi.encodePacked(domain, messageId, _message, _transfer.srcTxHash),\n _sigs,\n _signers,\n _powers\n );\n MsgDataTypes.TxStatus status;\n IMessageReceiverApp.ExecutionStatus est = executeMessageWithTransferRefund(_transfer, _message);\n if (est == IMessageReceiverApp.ExecutionStatus.Success) {\n status = MsgDataTypes.TxStatus.Success;\n } else if (est == IMessageReceiverApp.ExecutionStatus.Retry) {\n executedMessages[messageId] = MsgDataTypes.TxStatus.Null;\n emit NeedRetry(\n MsgDataTypes.MsgType.MessageWithTransfer,\n messageId,\n _transfer.srcChainId,\n _transfer.srcTxHash\n );\n return;\n } else {\n status = MsgDataTypes.TxStatus.Fail;\n }\n executedMessages[messageId] = status;\n emitMessageWithTransferExecutedEvent(messageId, status, _transfer);\n }\n\n /**\n * @notice Execute a message not associated with a transfer.\n * @param _message Arbitrary message bytes originated from and encoded by the source app contract\n * @param _route The info about the sender and the receiver.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function executeMessage(\n bytes calldata _message,\n MsgDataTypes.RouteInfo calldata _route,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external payable {\n MsgDataTypes.Route memory route = getRouteInfo(_route);\n executeMessage(_message, route, _sigs, _signers, _powers, \"Message\");\n }\n\n // execute message from non-evm chain with bytes for sender address,\n // otherwise same as above.\n function executeMessage(\n bytes calldata _message,\n MsgDataTypes.RouteInfo2 calldata _route,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external payable {\n MsgDataTypes.Route memory route = getRouteInfo(_route);\n executeMessage(_message, route, _sigs, _signers, _powers, \"Message2\");\n }\n\n function executeMessage(\n bytes calldata _message,\n MsgDataTypes.Route memory _route,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers,\n string memory domainName\n ) private {\n // For message without associated token transfer, message Id is computed through message info,\n // in order to guarantee that each message can only be applied once\n bytes32 messageId = computeMessageOnlyId(_route, _message);\n require(executedMessages[messageId] == MsgDataTypes.TxStatus.Null, \"message already executed\");\n executedMessages[messageId] = MsgDataTypes.TxStatus.Pending;\n\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), domainName));\n IBridge(liquidityBridge).verifySigs(abi.encodePacked(domain, messageId), _sigs, _signers, _powers);\n MsgDataTypes.TxStatus status;\n IMessageReceiverApp.ExecutionStatus est = executeMessage(_route, _message);\n if (est == IMessageReceiverApp.ExecutionStatus.Success) {\n status = MsgDataTypes.TxStatus.Success;\n } else if (est == IMessageReceiverApp.ExecutionStatus.Retry) {\n executedMessages[messageId] = MsgDataTypes.TxStatus.Null;\n emit NeedRetry(MsgDataTypes.MsgType.MessageOnly, messageId, _route.srcChainId, _route.srcTxHash);\n return;\n } else {\n status = MsgDataTypes.TxStatus.Fail;\n }\n executedMessages[messageId] = status;\n emitMessageOnlyExecutedEvent(messageId, status, _route);\n }\n\n // ================= utils (to avoid stack too deep) =================\n\n function emitMessageWithTransferExecutedEvent(\n bytes32 _messageId,\n MsgDataTypes.TxStatus _status,\n MsgDataTypes.TransferInfo calldata _transfer\n ) private {\n emit Executed(\n MsgDataTypes.MsgType.MessageWithTransfer,\n _messageId,\n _status,\n _transfer.receiver,\n _transfer.srcChainId,\n _transfer.srcTxHash\n );\n }\n\n function emitMessageOnlyExecutedEvent(\n bytes32 _messageId,\n MsgDataTypes.TxStatus _status,\n MsgDataTypes.Route memory _route\n ) private {\n emit Executed(\n MsgDataTypes.MsgType.MessageOnly,\n _messageId,\n _status,\n _route.receiver,\n _route.srcChainId,\n _route.srcTxHash\n );\n }\n\n function executeMessageWithTransfer(MsgDataTypes.TransferInfo calldata _transfer, bytes calldata _message)\n private\n returns (IMessageReceiverApp.ExecutionStatus)\n {\n uint256 gasLeftBeforeExecution = gasleft();\n (bool ok, bytes memory res) = address(_transfer.receiver).call{value: msg.value}(\n abi.encodeWithSelector(\n IMessageReceiverApp.executeMessageWithTransfer.selector,\n _transfer.sender,\n _transfer.token,\n _transfer.amount,\n _transfer.srcChainId,\n _message,\n msg.sender\n )\n );\n if (ok) {\n return abi.decode((res), (IMessageReceiverApp.ExecutionStatus));\n }\n handleExecutionRevert(gasLeftBeforeExecution, res);\n return IMessageReceiverApp.ExecutionStatus.Fail;\n }\n\n function executeMessageWithTransferFallback(MsgDataTypes.TransferInfo calldata _transfer, bytes calldata _message)\n private\n returns (IMessageReceiverApp.ExecutionStatus)\n {\n uint256 gasLeftBeforeExecution = gasleft();\n (bool ok, bytes memory res) = address(_transfer.receiver).call{value: msg.value}(\n abi.encodeWithSelector(\n IMessageReceiverApp.executeMessageWithTransferFallback.selector,\n _transfer.sender,\n _transfer.token,\n _transfer.amount,\n _transfer.srcChainId,\n _message,\n msg.sender\n )\n );\n if (ok) {\n return abi.decode((res), (IMessageReceiverApp.ExecutionStatus));\n }\n handleExecutionRevert(gasLeftBeforeExecution, res);\n return IMessageReceiverApp.ExecutionStatus.Fail;\n }\n\n function executeMessageWithTransferRefund(MsgDataTypes.TransferInfo calldata _transfer, bytes calldata _message)\n private\n returns (IMessageReceiverApp.ExecutionStatus)\n {\n uint256 gasLeftBeforeExecution = gasleft();\n (bool ok, bytes memory res) = address(_transfer.receiver).call{value: msg.value}(\n abi.encodeWithSelector(\n IMessageReceiverApp.executeMessageWithTransferRefund.selector,\n _transfer.token,\n _transfer.amount,\n _message,\n msg.sender\n )\n );\n if (ok) {\n return abi.decode((res), (IMessageReceiverApp.ExecutionStatus));\n }\n handleExecutionRevert(gasLeftBeforeExecution, res);\n return IMessageReceiverApp.ExecutionStatus.Fail;\n }\n\n function verifyTransfer(MsgDataTypes.TransferInfo calldata _transfer) private view returns (bytes32) {\n bytes32 transferId;\n address bridgeAddr;\n MsgDataTypes.TransferType t = _transfer.t;\n if (t == MsgDataTypes.TransferType.LqRelay) {\n bridgeAddr = liquidityBridge;\n transferId = keccak256(\n abi.encodePacked(\n _transfer.sender,\n _transfer.receiver,\n _transfer.token,\n _transfer.amount,\n _transfer.srcChainId,\n uint64(block.chainid),\n _transfer.refId\n )\n );\n require(IBridge(bridgeAddr).transfers(transferId) == true, \"relay not exist\");\n } else if (t == MsgDataTypes.TransferType.LqWithdraw) {\n bridgeAddr = liquidityBridge;\n transferId = keccak256(\n abi.encodePacked(\n uint64(block.chainid),\n _transfer.wdseq,\n _transfer.receiver,\n _transfer.token,\n _transfer.amount\n )\n );\n require(IBridge(bridgeAddr).withdraws(transferId) == true, \"withdraw not exist\");\n } else {\n if (t == MsgDataTypes.TransferType.PegMint || t == MsgDataTypes.TransferType.PegWithdraw) {\n bridgeAddr = (t == MsgDataTypes.TransferType.PegMint) ? pegBridge : pegVault;\n transferId = keccak256(\n abi.encodePacked(\n _transfer.receiver,\n _transfer.token,\n _transfer.amount,\n _transfer.sender,\n _transfer.srcChainId,\n _transfer.refId\n )\n );\n } else {\n bridgeAddr = (t == MsgDataTypes.TransferType.PegV2Mint) ? pegBridgeV2 : pegVaultV2;\n transferId = keccak256(\n abi.encodePacked(\n _transfer.receiver,\n _transfer.token,\n _transfer.amount,\n _transfer.sender,\n _transfer.srcChainId,\n _transfer.refId,\n bridgeAddr\n )\n );\n }\n // function is same for peg, peg2, vault, vault2\n require(IPeggedTokenBridge(bridgeAddr).records(transferId) == true, \"record not exist\");\n }\n require(IDelayedTransfer(bridgeAddr).delayedTransfers(transferId).timestamp == 0, \"transfer delayed\");\n return keccak256(abi.encodePacked(MsgDataTypes.MsgType.MessageWithTransfer, bridgeAddr, transferId));\n }\n\n function computeMessageOnlyId(MsgDataTypes.Route memory _route, bytes calldata _message)\n private\n view\n returns (bytes32)\n {\n bytes memory sender = _route.senderBytes;\n if (sender.length == 0) {\n sender = abi.encodePacked(_route.sender);\n }\n return\n keccak256(\n abi.encodePacked(\n MsgDataTypes.MsgType.MessageOnly,\n sender,\n _route.receiver,\n _route.srcChainId,\n _route.srcTxHash,\n uint64(block.chainid),\n _message\n )\n );\n }\n\n function executeMessage(MsgDataTypes.Route memory _route, bytes calldata _message)\n private\n returns (IMessageReceiverApp.ExecutionStatus)\n {\n uint256 gasLeftBeforeExecution = gasleft();\n bool ok;\n bytes memory res;\n if (_route.senderBytes.length == 0) {\n (ok, res) = address(_route.receiver).call{value: msg.value}(\n abi.encodeWithSelector(\n bytes4(keccak256(bytes(\"executeMessage(address,uint64,bytes,address)\"))),\n _route.sender,\n _route.srcChainId,\n _message,\n msg.sender\n )\n );\n } else {\n (ok, res) = address(_route.receiver).call{value: msg.value}(\n abi.encodeWithSelector(\n bytes4(keccak256(bytes(\"executeMessage(bytes,uint64,bytes,address)\"))),\n _route.senderBytes,\n _route.srcChainId,\n _message,\n msg.sender\n )\n );\n }\n if (ok) {\n return abi.decode((res), (IMessageReceiverApp.ExecutionStatus));\n }\n handleExecutionRevert(gasLeftBeforeExecution, res);\n return IMessageReceiverApp.ExecutionStatus.Fail;\n }\n\n function handleExecutionRevert(uint256 _gasLeftBeforeExecution, bytes memory _returnData) private {\n uint256 gasLeftAfterExecution = gasleft();\n uint256 maxTargetGasLimit = block.gaslimit - preExecuteMessageGasUsage;\n if (_gasLeftBeforeExecution < maxTargetGasLimit && gasLeftAfterExecution <= _gasLeftBeforeExecution / 64) {\n // if this happens, the executor must have not provided sufficient gas limit,\n // then the tx should revert instead of recording a non-retryable failure status\n // https://github.com/wolflo/evm-opcodes/blob/main/gas.md#aa-f-gas-to-send-with-call-operations\n assembly {\n invalid()\n }\n }\n string memory revertMsg = Utils.getRevertMsg(_returnData);\n // revert the execution if the revert message has the ABORT prefix\n checkAbortPrefix(revertMsg);\n // otherwiase, emit revert message, return and mark the execution as failed (non-retryable)\n emit CallReverted(revertMsg);\n }\n\n function checkAbortPrefix(string memory _revertMsg) private pure {\n bytes memory prefixBytes = bytes(MsgDataTypes.ABORT_PREFIX);\n bytes memory msgBytes = bytes(_revertMsg);\n if (msgBytes.length >= prefixBytes.length) {\n for (uint256 i = 0; i < prefixBytes.length; i++) {\n if (msgBytes[i] != prefixBytes[i]) {\n return; // prefix not match, return\n }\n }\n revert(_revertMsg); // prefix match, revert\n }\n }\n\n function getRouteInfo(MsgDataTypes.RouteInfo calldata _route) private pure returns (MsgDataTypes.Route memory) {\n return MsgDataTypes.Route(_route.sender, \"\", _route.receiver, _route.srcChainId, _route.srcTxHash);\n }\n\n function getRouteInfo(MsgDataTypes.RouteInfo2 calldata _route) private pure returns (MsgDataTypes.Route memory) {\n return MsgDataTypes.Route(address(0), _route.sender, _route.receiver, _route.srcChainId, _route.srcTxHash);\n }\n\n // ================= helper functions =====================\n\n /**\n * @notice combine bridge transfer and msg execution calls into a single tx\n * @dev caller needs to get the required input params from SGN\n * @param _tp params to call bridge transfer\n * @param _mp params to execute message\n */\n function transferAndExecuteMsg(\n MsgDataTypes.BridgeTransferParams calldata _tp,\n MsgDataTypes.MsgWithTransferExecutionParams calldata _mp\n ) external {\n _bridgeTransfer(_mp.transfer.t, _tp);\n executeMessageWithTransfer(_mp.message, _mp.transfer, _mp.sigs, _mp.signers, _mp.powers);\n }\n\n /**\n * @notice combine bridge refund and msg execution calls into a single tx\n * @dev caller needs to get the required input params from SGN\n * @param _tp params to call bridge transfer for refund\n * @param _mp params to execute message for refund\n */\n function refundAndExecuteMsg(\n MsgDataTypes.BridgeTransferParams calldata _tp,\n MsgDataTypes.MsgWithTransferExecutionParams calldata _mp\n ) external {\n _bridgeTransfer(_mp.transfer.t, _tp);\n executeMessageWithTransferRefund(_mp.message, _mp.transfer, _mp.sigs, _mp.signers, _mp.powers);\n }\n\n function _bridgeTransfer(MsgDataTypes.TransferType t, MsgDataTypes.BridgeTransferParams calldata _params) private {\n if (t == MsgDataTypes.TransferType.LqRelay) {\n IBridge(liquidityBridge).relay(_params.request, _params.sigs, _params.signers, _params.powers);\n } else if (t == MsgDataTypes.TransferType.LqWithdraw) {\n IBridge(liquidityBridge).withdraw(_params.request, _params.sigs, _params.signers, _params.powers);\n } else if (t == MsgDataTypes.TransferType.PegMint) {\n IPeggedTokenBridge(pegBridge).mint(_params.request, _params.sigs, _params.signers, _params.powers);\n } else if (t == MsgDataTypes.TransferType.PegV2Mint) {\n IPeggedTokenBridgeV2(pegBridgeV2).mint(_params.request, _params.sigs, _params.signers, _params.powers);\n } else if (t == MsgDataTypes.TransferType.PegWithdraw) {\n IOriginalTokenVault(pegVault).withdraw(_params.request, _params.sigs, _params.signers, _params.powers);\n } else if (t == MsgDataTypes.TransferType.PegV2Withdraw) {\n IOriginalTokenVaultV2(pegVaultV2).withdraw(_params.request, _params.sigs, _params.signers, _params.powers);\n }\n }\n\n // ================= contract config =================\n\n function setLiquidityBridge(address _addr) public onlyOwner {\n require(_addr != address(0), \"invalid address\");\n liquidityBridge = _addr;\n emit LiquidityBridgeUpdated(liquidityBridge);\n }\n\n function setPegBridge(address _addr) public onlyOwner {\n require(_addr != address(0), \"invalid address\");\n pegBridge = _addr;\n emit PegBridgeUpdated(pegBridge);\n }\n\n function setPegVault(address _addr) public onlyOwner {\n require(_addr != address(0), \"invalid address\");\n pegVault = _addr;\n emit PegVaultUpdated(pegVault);\n }\n\n function setPegBridgeV2(address _addr) public onlyOwner {\n require(_addr != address(0), \"invalid address\");\n pegBridgeV2 = _addr;\n emit PegBridgeV2Updated(pegBridgeV2);\n }\n\n function setPegVaultV2(address _addr) public onlyOwner {\n require(_addr != address(0), \"invalid address\");\n pegVaultV2 = _addr;\n emit PegVaultV2Updated(pegVaultV2);\n }\n\n function setPreExecuteMessageGasUsage(uint256 _usage) public onlyOwner {\n preExecuteMessageGasUsage = _usage;\n }\n}\n" + }, + "contracts/message/messagebus/MessageBusSender.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"../../safeguard/Ownable.sol\";\nimport \"../../interfaces/ISigsVerifier.sol\";\n\ncontract MessageBusSender is Ownable {\n ISigsVerifier public immutable sigsVerifier;\n\n uint256 public feeBase;\n uint256 public feePerByte;\n mapping(address => uint256) public withdrawnFees;\n\n event Message(address indexed sender, address receiver, uint256 dstChainId, bytes message, uint256 fee);\n // message to non-evm chain with >20 bytes addr\n event Message2(address indexed sender, bytes receiver, uint256 dstChainId, bytes message, uint256 fee);\n\n event MessageWithTransfer(\n address indexed sender,\n address receiver,\n uint256 dstChainId,\n address bridge,\n bytes32 srcTransferId,\n bytes message,\n uint256 fee\n );\n\n event FeeWithdrawn(address receiver, uint256 amount);\n\n event FeeBaseUpdated(uint256 feeBase);\n event FeePerByteUpdated(uint256 feePerByte);\n\n constructor(ISigsVerifier _sigsVerifier) {\n sigsVerifier = _sigsVerifier;\n }\n\n /**\n * @notice Sends a message to a contract on another chain.\n * Sender needs to make sure the uniqueness of the message Id, which is computed as\n * hash(type.MessageOnly, sender, receiver, srcChainId, srcTxHash, dstChainId, message).\n * If messages with the same Id are sent, only one of them will succeed at dst chain.\n * A fee is charged in the native gas token.\n * @param _receiver The address of the destination app contract.\n * @param _dstChainId The destination chain ID.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n */\n function sendMessage(\n address _receiver,\n uint256 _dstChainId,\n bytes calldata _message\n ) external payable {\n _sendMessage(_dstChainId, _message);\n emit Message(msg.sender, _receiver, _dstChainId, _message, msg.value);\n }\n\n // Send message to non-evm chain with bytes for receiver address,\n // otherwise same as above.\n function sendMessage(\n bytes calldata _receiver,\n uint256 _dstChainId,\n bytes calldata _message\n ) external payable {\n _sendMessage(_dstChainId, _message);\n emit Message2(msg.sender, _receiver, _dstChainId, _message, msg.value);\n }\n\n function _sendMessage(uint256 _dstChainId, bytes calldata _message) private {\n require(_dstChainId != block.chainid, \"Invalid chainId\");\n uint256 minFee = calcFee(_message);\n require(msg.value >= minFee, \"Insufficient fee\");\n }\n\n /**\n * @notice Sends a message associated with a transfer to a contract on another chain.\n * If messages with the same srcTransferId are sent, only one of them will succeed.\n * A fee is charged in the native token.\n * @param _receiver The address of the destination app contract.\n * @param _dstChainId The destination chain ID.\n * @param _srcBridge The bridge contract to send the transfer with.\n * @param _srcTransferId The transfer ID.\n * @param _dstChainId The destination chain ID.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n */\n function sendMessageWithTransfer(\n address _receiver,\n uint256 _dstChainId,\n address _srcBridge,\n bytes32 _srcTransferId,\n bytes calldata _message\n ) external payable {\n require(_dstChainId != block.chainid, \"Invalid chainId\");\n uint256 minFee = calcFee(_message);\n require(msg.value >= minFee, \"Insufficient fee\");\n // SGN needs to verify\n // 1. msg.sender matches sender of the src transfer\n // 2. dstChainId matches dstChainId of the src transfer\n // 3. bridge is either liquidity bridge, peg src vault, or peg dst bridge\n emit MessageWithTransfer(msg.sender, _receiver, _dstChainId, _srcBridge, _srcTransferId, _message, msg.value);\n }\n\n /**\n * @notice Withdraws message fee in the form of native gas token.\n * @param _account The address receiving the fee.\n * @param _cumulativeFee The cumulative fee credited to the account. Tracked by SGN.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A withdrawal must be\n * signed-off by +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function withdrawFee(\n address _account,\n uint256 _cumulativeFee,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"withdrawFee\"));\n sigsVerifier.verifySigs(abi.encodePacked(domain, _account, _cumulativeFee), _sigs, _signers, _powers);\n uint256 amount = _cumulativeFee - withdrawnFees[_account];\n require(amount > 0, \"No new amount to withdraw\");\n withdrawnFees[_account] = _cumulativeFee;\n (bool sent, ) = _account.call{value: amount, gas: 50000}(\"\");\n require(sent, \"failed to withdraw fee\");\n emit FeeWithdrawn(_account, amount);\n }\n\n /**\n * @notice Calculates the required fee for the message.\n * @param _message Arbitrary message bytes to be decoded by the destination app contract.\n @ @return The required fee.\n */\n function calcFee(bytes calldata _message) public view returns (uint256) {\n return feeBase + _message.length * feePerByte;\n }\n\n // -------------------- Admin --------------------\n\n function setFeePerByte(uint256 _fee) external onlyOwner {\n feePerByte = _fee;\n emit FeePerByteUpdated(feePerByte);\n }\n\n function setFeeBase(uint256 _fee) external onlyOwner {\n feeBase = _fee;\n emit FeeBaseUpdated(feeBase);\n }\n}\n" + }, + "contracts/message/safeguard/DelayedMessage.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"../../safeguard/Ownable.sol\";\n\nabstract contract DelayedMessage is Ownable {\n // universal unique id (not msgId) => delay start time\n mapping(bytes32 => uint256) public delayedMessages;\n uint256 public delayPeriod; // in seconds\n uint32 public nonce;\n\n event DelayedMessageAdded(bytes32 id, address srcContract, uint64 srcChainId, bytes message, uint32 nonce);\n event DelayedMessageExecuted(bytes32 id);\n\n event DelayPeriodUpdated(uint256 period);\n\n function _addDelayedMessage(\n address _srcContract,\n uint64 _srcChainId,\n bytes calldata _message\n ) internal {\n bytes32 id = keccak256(abi.encodePacked(_srcContract, _srcChainId, _message, uint64(block.chainid), nonce));\n delayedMessages[id] = uint256(block.timestamp);\n emit DelayedMessageAdded(id, _srcContract, _srcChainId, _message, nonce);\n nonce += 1;\n }\n\n // caller needs to do the actual message execution\n function _executeDelayedMessage(\n address _srcContract,\n uint64 _srcChainId,\n bytes memory _message,\n uint32 _nonce\n ) internal {\n bytes32 id = keccak256(abi.encodePacked(_srcContract, _srcChainId, _message, uint64(block.chainid), _nonce));\n require(delayedMessages[id] > 0, \"delayed message not exist\");\n require(block.timestamp > delayedMessages[id] + delayPeriod, \"delayed message still locked\");\n delete delayedMessages[id];\n emit DelayedMessageExecuted(id);\n }\n\n function setDelayPeriod(uint256 _period) external onlyOwner {\n delayPeriod = _period;\n emit DelayPeriodUpdated(_period);\n }\n}\n" + }, + "contracts/message/safeguard/MessageAppPauser.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.0;\n\nimport \"../libraries/MsgDataTypes.sol\";\nimport \"../../safeguard/Pauser.sol\";\n\nabstract contract MessageAppPauser is Pauser {\n /**\n * @dev Modifier to make the message execution function callable only when\n * the contract is not paused.\n *\n * Added the ABORT_PREFIX (\"MSG::ABORT:\") in front of the revert message to\n * work with the Celer IM MessageBus contract, so that the message execution\n * can be retried later when the contract is unpaused.\n */\n modifier whenNotMsgPaused() {\n require(!paused(), MsgDataTypes.abortReason(\"Pausable: paused\"));\n _;\n }\n}\n" + }, + "contracts/miscs/Faucet.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract Faucet is Ownable {\n using SafeERC20 for IERC20;\n\n uint256 public minDripBlkInterval;\n mapping(address => uint256) public lastDripBlk;\n\n /**\n * @dev Sends 0.01% of each token to the caller.\n * @param tokens The tokens to drip.\n */\n function drip(address[] calldata tokens) public {\n require(block.number - lastDripBlk[msg.sender] >= minDripBlkInterval, \"too frequent\");\n for (uint256 i = 0; i < tokens.length; i++) {\n IERC20 token = IERC20(tokens[i]);\n uint256 balance = token.balanceOf(address(this));\n require(balance > 0, \"Faucet is empty\");\n token.safeTransfer(msg.sender, balance / 10000); // 0.01%\n }\n lastDripBlk[msg.sender] = block.number;\n }\n\n /**\n * @dev Owner set minDripBlkInterval\n *\n * @param _interval minDripBlkInterval value\n */\n function setMinDripBlkInterval(uint256 _interval) external onlyOwner {\n minDripBlkInterval = _interval;\n }\n\n /**\n * @dev Owner drains one type of tokens\n *\n * @param _asset drained asset address\n * @param _amount drained asset amount\n */\n function drainToken(address _asset, uint256 _amount) external onlyOwner {\n IERC20(_asset).safeTransfer(msg.sender, _amount);\n }\n}\n" + }, + "contracts/miscs/MintableERC20.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\n\n/**\n * @title A mintable {ERC20} token.\n */\ncontract MintableERC20 is ERC20Burnable, Ownable {\n uint8 private _decimals;\n\n /**\n * @dev Constructor that gives msg.sender an initial supply of tokens.\n */\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n uint256 initialSupply_\n ) ERC20(name_, symbol_) {\n _decimals = decimals_;\n _mint(msg.sender, initialSupply_);\n }\n\n /**\n * @dev Creates `amount` new tokens for `to`.\n */\n function mint(address to, uint256 amount) public onlyOwner {\n _mint(to, amount);\n }\n\n function decimals() public view override returns (uint8) {\n return _decimals;\n }\n}\n" + }, + "contracts/miscs/oasys/L1StandardERC20.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol\";\nimport \"@openzeppelin/contracts/access/AccessControlEnumerable.sol\";\nimport \"@openzeppelin/contracts/utils/Context.sol\";\n\n/**\n * @dev {ERC20} token, including:\n *\n * - ability for holders to burn (destroy) their tokens\n * - a minter role that allows for token minting (creation)\n * - a pauser role that allows to stop all token transfers\n *\n * This contract uses {AccessControl} to lock permissioned functions using the\n * different roles - head to its documentation for details.\n *\n * The account that deploys the contract will be granted the minter and pauser\n * roles, as well as the default admin role, which will let it grant both minter\n * and pauser roles to other accounts.\n */\ncontract L1StandardERC20 is Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable {\n bytes32 public constant MINTER_ROLE = keccak256(\"MINTER_ROLE\");\n bytes32 public constant PAUSER_ROLE = keccak256(\"PAUSER_ROLE\");\n\n /**\n * @dev Grants `DEFAULT_ADMIN_ROLE`, `MINTER_ROLE` and `PAUSER_ROLE` to the\n * account that deploys the contract.\n *\n * See {ERC20-constructor}.\n */\n constructor(\n address owner,\n string memory name,\n string memory symbol\n ) ERC20(name, symbol) {\n _setupRole(DEFAULT_ADMIN_ROLE, owner);\n\n _setupRole(MINTER_ROLE, owner);\n _setupRole(PAUSER_ROLE, owner);\n }\n\n /**\n * @dev Creates `amount` new tokens for `to`.\n *\n * See {ERC20-_mint}.\n *\n * Requirements:\n *\n * - the caller must have the `MINTER_ROLE`.\n */\n function mint(address to, uint256 amount) public virtual {\n require(hasRole(MINTER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have minter role to mint\");\n _mint(to, amount);\n }\n\n /**\n * @dev Pauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_pause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function pause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to pause\");\n _pause();\n }\n\n /**\n * @dev Unpauses all token transfers.\n *\n * See {ERC20Pausable} and {Pausable-_unpause}.\n *\n * Requirements:\n *\n * - the caller must have the `PAUSER_ROLE`.\n */\n function unpause() public virtual {\n require(hasRole(PAUSER_ROLE, _msgSender()), \"ERC20PresetMinterPauser: must have pauser role to unpause\");\n _unpause();\n }\n\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override(ERC20, ERC20Pausable) {\n super._beforeTokenTransfer(from, to, amount);\n }\n}\n" + }, + "contracts/miscs/oasys/L1StandardERC20Factory.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.9;\n\nimport {L1StandardERC20} from \"./L1StandardERC20.sol\";\n\n/**\n * @title L1StandardERC20Factory\n * @dev L1StandardERC20Factory deploys the Oasys Standard ERC20 contract.\n */\ncontract L1StandardERC20Factory {\n /**********\n * Events *\n **********/\n\n event ERC20Created(string indexed _symbol, address indexed _address);\n\n /********************\n * Public Functions *\n ********************/\n\n /**\n * Deploys the Oasys Standard ERC20.\n * @param _name Name of the ERC20.\n * @param _symbol Symbol of the ERC20.\n */\n function createStandardERC20(string memory _name, string memory _symbol) external {\n L1StandardERC20 erc20 = new L1StandardERC20(msg.sender, _name, _symbol);\n emit ERC20Created(_symbol, address(erc20));\n }\n}\n" + }, + "contracts/pegged-bridge/customized/PeggedNativeTokenBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"../PeggedTokenBridgeV2.sol\";\n\ninterface INativeVault {\n function burn() external payable;\n}\n\ncontract PeggedNativeTokenBridge is PeggedTokenBridgeV2 {\n // native vault address is treated as the pegged natvie token address\n address public nativeVault;\n\n constructor(ISigsVerifier _sigsVerifier) PeggedTokenBridgeV2(_sigsVerifier) {}\n\n function burnNative(\n uint64 _toChainId,\n address _toAccount,\n uint64 _nonce\n ) external payable whenNotPaused returns (bytes32) {\n require(msg.value > 0, \"zero msg value\");\n bytes32 burnId = _burn(nativeVault, msg.value, _toChainId, _toAccount, _nonce);\n INativeVault(nativeVault).burn{value: msg.value}();\n return burnId;\n }\n\n function setNativeVault(address _natvieVault) external onlyOwner {\n nativeVault = _natvieVault;\n }\n}\n" + }, + "contracts/pegged-bridge/OriginalTokenVault.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/ISigsVerifier.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"../libraries/PbPegged.sol\";\nimport \"../safeguard/Pauser.sol\";\nimport \"../safeguard/VolumeControl.sol\";\nimport \"../safeguard/DelayedTransfer.sol\";\n\n/**\n * @title the vault to deposit and withdraw original tokens\n * @dev Work together with PeggedTokenBridge contracts deployed at remote chains\n */\ncontract OriginalTokenVault is ReentrancyGuard, Pauser, VolumeControl, DelayedTransfer {\n using SafeERC20 for IERC20;\n\n ISigsVerifier public immutable sigsVerifier;\n\n mapping(bytes32 => bool) public records;\n\n mapping(address => uint256) public minDeposit;\n mapping(address => uint256) public maxDeposit;\n\n address public nativeWrap;\n\n event Deposited(\n bytes32 depositId,\n address depositor,\n address token,\n uint256 amount,\n uint64 mintChainId,\n address mintAccount\n );\n event Withdrawn(\n bytes32 withdrawId,\n address receiver,\n address token,\n uint256 amount,\n // ref_chain_id defines the reference chain ID, taking values of:\n // 1. The common case of burn-withdraw: the chain ID on which the corresponding burn happened;\n // 2. Pegbridge fee claim: zero / not applicable;\n // 3. Refund for wrong deposit: this chain ID on which the deposit happened\n uint64 refChainId,\n // ref_id defines a unique reference ID, taking values of:\n // 1. The common case of burn-withdraw: the burn ID on the remote chain;\n // 2. Pegbridge fee claim: a per-account nonce;\n // 3. Refund for wrong deposit: the deposit ID on this chain\n bytes32 refId,\n address burnAccount\n );\n event MinDepositUpdated(address token, uint256 amount);\n event MaxDepositUpdated(address token, uint256 amount);\n\n constructor(ISigsVerifier _sigsVerifier) {\n sigsVerifier = _sigsVerifier;\n }\n\n /**\n * @notice Lock original tokens to trigger cross-chain mint of pegged tokens at a remote chain's PeggedTokenBridge.\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\n * @param _token The original token address.\n * @param _amount The amount to deposit.\n * @param _mintChainId The destination chain ID to mint tokens.\n * @param _mintAccount The destination account to receive the minted pegged tokens.\n * @param _nonce A number input to guarantee unique depositId. Can be timestamp in practice.\n */\n function deposit(\n address _token,\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) external nonReentrant whenNotPaused {\n bytes32 depId = _deposit(_token, _amount, _mintChainId, _mintAccount, _nonce);\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n emit Deposited(depId, msg.sender, _token, _amount, _mintChainId, _mintAccount);\n }\n\n /**\n * @notice Lock native token as original token to trigger cross-chain mint of pegged tokens at a remote chain's\n * PeggedTokenBridge.\n * @param _amount The amount to deposit.\n * @param _mintChainId The destination chain ID to mint tokens.\n * @param _mintAccount The destination account to receive the minted pegged tokens.\n * @param _nonce A number input to guarantee unique depositId. Can be timestamp in practice.\n */\n function depositNative(\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) external payable nonReentrant whenNotPaused {\n require(msg.value == _amount, \"Amount mismatch\");\n require(nativeWrap != address(0), \"Native wrap not set\");\n bytes32 depId = _deposit(nativeWrap, _amount, _mintChainId, _mintAccount, _nonce);\n IWETH(nativeWrap).deposit{value: _amount}();\n emit Deposited(depId, msg.sender, nativeWrap, _amount, _mintChainId, _mintAccount);\n }\n\n function _deposit(\n address _token,\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) private returns (bytes32) {\n require(_amount > minDeposit[_token], \"amount too small\");\n require(maxDeposit[_token] == 0 || _amount <= maxDeposit[_token], \"amount too large\");\n bytes32 depId = keccak256(\n // len = 20 + 20 + 32 + 8 + 20 + 8 + 8 = 116\n abi.encodePacked(msg.sender, _token, _amount, _mintChainId, _mintAccount, _nonce, uint64(block.chainid))\n );\n require(records[depId] == false, \"record exists\");\n records[depId] = true;\n return depId;\n }\n\n /**\n * @notice Withdraw locked original tokens triggered by a burn at a remote chain's PeggedTokenBridge.\n * @param _request The serialized Withdraw protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the bridge's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function withdraw(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external whenNotPaused {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"Withdraw\"));\n sigsVerifier.verifySigs(abi.encodePacked(domain, _request), _sigs, _signers, _powers);\n PbPegged.Withdraw memory request = PbPegged.decWithdraw(_request);\n bytes32 wdId = keccak256(\n // len = 20 + 20 + 32 + 20 + 8 + 32 = 132\n abi.encodePacked(\n request.receiver,\n request.token,\n request.amount,\n request.burnAccount,\n request.refChainId,\n request.refId\n )\n );\n require(records[wdId] == false, \"record exists\");\n records[wdId] = true;\n _updateVolume(request.token, request.amount);\n uint256 delayThreshold = delayThresholds[request.token];\n if (delayThreshold > 0 && request.amount > delayThreshold) {\n _addDelayedTransfer(wdId, request.receiver, request.token, request.amount);\n } else {\n _sendToken(request.receiver, request.token, request.amount);\n }\n emit Withdrawn(\n wdId,\n request.receiver,\n request.token,\n request.amount,\n request.refChainId,\n request.refId,\n request.burnAccount\n );\n }\n\n function executeDelayedTransfer(bytes32 id) external whenNotPaused {\n delayedTransfer memory transfer = _executeDelayedTransfer(id);\n _sendToken(transfer.receiver, transfer.token, transfer.amount);\n }\n\n function setMinDeposit(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n minDeposit[_tokens[i]] = _amounts[i];\n emit MinDepositUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setMaxDeposit(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n maxDeposit[_tokens[i]] = _amounts[i];\n emit MaxDepositUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setWrap(address _weth) external onlyOwner {\n nativeWrap = _weth;\n }\n\n function _sendToken(\n address _receiver,\n address _token,\n uint256 _amount\n ) private {\n if (_token == nativeWrap) {\n // withdraw then transfer native to receiver\n IWETH(nativeWrap).withdraw(_amount);\n (bool sent, ) = _receiver.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"failed to send native token\");\n } else {\n IERC20(_token).safeTransfer(_receiver, _amount);\n }\n }\n\n receive() external payable {}\n}\n" + }, + "contracts/pegged-bridge/OriginalTokenVaultV2.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"../interfaces/ISigsVerifier.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"../libraries/PbPegged.sol\";\nimport \"../safeguard/Pauser.sol\";\nimport \"../safeguard/VolumeControl.sol\";\nimport \"../safeguard/DelayedTransfer.sol\";\n\n/**\n * @title the vault to deposit and withdraw original tokens\n * @dev Work together with PeggedTokenBridge contracts deployed at remote chains\n */\ncontract OriginalTokenVaultV2 is ReentrancyGuard, Pauser, VolumeControl, DelayedTransfer {\n using SafeERC20 for IERC20;\n\n ISigsVerifier public immutable sigsVerifier;\n\n mapping(bytes32 => bool) public records;\n\n mapping(address => uint256) public minDeposit;\n mapping(address => uint256) public maxDeposit;\n\n address public nativeWrap;\n\n event Deposited(\n bytes32 depositId,\n address depositor,\n address token,\n uint256 amount,\n uint64 mintChainId,\n address mintAccount,\n uint64 nonce\n );\n event Withdrawn(\n bytes32 withdrawId,\n address receiver,\n address token,\n uint256 amount,\n // ref_chain_id defines the reference chain ID, taking values of:\n // 1. The common case of burn-withdraw: the chain ID on which the corresponding burn happened;\n // 2. Pegbridge fee claim: zero / not applicable;\n // 3. Refund for wrong deposit: this chain ID on which the deposit happened\n uint64 refChainId,\n // ref_id defines a unique reference ID, taking values of:\n // 1. The common case of burn-withdraw: the burn ID on the remote chain;\n // 2. Pegbridge fee claim: a per-account nonce;\n // 3. Refund for wrong deposit: the deposit ID on this chain\n bytes32 refId,\n address burnAccount\n );\n event MinDepositUpdated(address token, uint256 amount);\n event MaxDepositUpdated(address token, uint256 amount);\n\n constructor(ISigsVerifier _sigsVerifier) {\n sigsVerifier = _sigsVerifier;\n }\n\n /**\n * @notice Lock original tokens to trigger cross-chain mint of pegged tokens at a remote chain's PeggedTokenBridge.\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\n * @param _token The original token address.\n * @param _amount The amount to deposit.\n * @param _mintChainId The destination chain ID to mint tokens.\n * @param _mintAccount The destination account to receive the minted pegged tokens.\n * @param _nonce A number input to guarantee unique depositId. Can be timestamp in practice.\n */\n function deposit(\n address _token,\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) external nonReentrant whenNotPaused returns (bytes32) {\n bytes32 depId = _deposit(_token, _amount, _mintChainId, _mintAccount, _nonce);\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n emit Deposited(depId, msg.sender, _token, _amount, _mintChainId, _mintAccount, _nonce);\n return depId;\n }\n\n /**\n * @notice Lock native token as original token to trigger cross-chain mint of pegged tokens at a remote chain's\n * PeggedTokenBridge.\n * @param _amount The amount to deposit.\n * @param _mintChainId The destination chain ID to mint tokens.\n * @param _mintAccount The destination account to receive the minted pegged tokens.\n * @param _nonce A number input to guarantee unique depositId. Can be timestamp in practice.\n */\n function depositNative(\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) external payable nonReentrant whenNotPaused returns (bytes32) {\n require(msg.value == _amount, \"Amount mismatch\");\n require(nativeWrap != address(0), \"Native wrap not set\");\n bytes32 depId = _deposit(nativeWrap, _amount, _mintChainId, _mintAccount, _nonce);\n IWETH(nativeWrap).deposit{value: _amount}();\n emit Deposited(depId, msg.sender, nativeWrap, _amount, _mintChainId, _mintAccount, _nonce);\n return depId;\n }\n\n function _deposit(\n address _token,\n uint256 _amount,\n uint64 _mintChainId,\n address _mintAccount,\n uint64 _nonce\n ) private returns (bytes32) {\n require(_amount > minDeposit[_token], \"amount too small\");\n require(maxDeposit[_token] == 0 || _amount <= maxDeposit[_token], \"amount too large\");\n bytes32 depId = keccak256(\n // len = 20 + 20 + 32 + 8 + 20 + 8 + 8 + 20 = 136\n abi.encodePacked(\n msg.sender,\n _token,\n _amount,\n _mintChainId,\n _mintAccount,\n _nonce,\n uint64(block.chainid),\n address(this)\n )\n );\n require(records[depId] == false, \"record exists\");\n records[depId] = true;\n return depId;\n }\n\n /**\n * @notice Withdraw locked original tokens triggered by a burn at a remote chain's PeggedTokenBridge.\n * @param _request The serialized Withdraw protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the bridge's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function withdraw(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external whenNotPaused returns (bytes32) {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"Withdraw\"));\n sigsVerifier.verifySigs(abi.encodePacked(domain, _request), _sigs, _signers, _powers);\n PbPegged.Withdraw memory request = PbPegged.decWithdraw(_request);\n bytes32 wdId = keccak256(\n // len = 20 + 20 + 32 + 20 + 8 + 32 + 20 = 152\n abi.encodePacked(\n request.receiver,\n request.token,\n request.amount,\n request.burnAccount,\n request.refChainId,\n request.refId,\n address(this)\n )\n );\n require(records[wdId] == false, \"record exists\");\n records[wdId] = true;\n _updateVolume(request.token, request.amount);\n uint256 delayThreshold = delayThresholds[request.token];\n if (delayThreshold > 0 && request.amount > delayThreshold) {\n _addDelayedTransfer(wdId, request.receiver, request.token, request.amount);\n } else {\n _sendToken(request.receiver, request.token, request.amount);\n }\n emit Withdrawn(\n wdId,\n request.receiver,\n request.token,\n request.amount,\n request.refChainId,\n request.refId,\n request.burnAccount\n );\n return wdId;\n }\n\n function executeDelayedTransfer(bytes32 id) external whenNotPaused {\n delayedTransfer memory transfer = _executeDelayedTransfer(id);\n _sendToken(transfer.receiver, transfer.token, transfer.amount);\n }\n\n function setMinDeposit(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n minDeposit[_tokens[i]] = _amounts[i];\n emit MinDepositUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setMaxDeposit(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n maxDeposit[_tokens[i]] = _amounts[i];\n emit MaxDepositUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setWrap(address _weth) external onlyOwner {\n nativeWrap = _weth;\n }\n\n function _sendToken(\n address _receiver,\n address _token,\n uint256 _amount\n ) private {\n if (_token == nativeWrap) {\n // withdraw then transfer native to receiver\n IWETH(nativeWrap).withdraw(_amount);\n (bool sent, ) = _receiver.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"failed to send native token\");\n } else {\n IERC20(_token).safeTransfer(_receiver, _amount);\n }\n }\n\n receive() external payable {}\n}\n" + }, + "contracts/pegged-bridge/PeggedTokenBridge.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"../interfaces/ISigsVerifier.sol\";\nimport \"../interfaces/IPeggedToken.sol\";\nimport \"../libraries/PbPegged.sol\";\nimport \"../safeguard/Pauser.sol\";\nimport \"../safeguard/VolumeControl.sol\";\nimport \"../safeguard/DelayedTransfer.sol\";\n\n/**\n * @title The bridge contract to mint and burn pegged tokens\n * @dev Work together with OriginalTokenVault deployed at remote chains.\n */\ncontract PeggedTokenBridge is Pauser, VolumeControl, DelayedTransfer {\n ISigsVerifier public immutable sigsVerifier;\n\n mapping(bytes32 => bool) public records;\n\n mapping(address => uint256) public minBurn;\n mapping(address => uint256) public maxBurn;\n\n event Mint(\n bytes32 mintId,\n address token,\n address account,\n uint256 amount,\n // ref_chain_id defines the reference chain ID, taking values of:\n // 1. The common case: the chain ID on which the remote corresponding deposit or burn happened;\n // 2. Refund for wrong burn: this chain ID on which the burn happened\n uint64 refChainId,\n // ref_id defines a unique reference ID, taking values of:\n // 1. The common case of deposit/burn-mint: the deposit or burn ID on the remote chain;\n // 2. Refund for wrong burn: the burn ID on this chain\n bytes32 refId,\n address depositor\n );\n event Burn(bytes32 burnId, address token, address account, uint256 amount, address withdrawAccount);\n event MinBurnUpdated(address token, uint256 amount);\n event MaxBurnUpdated(address token, uint256 amount);\n\n constructor(ISigsVerifier _sigsVerifier) {\n sigsVerifier = _sigsVerifier;\n }\n\n /**\n * @notice Mint tokens triggered by deposit at a remote chain's OriginalTokenVault.\n * @param _request The serialized Mint protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function mint(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external whenNotPaused {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"Mint\"));\n sigsVerifier.verifySigs(abi.encodePacked(domain, _request), _sigs, _signers, _powers);\n PbPegged.Mint memory request = PbPegged.decMint(_request);\n bytes32 mintId = keccak256(\n // len = 20 + 20 + 32 + 20 + 8 + 32 = 132\n abi.encodePacked(\n request.account,\n request.token,\n request.amount,\n request.depositor,\n request.refChainId,\n request.refId\n )\n );\n require(records[mintId] == false, \"record exists\");\n records[mintId] = true;\n _updateVolume(request.token, request.amount);\n uint256 delayThreshold = delayThresholds[request.token];\n if (delayThreshold > 0 && request.amount > delayThreshold) {\n _addDelayedTransfer(mintId, request.account, request.token, request.amount);\n } else {\n IPeggedToken(request.token).mint(request.account, request.amount);\n }\n emit Mint(\n mintId,\n request.token,\n request.account,\n request.amount,\n request.refChainId,\n request.refId,\n request.depositor\n );\n }\n\n /**\n * @notice Burn pegged tokens to trigger a cross-chain withdrawal of the original tokens at a remote chain's\n * OriginalTokenVault.\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\n * @param _token The pegged token address.\n * @param _amount The amount to burn.\n * @param _withdrawAccount The account to receive the original tokens withdrawn on the remote chain.\n * @param _nonce A number to guarantee unique depositId. Can be timestamp in practice.\n */\n function burn(\n address _token,\n uint256 _amount,\n address _withdrawAccount,\n uint64 _nonce\n ) external whenNotPaused {\n require(_amount > minBurn[_token], \"amount too small\");\n require(maxBurn[_token] == 0 || _amount <= maxBurn[_token], \"amount too large\");\n bytes32 burnId = keccak256(\n // len = 20 + 20 + 32 + 20 + 8 + 8 = 108\n abi.encodePacked(msg.sender, _token, _amount, _withdrawAccount, _nonce, uint64(block.chainid))\n );\n require(records[burnId] == false, \"record exists\");\n records[burnId] = true;\n IPeggedToken(_token).burn(msg.sender, _amount);\n emit Burn(burnId, _token, msg.sender, _amount, _withdrawAccount);\n }\n\n function executeDelayedTransfer(bytes32 id) external whenNotPaused {\n delayedTransfer memory transfer = _executeDelayedTransfer(id);\n IPeggedToken(transfer.token).mint(transfer.receiver, transfer.amount);\n }\n\n function setMinBurn(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n minBurn[_tokens[i]] = _amounts[i];\n emit MinBurnUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setMaxBurn(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n maxBurn[_tokens[i]] = _amounts[i];\n emit MaxBurnUpdated(_tokens[i], _amounts[i]);\n }\n }\n}\n" + }, + "contracts/pegged-bridge/PeggedTokenBridgeV2.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"../interfaces/ISigsVerifier.sol\";\nimport \"../interfaces/IPeggedToken.sol\";\nimport \"../interfaces/IPeggedTokenBurnFrom.sol\";\nimport \"../libraries/PbPegged.sol\";\nimport \"../safeguard/Pauser.sol\";\nimport \"../safeguard/VolumeControl.sol\";\nimport \"../safeguard/DelayedTransfer.sol\";\n\n/**\n * @title The bridge contract to mint and burn pegged tokens\n * @dev Work together with OriginalTokenVault deployed at remote chains.\n */\ncontract PeggedTokenBridgeV2 is Pauser, VolumeControl, DelayedTransfer {\n ISigsVerifier public immutable sigsVerifier;\n\n mapping(bytes32 => bool) public records;\n mapping(address => uint256) public supplies;\n\n mapping(address => uint256) public minBurn;\n mapping(address => uint256) public maxBurn;\n\n event Mint(\n bytes32 mintId,\n address token,\n address account,\n uint256 amount,\n // ref_chain_id defines the reference chain ID, taking values of:\n // 1. The common case: the chain ID on which the remote corresponding deposit or burn happened;\n // 2. Refund for wrong burn: this chain ID on which the burn happened\n uint64 refChainId,\n // ref_id defines a unique reference ID, taking values of:\n // 1. The common case of deposit/burn-mint: the deposit or burn ID on the remote chain;\n // 2. Refund for wrong burn: the burn ID on this chain\n bytes32 refId,\n address depositor\n );\n event Burn(\n bytes32 burnId,\n address token,\n address account,\n uint256 amount,\n uint64 toChainId,\n address toAccount,\n uint64 nonce\n );\n event MinBurnUpdated(address token, uint256 amount);\n event MaxBurnUpdated(address token, uint256 amount);\n event SupplyUpdated(address token, uint256 supply);\n\n constructor(ISigsVerifier _sigsVerifier) {\n sigsVerifier = _sigsVerifier;\n }\n\n /**\n * @notice Mint tokens triggered by deposit at a remote chain's OriginalTokenVault.\n * @param _request The serialized Mint protobuf.\n * @param _sigs The list of signatures sorted by signing addresses in ascending order. A relay must be signed-off by\n * +2/3 of the sigsVerifier's current signing power to be delivered.\n * @param _signers The sorted list of signers.\n * @param _powers The signing powers of the signers.\n */\n function mint(\n bytes calldata _request,\n bytes[] calldata _sigs,\n address[] calldata _signers,\n uint256[] calldata _powers\n ) external whenNotPaused returns (bytes32) {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"Mint\"));\n sigsVerifier.verifySigs(abi.encodePacked(domain, _request), _sigs, _signers, _powers);\n PbPegged.Mint memory request = PbPegged.decMint(_request);\n bytes32 mintId = keccak256(\n // len = 20 + 20 + 32 + 20 + 8 + 32 + 20 = 152\n abi.encodePacked(\n request.account,\n request.token,\n request.amount,\n request.depositor,\n request.refChainId,\n request.refId,\n address(this)\n )\n );\n require(records[mintId] == false, \"record exists\");\n records[mintId] = true;\n _updateVolume(request.token, request.amount);\n uint256 delayThreshold = delayThresholds[request.token];\n if (delayThreshold > 0 && request.amount > delayThreshold) {\n _addDelayedTransfer(mintId, request.account, request.token, request.amount);\n } else {\n IPeggedToken(request.token).mint(request.account, request.amount);\n }\n supplies[request.token] += request.amount;\n emit Mint(\n mintId,\n request.token,\n request.account,\n request.amount,\n request.refChainId,\n request.refId,\n request.depositor\n );\n return mintId;\n }\n\n /**\n * @notice Burn pegged tokens to trigger a cross-chain withdrawal of the original tokens at a remote chain's\n * OriginalTokenVault, or mint at another remote chain\n * NOTE: This function DOES NOT SUPPORT fee-on-transfer / rebasing tokens.\n * @param _token The pegged token address.\n * @param _amount The amount to burn.\n * @param _toChainId If zero, withdraw from original vault; otherwise, the remote chain to mint tokens.\n * @param _toAccount The account to receive tokens on the remote chain\n * @param _nonce A number to guarantee unique depositId. Can be timestamp in practice.\n */\n function burn(\n address _token,\n uint256 _amount,\n uint64 _toChainId,\n address _toAccount,\n uint64 _nonce\n ) external whenNotPaused returns (bytes32) {\n bytes32 burnId = _burn(_token, _amount, _toChainId, _toAccount, _nonce);\n IPeggedToken(_token).burn(msg.sender, _amount);\n return burnId;\n }\n\n // same with `burn` above, use openzeppelin ERC20Burnable interface\n function burnFrom(\n address _token,\n uint256 _amount,\n uint64 _toChainId,\n address _toAccount,\n uint64 _nonce\n ) external whenNotPaused returns (bytes32) {\n bytes32 burnId = _burn(_token, _amount, _toChainId, _toAccount, _nonce);\n IPeggedTokenBurnFrom(_token).burnFrom(msg.sender, _amount);\n return burnId;\n }\n\n function _burn(\n address _token,\n uint256 _amount,\n uint64 _toChainId,\n address _toAccount,\n uint64 _nonce\n ) internal returns (bytes32) {\n require(_amount > minBurn[_token], \"amount too small\");\n require(maxBurn[_token] == 0 || _amount <= maxBurn[_token], \"amount too large\");\n supplies[_token] -= _amount;\n bytes32 burnId = keccak256(\n // len = 20 + 20 + 32 + 8 + 20 + 8 + 8 + 20 = 136\n abi.encodePacked(\n msg.sender,\n _token,\n _amount,\n _toChainId,\n _toAccount,\n _nonce,\n uint64(block.chainid),\n address(this)\n )\n );\n require(records[burnId] == false, \"record exists\");\n records[burnId] = true;\n emit Burn(burnId, _token, msg.sender, _amount, _toChainId, _toAccount, _nonce);\n return burnId;\n }\n\n function executeDelayedTransfer(bytes32 id) external whenNotPaused {\n delayedTransfer memory transfer = _executeDelayedTransfer(id);\n IPeggedToken(transfer.token).mint(transfer.receiver, transfer.amount);\n }\n\n function setMinBurn(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n minBurn[_tokens[i]] = _amounts[i];\n emit MinBurnUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setMaxBurn(address[] calldata _tokens, uint256[] calldata _amounts) external onlyGovernor {\n require(_tokens.length == _amounts.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n maxBurn[_tokens[i]] = _amounts[i];\n emit MaxBurnUpdated(_tokens[i], _amounts[i]);\n }\n }\n\n function setSupply(address _token, uint256 _supply) external onlyOwner {\n supplies[_token] = _supply;\n emit SupplyUpdated(_token, _supply);\n }\n\n function increaseSupply(address _token, uint256 _delta) external onlyOwner {\n supplies[_token] += _delta;\n emit SupplyUpdated(_token, supplies[_token]);\n }\n\n function decreaseSupply(address _token, uint256 _delta) external onlyOwner {\n supplies[_token] -= _delta;\n emit SupplyUpdated(_token, supplies[_token]);\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/customized/FraxBridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface IFraxCanoToken {\n function exchangeOldForCanonical(address, uint256) external returns (uint256);\n\n function exchangeCanonicalForOld(address, uint256) external returns (uint256);\n}\n\n/**\n * @title Intermediary bridge token that supports swapping with the canonical Frax token.\n */\ncontract FraxBridgeToken is ERC20, Ownable {\n using SafeERC20 for IERC20;\n\n // The PeggedTokenBridge\n address public bridge;\n // The canonical Frax token that supports swapping\n address public immutable canonical;\n\n event BridgeUpdated(address bridge);\n\n modifier onlyBridge() {\n require(msg.sender == bridge, \"caller is not bridge\");\n _;\n }\n\n constructor(\n string memory name_,\n string memory symbol_,\n address bridge_,\n address canonical_\n ) ERC20(name_, symbol_) {\n bridge = bridge_;\n canonical = canonical_;\n }\n\n function mint(address _to, uint256 _amount) external onlyBridge returns (bool) {\n _mint(address(this), _amount); // add amount to myself so exchangeOldForCanonical can transfer amount\n _approve(address(this), canonical, _amount);\n uint256 got = IFraxCanoToken(canonical).exchangeOldForCanonical(address(this), _amount);\n // now this has canonical token, next step is to transfer to user\n IERC20(canonical).safeTransfer(_to, got);\n return true;\n }\n\n function burn(address _from, uint256 _amount) external onlyBridge returns (bool) {\n IERC20(canonical).safeTransferFrom(_from, address(this), _amount);\n uint256 got = IFraxCanoToken(canonical).exchangeCanonicalForOld(address(this), _amount);\n _burn(address(this), got);\n return true;\n }\n\n function updateBridge(address _bridge) external onlyOwner {\n bridge = _bridge;\n emit BridgeUpdated(bridge);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return ERC20(canonical).decimals();\n }\n\n // to make compatible with BEP20\n function getOwner() external view returns (address) {\n return owner();\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/customized/MaiBridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface IMaiBridgeHub {\n // send bridge token, get asset\n function swapIn(address, uint256) external;\n\n // send asset, get bridge token back\n function swapOut(address, uint256) external;\n\n // asset address\n function asset() external view returns (address);\n}\n\n/**\n * @title Intermediary bridge token that supports swapping with the Mai hub.\n * NOTE: Mai hub is NOT the canonical token itself. The asset is set in the hub constructor.\n */\ncontract MaiBridgeToken is ERC20, Ownable {\n using SafeERC20 for IERC20;\n\n // The PeggedTokenBridge\n address public bridge;\n // Mai hub for swapping\n address public immutable maihub;\n // The canonical Mai token\n address public immutable asset;\n\n event BridgeUpdated(address bridge);\n\n modifier onlyBridge() {\n require(msg.sender == bridge, \"caller is not bridge\");\n _;\n }\n\n constructor(\n string memory name_,\n string memory symbol_,\n address bridge_,\n address maihub_\n ) ERC20(name_, symbol_) {\n bridge = bridge_;\n maihub = maihub_;\n asset = IMaiBridgeHub(maihub_).asset();\n }\n\n function mint(address _to, uint256 _amount) external onlyBridge returns (bool) {\n _mint(address(this), _amount); // add amount to myself so swapIn can transfer amount to hub\n _approve(address(this), maihub, _amount);\n IMaiBridgeHub(maihub).swapIn(address(this), _amount);\n // now this has canonical token, next step is to transfer to user\n IERC20(asset).safeTransfer(_to, _amount);\n return true;\n }\n\n function burn(address _from, uint256 _amount) external onlyBridge returns (bool) {\n IERC20(asset).safeTransferFrom(_from, address(this), _amount);\n IERC20(asset).safeIncreaseAllowance(address(maihub), _amount);\n IMaiBridgeHub(maihub).swapOut(address(this), _amount);\n _burn(address(this), _amount);\n return true;\n }\n\n function updateBridge(address _bridge) external onlyOwner {\n bridge = _bridge;\n emit BridgeUpdated(bridge);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return ERC20(asset).decimals();\n }\n\n // to make compatible with BEP20\n function getOwner() external view returns (address) {\n return owner();\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/customized/OntologyBridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface IOntologyBridgeTokenWrapper {\n function swapBridgeForCanonical(\n address bridgeToken,\n address _to,\n uint256 _amount\n ) external returns (uint256);\n\n function swapCanonicalForBridge(\n address bridgeToken,\n address _to,\n uint256 _amount\n ) external payable returns (uint256);\n}\n\n/**\n * @title Intermediary bridge token that supports swapping with the Ontology bridge token wrapper.\n * NOTE: The bridge wrapper is NOT the canonical token itself.\n */\ncontract OntologyBridgeToken is ERC20, Ownable {\n using SafeERC20 for IERC20;\n\n // The PeggedTokenBridge\n address public bridge;\n // Bridge token wrapper for swapping\n address public immutable wrapper;\n // The canonical token\n address public immutable canonical;\n\n event BridgeUpdated(address bridge);\n\n modifier onlyBridge() {\n require(msg.sender == bridge, \"caller is not bridge\");\n _;\n }\n\n constructor(\n string memory name_,\n string memory symbol_,\n address bridge_,\n address wrapper_,\n address canonical_\n ) ERC20(name_, symbol_) {\n bridge = bridge_;\n wrapper = wrapper_;\n canonical = canonical_;\n }\n\n function mint(address _to, uint256 _amount) external onlyBridge returns (bool) {\n _mint(address(this), _amount);\n _approve(address(this), wrapper, _amount);\n // NOTE: swapBridgeForCanonical automatically transfers canonical token to _to.\n IOntologyBridgeTokenWrapper(wrapper).swapBridgeForCanonical(address(this), _to, _amount);\n return true;\n }\n\n function burn(address _from, uint256 _amount) external onlyBridge returns (bool) {\n IERC20(canonical).safeTransferFrom(_from, address(this), _amount);\n IERC20(canonical).safeIncreaseAllowance(address(wrapper), _amount);\n // NOTE: swapCanonicalForBridge automatically transfers bridge token to _from.\n uint256 got = IOntologyBridgeTokenWrapper(wrapper).swapCanonicalForBridge(address(this), _from, _amount);\n _burn(_from, got);\n return true;\n }\n\n function updateBridge(address _bridge) external onlyOwner {\n bridge = _bridge;\n emit BridgeUpdated(bridge);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return ERC20(canonical).decimals();\n }\n\n // to make compatible with BEP20\n function getOwner() external view returns (address) {\n return owner();\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/customized/xc20/interfaces/IXC20BridgeHub.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.0;\n\ninterface IXC20BridgeHub {\n /**\n * @dev Swaps intermediary bridge token for canonical XC-20 token.\n * @param bridgeToken The intermediary bridge token\n * @param amount The amount to swap\n * @return The canonical token amount\n */\n function swapBridgeForCanonical(address bridgeToken, uint256 amount) external returns (uint256);\n\n /**\n * @dev Swaps canonical XC-20 token for intermediary bridge token.\n * @param bridgeToken The intermediary bridge token\n * @param amount The amount to swap\n * @return The bridge token amount\n */\n function swapCanonicalForBridge(address bridgeToken, uint256 amount) external returns (uint256);\n}\n" + }, + "contracts/pegged-bridge/tokens/customized/xc20/XC20BridgeHub.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"./interfaces/IXC20BridgeHub.sol\";\n\n/**\n * @title A hub for managing swapping between canonical XC20 tokens and intermediary bridge tokens.\n */\ncontract XC20BridgeHub is Ownable, IXC20BridgeHub, Pausable {\n using SafeERC20 for IERC20;\n\n struct TokenPair {\n address bridgeToken;\n address canonicalToken;\n bool paused;\n uint256 limit; // Max amount of bridge token allowed in the hub.\n }\n address[] public bridgeTokens;\n // bridge token address => TokenPair\n mapping(address => TokenPair) public tokenPairMap;\n\n event TokenPairAdded(address indexed bridgeToken, address indexed canonicalToken, uint256 limit);\n event TokenPairRemoved(address indexed bridgeToken, address indexed canonicalToken);\n event TokenPairPaused(address indexed bridgeToken, address indexed canonicalToken);\n event TokenPairUnpaused(address indexed bridgeToken, address indexed canonicalToken);\n event TokenPairLimitSet(address indexed bridgeToken, address indexed canonicalToken, uint256 limit);\n event BridgeSwappedForCanonical(\n address indexed bridgeToken,\n address indexed canonicalToken,\n uint256 bridgeTokenAmount,\n uint256 refund,\n uint256 canonicalTokenAmount\n );\n event CanonicalSwappedForBridge(\n address indexed bridgeToken,\n address indexed canonicalToken,\n uint256 canonicalTokenAmount,\n uint256 refund,\n uint256 bridgeTokenAmount\n );\n\n /**\n * @dev Pauses a token pair.\n * @param _bridgeToken The bridge token of the pair.\n */\n function pauseTokenPair(address _bridgeToken) external onlyOwner {\n TokenPair storage pair = tokenPairMap[_bridgeToken];\n require(pair.bridgeToken != address(0), \"XC20BridgeHub: non-existent bridge token\");\n require(!pair.paused, \"XC20BridgeHub: token pair already paused\");\n pair.paused = true;\n emit TokenPairPaused(_bridgeToken, pair.canonicalToken);\n }\n\n /**\n * @dev Unpauses a token pair.\n * @param _bridgeToken The bridge token of the pair.\n */\n function unpauseTokenPair(address _bridgeToken) external onlyOwner {\n TokenPair storage pair = tokenPairMap[_bridgeToken];\n require(pair.bridgeToken != address(0), \"XC20BridgeHub: non-existent bridge token\");\n require(pair.paused, \"XC20BridgeHub: token pair already unpaused\");\n pair.paused = false;\n emit TokenPairUnpaused(_bridgeToken, pair.canonicalToken);\n }\n\n /**\n * @dev Sets a token pair limit.\n * @param _bridgeToken The bridge token of the pair.\n * @param _limit The max amount of bridge token allowed in the hub.\n */\n function setTokenPairLimit(address _bridgeToken, uint256 _limit) external onlyOwner {\n TokenPair storage pair = tokenPairMap[_bridgeToken];\n require(pair.bridgeToken != address(0), \"XC20BridgeHub: non-existent bridge token\");\n pair.limit = _limit;\n emit TokenPairLimitSet(_bridgeToken, pair.canonicalToken, _limit);\n }\n\n /**\n * @dev Adds a token pair.\n * @param _bridgeToken The bridge token of the pair.\n * @param _canonicalToken The canonical token of the pair.\n * @param _limit The max amount of bridge token allowed in the hub.\n */\n function addTokenPair(\n address _bridgeToken,\n address _canonicalToken,\n uint256 _limit\n ) external onlyOwner {\n require(_bridgeToken != address(0), \"XC20BridgeHub: bridge token is zero address\");\n require(tokenPairMap[_bridgeToken].bridgeToken == address(0), \"XC20BridgeHub: bridge token exists\");\n require(\n IERC20Metadata(_bridgeToken).decimals() == IERC20Metadata(_canonicalToken).decimals(),\n \"XC20BridgeHub: decimals mismatch\"\n );\n\n TokenPair memory pair = TokenPair(address(_bridgeToken), address(_canonicalToken), false, _limit);\n bridgeTokens.push(_bridgeToken);\n tokenPairMap[_bridgeToken] = pair;\n emit TokenPairAdded(_bridgeToken, _canonicalToken, _limit);\n }\n\n /**\n * @dev Removes a token pair.\n * @param _bridgeToken The bridge token of the pair.\n */\n function removeTokenPair(address _bridgeToken) external onlyOwner {\n TokenPair memory pair = tokenPairMap[_bridgeToken];\n require(pair.bridgeToken != address(0), \"XC20BridgeHub: non-existent bridge token\");\n delete tokenPairMap[_bridgeToken];\n uint256 index = bridgeTokens.length;\n for (uint256 i = 0; i < bridgeTokens.length; i++) {\n if (bridgeTokens[i] == _bridgeToken) {\n index = i;\n break;\n }\n }\n if (index < bridgeTokens.length) {\n delete bridgeTokens[index];\n }\n emit TokenPairRemoved(_bridgeToken, pair.canonicalToken);\n }\n\n /**\n * @dev Returns all token pairs.\n */\n function getAllTokenPairs() external view returns (TokenPair[] memory) {\n TokenPair[] memory pairs = new TokenPair[](bridgeTokens.length);\n for (uint256 i = 0; i < pairs.length; i++) {\n pairs[i] = tokenPairMap[bridgeTokens[i]];\n }\n return pairs;\n }\n\n /**\n * @dev Swaps intermediary bridge token for canonical XC-20 token.\n * @param _bridgeToken The intermediary bridge token\n * @param _amount The amount to swap\n * @return The canonical token amount\n */\n function swapBridgeForCanonical(address _bridgeToken, uint256 _amount)\n external\n override\n whenNotPaused\n returns (uint256)\n {\n TokenPair memory pair = tokenPairMap[_bridgeToken];\n require(pair.bridgeToken != address(0), \"XC20BridgeHub: non-existent bridge token\");\n require(!pair.paused, \"XC20BridgeHub: token pair paused\");\n IERC20 bridgeErc20 = IERC20(_bridgeToken);\n require(\n pair.limit > 0 && (bridgeErc20.balanceOf(address(this))) + _amount <= pair.limit,\n \"XC20BridgeHub: exceeds bridge limit\"\n );\n\n address canonicalToken = pair.canonicalToken;\n uint256 delta = transferIn(_bridgeToken, _amount);\n (uint256 canonicalTokenAmount, uint256 refund) = calcTransferAmountWithDecimals(\n delta,\n IERC20Metadata(_bridgeToken).decimals(),\n IERC20Metadata(canonicalToken).decimals()\n );\n if (refund > 0) {\n IERC20(_bridgeToken).safeTransfer(msg.sender, refund);\n }\n if (canonicalTokenAmount > 0) {\n IERC20(pair.canonicalToken).safeTransfer(msg.sender, _amount);\n }\n emit BridgeSwappedForCanonical(_bridgeToken, canonicalToken, _amount, refund, canonicalTokenAmount);\n return canonicalTokenAmount;\n }\n\n /**\n * @dev Swaps canonical XC-20 token for intermediary bridge token.\n * @param _bridgeToken The intermediary bridge token\n * @param _amount The amount to swap\n * @return The bridge token amount\n */\n function swapCanonicalForBridge(address _bridgeToken, uint256 _amount)\n external\n override\n whenNotPaused\n returns (uint256)\n {\n TokenPair memory pair = tokenPairMap[_bridgeToken];\n require(pair.bridgeToken != address(0), \"XC20BridgeHub: non-existent bridge token\");\n require(!pair.paused, \"XC20BridgeHub: token pair paused\");\n\n address canonicalToken = pair.canonicalToken;\n uint256 delta = transferIn(canonicalToken, _amount);\n (uint256 bridgeTokenAmount, uint256 refund) = calcTransferAmountWithDecimals(\n delta,\n IERC20Metadata(canonicalToken).decimals(),\n IERC20Metadata(_bridgeToken).decimals()\n );\n if (refund > 0) {\n IERC20(canonicalToken).safeTransfer(msg.sender, refund);\n }\n if (bridgeTokenAmount > 0) {\n IERC20(_bridgeToken).safeTransfer(msg.sender, _amount);\n }\n emit CanonicalSwappedForBridge(_bridgeToken, canonicalToken, _amount, refund, bridgeTokenAmount);\n return bridgeTokenAmount;\n }\n\n /**\n * @dev Sets the paused status of the hub.\n * @param _paused Whether the hub should be paused\n */\n function setPaused(bool _paused) external onlyOwner {\n if (_paused) {\n _pause();\n } else {\n _unpause();\n }\n }\n\n /**\n * @dev Transfers the amount of tokens into the hub.\n * @param _token The token address\n * @param _amount The transfer amount\n * @return The balance change\n */\n function transferIn(address _token, uint256 _amount) internal returns (uint256) {\n uint256 balanceBefore = IERC20(_token).balanceOf(address(this));\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n uint256 balanceAfter = IERC20(_token).balanceOf(address(this));\n return balanceAfter - balanceBefore;\n }\n\n /**\n * @dev Calculates the transfer amount and if applicable, refund amount, taking into account the\n * difference between token decimals.\n * @param _amount The original amount\n * @param _aDecimals The decimals of token A\n * @param _bDecimals The decimals of token B\n */\n function calcTransferAmountWithDecimals(\n uint256 _amount,\n uint256 _aDecimals,\n uint256 _bDecimals\n ) internal pure returns (uint256 newAmount, uint256 refund) {\n if (_aDecimals > _bDecimals) {\n newAmount = _amount / (10**(_aDecimals - _bDecimals));\n refund = _amount - newAmount * (10**(_aDecimals - _bDecimals));\n } else if (_aDecimals < _bDecimals) {\n newAmount = _amount * (10**(_bDecimals - _aDecimals));\n } else {\n newAmount = _amount;\n }\n }\n\n // This account has to hold some amount of native currency in order to be eligible\n // to receive canonical x20 assets per Astar rule\n receive() external payable {}\n}\n" + }, + "contracts/pegged-bridge/tokens/customized/xc20/XC20BridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"./interfaces/IXC20BridgeHub.sol\";\n\n/**\n * @title Intermediary bridge token that supports swapping with the XC-20 bridge hub.\n * NOTE: XC-20 bridge hub is NOT the canonical token itself.\n */\ncontract XC20BridgeToken is ERC20, Ownable {\n using SafeERC20 for IERC20;\n\n // The pegged token bridge\n address public bridge;\n // XC20 bridge hub for swapping\n address public immutable bridgeHub;\n // The canonical token\n address public immutable canonicalToken;\n\n event BridgeUpdated(address bridge);\n\n modifier onlyBridge() {\n require(msg.sender == bridge, \"XC20BridgeToken: caller is not bridge\");\n _;\n }\n\n constructor(\n string memory name_,\n string memory symbol_,\n address _bridge,\n address _bridgeHub,\n address _canonicalToken\n ) ERC20(name_, symbol_) {\n bridge = _bridge;\n bridgeHub = _bridgeHub;\n canonicalToken = _canonicalToken;\n }\n\n function mint(address _to, uint256 _amount) external onlyBridge returns (bool) {\n _mint(address(this), _amount); // Mint to this contract to be transferred to the hub\n _approve(address(this), bridgeHub, _amount);\n IXC20BridgeHub(bridgeHub).swapBridgeForCanonical(address(this), _amount);\n // Now this has canonical token, next step is to transfer to user.\n IERC20(canonicalToken).safeTransfer(_to, _amount);\n return true;\n }\n\n function burn(address _from, uint256 _amount) external onlyBridge returns (bool) {\n IERC20(canonicalToken).safeTransferFrom(_from, address(this), _amount);\n IERC20(canonicalToken).safeIncreaseAllowance(address(bridgeHub), _amount);\n IXC20BridgeHub(bridgeHub).swapCanonicalForBridge(address(this), _amount);\n _burn(address(this), _amount);\n return true;\n }\n\n function updateBridge(address _bridge) external onlyOwner {\n bridge = _bridge;\n emit BridgeUpdated(bridge);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return ERC20(canonicalToken).decimals();\n }\n\n // For compatibility with BEP20\n function getOwner() external view returns (address) {\n return owner();\n }\n\n // This account has to hold some amount of native currency in order to be eligible\n // to receive canonical x20 assets per Astar rule\n receive() external payable {}\n}\n" + }, + "contracts/pegged-bridge/tokens/ERC20Permit/MintSwapCanonicalTokenPermit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\nimport \"../MintSwapCanonicalToken.sol\";\n\n/**\n * @title MintSwapCanonicalToke with ERC20Permit\n */\ncontract MintSwapCanonicalTokenPermit is ERC20Permit, MintSwapCanonicalToken {\n uint8 private immutable _decimals;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) MintSwapCanonicalToken(name_, symbol_, decimals_) ERC20Permit(name_) {\n _decimals = decimals_;\n }\n\n function decimals() public view override(ERC20, MultiBridgeToken) returns (uint8) {\n return _decimals;\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/ERC20Permit/MultiBridgeTokenPermit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\nimport \"../MultiBridgeToken.sol\";\n\n/**\n * @title Example Multi-Bridge Pegged ERC20Permit token\n */\ncontract MultiBridgeTokenPermit is ERC20Permit, MultiBridgeToken {\n uint8 private immutable _decimals;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) MultiBridgeToken(name_, symbol_, decimals_) ERC20Permit(name_) {\n _decimals = decimals_;\n }\n\n function decimals() public view override(ERC20, MultiBridgeToken) returns (uint8) {\n return _decimals;\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/ERC20Permit/SingleBridgeTokenPermit.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol\";\nimport \"../SingleBridgeToken.sol\";\n\n/**\n * @title Example Pegged ERC20Permit token\n */\ncontract SingleBridgeTokenPermit is ERC20Permit, SingleBridgeToken {\n uint8 private immutable _decimals;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address bridge_\n ) SingleBridgeToken(name_, symbol_, decimals_, bridge_) ERC20Permit(name_) {\n _decimals = decimals_;\n }\n\n function decimals() public view override(ERC20, SingleBridgeToken) returns (uint8) {\n return _decimals;\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/freezable/Freezable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nabstract contract Freezable {\n event Frozen(address account);\n event Unfrozen(address account);\n mapping(address => bool) internal freezes;\n\n function isFrozen(address _account) public view virtual returns (bool) {\n return freezes[_account];\n }\n\n modifier whenAccountNotFrozen(address _account) {\n require(!isFrozen(_account), \"Freezable: frozen\");\n _;\n }\n\n modifier whenAccountFrozen(address _account) {\n require(isFrozen(_account), \"Freezable: not frozen\");\n _;\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/freezable/MintSwapCanonicalTokenUpgradableFreezable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./Freezable.sol\";\nimport \"../MintSwapCanonicalTokenUpgradable.sol\";\n\n/**\n * @title Upgradable canonical token that supports multi-bridge minter and multi-token swap. Support freezable erc20 transfer\n */\ncontract MintSwapCanonicalTokenUpgradableFreezable is MintSwapCanonicalTokenUpgradable, Freezable {\n string private _name;\n string private _symbol;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) MintSwapCanonicalTokenUpgradable(name_, symbol_, decimals_) {}\n\n // freezable related\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256 amount\n ) internal virtual override {\n super._beforeTokenTransfer(from, to, amount);\n require(!isFrozen(from), \"ERC20Freezable: from account is frozen\");\n require(!isFrozen(to), \"ERC20Freezable: to account is frozen\");\n }\n\n function freeze(address _account) public onlyOwner {\n freezes[_account] = true;\n emit Frozen(_account);\n }\n\n function unfreeze(address _account) public onlyOwner {\n freezes[_account] = false;\n emit Unfrozen(_account);\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/IntermediaryBridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface IERC20MintableBurnable is IERC20 {\n function mint(address receiver, uint256 amount) external;\n\n function burn(uint256 amount) external;\n}\n\n/**\n * @title Per bridge intermediary token that delegates to a canonical token.\n * Useful for canonical tokens that don't support the burn / burnFrom function signature required by\n * PeggedTokenBridge.\n */\ncontract IntermediaryBridgeToken is ERC20, Ownable {\n using SafeERC20 for IERC20;\n\n address public bridge;\n address public immutable canonical; // canonical token that support swap\n\n event BridgeUpdated(address bridge);\n\n modifier onlyBridge() {\n require(msg.sender == bridge, \"caller is not bridge\");\n _;\n }\n\n constructor(\n string memory name_,\n string memory symbol_,\n address bridge_,\n address canonical_\n ) ERC20(name_, symbol_) {\n bridge = bridge_;\n canonical = canonical_;\n }\n\n function mint(address _to, uint256 _amount) external onlyBridge returns (bool) {\n _mint(address(this), _amount); // totalSupply == bridge liquidity\n IERC20MintableBurnable(canonical).mint(_to, _amount);\n return true;\n }\n\n function burn(address _from, uint256 _amount) external onlyBridge returns (bool) {\n _burn(address(this), _amount);\n IERC20(canonical).safeTransferFrom(_from, address(this), _amount);\n IERC20MintableBurnable(canonical).burn(_amount);\n return true;\n }\n\n function updateBridge(address _bridge) external onlyOwner {\n bridge = _bridge;\n emit BridgeUpdated(bridge);\n }\n\n // to make compatible with BEP20\n function getOwner() external view returns (address) {\n return owner();\n }\n\n function decimals() public view virtual override returns (uint8) {\n return ERC20(canonical).decimals();\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/IntermediaryOriginalToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @title Intermediary token that automatically transfers the canonical token when interacting with approved bridges.\n */\ncontract IntermediaryOriginalToken is ERC20, Ownable {\n using SafeERC20 for IERC20;\n\n mapping(address => bool) public bridges;\n address public immutable canonical; // canonical token\n\n event BridgeUpdated(address bridge, bool enable);\n\n constructor(\n string memory name_,\n string memory symbol_,\n address[] memory bridges_,\n address canonical_\n ) ERC20(name_, symbol_) {\n for (uint256 i = 0; i < bridges_.length; i++) {\n bridges[bridges_[i]] = true;\n }\n canonical = canonical_;\n }\n\n function transfer(address _to, uint256 _amount) public virtual override returns (bool) {\n bool success = super.transfer(_to, _amount);\n if (bridges[msg.sender]) {\n _burn(_to, _amount);\n IERC20(canonical).safeTransfer(_to, _amount);\n }\n return success;\n }\n\n function transferFrom(\n address _from,\n address _to,\n uint256 _amount\n ) public virtual override returns (bool) {\n if (bridges[msg.sender]) {\n _mint(_from, _amount);\n IERC20(canonical).safeTransferFrom(_from, address(this), _amount);\n }\n return super.transferFrom(_from, _to, _amount);\n }\n\n function updateBridge(address _bridge, bool _enable) external onlyOwner {\n bridges[_bridge] = _enable;\n emit BridgeUpdated(_bridge, _enable);\n }\n\n // to make compatible with BEP20\n function getOwner() external view returns (address) {\n return owner();\n }\n\n function decimals() public view virtual override returns (uint8) {\n return ERC20(canonical).decimals();\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/MintSwapCanonicalToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"./MultiBridgeToken.sol\";\n\n/**\n * @title Canonical token that supports multi-bridge minter and multi-token swap\n */\ncontract MintSwapCanonicalToken is MultiBridgeToken {\n using SafeERC20 for IERC20;\n\n // bridge token address -> minted amount and cap for each bridge\n mapping(address => Supply) public swapSupplies;\n\n event TokenSwapCapUpdated(address token, uint256 cap);\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) MultiBridgeToken(name_, symbol_, decimals_) {}\n\n /**\n * @notice msg.sender has bridge token and wants to get canonical token.\n * @param _bridgeToken The intermediary token address for a particular bridge.\n * @param _amount The amount.\n */\n function swapBridgeForCanonical(address _bridgeToken, uint256 _amount) external returns (uint256) {\n Supply storage supply = swapSupplies[_bridgeToken];\n require(supply.cap > 0, \"invalid bridge token\");\n require(supply.total + _amount <= supply.cap, \"exceed swap cap\");\n\n supply.total += _amount;\n _mint(msg.sender, _amount);\n\n // move bridge token from msg.sender to canonical token _amount\n IERC20(_bridgeToken).safeTransferFrom(msg.sender, address(this), _amount);\n return _amount;\n }\n\n /**\n * @notice msg.sender has canonical token and wants to get bridge token (eg. for cross chain burn).\n * @param _bridgeToken The intermediary token address for a particular bridge.\n * @param _amount The amount.\n */\n function swapCanonicalForBridge(address _bridgeToken, uint256 _amount) external returns (uint256) {\n Supply storage supply = swapSupplies[_bridgeToken];\n require(supply.cap > 0, \"invalid bridge token\");\n\n supply.total -= _amount;\n _burn(msg.sender, _amount);\n\n IERC20(_bridgeToken).safeTransfer(msg.sender, _amount);\n return _amount;\n }\n\n /**\n * @dev Update existing bridge token swap cap or add a new bridge token with swap cap.\n * Setting cap to 0 will disable the bridge token.\n * @param _bridgeToken The intermediary token address for a particular bridge.\n * @param _swapCap The new swap cap.\n */\n function setBridgeTokenSwapCap(address _bridgeToken, uint256 _swapCap) external onlyOwner {\n swapSupplies[_bridgeToken].cap = _swapCap;\n emit TokenSwapCapUpdated(_bridgeToken, _swapCap);\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/MintSwapCanonicalTokenUpgradable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"./MintSwapCanonicalToken.sol\";\n\n/**\n * @title Upgradable canonical token that supports multi-bridge minter and multi-token swap\n */\n\n// First deploy this contract, constructor will set name, symbol and owner in contract state, but these are NOT used.\n// decimal isn't saved in state because it's immutable in MultiBridgeToken and will be set in the code binary.\n// Then deploy proxy contract with this contract as impl, proxy constructor will delegatecall this.init which sets name, symbol and owner in proxy contract state.\n// why we need to shadow name and symbol: ERC20 only allows set them in constructor which isn't available after deploy so proxy state can't be updated.\ncontract MintSwapCanonicalTokenUpgradable is MintSwapCanonicalToken {\n string private _name;\n string private _symbol;\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) MintSwapCanonicalToken(name_, symbol_, decimals_) {}\n\n // only to be called by Proxy via delegatecall and will modify Proxy state\n // this func has no access control because initOwner only allows delegateCall\n function init(string memory name_, string memory symbol_) external {\n initOwner(); // this will fail if Ownable._owner is already set\n _name = name_;\n _symbol = symbol_;\n }\n\n // override name, symbol and owner getters\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/MultiBridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"../../safeguard/Ownable.sol\";\n\n/**\n * @title Example Multi-Bridge Pegged ERC20 token\n */\ncontract MultiBridgeToken is ERC20, Ownable {\n struct Supply {\n uint256 cap;\n uint256 total;\n }\n mapping(address => Supply) public bridges; // bridge address -> supply\n\n uint8 private immutable _decimals;\n\n event BridgeSupplyCapUpdated(address bridge, uint256 supplyCap);\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_\n ) ERC20(name_, symbol_) {\n _decimals = decimals_;\n }\n\n /**\n * @notice Mints tokens to an address. Increases total amount minted by the calling bridge.\n * @param _to The address to mint tokens to.\n * @param _amount The amount to mint.\n */\n function mint(address _to, uint256 _amount) external returns (bool) {\n Supply storage b = bridges[msg.sender];\n require(b.cap > 0, \"invalid caller\");\n b.total += _amount;\n require(b.total <= b.cap, \"exceeds bridge supply cap\");\n _mint(_to, _amount);\n return true;\n }\n\n /**\n * @notice Burns tokens for msg.sender.\n * @param _amount The amount to burn.\n */\n function burn(uint256 _amount) external returns (bool) {\n _burn(msg.sender, _amount);\n return true;\n }\n\n /**\n * @notice Burns tokens from an address. Decreases total amount minted if called by a bridge.\n * Alternative to {burnFrom} for compatibility with some bridge implementations.\n * See {_burnFrom}.\n * @param _from The address to burn tokens from.\n * @param _amount The amount to burn.\n */\n function burn(address _from, uint256 _amount) external returns (bool) {\n return _burnFrom(_from, _amount);\n }\n\n /**\n * @notice Burns tokens from an address. Decreases total amount minted if called by a bridge.\n * See {_burnFrom}.\n * @param _from The address to burn tokens from.\n * @param _amount The amount to burn.\n */\n function burnFrom(address _from, uint256 _amount) external returns (bool) {\n return _burnFrom(_from, _amount);\n }\n\n /**\n * @dev Burns tokens from an address, deducting from the caller's allowance.\n * Decreases total amount minted if called by a bridge.\n * @param _from The address to burn tokens from.\n * @param _amount The amount to burn.\n */\n function _burnFrom(address _from, uint256 _amount) internal returns (bool) {\n Supply storage b = bridges[msg.sender];\n if (b.cap > 0 || b.total > 0) {\n // set cap to 1 would effectively disable a deprecated bridge's ability to burn\n require(b.total >= _amount, \"exceeds bridge minted amount\");\n unchecked {\n b.total -= _amount;\n }\n }\n _spendAllowance(_from, msg.sender, _amount);\n _burn(_from, _amount);\n return true;\n }\n\n /**\n * @notice Returns the decimals of the token.\n */\n function decimals() public view virtual override returns (uint8) {\n return _decimals;\n }\n\n /**\n * @notice Updates the supply cap for a bridge.\n * @param _bridge The bridge address.\n * @param _cap The new supply cap.\n */\n function updateBridgeSupplyCap(address _bridge, uint256 _cap) external onlyOwner {\n // cap == 0 means revoking bridge role\n bridges[_bridge].cap = _cap;\n emit BridgeSupplyCapUpdated(_bridge, _cap);\n }\n\n /**\n * @notice Returns the owner address. Required by BEP20.\n */\n function getOwner() external view returns (address) {\n return owner();\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/owners/RestrictedMultiBridgeTokenOwner.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"../../../safeguard/Ownable.sol\";\n\ninterface IMultiBridgeToken {\n function updateBridgeSupplyCap(address _bridge, uint256 _cap) external;\n}\n\n// restrict multi-bridge token to effectively only have one bridge (minter)\ncontract RestrictedMultiBridgeTokenOwner is Ownable {\n address public immutable token;\n address public bridge;\n\n constructor(address _token, address _bridge) {\n token = _token;\n bridge = _bridge;\n }\n\n function updateBridgeSupplyCap(uint256 _cap) external onlyOwner {\n IMultiBridgeToken(token).updateBridgeSupplyCap(bridge, _cap);\n }\n\n function changeBridge(address _bridge, uint256 _cap) external onlyOwner {\n // set previous bridge cap to 1 to disable mint but still allow burn\n // till its total supply becomes zero\n IMultiBridgeToken(token).updateBridgeSupplyCap(bridge, 1);\n // set new bridge and cap\n IMultiBridgeToken(token).updateBridgeSupplyCap(_bridge, _cap);\n bridge = _bridge;\n }\n\n function revokeBridge(address _bridge) external onlyOwner {\n // set previous bridge cap to 0 to disable both mint and burn\n IMultiBridgeToken(token).updateBridgeSupplyCap(_bridge, 0);\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/SingleBridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @title Example Pegged ERC20 token\n */\ncontract SingleBridgeToken is ERC20, Ownable {\n address public bridge;\n\n uint8 private immutable _decimals;\n\n event BridgeUpdated(address bridge);\n\n modifier onlyBridge() {\n require(msg.sender == bridge, \"caller is not bridge\");\n _;\n }\n\n constructor(\n string memory name_,\n string memory symbol_,\n uint8 decimals_,\n address bridge_\n ) ERC20(name_, symbol_) {\n _decimals = decimals_;\n bridge = bridge_;\n }\n\n /**\n * @notice Mints tokens to an address.\n * @param _to The address to mint tokens to.\n * @param _amount The amount to mint.\n */\n function mint(address _to, uint256 _amount) external onlyBridge returns (bool) {\n _mint(_to, _amount);\n return true;\n }\n\n /**\n * @notice Burns tokens for msg.sender.\n * @param _amount The amount to burn.\n */\n function burn(uint256 _amount) external returns (bool) {\n _burn(msg.sender, _amount);\n return true;\n }\n\n /**\n * @notice Burns tokens from an address.\n * Alternative to {burnFrom} for compatibility with some bridge implementations.\n * See {_burnFrom}.\n * @param _from The address to burn tokens from.\n * @param _amount The amount to burn.\n */\n function burn(address _from, uint256 _amount) external returns (bool) {\n return _burnFrom(_from, _amount);\n }\n\n /**\n * @notice Burns tokens from an address.\n * See {_burnFrom}.\n * @param _from The address to burn tokens from.\n * @param _amount The amount to burn.\n */\n function burnFrom(address _from, uint256 _amount) external returns (bool) {\n return _burnFrom(_from, _amount);\n }\n\n /**\n * @dev Burns tokens from an address, deducting from the caller's allowance.\n * @param _from The address to burn tokens from.\n * @param _amount The amount to burn.\n */\n function _burnFrom(address _from, uint256 _amount) internal returns (bool) {\n _spendAllowance(_from, msg.sender, _amount);\n _burn(_from, _amount);\n return true;\n }\n\n /**\n * @notice Returns the decimals of the token.\n */\n function decimals() public view virtual override returns (uint8) {\n return _decimals;\n }\n\n /**\n * @notice Updates the bridge address.\n * @param _bridge The bridge address.\n */\n function updateBridge(address _bridge) external onlyOwner {\n bridge = _bridge;\n emit BridgeUpdated(bridge);\n }\n\n /**\n * @notice Returns the owner address. Required by BEP20.\n */\n function getOwner() external view returns (address) {\n return owner();\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/SwapBridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ninterface ISwapCanoToken {\n function swapBridgeForCanonical(address, uint256) external returns (uint256);\n\n function swapCanonicalForBridge(address, uint256) external returns (uint256);\n}\n\n/**\n * @title Per bridge intermediary token that supports swapping with a canonical token.\n */\ncontract SwapBridgeToken is ERC20, Ownable {\n using SafeERC20 for IERC20;\n\n address public bridge;\n address public immutable canonical; // canonical token that support swap\n\n event BridgeUpdated(address bridge);\n\n modifier onlyBridge() {\n require(msg.sender == bridge, \"caller is not bridge\");\n _;\n }\n\n constructor(\n string memory name_,\n string memory symbol_,\n address bridge_,\n address canonical_\n ) ERC20(name_, symbol_) {\n bridge = bridge_;\n canonical = canonical_;\n }\n\n function mint(address _to, uint256 _amount) external onlyBridge returns (bool) {\n _mint(address(this), _amount); // add amount to myself so swapBridgeForCanonical can transfer amount\n uint256 got = ISwapCanoToken(canonical).swapBridgeForCanonical(address(this), _amount);\n // now this has canonical token, next step is to transfer to user\n IERC20(canonical).safeTransfer(_to, got);\n return true;\n }\n\n function burn(address _from, uint256 _amount) external onlyBridge returns (bool) {\n IERC20(canonical).safeTransferFrom(_from, address(this), _amount);\n uint256 got = ISwapCanoToken(canonical).swapCanonicalForBridge(address(this), _amount);\n _burn(address(this), got);\n return true;\n }\n\n function updateBridge(address _bridge) external onlyOwner {\n bridge = _bridge;\n emit BridgeUpdated(bridge);\n }\n\n // approve canonical token so swapBridgeForCanonical can work. or we approve before call it in mint w/ added gas\n function approveCanonical() external onlyOwner {\n _approve(address(this), canonical, type(uint256).max);\n }\n\n function revokeCanonical() external onlyOwner {\n _approve(address(this), canonical, 0);\n }\n\n // to make compatible with BEP20\n function getOwner() external view returns (address) {\n return owner();\n }\n\n function decimals() public view virtual override returns (uint8) {\n return ERC20(canonical).decimals();\n }\n}\n" + }, + "contracts/pegged-bridge/tokens/WrappedBridgeToken.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n// Use pegged model to support no-slippage liquidity pool\ncontract WrappedBridgeToken is ERC20, Ownable {\n using SafeERC20 for IERC20;\n\n // The PeggedTokenBridge\n address public bridge;\n // The canonical\n address public immutable canonical;\n\n mapping(address => uint256) public liquidity;\n\n event BridgeUpdated(address bridge);\n event LiquidityAdded(address provider, uint256 amount);\n event LiquidityRemoved(address provider, uint256 amount);\n\n modifier onlyBridge() {\n require(msg.sender == bridge, \"caller is not bridge\");\n _;\n }\n\n constructor(\n string memory name_,\n string memory symbol_,\n address bridge_,\n address canonical_\n ) ERC20(name_, symbol_) {\n bridge = bridge_;\n canonical = canonical_;\n }\n\n function mint(address _to, uint256 _amount) external onlyBridge returns (bool) {\n _mint(address(this), _amount);\n IERC20(canonical).safeTransfer(_to, _amount);\n return true;\n }\n\n function burn(address _from, uint256 _amount) external onlyBridge returns (bool) {\n _burn(address(this), _amount);\n IERC20(canonical).safeTransferFrom(_from, address(this), _amount);\n return true;\n }\n\n function addLiquidity(uint256 _amount) external {\n liquidity[msg.sender] += _amount;\n IERC20(canonical).safeTransferFrom(msg.sender, address(this), _amount);\n emit LiquidityAdded(msg.sender, _amount);\n }\n\n function removeLiquidity(uint256 _amount) external {\n liquidity[msg.sender] -= _amount;\n IERC20(canonical).safeTransfer(msg.sender, _amount);\n emit LiquidityRemoved(msg.sender, _amount);\n }\n\n function updateBridge(address _bridge) external onlyOwner {\n bridge = _bridge;\n emit BridgeUpdated(bridge);\n }\n\n function decimals() public view virtual override returns (uint8) {\n return ERC20(canonical).decimals();\n }\n\n // to make compatible with BEP20\n function getOwner() external view returns (address) {\n return owner();\n }\n}\n" + }, + "contracts/proxy/TransferAgent.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\nimport \"../libraries/BridgeTransferLib.sol\";\nimport \"../safeguard/Ownable.sol\";\n\n/**\n * @title Transfer agent. Designed to support arbitrary length receiver address for transfer. Supports the liquidity pool-based {Bridge}, the {OriginalTokenVault} for pegged\n * deposit and the {PeggedTokenBridge} for pegged burn.\n */\ncontract TransferAgent is ReentrancyGuard, Ownable {\n using SafeERC20 for IERC20;\n\n struct Extension {\n uint8 Type;\n bytes Value;\n }\n\n mapping(BridgeTransferLib.BridgeSendType => address) public bridges;\n\n event Supplement(\n BridgeTransferLib.BridgeSendType bridgeSendType,\n bytes32 transferId,\n address sender,\n bytes receiver,\n Extension[] extensions\n );\n event BridgeUpdated(BridgeTransferLib.BridgeSendType bridgeSendType, address bridgeAddr);\n\n /**\n * @notice Send a cross-chain transfer of ERC20 token either via liquidity pool-based bridge or in form of mint/burn.\n * @param _receiver The address of the receiver.\n * @param _token The address of the token.\n * @param _amount The amount of the transfer.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least\n * (100% - max slippage percentage) * amount or the transfer can be refunded.\n * Only applicable to the {BridgeSendType.Liquidity}.\n * @param _bridgeSendType The type of bridge used by this transfer. One of the {BridgeSendType} enum.\n * @param _extensions A list of extension to be processed by agent, is designed to be used for extending\n * present transfer. Contact Celer team to learn about already supported type of extension.\n */\n function transfer(\n bytes calldata _receiver,\n address _token,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage, // slippage * 1M, eg. 0.5% -> 5000\n BridgeTransferLib.BridgeSendType _bridgeSendType,\n Extension[] calldata _extensions\n ) external nonReentrant returns (bytes32) {\n bytes32 transferId;\n {\n address _bridgeAddr = bridges[_bridgeSendType];\n require(_bridgeAddr != address(0), \"unknown bridge type\");\n IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);\n transferId = BridgeTransferLib.sendTransfer(\n address(0),\n _token,\n _amount,\n _dstChainId,\n _nonce,\n _maxSlippage,\n _bridgeSendType,\n _bridgeAddr\n );\n }\n emit Supplement(_bridgeSendType, transferId, msg.sender, _receiver, _extensions);\n return transferId;\n }\n\n /**\n * @notice Send a cross-chain transfer of native token either via liquidity pool-based bridge or in form of mint/burn.\n * @param _receiver The address of the receiver.\n * @param _amount The amount of the transfer.\n * @param _dstChainId The destination chain ID.\n * @param _nonce A number input to guarantee uniqueness of transferId. Can be timestamp in practice.\n * @param _maxSlippage The max slippage accepted, given as percentage in point (pip). Eg. 5000 means 0.5%.\n * Must be greater than minimalMaxSlippage. Receiver is guaranteed to receive at least\n * (100% - max slippage percentage) * amount or the transfer can be refunded.\n * Only applicable to the {BridgeSendType.Liquidity}.\n * @param _bridgeSendType The type of bridge used by this transfer. One of the {BridgeSendType} enum.\n * @param _extensions A list of extension to be processed by agent, is designed to be used for extending\n * present transfer. Contact Celer team to learn about already supported type of extension.\n */\n function transferNative(\n bytes calldata _receiver,\n uint256 _amount,\n uint64 _dstChainId,\n uint64 _nonce,\n uint32 _maxSlippage, // slippage * 1M, eg. 0.5% -> 5000\n BridgeTransferLib.BridgeSendType _bridgeSendType,\n Extension[] calldata _extensions\n ) external payable nonReentrant returns (bytes32) {\n bytes32 transferId;\n {\n address _bridgeAddr = bridges[_bridgeSendType];\n require(_bridgeAddr != address(0), \"unknown bridge type\");\n require(msg.value == _amount, \"amount mismatch\");\n transferId = BridgeTransferLib.sendNativeTransfer(\n address(0),\n _amount,\n _dstChainId,\n _nonce,\n _maxSlippage,\n _bridgeSendType,\n _bridgeAddr\n );\n }\n emit Supplement(_bridgeSendType, transferId, msg.sender, _receiver, _extensions);\n return transferId;\n }\n\n // ----------------------Admin operation-----------------------\n\n function setBridgeAddress(BridgeTransferLib.BridgeSendType _bridgeSendType, address _addr) public onlyOwner {\n require(_addr != address(0), \"invalid address\");\n bridges[_bridgeSendType] = _addr;\n emit BridgeUpdated(_bridgeSendType, _addr);\n }\n}\n" + }, + "contracts/safeguard/DelayedTransfer.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./Governor.sol\";\n\nabstract contract DelayedTransfer is Governor {\n struct delayedTransfer {\n address receiver;\n address token;\n uint256 amount;\n uint256 timestamp;\n }\n mapping(bytes32 => delayedTransfer) public delayedTransfers;\n mapping(address => uint256) public delayThresholds;\n uint256 public delayPeriod; // in seconds\n\n event DelayedTransferAdded(bytes32 id);\n event DelayedTransferExecuted(bytes32 id, address receiver, address token, uint256 amount);\n\n event DelayPeriodUpdated(uint256 period);\n event DelayThresholdUpdated(address token, uint256 threshold);\n\n function setDelayThresholds(address[] calldata _tokens, uint256[] calldata _thresholds) external onlyGovernor {\n require(_tokens.length == _thresholds.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n delayThresholds[_tokens[i]] = _thresholds[i];\n emit DelayThresholdUpdated(_tokens[i], _thresholds[i]);\n }\n }\n\n function setDelayPeriod(uint256 _period) external onlyGovernor {\n delayPeriod = _period;\n emit DelayPeriodUpdated(_period);\n }\n\n function _addDelayedTransfer(\n bytes32 id,\n address receiver,\n address token,\n uint256 amount\n ) internal {\n require(delayedTransfers[id].timestamp == 0, \"delayed transfer already exists\");\n delayedTransfers[id] = delayedTransfer({\n receiver: receiver,\n token: token,\n amount: amount,\n timestamp: block.timestamp\n });\n emit DelayedTransferAdded(id);\n }\n\n // caller needs to do the actual token transfer\n function _executeDelayedTransfer(bytes32 id) internal returns (delayedTransfer memory) {\n delayedTransfer memory transfer = delayedTransfers[id];\n require(transfer.timestamp > 0, \"delayed transfer not exist\");\n require(block.timestamp > transfer.timestamp + delayPeriod, \"delayed transfer still locked\");\n delete delayedTransfers[id];\n emit DelayedTransferExecuted(id, transfer.receiver, transfer.token, transfer.amount);\n return transfer;\n }\n}\n" + }, + "contracts/safeguard/Governor.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./Ownable.sol\";\n\nabstract contract Governor is Ownable {\n mapping(address => bool) public governors;\n\n event GovernorAdded(address account);\n event GovernorRemoved(address account);\n\n modifier onlyGovernor() {\n require(isGovernor(msg.sender), \"Caller is not governor\");\n _;\n }\n\n constructor() {\n _addGovernor(msg.sender);\n }\n\n function isGovernor(address _account) public view returns (bool) {\n return governors[_account];\n }\n\n function addGovernor(address _account) public onlyOwner {\n _addGovernor(_account);\n }\n\n function removeGovernor(address _account) public onlyOwner {\n _removeGovernor(_account);\n }\n\n function renounceGovernor() public {\n _removeGovernor(msg.sender);\n }\n\n function _addGovernor(address _account) private {\n require(!isGovernor(_account), \"Account is already governor\");\n governors[_account] = true;\n emit GovernorAdded(_account);\n }\n\n function _removeGovernor(address _account) private {\n require(isGovernor(_account), \"Account is not governor\");\n governors[_account] = false;\n emit GovernorRemoved(_account);\n }\n}\n" + }, + "contracts/safeguard/Ownable.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity ^0.8.0;\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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 *\n * This adds a normal func that setOwner if _owner is address(0). So we can't allow\n * renounceOwnership. So we can support Proxy based upgradable contract\n */\nabstract contract Ownable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _setOwner(msg.sender);\n }\n\n /**\n * @dev Only to be called by inherit contracts, in their init func called by Proxy\n * we require _owner == address(0), which is only possible when it's a delegateCall\n * because constructor sets _owner in contract state.\n */\n function initOwner() internal {\n require(_owner == address(0), \"owner already set\");\n _setOwner(msg.sender);\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 called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == msg.sender, \"Ownable: caller is not the owner\");\n _;\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 require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _setOwner(newOwner);\n }\n\n function _setOwner(address newOwner) private {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "contracts/safeguard/Pauser.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\nimport \"./Ownable.sol\";\n\nabstract contract Pauser is Ownable, Pausable {\n mapping(address => bool) public pausers;\n\n event PauserAdded(address account);\n event PauserRemoved(address account);\n\n constructor() {\n _addPauser(msg.sender);\n }\n\n modifier onlyPauser() {\n require(isPauser(msg.sender), \"Caller is not pauser\");\n _;\n }\n\n function pause() public onlyPauser {\n _pause();\n }\n\n function unpause() public onlyPauser {\n _unpause();\n }\n\n function isPauser(address account) public view returns (bool) {\n return pausers[account];\n }\n\n function addPauser(address account) public onlyOwner {\n _addPauser(account);\n }\n\n function removePauser(address account) public onlyOwner {\n _removePauser(account);\n }\n\n function renouncePauser() public {\n _removePauser(msg.sender);\n }\n\n function _addPauser(address account) private {\n require(!isPauser(account), \"Account is already pauser\");\n pausers[account] = true;\n emit PauserAdded(account);\n }\n\n function _removePauser(address account) private {\n require(isPauser(account), \"Account is not pauser\");\n pausers[account] = false;\n emit PauserRemoved(account);\n }\n}\n" + }, + "contracts/safeguard/VolumeControl.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./Governor.sol\";\n\nabstract contract VolumeControl is Governor {\n uint256 public epochLength; // seconds\n mapping(address => uint256) public epochVolumes; // key is token\n mapping(address => uint256) public epochVolumeCaps; // key is token\n mapping(address => uint256) public lastOpTimestamps; // key is token\n\n event EpochLengthUpdated(uint256 length);\n event EpochVolumeUpdated(address token, uint256 cap);\n\n function setEpochLength(uint256 _length) external onlyGovernor {\n epochLength = _length;\n emit EpochLengthUpdated(_length);\n }\n\n function setEpochVolumeCaps(address[] calldata _tokens, uint256[] calldata _caps) external onlyGovernor {\n require(_tokens.length == _caps.length, \"length mismatch\");\n for (uint256 i = 0; i < _tokens.length; i++) {\n epochVolumeCaps[_tokens[i]] = _caps[i];\n emit EpochVolumeUpdated(_tokens[i], _caps[i]);\n }\n }\n\n function _updateVolume(address _token, uint256 _amount) internal {\n if (epochLength == 0) {\n return;\n }\n uint256 cap = epochVolumeCaps[_token];\n if (cap == 0) {\n return;\n }\n uint256 volume = epochVolumes[_token];\n uint256 timestamp = block.timestamp;\n uint256 epochStartTime = (timestamp / epochLength) * epochLength;\n if (lastOpTimestamps[_token] < epochStartTime) {\n volume = _amount;\n } else {\n volume += _amount;\n }\n require(volume <= cap, \"volume exceeds cap\");\n epochVolumes[_token] = volume;\n lastOpTimestamps[_token] = timestamp;\n }\n}\n" + }, + "contracts/safeguard/Whitelist.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"./Ownable.sol\";\n\nabstract contract Whitelist is Ownable {\n mapping(address => bool) public whitelist;\n bool public whitelistEnabled;\n\n event WhitelistedAdded(address account);\n event WhitelistedRemoved(address account);\n\n modifier onlyWhitelisted() {\n if (whitelistEnabled) {\n require(isWhitelisted(msg.sender), \"Caller is not whitelisted\");\n }\n _;\n }\n\n /**\n * @notice Set whitelistEnabled\n */\n function setWhitelistEnabled(bool _whitelistEnabled) external onlyOwner {\n whitelistEnabled = _whitelistEnabled;\n }\n\n /**\n * @notice Add an account to whitelist\n */\n function addWhitelisted(address account) external onlyOwner {\n require(!isWhitelisted(account), \"Already whitelisted\");\n whitelist[account] = true;\n emit WhitelistedAdded(account);\n }\n\n /**\n * @notice Remove an account from whitelist\n */\n function removeWhitelisted(address account) external onlyOwner {\n require(isWhitelisted(account), \"Not whitelisted\");\n whitelist[account] = false;\n emit WhitelistedRemoved(account);\n }\n\n /**\n * @return is account whitelisted\n */\n function isWhitelisted(address account) public view returns (bool) {\n return whitelist[account];\n }\n}\n" + }, + "contracts/staking/DataTypes.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nlibrary DataTypes {\n uint256 constant CELR_DECIMAL = 1e18;\n uint256 constant MAX_INT = 2**256 - 1;\n uint256 constant COMMISSION_RATE_BASE = 10000; // 1 commissionRate means 0.01%\n uint256 constant MAX_UNDELEGATION_ENTRIES = 10;\n uint256 constant SLASH_FACTOR_DECIMAL = 1e6;\n\n enum ValidatorStatus {\n Null,\n Unbonded,\n Unbonding,\n Bonded\n }\n\n enum ParamName {\n ProposalDeposit,\n VotingPeriod,\n UnbondingPeriod,\n MaxBondedValidators,\n MinValidatorTokens,\n MinSelfDelegation,\n AdvanceNoticePeriod,\n ValidatorBondInterval,\n MaxSlashFactor\n }\n\n struct Undelegation {\n uint256 shares;\n uint256 creationBlock;\n }\n\n struct Undelegations {\n mapping(uint256 => Undelegation) queue;\n uint32 head;\n uint32 tail;\n }\n\n struct Delegator {\n uint256 shares;\n Undelegations undelegations;\n }\n\n struct Validator {\n ValidatorStatus status;\n address signer;\n uint256 tokens; // sum of all tokens delegated to this validator\n uint256 shares; // sum of all delegation shares\n uint256 undelegationTokens; // tokens being undelegated\n uint256 undelegationShares; // shares of tokens being undelegated\n mapping(address => Delegator) delegators;\n uint256 minSelfDelegation;\n uint64 bondBlock; // cannot become bonded before this block\n uint64 unbondBlock; // cannot become unbonded before this block\n uint64 commissionRate; // equal to real commission rate * COMMISSION_RATE_BASE\n }\n\n // used for external view output\n struct ValidatorTokens {\n address valAddr;\n uint256 tokens;\n }\n\n // used for external view output\n struct ValidatorInfo {\n address valAddr;\n ValidatorStatus status;\n address signer;\n uint256 tokens;\n uint256 shares;\n uint256 minSelfDelegation;\n uint64 commissionRate;\n }\n\n // used for external view output\n struct DelegatorInfo {\n address valAddr;\n uint256 tokens;\n uint256 shares;\n Undelegation[] undelegations;\n uint256 undelegationTokens;\n uint256 withdrawableUndelegationTokens;\n }\n}\n" + }, + "contracts/staking/Govern.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {DataTypes as dt} from \"./DataTypes.sol\";\nimport \"./Staking.sol\";\n\n/**\n * @title Governance module for Staking contract\n */\ncontract Govern {\n using SafeERC20 for IERC20;\n\n Staking public immutable staking;\n IERC20 public immutable celerToken;\n\n enum ProposalStatus {\n Uninitiated,\n Voting,\n Closed\n }\n\n enum VoteOption {\n Null,\n Yes,\n Abstain,\n No\n }\n\n struct ParamProposal {\n address proposer;\n uint256 deposit;\n uint256 voteDeadline;\n dt.ParamName name;\n uint256 newValue;\n ProposalStatus status;\n mapping(address => VoteOption) votes;\n }\n\n mapping(uint256 => ParamProposal) public paramProposals;\n uint256 public nextParamProposalId;\n\n uint256 public forfeiture;\n address public immutable collector;\n\n event CreateParamProposal(\n uint256 proposalId,\n address proposer,\n uint256 deposit,\n uint256 voteDeadline,\n dt.ParamName name,\n uint256 newValue\n );\n event VoteParam(uint256 proposalId, address voter, VoteOption vote);\n event ConfirmParamProposal(uint256 proposalId, bool passed, dt.ParamName name, uint256 newValue);\n\n constructor(\n Staking _staking,\n address _celerTokenAddress,\n address _collector\n ) {\n staking = _staking;\n celerToken = IERC20(_celerTokenAddress);\n collector = _collector;\n }\n\n /**\n * @notice Get the vote type of a voter on a parameter proposal\n * @param _proposalId the proposal id\n * @param _voter the voter address\n * @return the vote type of the given voter on the given parameter proposal\n */\n function getParamProposalVote(uint256 _proposalId, address _voter) public view returns (VoteOption) {\n return paramProposals[_proposalId].votes[_voter];\n }\n\n /**\n * @notice Create a parameter proposal\n * @param _name the key of this parameter\n * @param _value the new proposed value of this parameter\n */\n function createParamProposal(dt.ParamName _name, uint256 _value) external {\n ParamProposal storage p = paramProposals[nextParamProposalId];\n nextParamProposalId = nextParamProposalId + 1;\n address msgSender = msg.sender;\n uint256 deposit = staking.getParamValue(dt.ParamName.ProposalDeposit);\n\n p.proposer = msgSender;\n p.deposit = deposit;\n p.voteDeadline = block.number + staking.getParamValue(dt.ParamName.VotingPeriod);\n p.name = _name;\n p.newValue = _value;\n p.status = ProposalStatus.Voting;\n\n celerToken.safeTransferFrom(msgSender, address(this), deposit);\n\n emit CreateParamProposal(nextParamProposalId - 1, msgSender, deposit, p.voteDeadline, _name, _value);\n }\n\n /**\n * @notice Vote for a parameter proposal with a specific type of vote\n * @param _proposalId the id of the parameter proposal\n * @param _vote the type of vote\n */\n function voteParam(uint256 _proposalId, VoteOption _vote) external {\n address valAddr = msg.sender;\n require(staking.getValidatorStatus(valAddr) == dt.ValidatorStatus.Bonded, \"Voter is not a bonded validator\");\n ParamProposal storage p = paramProposals[_proposalId];\n require(p.status == ProposalStatus.Voting, \"Invalid proposal status\");\n require(block.number < p.voteDeadline, \"Vote deadline passed\");\n require(p.votes[valAddr] == VoteOption.Null, \"Voter has voted\");\n require(_vote != VoteOption.Null, \"Invalid vote\");\n\n p.votes[valAddr] = _vote;\n\n emit VoteParam(_proposalId, valAddr, _vote);\n }\n\n /**\n * @notice Confirm a parameter proposal\n * @param _proposalId the id of the parameter proposal\n */\n function confirmParamProposal(uint256 _proposalId) external {\n uint256 yesVotes;\n uint256 bondedTokens;\n dt.ValidatorTokens[] memory validators = staking.getBondedValidatorsTokens();\n for (uint32 i = 0; i < validators.length; i++) {\n if (getParamProposalVote(_proposalId, validators[i].valAddr) == VoteOption.Yes) {\n yesVotes += validators[i].tokens;\n }\n bondedTokens += validators[i].tokens;\n }\n bool passed = (yesVotes >= (bondedTokens * 2) / 3 + 1);\n\n ParamProposal storage p = paramProposals[_proposalId];\n require(p.status == ProposalStatus.Voting, \"Invalid proposal status\");\n require(block.number >= p.voteDeadline, \"Vote deadline not reached\");\n\n p.status = ProposalStatus.Closed;\n if (passed) {\n staking.setParamValue(p.name, p.newValue);\n celerToken.safeTransfer(p.proposer, p.deposit);\n } else {\n forfeiture += p.deposit;\n }\n\n emit ConfirmParamProposal(_proposalId, passed, p.name, p.newValue);\n }\n\n function collectForfeiture() external {\n require(forfeiture > 0, \"Nothing to collect\");\n celerToken.safeTransfer(collector, forfeiture);\n forfeiture = 0;\n }\n}\n" + }, + "contracts/staking/SGN.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {DataTypes as dt} from \"./DataTypes.sol\";\nimport \"../libraries/PbSgn.sol\";\nimport \"../safeguard/Pauser.sol\";\nimport \"./Staking.sol\";\n\n/**\n * @title contract of SGN chain\n */\ncontract SGN is Pauser {\n using SafeERC20 for IERC20;\n\n Staking public immutable staking;\n bytes32[] public deposits;\n // account -> (token -> amount)\n mapping(address => mapping(address => uint256)) public withdrawnAmts;\n mapping(address => bytes) public sgnAddrs;\n\n /* Events */\n event SgnAddrUpdate(address indexed valAddr, bytes oldAddr, bytes newAddr);\n event Deposit(uint256 depositId, address account, address token, uint256 amount);\n event Withdraw(address account, address token, uint256 amount);\n\n /**\n * @notice SGN constructor\n * @dev Need to deploy Staking contract first before deploying SGN contract\n * @param _staking address of Staking Contract\n */\n constructor(Staking _staking) {\n staking = _staking;\n }\n\n /**\n * @notice Update sgn address\n * @param _sgnAddr the new address in the layer 2 SGN\n */\n function updateSgnAddr(bytes calldata _sgnAddr) external {\n address valAddr = msg.sender;\n if (staking.signerVals(msg.sender) != address(0)) {\n valAddr = staking.signerVals(msg.sender);\n }\n\n dt.ValidatorStatus status = staking.getValidatorStatus(valAddr);\n require(status == dt.ValidatorStatus.Unbonded, \"Not unbonded validator\");\n\n bytes memory oldAddr = sgnAddrs[valAddr];\n sgnAddrs[valAddr] = _sgnAddr;\n\n staking.validatorNotice(valAddr, \"sgn-addr\", _sgnAddr);\n emit SgnAddrUpdate(valAddr, oldAddr, _sgnAddr);\n }\n\n /**a\n * @notice Deposit to SGN\n * @param _amount subscription fee paid along this function call in CELR tokens\n */\n function deposit(address _token, uint256 _amount) external whenNotPaused {\n address msgSender = msg.sender;\n deposits.push(keccak256(abi.encodePacked(msgSender, _token, _amount)));\n IERC20(_token).safeTransferFrom(msgSender, address(this), _amount);\n uint64 depositId = uint64(deposits.length - 1);\n emit Deposit(depositId, msgSender, _token, _amount);\n }\n\n /**\n * @notice Withdraw token\n * @dev Here we use cumulative amount to make withdrawal process idempotent\n * @param _withdrawalRequest withdrawal request bytes coded in protobuf\n * @param _sigs list of validator signatures\n */\n function withdraw(bytes calldata _withdrawalRequest, bytes[] calldata _sigs) external whenNotPaused {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"Withdrawal\"));\n staking.verifySignatures(abi.encodePacked(domain, _withdrawalRequest), _sigs);\n PbSgn.Withdrawal memory withdrawal = PbSgn.decWithdrawal(_withdrawalRequest);\n\n uint256 amount = withdrawal.cumulativeAmount - withdrawnAmts[withdrawal.account][withdrawal.token];\n require(amount > 0, \"No new amount to withdraw\");\n withdrawnAmts[withdrawal.account][withdrawal.token] = withdrawal.cumulativeAmount;\n\n IERC20(withdrawal.token).safeTransfer(withdrawal.account, amount);\n emit Withdraw(withdrawal.account, withdrawal.token, amount);\n }\n\n /**\n * @notice Owner drains one type of tokens when the contract is paused\n * @dev emergency use only\n * @param _amount drained token amount\n */\n function drainToken(address _token, uint256 _amount) external whenPaused onlyOwner {\n IERC20(_token).safeTransfer(msg.sender, _amount);\n }\n}\n" + }, + "contracts/staking/Staking.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport {DataTypes as dt} from \"./DataTypes.sol\";\nimport \"../interfaces/ISigsVerifier.sol\";\nimport \"../libraries/PbStaking.sol\";\nimport \"../safeguard/Pauser.sol\";\nimport \"../safeguard/Whitelist.sol\";\n\n/**\n * @title A Staking contract shared by all external sidechains and apps\n */\ncontract Staking is ISigsVerifier, Pauser, Whitelist {\n using SafeERC20 for IERC20;\n using ECDSA for bytes32;\n\n IERC20 public immutable CELER_TOKEN;\n\n uint256 public bondedTokens;\n uint256 public nextBondBlock;\n address[] public valAddrs;\n address[] public bondedValAddrs;\n mapping(address => dt.Validator) public validators; // key is valAddr\n mapping(address => address) public signerVals; // signerAddr -> valAddr\n mapping(uint256 => bool) public slashNonces;\n\n mapping(dt.ParamName => uint256) public params;\n address public govContract;\n address public rewardContract;\n uint256 public forfeiture;\n\n /* Events */\n event ValidatorNotice(address indexed valAddr, string key, bytes data, address from);\n event ValidatorStatusUpdate(address indexed valAddr, dt.ValidatorStatus indexed status);\n event DelegationUpdate(\n address indexed valAddr,\n address indexed delAddr,\n uint256 valTokens,\n uint256 delShares,\n int256 tokenDiff\n );\n event Undelegated(address indexed valAddr, address indexed delAddr, uint256 amount);\n event Slash(address indexed valAddr, uint64 nonce, uint256 slashAmt);\n event SlashAmtCollected(address indexed recipient, uint256 amount);\n\n /**\n * @notice Staking constructor\n * @param _celerTokenAddress address of Celer Token Contract\n * @param _proposalDeposit required deposit amount for a governance proposal\n * @param _votingPeriod voting timeout for a governance proposal\n * @param _unbondingPeriod the locking time for funds locked before withdrawn\n * @param _maxBondedValidators the maximum number of bonded validators\n * @param _minValidatorTokens the global minimum token amount requirement for bonded validator\n * @param _minSelfDelegation minimal amount of self-delegated tokens\n * @param _advanceNoticePeriod the wait time after the announcement and prior to the effective date of an update\n * @param _validatorBondInterval min interval between bondValidator\n * @param _maxSlashFactor maximal slashing factor (1e6 = 100%)\n */\n constructor(\n address _celerTokenAddress,\n uint256 _proposalDeposit,\n uint256 _votingPeriod,\n uint256 _unbondingPeriod,\n uint256 _maxBondedValidators,\n uint256 _minValidatorTokens,\n uint256 _minSelfDelegation,\n uint256 _advanceNoticePeriod,\n uint256 _validatorBondInterval,\n uint256 _maxSlashFactor\n ) {\n CELER_TOKEN = IERC20(_celerTokenAddress);\n\n params[dt.ParamName.ProposalDeposit] = _proposalDeposit;\n params[dt.ParamName.VotingPeriod] = _votingPeriod;\n params[dt.ParamName.UnbondingPeriod] = _unbondingPeriod;\n params[dt.ParamName.MaxBondedValidators] = _maxBondedValidators;\n params[dt.ParamName.MinValidatorTokens] = _minValidatorTokens;\n params[dt.ParamName.MinSelfDelegation] = _minSelfDelegation;\n params[dt.ParamName.AdvanceNoticePeriod] = _advanceNoticePeriod;\n params[dt.ParamName.ValidatorBondInterval] = _validatorBondInterval;\n params[dt.ParamName.MaxSlashFactor] = _maxSlashFactor;\n }\n\n receive() external payable {}\n\n /*********************************\n * External and Public Functions *\n *********************************/\n\n /**\n * @notice Initialize a validator candidate\n * @param _signer signer address\n * @param _minSelfDelegation minimal amount of tokens staked by the validator itself\n * @param _commissionRate the self-declaimed commission rate\n */\n function initializeValidator(\n address _signer,\n uint256 _minSelfDelegation,\n uint64 _commissionRate\n ) external whenNotPaused onlyWhitelisted {\n address valAddr = msg.sender;\n dt.Validator storage validator = validators[valAddr];\n require(validator.status == dt.ValidatorStatus.Null, \"Validator is initialized\");\n require(validators[_signer].status == dt.ValidatorStatus.Null, \"Signer is other validator\");\n require(signerVals[valAddr] == address(0), \"Validator is other signer\");\n require(signerVals[_signer] == address(0), \"Signer already used\");\n require(_commissionRate <= dt.COMMISSION_RATE_BASE, \"Invalid commission rate\");\n require(_minSelfDelegation >= params[dt.ParamName.MinSelfDelegation], \"Insufficient min self delegation\");\n validator.signer = _signer;\n validator.status = dt.ValidatorStatus.Unbonded;\n validator.minSelfDelegation = _minSelfDelegation;\n validator.commissionRate = _commissionRate;\n valAddrs.push(valAddr);\n signerVals[_signer] = valAddr;\n\n delegate(valAddr, _minSelfDelegation);\n emit ValidatorNotice(valAddr, \"init\", abi.encode(_signer, _minSelfDelegation, _commissionRate), address(0));\n }\n\n /**\n * @notice Update validator signer address\n * @param _signer signer address\n */\n function updateValidatorSigner(address _signer) external {\n address valAddr = msg.sender;\n dt.Validator storage validator = validators[valAddr];\n require(validator.status != dt.ValidatorStatus.Null, \"Validator not initialized\");\n require(signerVals[_signer] == address(0), \"Signer already used\");\n if (_signer != valAddr) {\n require(validators[_signer].status == dt.ValidatorStatus.Null, \"Signer is other validator\");\n }\n\n delete signerVals[validator.signer];\n validator.signer = _signer;\n signerVals[_signer] = valAddr;\n\n emit ValidatorNotice(valAddr, \"signer\", abi.encode(_signer), address(0));\n }\n\n /**\n * @notice Candidate claims to become a bonded validator\n * @dev caller can be either validator owner or signer\n */\n function bondValidator() external {\n address valAddr = msg.sender;\n if (signerVals[msg.sender] != address(0)) {\n valAddr = signerVals[msg.sender];\n }\n dt.Validator storage validator = validators[valAddr];\n require(\n validator.status == dt.ValidatorStatus.Unbonded || validator.status == dt.ValidatorStatus.Unbonding,\n \"Invalid validator status\"\n );\n require(block.number >= validator.bondBlock, \"Bond block not reached\");\n require(block.number >= nextBondBlock, \"Too frequent validator bond\");\n nextBondBlock = block.number + params[dt.ParamName.ValidatorBondInterval];\n require(hasMinRequiredTokens(valAddr, true), \"Not have min tokens\");\n\n uint256 maxBondedValidators = params[dt.ParamName.MaxBondedValidators];\n // if the number of validators has not reached the max_validator_num,\n // add validator directly\n if (bondedValAddrs.length < maxBondedValidators) {\n _bondValidator(valAddr);\n _decentralizationCheck(validator.tokens);\n return;\n }\n // if the number of validators has already reached the max_validator_num,\n // add validator only if its tokens is more than the current least bonded validator tokens\n uint256 minTokens = dt.MAX_INT;\n uint256 minTokensIndex;\n for (uint256 i = 0; i < maxBondedValidators; i++) {\n if (validators[bondedValAddrs[i]].tokens < minTokens) {\n minTokensIndex = i;\n minTokens = validators[bondedValAddrs[i]].tokens;\n if (minTokens == 0) {\n break;\n }\n }\n }\n require(validator.tokens > minTokens, \"Insufficient tokens\");\n _replaceBondedValidator(valAddr, minTokensIndex);\n _decentralizationCheck(validator.tokens);\n }\n\n /**\n * @notice Confirm validator status from Unbonding to Unbonded\n * @param _valAddr the address of the validator\n */\n function confirmUnbondedValidator(address _valAddr) external {\n dt.Validator storage validator = validators[_valAddr];\n require(validator.status == dt.ValidatorStatus.Unbonding, \"Validator not unbonding\");\n require(block.number >= validator.unbondBlock, \"Unbond block not reached\");\n\n validator.status = dt.ValidatorStatus.Unbonded;\n delete validator.unbondBlock;\n emit ValidatorStatusUpdate(_valAddr, dt.ValidatorStatus.Unbonded);\n }\n\n /**\n * @notice Delegate CELR tokens to a validator\n * @dev Minimal amount per delegate operation is 1 CELR\n * @param _valAddr validator to delegate\n * @param _tokens the amount of delegated CELR tokens\n */\n function delegate(address _valAddr, uint256 _tokens) public whenNotPaused {\n address delAddr = msg.sender;\n require(_tokens >= dt.CELR_DECIMAL, \"Minimal amount is 1 CELR\");\n\n dt.Validator storage validator = validators[_valAddr];\n require(validator.status != dt.ValidatorStatus.Null, \"Validator is not initialized\");\n uint256 shares = _tokenToShare(_tokens, validator.tokens, validator.shares);\n\n dt.Delegator storage delegator = validator.delegators[delAddr];\n delegator.shares += shares;\n validator.shares += shares;\n validator.tokens += _tokens;\n if (validator.status == dt.ValidatorStatus.Bonded) {\n bondedTokens += _tokens;\n _decentralizationCheck(validator.tokens);\n }\n CELER_TOKEN.safeTransferFrom(delAddr, address(this), _tokens);\n emit DelegationUpdate(_valAddr, delAddr, validator.tokens, delegator.shares, int256(_tokens));\n }\n\n /**\n * @notice Undelegate shares from a validator\n * @dev Tokens are delegated by the msgSender to the validator\n * @param _valAddr the address of the validator\n * @param _shares undelegate shares\n */\n function undelegateShares(address _valAddr, uint256 _shares) external {\n require(_shares >= dt.CELR_DECIMAL, \"Minimal amount is 1 share\");\n dt.Validator storage validator = validators[_valAddr];\n require(validator.status != dt.ValidatorStatus.Null, \"Validator is not initialized\");\n uint256 tokens = _shareToToken(_shares, validator.tokens, validator.shares);\n _undelegate(validator, _valAddr, tokens, _shares);\n }\n\n /**\n * @notice Undelegate shares from a validator\n * @dev Tokens are delegated by the msgSender to the validator\n * @param _valAddr the address of the validator\n * @param _tokens undelegate tokens\n */\n function undelegateTokens(address _valAddr, uint256 _tokens) external {\n require(_tokens >= dt.CELR_DECIMAL, \"Minimal amount is 1 CELR\");\n dt.Validator storage validator = validators[_valAddr];\n require(validator.status != dt.ValidatorStatus.Null, \"Validator is not initialized\");\n uint256 shares = _tokenToShare(_tokens, validator.tokens, validator.shares);\n _undelegate(validator, _valAddr, _tokens, shares);\n }\n\n /**\n * @notice Complete pending undelegations from a validator\n * @param _valAddr the address of the validator\n */\n function completeUndelegate(address _valAddr) external {\n address delAddr = msg.sender;\n dt.Validator storage validator = validators[_valAddr];\n require(validator.status != dt.ValidatorStatus.Null, \"Validator is not initialized\");\n dt.Delegator storage delegator = validator.delegators[delAddr];\n\n uint256 unbondingPeriod = params[dt.ParamName.UnbondingPeriod];\n bool isUnbonded = validator.status == dt.ValidatorStatus.Unbonded;\n // for all pending undelegations\n uint32 i;\n uint256 undelegationShares;\n for (i = delegator.undelegations.head; i < delegator.undelegations.tail; i++) {\n if (isUnbonded || delegator.undelegations.queue[i].creationBlock + unbondingPeriod <= block.number) {\n // complete undelegation when the validator becomes unbonded or\n // the unbondingPeriod for the pending undelegation is up.\n undelegationShares += delegator.undelegations.queue[i].shares;\n delete delegator.undelegations.queue[i];\n continue;\n }\n break;\n }\n delegator.undelegations.head = i;\n\n require(undelegationShares > 0, \"No undelegation ready to be completed\");\n uint256 tokens = _shareToToken(undelegationShares, validator.undelegationTokens, validator.undelegationShares);\n validator.undelegationShares -= undelegationShares;\n validator.undelegationTokens -= tokens;\n CELER_TOKEN.safeTransfer(delAddr, tokens);\n emit Undelegated(_valAddr, delAddr, tokens);\n }\n\n /**\n * @notice Update commission rate\n * @param _newRate new commission rate\n */\n function updateCommissionRate(uint64 _newRate) external {\n address valAddr = msg.sender;\n dt.Validator storage validator = validators[valAddr];\n require(validator.status != dt.ValidatorStatus.Null, \"Validator is not initialized\");\n require(_newRate <= dt.COMMISSION_RATE_BASE, \"Invalid new rate\");\n validator.commissionRate = _newRate;\n emit ValidatorNotice(valAddr, \"commission\", abi.encode(_newRate), address(0));\n }\n\n /**\n * @notice Update minimal self delegation value\n * @param _minSelfDelegation minimal amount of tokens staked by the validator itself\n */\n function updateMinSelfDelegation(uint256 _minSelfDelegation) external {\n address valAddr = msg.sender;\n dt.Validator storage validator = validators[valAddr];\n require(validator.status != dt.ValidatorStatus.Null, \"Validator is not initialized\");\n require(_minSelfDelegation >= params[dt.ParamName.MinSelfDelegation], \"Insufficient min self delegation\");\n if (_minSelfDelegation < validator.minSelfDelegation) {\n require(validator.status != dt.ValidatorStatus.Bonded, \"Validator is bonded\");\n validator.bondBlock = uint64(block.number + params[dt.ParamName.AdvanceNoticePeriod]);\n }\n validator.minSelfDelegation = _minSelfDelegation;\n emit ValidatorNotice(valAddr, \"min-self-delegation\", abi.encode(_minSelfDelegation), address(0));\n }\n\n /**\n * @notice Slash a validator and its delegators\n * @param _slashRequest slash request bytes coded in protobuf\n * @param _sigs list of validator signatures\n */\n function slash(bytes calldata _slashRequest, bytes[] calldata _sigs) external whenNotPaused {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"Slash\"));\n verifySignatures(abi.encodePacked(domain, _slashRequest), _sigs);\n\n PbStaking.Slash memory request = PbStaking.decSlash(_slashRequest);\n require(block.timestamp < request.expireTime, \"Slash expired\");\n require(request.slashFactor <= dt.SLASH_FACTOR_DECIMAL, \"Invalid slash factor\");\n require(request.slashFactor <= params[dt.ParamName.MaxSlashFactor], \"Exceed max slash factor\");\n require(!slashNonces[request.nonce], \"Used slash nonce\");\n slashNonces[request.nonce] = true;\n\n address valAddr = request.validator;\n dt.Validator storage validator = validators[valAddr];\n require(\n validator.status == dt.ValidatorStatus.Bonded || validator.status == dt.ValidatorStatus.Unbonding,\n \"Invalid validator status\"\n );\n\n // slash delegated tokens\n uint256 slashAmt = (validator.tokens * request.slashFactor) / dt.SLASH_FACTOR_DECIMAL;\n validator.tokens -= slashAmt;\n if (validator.status == dt.ValidatorStatus.Bonded) {\n bondedTokens -= slashAmt;\n if (request.jailPeriod > 0 || !hasMinRequiredTokens(valAddr, true)) {\n _unbondValidator(valAddr);\n }\n }\n if (validator.status == dt.ValidatorStatus.Unbonding && request.jailPeriod > 0) {\n validator.bondBlock = uint64(block.number + request.jailPeriod);\n }\n emit DelegationUpdate(valAddr, address(0), validator.tokens, 0, -int256(slashAmt));\n\n // slash pending undelegations\n uint256 slashUndelegation = (validator.undelegationTokens * request.slashFactor) / dt.SLASH_FACTOR_DECIMAL;\n validator.undelegationTokens -= slashUndelegation;\n slashAmt += slashUndelegation;\n\n uint256 collectAmt;\n for (uint256 i = 0; i < request.collectors.length; i++) {\n PbStaking.AcctAmtPair memory collector = request.collectors[i];\n if (collectAmt + collector.amount > slashAmt) {\n collector.amount = slashAmt - collectAmt;\n }\n if (collector.amount > 0) {\n collectAmt += collector.amount;\n if (collector.account == address(0)) {\n CELER_TOKEN.safeTransfer(msg.sender, collector.amount);\n emit SlashAmtCollected(msg.sender, collector.amount);\n } else {\n CELER_TOKEN.safeTransfer(collector.account, collector.amount);\n emit SlashAmtCollected(collector.account, collector.amount);\n }\n }\n }\n forfeiture += slashAmt - collectAmt;\n emit Slash(valAddr, request.nonce, slashAmt);\n }\n\n function collectForfeiture() external {\n require(forfeiture > 0, \"Nothing to collect\");\n CELER_TOKEN.safeTransfer(rewardContract, forfeiture);\n forfeiture = 0;\n }\n\n /**\n * @notice Validator notice event, could be triggered by anyone\n */\n function validatorNotice(\n address _valAddr,\n string calldata _key,\n bytes calldata _data\n ) external {\n dt.Validator storage validator = validators[_valAddr];\n require(validator.status != dt.ValidatorStatus.Null, \"Validator is not initialized\");\n emit ValidatorNotice(_valAddr, _key, _data, msg.sender);\n }\n\n function setParamValue(dt.ParamName _name, uint256 _value) external {\n require(msg.sender == govContract, \"Caller is not gov contract\");\n if (_name == dt.ParamName.MaxBondedValidators) {\n require(bondedValAddrs.length <= _value, \"invalid value\");\n }\n params[_name] = _value;\n }\n\n function setGovContract(address _addr) external onlyOwner {\n govContract = _addr;\n }\n\n function setRewardContract(address _addr) external onlyOwner {\n rewardContract = _addr;\n }\n\n /**\n * @notice Set max slash factor\n */\n function setMaxSlashFactor(uint256 _maxSlashFactor) external onlyOwner {\n params[dt.ParamName.MaxSlashFactor] = _maxSlashFactor;\n }\n\n /**\n * @notice Owner drains tokens when the contract is paused\n * @dev emergency use only\n * @param _amount drained token amount\n */\n function drainToken(uint256 _amount) external whenPaused onlyOwner {\n CELER_TOKEN.safeTransfer(msg.sender, _amount);\n }\n\n /**************************\n * Public View Functions *\n **************************/\n\n /**\n * @notice Validate if a message is signed by quorum tokens\n * @param _msg signed message\n * @param _sigs list of validator signatures\n */\n function verifySignatures(bytes memory _msg, bytes[] memory _sigs) public view returns (bool) {\n bytes32 hash = keccak256(_msg).toEthSignedMessageHash();\n uint256 signedTokens;\n address prev = address(0);\n uint256 quorum = getQuorumTokens();\n for (uint256 i = 0; i < _sigs.length; i++) {\n address signer = hash.recover(_sigs[i]);\n require(signer > prev, \"Signers not in ascending order\");\n prev = signer;\n dt.Validator storage validator = validators[signerVals[signer]];\n if (validator.status != dt.ValidatorStatus.Bonded) {\n continue;\n }\n signedTokens += validator.tokens;\n if (signedTokens >= quorum) {\n return true;\n }\n }\n revert(\"Quorum not reached\");\n }\n\n /**\n * @notice Verifies that a message is signed by a quorum among the validators.\n * @param _msg signed message\n * @param _sigs the list of signatures\n */\n function verifySigs(\n bytes memory _msg,\n bytes[] calldata _sigs,\n address[] calldata,\n uint256[] calldata\n ) public view override {\n require(verifySignatures(_msg, _sigs), \"Failed to verify sigs\");\n }\n\n /**\n * @notice Get quorum amount of tokens\n * @return the quorum amount\n */\n function getQuorumTokens() public view returns (uint256) {\n return (bondedTokens * 2) / 3 + 1;\n }\n\n /**\n * @notice Get validator info\n * @param _valAddr the address of the validator\n * @return Validator token amount\n */\n function getValidatorTokens(address _valAddr) public view returns (uint256) {\n return validators[_valAddr].tokens;\n }\n\n /**\n * @notice Get validator info\n * @param _valAddr the address of the validator\n * @return Validator status\n */\n function getValidatorStatus(address _valAddr) public view returns (dt.ValidatorStatus) {\n return validators[_valAddr].status;\n }\n\n /**\n * @notice Check the given address is a validator or not\n * @param _addr the address to check\n * @return the given address is a validator or not\n */\n function isBondedValidator(address _addr) public view returns (bool) {\n return validators[_addr].status == dt.ValidatorStatus.Bonded;\n }\n\n /**\n * @notice Get the number of validators\n * @return the number of validators\n */\n function getValidatorNum() public view returns (uint256) {\n return valAddrs.length;\n }\n\n /**\n * @notice Get the number of bonded validators\n * @return the number of bonded validators\n */\n function getBondedValidatorNum() public view returns (uint256) {\n return bondedValAddrs.length;\n }\n\n /**\n * @return addresses and token amounts of bonded validators\n */\n function getBondedValidatorsTokens() public view returns (dt.ValidatorTokens[] memory) {\n dt.ValidatorTokens[] memory infos = new dt.ValidatorTokens[](bondedValAddrs.length);\n for (uint256 i = 0; i < bondedValAddrs.length; i++) {\n address valAddr = bondedValAddrs[i];\n infos[i] = dt.ValidatorTokens(valAddr, validators[valAddr].tokens);\n }\n return infos;\n }\n\n /**\n * @notice Check if min token requirements are met\n * @param _valAddr the address of the validator\n * @param _checkSelfDelegation check self delegation\n */\n function hasMinRequiredTokens(address _valAddr, bool _checkSelfDelegation) public view returns (bool) {\n dt.Validator storage v = validators[_valAddr];\n uint256 valTokens = v.tokens;\n if (valTokens < params[dt.ParamName.MinValidatorTokens]) {\n return false;\n }\n if (_checkSelfDelegation) {\n uint256 selfDelegation = _shareToToken(v.delegators[_valAddr].shares, valTokens, v.shares);\n if (selfDelegation < v.minSelfDelegation) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * @notice Get the delegator info of a specific validator\n * @param _valAddr the address of the validator\n * @param _delAddr the address of the delegator\n * @return DelegatorInfo from the given validator\n */\n function getDelegatorInfo(address _valAddr, address _delAddr) public view returns (dt.DelegatorInfo memory) {\n dt.Validator storage validator = validators[_valAddr];\n dt.Delegator storage d = validator.delegators[_delAddr];\n uint256 tokens = _shareToToken(d.shares, validator.tokens, validator.shares);\n\n uint256 undelegationShares;\n uint256 withdrawableUndelegationShares;\n uint256 unbondingPeriod = params[dt.ParamName.UnbondingPeriod];\n bool isUnbonded = validator.status == dt.ValidatorStatus.Unbonded;\n uint256 len = d.undelegations.tail - d.undelegations.head;\n dt.Undelegation[] memory undelegations = new dt.Undelegation[](len);\n for (uint256 i = 0; i < len; i++) {\n undelegations[i] = d.undelegations.queue[i + d.undelegations.head];\n undelegationShares += undelegations[i].shares;\n if (isUnbonded || undelegations[i].creationBlock + unbondingPeriod <= block.number) {\n withdrawableUndelegationShares += undelegations[i].shares;\n }\n }\n uint256 undelegationTokens = _shareToToken(\n undelegationShares,\n validator.undelegationTokens,\n validator.undelegationShares\n );\n uint256 withdrawableUndelegationTokens = _shareToToken(\n withdrawableUndelegationShares,\n validator.undelegationTokens,\n validator.undelegationShares\n );\n\n return\n dt.DelegatorInfo(\n _valAddr,\n tokens,\n d.shares,\n undelegations,\n undelegationTokens,\n withdrawableUndelegationTokens\n );\n }\n\n /**\n * @notice Get the value of a specific uint parameter\n * @param _name the key of this parameter\n * @return the value of this parameter\n */\n function getParamValue(dt.ParamName _name) public view returns (uint256) {\n return params[_name];\n }\n\n /*********************\n * Private Functions *\n *********************/\n\n function _undelegate(\n dt.Validator storage validator,\n address _valAddr,\n uint256 _tokens,\n uint256 _shares\n ) private {\n address delAddr = msg.sender;\n dt.Delegator storage delegator = validator.delegators[delAddr];\n delegator.shares -= _shares;\n validator.shares -= _shares;\n validator.tokens -= _tokens;\n if (validator.tokens != validator.shares && delegator.shares <= 2) {\n // Remove residual share caused by rounding error when total shares and tokens are not equal\n validator.shares -= delegator.shares;\n delegator.shares = 0;\n }\n require(delegator.shares == 0 || delegator.shares >= dt.CELR_DECIMAL, \"not enough remaining shares\");\n\n if (validator.status == dt.ValidatorStatus.Unbonded) {\n CELER_TOKEN.safeTransfer(delAddr, _tokens);\n emit Undelegated(_valAddr, delAddr, _tokens);\n return;\n } else if (validator.status == dt.ValidatorStatus.Bonded) {\n bondedTokens -= _tokens;\n if (!hasMinRequiredTokens(_valAddr, delAddr == _valAddr)) {\n _unbondValidator(_valAddr);\n }\n }\n require(\n delegator.undelegations.tail - delegator.undelegations.head < dt.MAX_UNDELEGATION_ENTRIES,\n \"Exceed max undelegation entries\"\n );\n\n uint256 undelegationShares = _tokenToShare(_tokens, validator.undelegationTokens, validator.undelegationShares);\n validator.undelegationShares += undelegationShares;\n validator.undelegationTokens += _tokens;\n dt.Undelegation storage undelegation = delegator.undelegations.queue[delegator.undelegations.tail];\n undelegation.shares = undelegationShares;\n undelegation.creationBlock = block.number;\n delegator.undelegations.tail++;\n\n emit DelegationUpdate(_valAddr, delAddr, validator.tokens, delegator.shares, -int256(_tokens));\n }\n\n /**\n * @notice Set validator to bonded\n * @param _valAddr the address of the validator\n */\n function _setBondedValidator(address _valAddr) private {\n dt.Validator storage validator = validators[_valAddr];\n validator.status = dt.ValidatorStatus.Bonded;\n delete validator.unbondBlock;\n bondedTokens += validator.tokens;\n emit ValidatorStatusUpdate(_valAddr, dt.ValidatorStatus.Bonded);\n }\n\n /**\n * @notice Set validator to unbonding\n * @param _valAddr the address of the validator\n */\n function _setUnbondingValidator(address _valAddr) private {\n dt.Validator storage validator = validators[_valAddr];\n validator.status = dt.ValidatorStatus.Unbonding;\n validator.unbondBlock = uint64(block.number + params[dt.ParamName.UnbondingPeriod]);\n bondedTokens -= validator.tokens;\n emit ValidatorStatusUpdate(_valAddr, dt.ValidatorStatus.Unbonding);\n }\n\n /**\n * @notice Bond a validator\n * @param _valAddr the address of the validator\n */\n function _bondValidator(address _valAddr) private {\n bondedValAddrs.push(_valAddr);\n _setBondedValidator(_valAddr);\n }\n\n /**\n * @notice Replace a bonded validator\n * @param _valAddr the address of the new validator\n * @param _index the index of the validator to be replaced\n */\n function _replaceBondedValidator(address _valAddr, uint256 _index) private {\n _setUnbondingValidator(bondedValAddrs[_index]);\n bondedValAddrs[_index] = _valAddr;\n _setBondedValidator(_valAddr);\n }\n\n /**\n * @notice Unbond a validator\n * @param _valAddr validator to be removed\n */\n function _unbondValidator(address _valAddr) private {\n uint256 lastIndex = bondedValAddrs.length - 1;\n for (uint256 i = 0; i < bondedValAddrs.length; i++) {\n if (bondedValAddrs[i] == _valAddr) {\n if (i < lastIndex) {\n bondedValAddrs[i] = bondedValAddrs[lastIndex];\n }\n bondedValAddrs.pop();\n _setUnbondingValidator(_valAddr);\n return;\n }\n }\n revert(\"Not bonded validator\");\n }\n\n /**\n * @notice Check if one validator has too much power\n * @param _valTokens token amounts of the validator\n */\n function _decentralizationCheck(uint256 _valTokens) private view {\n uint256 bondedValNum = bondedValAddrs.length;\n if (bondedValNum == 2 || bondedValNum == 3) {\n require(_valTokens < getQuorumTokens(), \"Single validator should not have quorum tokens\");\n } else if (bondedValNum > 3) {\n require(_valTokens < bondedTokens / 3, \"Single validator should not have 1/3 tokens\");\n }\n }\n\n /**\n * @notice Convert token to share\n */\n function _tokenToShare(\n uint256 tokens,\n uint256 totalTokens,\n uint256 totalShares\n ) private pure returns (uint256) {\n if (totalTokens == 0) {\n return tokens;\n }\n return (tokens * totalShares) / totalTokens;\n }\n\n /**\n * @notice Convert share to token\n */\n function _shareToToken(\n uint256 shares,\n uint256 totalTokens,\n uint256 totalShares\n ) private pure returns (uint256) {\n if (totalShares == 0) {\n return shares;\n }\n return (shares * totalTokens) / totalShares;\n }\n}\n" + }, + "contracts/staking/StakingReward.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {DataTypes as dt} from \"./DataTypes.sol\";\nimport \"../safeguard/Pauser.sol\";\nimport \"./Staking.sol\";\n\n/**\n * @title A contract to hold and distribute CELR staking rewards.\n */\ncontract StakingReward is Pauser {\n using SafeERC20 for IERC20;\n\n Staking public immutable staking;\n\n // recipient => CELR reward amount\n mapping(address => uint256) public claimedRewardAmounts;\n\n event StakingRewardClaimed(address indexed recipient, uint256 reward);\n event StakingRewardContributed(address indexed contributor, uint256 contribution);\n\n constructor(Staking _staking) {\n staking = _staking;\n }\n\n /**\n * @notice Claim reward\n * @dev Here we use cumulative reward to make claim process idempotent\n * @param _rewardRequest reward request bytes coded in protobuf\n * @param _sigs list of validator signatures\n */\n function claimReward(bytes calldata _rewardRequest, bytes[] calldata _sigs) external whenNotPaused {\n bytes32 domain = keccak256(abi.encodePacked(block.chainid, address(this), \"StakingReward\"));\n staking.verifySignatures(abi.encodePacked(domain, _rewardRequest), _sigs);\n PbStaking.StakingReward memory reward = PbStaking.decStakingReward(_rewardRequest);\n\n uint256 cumulativeRewardAmount = reward.cumulativeRewardAmount;\n uint256 newReward = cumulativeRewardAmount - claimedRewardAmounts[reward.recipient];\n require(newReward > 0, \"No new reward\");\n claimedRewardAmounts[reward.recipient] = cumulativeRewardAmount;\n staking.CELER_TOKEN().safeTransfer(reward.recipient, newReward);\n emit StakingRewardClaimed(reward.recipient, newReward);\n }\n\n /**\n * @notice Contribute CELR tokens to the reward pool\n * @param _amount the amount of CELR token to contribute\n */\n function contributeToRewardPool(uint256 _amount) external whenNotPaused {\n address contributor = msg.sender;\n IERC20(staking.CELER_TOKEN()).safeTransferFrom(contributor, address(this), _amount);\n\n emit StakingRewardContributed(contributor, _amount);\n }\n\n /**\n * @notice Owner drains CELR tokens when the contract is paused\n * @dev emergency use only\n * @param _amount drained CELR token amount\n */\n function drainToken(uint256 _amount) external whenPaused onlyOwner {\n IERC20(staking.CELER_TOKEN()).safeTransfer(msg.sender, _amount);\n }\n}\n" + }, + "contracts/staking/Viewer.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport {DataTypes as dt} from \"./DataTypes.sol\";\nimport \"./Staking.sol\";\n\n/**\n * @title Viewer of the staking contract\n * @notice Using a separate viewer contract to reduce staking contract size\n */\ncontract Viewer {\n Staking public immutable staking;\n\n constructor(Staking _staking) {\n staking = _staking;\n }\n\n function getValidatorInfos() public view returns (dt.ValidatorInfo[] memory) {\n uint256 valNum = staking.getValidatorNum();\n dt.ValidatorInfo[] memory infos = new dt.ValidatorInfo[](valNum);\n for (uint32 i = 0; i < valNum; i++) {\n infos[i] = getValidatorInfo(staking.valAddrs(i));\n }\n return infos;\n }\n\n function getBondedValidatorInfos() public view returns (dt.ValidatorInfo[] memory) {\n uint256 bondedValNum = staking.getBondedValidatorNum();\n dt.ValidatorInfo[] memory infos = new dt.ValidatorInfo[](bondedValNum);\n for (uint32 i = 0; i < bondedValNum; i++) {\n infos[i] = getValidatorInfo(staking.bondedValAddrs(i));\n }\n return infos;\n }\n\n function getValidatorInfo(address _valAddr) public view returns (dt.ValidatorInfo memory) {\n (\n dt.ValidatorStatus status,\n address signer,\n uint256 tokens,\n uint256 shares,\n ,\n ,\n uint256 minSelfDelegation,\n ,\n ,\n uint64 commissionRate\n ) = staking.validators(_valAddr);\n return\n dt.ValidatorInfo({\n valAddr: _valAddr,\n status: status,\n signer: signer,\n tokens: tokens,\n shares: shares,\n minSelfDelegation: minSelfDelegation,\n commissionRate: commissionRate\n });\n }\n\n function getDelegatorInfos(address _delAddr) public view returns (dt.DelegatorInfo[] memory) {\n uint256 valNum = staking.getValidatorNum();\n dt.DelegatorInfo[] memory infos = new dt.DelegatorInfo[](valNum);\n uint32 num = 0;\n for (uint32 i = 0; i < valNum; i++) {\n address valAddr = staking.valAddrs(i);\n infos[i] = staking.getDelegatorInfo(valAddr, _delAddr);\n if (infos[i].shares != 0 || infos[i].undelegationTokens != 0) {\n num++;\n }\n }\n dt.DelegatorInfo[] memory res = new dt.DelegatorInfo[](num);\n uint32 j = 0;\n for (uint32 i = 0; i < valNum; i++) {\n if (infos[i].shares != 0 || infos[i].undelegationTokens != 0) {\n res[j] = infos[i];\n j++;\n }\n }\n return res;\n }\n\n function getDelegatorTokens(address _delAddr) public view returns (uint256, uint256) {\n dt.DelegatorInfo[] memory infos = getDelegatorInfos(_delAddr);\n uint256 tokens;\n uint256 undelegationTokens;\n for (uint32 i = 0; i < infos.length; i++) {\n tokens += infos[i].tokens;\n undelegationTokens += infos[i].undelegationTokens;\n }\n return (tokens, undelegationTokens);\n }\n\n /**\n * @notice Get the minimum staking pool of all bonded validators\n * @return the minimum staking pool of all bonded validators\n */\n function getMinValidatorTokens() public view returns (uint256) {\n uint256 bondedValNum = staking.getBondedValidatorNum();\n if (bondedValNum < staking.params(dt.ParamName.MaxBondedValidators)) {\n return 0;\n }\n uint256 minTokens = dt.MAX_INT;\n for (uint256 i = 0; i < bondedValNum; i++) {\n uint256 tokens = staking.getValidatorTokens(staking.bondedValAddrs(i));\n if (tokens < minTokens) {\n minTokens = tokens;\n if (minTokens == 0) {\n return 0;\n }\n }\n }\n return minTokens;\n }\n\n function shouldBondValidator(address _valAddr) public view returns (bool) {\n (dt.ValidatorStatus status, , uint256 tokens, , , , , uint64 bondBlock, , ) = staking.validators(_valAddr);\n if (status == dt.ValidatorStatus.Null || status == dt.ValidatorStatus.Bonded) {\n return false;\n }\n if (block.number < bondBlock) {\n return false;\n }\n if (!staking.hasMinRequiredTokens(_valAddr, true)) {\n return false;\n }\n if (tokens <= getMinValidatorTokens()) {\n return false;\n }\n uint256 nextBondBlock = staking.nextBondBlock();\n if (block.number < nextBondBlock) {\n return false;\n }\n return true;\n }\n}\n" + }, + "contracts/test-helpers/DummySwap.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract DummySwap {\n using SafeERC20 for IERC20;\n\n uint256 fakeSlippage; // 100% = 100 * 1e4\n uint256 hundredPercent = 100 * 1e4;\n\n constructor(uint256 _fakeSlippage) {\n fakeSlippage = _fakeSlippage;\n }\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts) {\n require(deadline != 0 && deadline > block.timestamp, \"deadline exceeded\");\n require(path.length > 1, \"path must have more than 1 token in it\");\n IERC20(path[0]).transferFrom(msg.sender, address(this), amountIn);\n // fake simulate slippage\n uint256 amountAfterSlippage = (amountIn * (hundredPercent - fakeSlippage)) / hundredPercent;\n require(amountAfterSlippage > amountOutMin, \"bad slippage\");\n\n IERC20(path[path.length - 1]).safeTransfer(to, amountAfterSlippage);\n uint256[] memory ret = new uint256[](2);\n ret[0] = amountIn;\n ret[1] = amountAfterSlippage;\n return ret;\n }\n\n function setFakeSlippage(uint256 _fakeSlippage) public {\n fakeSlippage = _fakeSlippage;\n }\n}\n" + }, + "contracts/test-helpers/TestERC20.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity 0.8.17;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/**\n * @title A test ERC20 token.\n */\ncontract TestERC20 is ERC20 {\n uint256 public constant INITIAL_SUPPLY = 1e28;\n\n /**\n * @dev Constructor that gives msg.sender all of the existing tokens.\n */\n constructor() ERC20(\"TestERC20\", \"TERC20\") {\n _mint(msg.sender, INITIAL_SUPPLY);\n }\n}\n" + }, + "contracts/test-helpers/WETH.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\n\npragma solidity >=0.8.9;\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract WETH is ERC20 {\n constructor() ERC20(\"WETH\", \"WETH\") {}\n\n function deposit() external payable {\n _mint(msg.sender, msg.value);\n }\n\n function withdraw(uint256 _amount) external {\n _burn(msg.sender, _amount);\n (bool sent, ) = msg.sender.call{value: _amount, gas: 50000}(\"\");\n require(sent, \"failed to send\");\n }\n\n receive() external payable {}\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 800 + }, + "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/hardhat.config.ts b/hardhat.config.ts index b18dde173..ddc9c1957 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -231,6 +231,9 @@ const polygonZkevmPrivateKey = process.env.POLYGON_ZKEVM_PRIVATE_KEY || DEFAULT_ const antimatterB2Endpoint = process.env.ANTIMATTER_B2_ENDPOINT || DEFAULT_ENDPOINT; const antimatterB2PrivateKey = process.env.ANTIMATTER_B2_PRIVATE_KEY || DEFAULT_PRIVATE_KEY; +const lineaEndpoint = process.env.LINEA_ENDPOINT || DEFAULT_ENDPOINT; +const lineaPrivateKey = process.env.LINEA_PRIVATE_KEY || DEFAULT_PRIVATE_KEY; + // use kmsKeyId if it's not empty, otherwise use privateKey function getNetworkConfig(url: string, kmsKeyId: string, privateKey: string, gasPrice?: number): NetworkUserConfig { const network: NetworkUserConfig = !kmsKeyId @@ -400,7 +403,8 @@ const config: HardhatUserConfig = { fvm: getNetworkConfig(fvmEndpoint, kmsKeyId, fvmPrivateKey), canto: getNetworkConfig(cantoEndpoint, kmsKeyId, cantoPrivateKey), polygonZkevm: getNetworkConfig(polygonZkevmEndpoint, kmsKeyId, polygonZkevmPrivateKey), - antimatterB2: getNetworkConfig(antimatterB2Endpoint, kmsKeyId, antimatterB2PrivateKey) + antimatterB2: getNetworkConfig(antimatterB2Endpoint, kmsKeyId, antimatterB2PrivateKey), + linea: getNetworkConfig(lineaEndpoint, kmsKeyId, lineaPrivateKey) }, namedAccounts: { deployer: { @@ -451,7 +455,8 @@ const config: HardhatUserConfig = { moonriver: process.env.MOONRIVER_MOONSCAN_API_KEY || '', moonbeam: process.env.MOONBEAM_MOONSCAN_API_KEY || '', heco: process.env.HECOSCAN_API_KEY || '', - arbitrumNova: process.env.ARBISCAN_NOVA_API_KEY || '' + arbitrumNova: process.env.ARBISCAN_NOVA_API_KEY || '', + linea: process.env.LINEA_API_KEY || '' }, customChains: [ { @@ -461,6 +466,14 @@ const config: HardhatUserConfig = { apiURL: process.env.ARBITRUM_NOVA_ENDPOINT || '', browserURL: process.env.ARBITRUM_NOVA_EXPLORER || '' } + }, + { + network: 'linea', + chainId: 59144, + urls: { + apiURL: process.env.LINEA_API_ENDPOINT || '', + browserURL: process.env.LINEA_EXPLORER || '' + } } ] }