Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x15725391A37A5fFeB04F79cf25DA8460A3f068F6
Balance 0 ETH
Nonce 1
Code Size 9748 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

9748 bytes
0x608060405234801561001057600080fd5b50600436106101365760003560e01c8063aa815743116100b2578063d87a26aa11610081578063f2fde38b11610066578063f2fde38b146102ee578063fb099fd914610301578063fc2cde481461033457600080fd5b8063d87a26aa146102b4578063dd6ba7c2146102db57600080fd5b8063aa81574314610268578063acec84fc1461027b578063bae3264e1461028e578063d7f35da0146102a157600080fd5b8063715018a6116101095780638b69af5a116100ee5780638b69af5a146102085780638da5cb5b14610230578063a5eb539b1461025557600080fd5b8063715018a6146101ed5780637e636b4d146101f557600080fd5b806309d2a7761461013b57806316934fc4146101615780633072133a146101c5578063422c63c9146101da575b600080fd5b61014e6101493660046121c4565b610357565b6040519081526020015b60405180910390f35b61019d61016f3660046121c4565b6002602052600090815260409020546001600160801b03811690600160801b900467ffffffffffffffff1682565b604080516001600160801b03909316835267ffffffffffffffff909116602083015201610158565b6101d86101d336600461220f565b6103f2565b005b6101d86101e8366004612242565b610486565b6101d86105bc565b6101d861020336600461227a565b610632565b60015461021d90600160a01b900461ffff1681565b60405161ffff9091168152602001610158565b6001546001600160a01b03165b6040516001600160a01b039091168152602001610158565b6101d86102633660046122b1565b6107d8565b6101d8610276366004612305565b610b03565b6101d861028936600461220f565b610bd5565b6101d861029c366004612375565b610f79565b6101d86102af3660046121c4565b61107a565b61023d7f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc81565b6101d86102e936600461227a565b6114b2565b6101d86102fc3660046121c4565b611650565b61032461030f3660046121c4565b60036020526000908152604090205460ff1681565b6040519015158152602001610158565b6103246103423660046121c4565b60046020526000908152604090205460ff1681565b6001600160a01b03811660009081526002602090815260408083208151808301909252546001600160801b0381168252600160801b900467ffffffffffffffff1691810182905282914210156103c45742816020015167ffffffffffffffff166103c191906123bf565b91505b8051630784ce00906103e09084906001600160801b03166123d6565b6103ea9190612413565b949350505050565b6103fd3383836116dd565b604080516001600160801b038416815261ffff8316602082015233917f86b3e0a1de6bacc903f2345288bc1d2c660fc307c42f9101090143f7efc8f664910160405180910390a26104826001600160a01b037f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc1633306001600160801b038616611a64565b5050565b333b6105255760405162461bcd60e51b815260206004820152604260248201527f5374616b696e675661756c743a3a696e6372656173654846545374616b65416d60448201527f6f756e74466f722043616c6c65722073686f756c6420626520636f6e7472616360648201527f742e000000000000000000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b610531828260006116dd565b604080516001600160801b0383168152600060208201526001600160a01b038416917f86b3e0a1de6bacc903f2345288bc1d2c660fc307c42f9101090143f7efc8f664910160405180910390a26104826001600160a01b037f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc1633306001600160801b038516611a64565b6105c4611b15565b60405162461bcd60e51b815260206004820152603a60248201527f5374616b696e675661756c743a3a72656e6f756e63654f776e6572736869702060448201527f43616e6e6f742072656e6f756e6365206f776e6572736869702e000000000000606482015260840161051c565b61063a611b15565b306001600160a01b038316036106de5760405162461bcd60e51b815260206004820152604360248201527f5374616b696e675661756c743a3a757064617465536f757263655661756c744160448201527f7574686f72697a6174696f6e2043616e6e6f742073656c662d617574686f726960648201527f7a652e0000000000000000000000000000000000000000000000000000000000608482015260a40161051c565b6001600160a01b03821660009081526003602052604090205481151560ff9091161515036107745760405162461bcd60e51b815260206004820152603360248201527f5374616b696e675661756c743a3a757064617465536f757263655661756c744160448201527f7574686f72697a6174696f6e204e6f2d6f702e00000000000000000000000000606482015260840161051c565b6001600160a01b038216600081815260036020908152604091829020805460ff19168515159081179091558251938452908301527f70732b7013abd74771dcf234d3590fe1c500ea2682edf734f6eaa3940b9ea2aa91015b60405180910390a15050565b6107e0611b71565b3360009081526003602052604090205460ff1661088b5760405162461bcd60e51b815260206004820152604260248201527f5374616b696e675661756c743a3a726563656976654846545374616b6554726160448201527f6e7366657220536f75726365205661756c74206e6f7420617574686f72697a6560648201527f642e000000000000000000000000000000000000000000000000000000000000608482015260a40161051c565b6001600160a01b0383166000908152600260209081526040918290208251808401909352546001600160801b038116835267ffffffffffffffff600160801b909104811691830182905283929190831610156108e957806020015191505b600154610905906201518090600160a01b900461ffff1661244e565b61090f904261247e565b67ffffffffffffffff168267ffffffffffffffff1611156109985760405162461bcd60e51b815260206004820152603960248201527f5374616b696e675661756c743a3a726563656976654846545374616b6554726160448201527f6e736665722054696d65206c6f636b20746f6f20686967682e00000000000000606482015260840161051c565b67ffffffffffffffff8216602082015280516001600160801b03908116906109c19086906124aa565b6001600160801b031611610a3d5760405162461bcd60e51b815260206004820152603660248201527f5374616b696e675661756c743a3a726563656976654846545374616b6554726160448201527f6e7366657220616d6f756e7420746f6f20686967682e00000000000000000000606482015260840161051c565b8381600001818151610a4f91906124d2565b6001600160801b039081169091526001600160a01b038088166000908152600260209081526040909120855181549287015167ffffffffffffffff16600160801b027fffffffffffffffff00000000000000000000000000000000000000000000000090931690851617919091179055610af292507f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc1690339030908816611a64565b5050610afe6001600055565b505050565b610b0e3388886116dd565b604080516001600160801b038916815261ffff8816602082015233917f86b3e0a1de6bacc903f2345288bc1d2c660fc307c42f9101090143f7efc8f664910160405180910390a2610b8e6001600160a01b037f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc1633308489898989611bca565b610bcc6001600160a01b037f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc1633306001600160801b038b16611a64565b50505050505050565b336000908152600260209081526040918290208251808401909352546001600160801b0381168352600160801b900467ffffffffffffffff16908201819052421015610c895760405162461bcd60e51b815260206004820152602860248201527f5374616b696e675661756c743a3a77697468647261774846542048465420697360448201527f206c6f636b65642e000000000000000000000000000000000000000000000000606482015260840161051c565b80516001600160801b0316610d065760405162461bcd60e51b815260206004820152602860248201527f5374616b696e675661756c743a3a7769746864726177484654204e6f2048465460448201527f207374616b65642e000000000000000000000000000000000000000000000000606482015260840161051c565b80516001600160801b03841615610e2a5760008361ffff1611610d915760405162461bcd60e51b815260206004820152603260248201527f5374616b696e675661756c743a3a77697468647261774846542054696d65206c60448201527f6f636b206e6f74207370656369666965642e0000000000000000000000000000606482015260840161051c565b81600001516001600160801b0316846001600160801b03161115610e1d5760405162461bcd60e51b815260206004820152603360248201527f5374616b696e675661756c743a3a77697468647261774846542052652d73746160448201527f6b6520616d6f756e7420746f6f20686967682e00000000000000000000000000606482015260840161051c565b610e2784826124aa565b90505b60008083523380825260026020908152604092839020855181548388015167ffffffffffffffff16600160801b81027fffffffffffffffff0000000000000000000000000000000000000000000000009092166001600160801b039093169283179190911790925584519081529182015290917fdbdb18caec8ad3ec704832308d0bd122427925c5d868b0433d7274abcb3dced9910160405180910390a26001600160801b03841615610ee257610ee23385856116dd565b604080516001600160801b0380841682528616602082015233917f494cd4093d13ed8794a3d071baa5d2303ef94892de13e5de5867b32f36a791ed910160405180910390a26001600160801b03811615610f7357610f736001600160a01b037f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc16336001600160801b038416611e09565b50505050565b610f81611b15565b60015461ffff600160a01b9091048116908216036110075760405162461bcd60e51b815260206004820152603a60248201527f5374616b696e675661756c743a3a7570646174654d617844617973546f53746160448201527f6b65204e756d62657220686173206e6f74206368616e6765642e000000000000606482015260840161051c565b600180547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff16600160a01b61ffff8481168202929092179283905560405192041681527f9a08e049fdbac625df76c3bf444b79a8efce4cbacbdecb8256e15b706870427f9060200160405180910390a150565b611082611b71565b6001600160a01b03811660009081526004602052604090205460ff166111105760405162461bcd60e51b815260206004820152603b60248201527f5374616b696e675661756c743a3a7472616e736665724846545374616b65205460448201527f6172676574205661756c74206e6f7420617574686f72697a65642e0000000000606482015260840161051c565b336000908152600260209081526040918290208251808401909352546001600160801b038116808452600160801b90910467ffffffffffffffff16918301919091526111c45760405162461bcd60e51b815260206004820152602d60248201527f5374616b696e675661756c743a3a7472616e736665724846545374616b65204e60448201527f6f20484654206c6f636b65642e00000000000000000000000000000000000000606482015260840161051c565b805160208083018051600080865280835233808252600285526040918290208751815495516001600160801b039091167fffffffffffffffff0000000000000000000000000000000000000000000000009096168617600160801b67ffffffffffffffff909216918202179091558251948552948401949094529092917fdbdb18caec8ad3ec704832308d0bd122427925c5d868b0433d7274abcb3dced9910160405180910390a2604080516001600160a01b03861681526001600160801b038416602082015233917ffb37715dec5843656a46bcaec02818c7312ec8634e32d05ca8e6c394078faf5d910160405180910390a26112f56001600160a01b037f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc16856001600160801b038516611e52565b6040517fa5eb539b0000000000000000000000000000000000000000000000000000000081523360048201526001600160801b038316602482015267ffffffffffffffff821660448201526001600160a01b0385169063a5eb539b90606401600060405180830381600087803b15801561136e57600080fd5b505af1158015611382573d6000803e3d6000fd5b50506040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b0387811660248301527f000000000000000000000000b3999f658c0391d94a37f7ff328f3fec942bcadc16925063dd62ed3e9150604401602060405180830381865afa15801561140b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142f91906124f4565b156114a25760405162461bcd60e51b815260206004820152602d60248201527f5374616b696e675661756c743a3a7472616e736665724846545374616b65204860448201527f4654206e6f74207370656e742e00000000000000000000000000000000000000606482015260840161051c565b5050506114af6001600055565b50565b6114ba611b15565b306001600160a01b0383160361155e5760405162461bcd60e51b815260206004820152604360248201527f5374616b696e675661756c743a3a7570646174655461726765745661756c744160448201527f7574686f72697a6174696f6e2043616e6e6f742073656c662d617574686f726960648201527f7a652e0000000000000000000000000000000000000000000000000000000000608482015260a40161051c565b6001600160a01b03821660009081526004602052604090205481151560ff9091161515036115f45760405162461bcd60e51b815260206004820152603360248201527f5374616b696e675661756c743a3a7570646174655461726765745661756c744160448201527f7574686f72697a6174696f6e204e6f2d6f702e00000000000000000000000000606482015260840161051c565b6001600160a01b038216600081815260046020908152604091829020805460ff19168515159081179091558251938452908301527fe3092a057e4413769c2e5e18895003df1e1dafe3f2327ae9365dd5dc1228499291016107cc565b611658611b15565b6001600160a01b0381166116d45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161051c565b6114af81611f36565b6000826001600160801b031611806116f9575060008161ffff16115b61176b5760405162461bcd60e51b815260206004820152603a60248201527f5374616b696e675661756c743a3a5f626f6f73744846545374616b6520416d6f60448201527f756e74206f722064617973206861766520746f206265203e2030000000000000606482015260840161051c565b6001600160a01b0383166000908152600260209081526040918290208251808401909352546001600160801b0381168352600160801b900467ffffffffffffffff169082015261ffff8216156118fb57600042826020015167ffffffffffffffff1611156117e6574282602001516117e3919061250d565b90505b60006117f96201518061ffff861661244e565b600154909150611818906201518090600160a01b900461ffff1661244e565b67ffffffffffffffff1661182c838361247e565b67ffffffffffffffff1611156118aa5760405162461bcd60e51b815260206004820152602f60248201527f5374616b696e675661756c743a3a5f626f6f73744846545374616b652054696d60448201527f65206c6f636b20746f6f20686967680000000000000000000000000000000000606482015260840161051c565b67ffffffffffffffff8216156118de5780836020018181516118cc919061247e565b67ffffffffffffffff169052506118f8565b6118e8814261247e565b67ffffffffffffffff1660208401525b50505b6001600160801b038316156119bc5780516001600160801b0380851691611921916124aa565b6001600160801b03161161199d5760405162461bcd60e51b815260206004820152602d60248201527f5374616b696e675661756c743a3a5f626f6f73744846545374616b6520616d6f60448201527f756e7420746f6f20686967682e00000000000000000000000000000000000000606482015260840161051c565b82816000018181516119af91906124d2565b6001600160801b03169052505b6001600160a01b038416600081815260026020908152604091829020845181548684015167ffffffffffffffff16600160801b81027fffffffffffffffff0000000000000000000000000000000000000000000000009092166001600160801b03909316928317919091179092558351908152918201527fdbdb18caec8ad3ec704832308d0bd122427925c5d868b0433d7274abcb3dced9910160405180910390a250505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610f739085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611fa0565b6001546001600160a01b03163314611b6f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161051c565b565b600260005403611bc35760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161051c565b6002600055565b6040517f7ecebe000000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152600091908a1690637ecebe0090602401602060405180830381865afa158015611c2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5191906124f4565b6040517fd505accf0000000000000000000000000000000000000000000000000000000081526001600160a01b038a811660048301528981166024830152604482018990526064820188905260ff8716608483015260a4820186905260c48201859052919250908a169063d505accf9060e401600060405180830381600087803b158015611cde57600080fd5b505af1158015611cf2573d6000803e3d6000fd5b50506040517f7ecebe000000000000000000000000000000000000000000000000000000000081526001600160a01b038b81166004830152600093508c169150637ecebe0090602401602060405180830381865afa158015611d58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d7c91906124f4565b9050611d8982600161252e565b8114611dfd5760405162461bcd60e51b815260206004820152602160248201527f5361666545524332303a207065726d697420646964206e6f742073756363656560448201527f6400000000000000000000000000000000000000000000000000000000000000606482015260840161051c565b50505050505050505050565b6040516001600160a01b038316602482015260448101829052610afe9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611ab1565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038381166024830152600091839186169063dd62ed3e90604401602060405180830381865afa158015611ebc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ee091906124f4565b611eea919061252e565b6040516001600160a01b038516602482015260448101829052909150610f739085907f095ea7b30000000000000000000000000000000000000000000000000000000090606401611ab1565b600180546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000611ff5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120859092919063ffffffff16565b805190915015610afe57808060200190518101906120139190612546565b610afe5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161051c565b60606103ea848460008585600080866001600160a01b031685876040516120ac919061258f565b60006040518083038185875af1925050503d80600081146120e9576040519150601f19603f3d011682016040523d82523d6000602084013e6120ee565b606091505b50915091506120ff8783838761210a565b979650505050505050565b60608315612179578251600003612172576001600160a01b0385163b6121725760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161051c565b50816103ea565b6103ea838381511561218e5781518083602001fd5b8060405162461bcd60e51b815260040161051c91906125ab565b80356001600160a01b03811681146121bf57600080fd5b919050565b6000602082840312156121d657600080fd5b6121df826121a8565b9392505050565b80356001600160801b03811681146121bf57600080fd5b803561ffff811681146121bf57600080fd5b6000806040838503121561222257600080fd5b61222b836121e6565b9150612239602084016121fd565b90509250929050565b6000806040838503121561225557600080fd5b61225e836121a8565b9150612239602084016121e6565b80151581146114af57600080fd5b6000806040838503121561228d57600080fd5b612296836121a8565b915060208301356122a68161226c565b809150509250929050565b6000806000606084860312156122c657600080fd5b6122cf846121a8565b92506122dd602085016121e6565b9150604084013567ffffffffffffffff811681146122fa57600080fd5b809150509250925092565b600080600080600080600060e0888a03121561232057600080fd5b612329886121e6565b9650612337602089016121fd565b955060408801359450606088013560ff8116811461235457600080fd5b9699959850939660808101359560a0820135955060c0909101359350915050565b60006020828403121561238757600080fd5b6121df826121fd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000828210156123d1576123d1612390565b500390565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561240e5761240e612390565b500290565b600082612449577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600067ffffffffffffffff8083168185168183048111821515161561247557612475612390565b02949350505050565b600067ffffffffffffffff8083168185168083038211156124a1576124a1612390565b01949350505050565b60006001600160801b03838116908316818110156124ca576124ca612390565b039392505050565b60006001600160801b038083168185168083038211156124a1576124a1612390565b60006020828403121561250657600080fd5b5051919050565b600067ffffffffffffffff838116908316818110156124ca576124ca612390565b6000821982111561254157612541612390565b500190565b60006020828403121561255857600080fd5b81516121df8161226c565b60005b8381101561257e578181015183820152602001612566565b83811115610f735750506000910152565b600082516125a1818460208701612563565b9190910192915050565b60208152600082518060208401526125ca816040850160208701612563565b601f01601f1916919091016040019291505056fea26469706673582212205ae1b6e2a2823b855162f9d143aa1444320e4578331942f9fc27b4f1608d1a2264736f6c634300080d0033

Verified Source Code Partial Match

Compiler: v0.8.13+commit.abaa5c0e EVM: london Optimization: Yes (2000 runs)
StakingVault.sol 1065 lines
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

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

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

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

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

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

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

interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

interface IStakingVault {
    /// @notice Represents the stake a user has in the vault.
    struct Stake {
        uint128 amount;
        uint64 lockExpiry;
    }

    // Events.

    /// @notice Emitted every time a user's stake changes.
    event StakeChanged(
        address indexed account,
        uint128 amount,
        uint64 lockExpiry
    );

    /// @notice Emitted when a user boosts either the value or the lock of their stake.
    event BoostHFTStake(
        address indexed account,
        uint128 amount,
        uint64 daysStaked
    );

    /// @notice Emitted when HFT is withdrawn.
    event WithdrawHFT(
        address indexed account,
        uint128 amountWithdrawn,
        uint128 amountRestaked
    );

    /// @notice Emitted when a stake is transferred to a different vault.
    event TransferHFTStake(
        address indexed account,
        address targetVault,
        uint128 amount
    );

    /// @notice Emitted when the max number of staking days is updated.
    event UpdateMaxDaysToStake(uint16 maxDaysToStake);

    /// @notice Emitted when a source vault authorization status changes.
    event UpdateSourceVaultAuthorization(address vault, bool isAuthorized);

    /// @notice Emitted when a target vault authorization status changes.
    event UpdateTargetVaultAuthorization(address vault, bool isAuthorized);

    // Auto-generated functions.

    /// @notice Returns the stake that a user has.
    function stakes(address user) external returns (uint128, uint64);

    /// @notice Returns the authorization status of a vault to receive HFT from.
    /// @param vault The source vault.
    /// @return The authorization status.
    function sourceVaultAuthorization(address vault) external returns (bool);

    /// @notice Returns the authorization status of a vault to send HFT to.
    /// @param vault The source vault.
    /// @return The authorization status.
    function targetVaultAuthorization(address vault) external returns (bool);

    // Functions.

    /// @notice The total (voting) power of a user's stake.
    /// @param user The user to compute the power for.
    /// @return Total stake power.
    function getStakePower(address user) external view returns (uint256);

    /// @notice Increases the amount or the lock of a stake, or both.
    /// @param amount Amount to increase the stake by.
    /// @param daysToStake Days to increase the stake lock by.
    function boostHFTStake(uint128 amount, uint16 daysToStake) external;

    /**
     * @notice Increases the amount or the lock of a stake, or both.
     *
     * Uses an ERC-721 permit for HFT allowance.
     */
    /// @param amount Amount to increase the stake by.
    /// @param daysToStake Days to increase the stake lock by.
    /// @param deadline Deadline of permit.
    /// @param v v-part of the permit signature.
    /// @param r r-part of the permit signature.
    /// @param s s-part of the permit signature.
    /// @param approvalAmount Amount of HFT to spend that the permit approves.
    function boostHFTStakeWithPermit(
        uint128 amount,
        uint16 daysToStake,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s,
        uint256 approvalAmount
    ) external;

    /// @notice Increases the HFT amount of a user's stake.
    /// @param user The user to increase the stake for.
    /// @param amount Amount by which the stake needs to be increased.
    /// @dev Can only be called by a contract.
    function increaseHFTStakeAmountFor(address user, uint128 amount) external;

    /// @notice Withdraws HFT to the user.
    /// @param amountToRestake Amount of HFT to re-stake instead of withdrawing.
    /// @param daysToRestake Number of days to lock the re-staked portion.
    function withdrawHFT(
        uint128 amountToRestake,
        uint16 daysToRestake
    ) external;

    /// @notice Transfers a user's stake to another vault.
    /// @param targetVault The address of the target vault.
    function transferHFTStake(address targetVault) external;

    /// @notice Receives a stake transfer that is issued via transferHFTStake.
    /// @param user The user to receive the transfer for.
    /// @param amount Amount of stake to receive.
    /// @param lockExpiry Lock expiry in the source vault.
    function receiveHFTStakeTransfer(
        address user,
        uint128 amount,
        uint64 lockExpiry
    ) external;

    // Admin.

    /// @notice Updates the max staking period, in days.
    /// @param maxDaysToStake The new max number of days a user is allowed to stake.
    function updateMaxDaysToStake(uint16 maxDaysToStake) external;

    /// @notice Updates the authorization status of a source vault, for stake transfer.
    /// @param vault The vault to update the authorization for.
    /// @param isAuthorized The new authorization status.
    function updateSourceVaultAuthorization(
        address vault,
        bool isAuthorized
    ) external;

    /// @notice Updates the authorization status of a target vault, for stake transfer.
    /// @param vault The vault to update the authorization for.
    /// @param isAuthorized The new authorization status.
    function updateTargetVaultAuthorization(
        address vault,
        bool isAuthorized
    ) external;
}

contract StakingVault is IStakingVault, ReentrancyGuard, Ownable {
    using SafeERC20 for IERC20;
    using SafeERC20 for IERC20Permit;
    using Address for address;

    address public immutable hft;

    uint16 public maxDaysToStake;

    mapping(address => Stake) public stakes;

    mapping(address => bool) public sourceVaultAuthorization;
    mapping(address => bool) public targetVaultAuthorization;

    constructor(address _hft) {
        require(
            _hft != address(0),
            'StakingVault::constructor HFT is 0 address.'
        );
        hft = _hft;

        // 4 years by default.
        maxDaysToStake = 4 * 365;
    }

    function getStakePower(
        address user
    ) external view override returns (uint256) {
        uint256 timeUntilExpiry = 0;

        Stake memory stake = stakes[user];
        if (stake.lockExpiry > block.timestamp) {
            timeUntilExpiry = uint256(stake.lockExpiry) - block.timestamp;
        }

        /**
         * @dev We give 1 power for every 4 years of HFT collectively locked
         * in the vault by the user.
         */
        return (stake.amount * timeUntilExpiry) / (4 * (365 days));
    }

    function boostHFTStake(
        uint128 amount,
        uint16 daysToStake
    ) external override {
        _boostHFTStake(msg.sender, amount, daysToStake);

        emit BoostHFTStake(msg.sender, amount, daysToStake);

        IERC20(hft).safeTransferFrom(msg.sender, address(this), amount);
    }

    function boostHFTStakeWithPermit(
        uint128 amount,
        uint16 daysToStake,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s,
        uint256 approvalAmount
    ) external override {
        _boostHFTStake(msg.sender, amount, daysToStake);

        emit BoostHFTStake(msg.sender, amount, daysToStake);

        IERC20Permit(hft).safePermit(
            msg.sender,
            address(this),
            approvalAmount,
            deadline,
            v,
            r,
            s
        );

        IERC20(hft).safeTransferFrom(msg.sender, address(this), amount);
    }

    function increaseHFTStakeAmountFor(
        address user,
        uint128 amount
    ) external override {
        require(
            msg.sender.isContract(),
            'StakingVault::increaseHFTStakeAmountFor Caller should be contract.'
        );

        _boostHFTStake(user, amount, 0);

        emit BoostHFTStake(user, amount, 0);

        IERC20(hft).safeTransferFrom(msg.sender, address(this), amount);
    }

    function withdrawHFT(
        uint128 amountToRestake,
        uint16 daysToRestake
    ) external override {
        Stake memory currentStake = stakes[msg.sender];

        require(
            currentStake.lockExpiry <= block.timestamp,
            'StakingVault::withdrawHFT HFT is locked.'
        );
        require(
            currentStake.amount > 0,
            'StakingVault::withdrawHFT No HFT staked.'
        );

        uint128 amountToWithdraw = currentStake.amount;

        if (amountToRestake > 0) {
            require(
                daysToRestake > 0,
                'StakingVault::withdrawHFT Time lock not specified.'
            );
            require(
                amountToRestake <= currentStake.amount,
                'StakingVault::withdrawHFT Re-stake amount too high.'
            );

            amountToWithdraw -= amountToRestake;
        }

        currentStake.amount = 0;

        stakes[msg.sender] = currentStake;

        emit StakeChanged(
            msg.sender,
            currentStake.amount,
            currentStake.lockExpiry
        );

        if (amountToRestake > 0) {
            _boostHFTStake(msg.sender, amountToRestake, daysToRestake);
        }

        emit WithdrawHFT(msg.sender, amountToWithdraw, amountToRestake);

        if (amountToWithdraw > 0) {
            IERC20(hft).safeTransfer(msg.sender, amountToWithdraw);
        }
    }

    function transferHFTStake(
        address targetVault
    ) external override nonReentrant {
        require(
            targetVaultAuthorization[targetVault],
            'StakingVault::transferHFTStake Target Vault not authorized.'
        );

        Stake memory currentStake = stakes[msg.sender];

        require(
            currentStake.amount > 0,
            'StakingVault::transferHFTStake No HFT locked.'
        );

        uint128 amountToTransfer = currentStake.amount;
        uint64 lockExpiryToTransfer = currentStake.lockExpiry;

        currentStake.amount = 0;
        currentStake.lockExpiry = 0;

        stakes[msg.sender] = currentStake;

        emit StakeChanged(
            msg.sender,
            currentStake.amount,
            currentStake.lockExpiry
        );

        emit TransferHFTStake(msg.sender, targetVault, amountToTransfer);

        IERC20(hft).safeIncreaseAllowance(
            targetVault,
            uint256(amountToTransfer)
        );

        IStakingVault(targetVault).receiveHFTStakeTransfer(
            msg.sender,
            amountToTransfer,
            lockExpiryToTransfer
        );

        require(
            IERC20(hft).allowance(address(this), targetVault) == 0,
            'StakingVault::transferHFTStake HFT not spent.'
        );
    }

    function receiveHFTStakeTransfer(
        address user,
        uint128 amount,
        uint64 lockExpiry
    ) external override nonReentrant {
        require(
            sourceVaultAuthorization[msg.sender],
            'StakingVault::receiveHFTStakeTransfer Source Vault not authorized.'
        );
        uint64 newExpiry = lockExpiry;

        Stake memory currentStake = stakes[user];

        if (currentStake.lockExpiry > newExpiry) {
            newExpiry = currentStake.lockExpiry;
        }

        require(
            newExpiry <=
                (uint64(block.timestamp) +
                    uint64(maxDaysToStake) *
                    uint64(1 days)),
            'StakingVault::receiveHFTStakeTransfer Time lock too high.'
        );

        currentStake.lockExpiry = newExpiry;

        require(
            type(uint128).max - amount > currentStake.amount,
            'StakingVault::receiveHFTStakeTransfer amount too high.'
        );

        currentStake.amount += amount;

        stakes[user] = currentStake;

        IERC20(hft).safeTransferFrom(msg.sender, address(this), amount);
    }

    // Admin

    function updateMaxDaysToStake(
        uint16 newMaxDaysToStake
    ) external override onlyOwner {
        require(
            newMaxDaysToStake != maxDaysToStake,
            'StakingVault::updateMaxDaysToStake Number has not changed.'
        );
        maxDaysToStake = newMaxDaysToStake;

        emit UpdateMaxDaysToStake(maxDaysToStake);
    }

    function updateSourceVaultAuthorization(
        address vault,
        bool isAuthorized
    ) external override onlyOwner {
        require(
            vault != address(this),
            'StakingVault::updateSourceVaultAuthorization Cannot self-authorize.'
        );
        require(
            sourceVaultAuthorization[vault] != isAuthorized,
            'StakingVault::updateSourceVaultAuthorization No-op.'
        );
        sourceVaultAuthorization[vault] = isAuthorized;

        emit UpdateSourceVaultAuthorization(vault, isAuthorized);
    }

    function updateTargetVaultAuthorization(
        address vault,
        bool isAuthorized
    ) external override onlyOwner {
        require(
            vault != address(this),
            'StakingVault::updateTargetVaultAuthorization Cannot self-authorize.'
        );
        require(
            targetVaultAuthorization[vault] != isAuthorized,
            'StakingVault::updateTargetVaultAuthorization No-op.'
        );
        targetVaultAuthorization[vault] = isAuthorized;

        emit UpdateTargetVaultAuthorization(vault, isAuthorized);
    }

    function renounceOwnership() public view override onlyOwner {
        revert('StakingVault::renounceOwnership Cannot renounce ownership.');
    }

    // Internal functions.

    function _boostHFTStake(
        address user,
        uint128 amount,
        uint16 daysToStake
    ) internal {
        require(
            amount > 0 || daysToStake > 0,
            'StakingVault::_boostHFTStake Amount or days have to be > 0'
        );
        Stake memory currentStake = stakes[user];

        if (daysToStake > 0) {
            uint64 timeUntilExpiry = 0;
            if (currentStake.lockExpiry > block.timestamp) {
                timeUntilExpiry =
                    currentStake.lockExpiry -
                    uint64(block.timestamp);
            }

            uint64 extraLockTime = uint64(daysToStake) * uint64(1 days);

            require(
                extraLockTime + timeUntilExpiry <=
                    uint64(maxDaysToStake) * uint64(1 days),
                'StakingVault::_boostHFTStake Time lock too high'
            );

            if (timeUntilExpiry > 0) {
                currentStake.lockExpiry += extraLockTime;
            } else {
                currentStake.lockExpiry =
                    uint64(block.timestamp) +
                    extraLockTime;
            }
        }

        if (amount > 0) {
            require(
                type(uint128).max - currentStake.amount > amount,
                'StakingVault::_boostHFTStake amount too high.'
            );
            currentStake.amount += amount;
        }

        stakes[user] = currentStake;

        emit StakeChanged(user, currentStake.amount, currentStake.lockExpiry);
    }
}

Read Contract

getStakePower 0x09d2a776 → uint256
hft 0xd87a26aa → address
maxDaysToStake 0x8b69af5a → uint16
owner 0x8da5cb5b → address
renounceOwnership 0x715018a6
sourceVaultAuthorization 0xfb099fd9 → bool
stakes 0x16934fc4 → uint128, uint64
targetVaultAuthorization 0xfc2cde48 → bool

Write Contract 10 functions

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

boostHFTStake 0x3072133a
uint128 amount
uint16 daysToStake
boostHFTStakeWithPermit 0xaa815743
uint128 amount
uint16 daysToStake
uint256 deadline
uint8 v
bytes32 r
bytes32 s
uint256 approvalAmount
increaseHFTStakeAmountFor 0x422c63c9
address user
uint128 amount
receiveHFTStakeTransfer 0xa5eb539b
address user
uint128 amount
uint64 lockExpiry
transferHFTStake 0xd7f35da0
address targetVault
transferOwnership 0xf2fde38b
address newOwner
updateMaxDaysToStake 0xbae3264e
uint16 newMaxDaysToStake
updateSourceVaultAuthorization 0x7e636b4d
address vault
bool isAuthorized
updateTargetVaultAuthorization 0xdd6ba7c2
address vault
bool isAuthorized
withdrawHFT 0xacec84fc
uint128 amountToRestake
uint16 daysToRestake

Recent Transactions

No transactions found for this address